I suppose that logical thinking is not my problem. I wrote an A* pathfinder to move mobs in a Minecraft-like voxel game called Minetest in Lua, including steering behavior.
You can see the final result in this video
I was almost happy with the result, but I wasn't happy with the code because it was written relatively naively and straight forward.
I also wrote some websites in PHP and Python, some other game mods in Lua and a few embedded Projects in C and ASM.
One problem is, that most books, tutorials or videos just teach you the syntax of a language. They don't necessarily teach you how to write good, maintainable code. And if no one tells you, that you are doing something wrong, you will continue to do it wrong, no matter how long you try.
Also, most books have an emphasis on syntax, but I have recently learned that it is more important to understand data structures and the algorithms to work with them. If you don't know what kind of data structure you should use in a particular situation you will end in some messy, slow code.
In the last few month I realized that I'm doing something wrong. I accidentally watched a video from Andy Harris "How to think like a programmer". That opened my eyes (at least a bit).
Since then I tried to find resources to get deeper and I learned new things I never heard before. I never heard of principles like DRY because no one ever told me this. No one ever told me to analyse a problem and split it into smaller parts and write an "algorithm" to solve each of this parts.
This is how I understand "how to think like a programmer":
- Understand the problem
- Split the problem in smaller parts
- Write some kind of algorithm as detailed as possible, e.g. as comment in the source file
- Fill the space between the comments with code
Maybe a bit simplified, but I think you get the point.
But it is still difficult to "reset" my brain to use the new stuff. I still write naive, straight forward code.
I want to "restart" my coding career with Rust. And I want to focus on console tools and embedded programming. I've chosen Rust because It is the only usable language for embedded systems besides C/C++ and it is not object oriented (I cannot cope with this).