this post was submitted on 20 Oct 2023
15 points (94.1% liked)
Programming
17483 readers
186 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities [email protected]
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Research what other people have done, to be honest.
Most of the time, I find a library that does it for me so I use that.
Then I might run into limitations of that library... so I either extend/wrap it, reimplement it myself following a similar pattern (but how I want it), find a similar library that doesn't have the limitations, or learn that the way the library implements it doesn't work for me and try something else.
And all of this contributes towards my experience. Recognising the shape of a problem when starting to work on something, and having experiences using patterns that fit that shape.
It really is a time to be standing in shoulders of giants for a lot of the work. Either find a library, or figure out what other people have done.
I would bet that only really low-level stuff and cryptography are implementing any "new" code.
Everything else is just glue.
For example, right now I'm doing some embedded systems work. I found a project that does something similar, so I learnt from it and implemented something similar.
I've worked out the main parts of the system, and I now realise it's a bunch of state machines where the logic for transitioning between states is more important than what happens in a state (in the states is fairly straightforward, but the transitions are confusing and where the bugs are going to happen).
So now I'm looking at some libraries for how a FSM can be nicely implemented in CPP, and I'll probably draw from a few examples to get my own working.
But something that I had originally built as a stitch-together of functions, turned into many complex switch statements, and will now hopefully turn into some elegant, descriptive and abstracted-away state machine.
Yeh, I could probably have predicted it would be an FSM from the start. But I didn't know that, I didn't even know if the project was viable, and I don't do much embedded systems programming.
The similar projects I drew reference from were hobbyist and a mess.
So, now I have a little more experience to think "is this an FSM" when it comes to embedded systems, and whether I want to go with switch statements, or if I go for some fancy system to make the transition logic easier.