Learning logic is just like learning mathematics. It’s a skill that you have to develop by doing. This could be by direct application in programming, or it could be indirectly by doing logic puzzles. The critical parts of the skill are:
1: Understanding the formal moves you can make in your system.
2: Breaking your problem down into small pieces such that you can address each part in a simple way.
3: Understanding how to apply the moves to get where you need.
It sounds simple, but as anyone that has ever done mathematics knows, the application of simple rules can be very challenging at times. Doing some mathematics can certainly help since the core skills are very similar. Again, the critical part is doing — actually solving problems. Or doing some formal logic problem sets would also be worthwhile in developing these skills.
The absolute critical part is learning to solve the problems for yourself. Suppose you watch videos or copy others' solutions that are never going to get you where you need to be. Seeing solutions is helpful, but doing the solving yourself must make up the core of your practice.
Programming outlines every step.
For example, if you wanted to tell a computer to make a peanut butter and jelly sandwich
it would go something like this
- Verify we have peanut butter, else stop.
- Verify we have jelly, else stop.
- Verify we have bread, else stop.
- Retrieve {pb, jelly, bread}
- Lay out bread.
- Get a knife, else use your hand,
- Open PB.
- insert an object into PB.
- spread p…
And SO ON ……..
If you miss a step, it won't work and you won’t have a sandwich.
For example, if you skipped step 7, you'd just be jamming a knife into a peanut butter jar lid during step 8…
So, learning the “logic” of programming
is learning what your application has to do. Other than that, it is applying syntax and language structures (objects, classes, functions,..to your expert knowledge of making a pb&j.