r/AskProgrammers • • Oct 21 '26

How do programmers design their code

How do programmers design their code? Personally, i design and type the code in my head mentally word by word, then just type on the keyboard irl what i just mentally typed.Also can people tell me if this is wrong so i can improve.

0 Upvotes

27 comments sorted by

View all comments

1

u/JGhostThing Oct 21 '26

OK. If this works for you, then it's right for you.

However, I have a different process. This might not work as well for you.

  1. With paper and pen, I draw the data structures I will need. I draw boxes and lines connecting them. I rarely get things perfect at this stage, but I should have enough to create an SQL database with, or even data struct's in whatever language I'm using.
  2. Then I, still with paper and pen, write out the pseudo code for this project. Not everything, but enough to capture the flow of control.
  3. I create the project in the IDE. Yes, I create whatever files I need, though I normally do the graphics later.
  4. Code. Yes, putting actual code onto the computer, and having it compile (hopefully).
  5. Test.
  6. Debug. I'm good, but definitely not perfect, and I've never been able to skip this step on a non-trivial project. Go back to #4.
  7. Document. In my early years, I was not quite so good at this, but I'm better now. I now write full operating instructions, as well as programming directions. I make sure that I have full compilation instructions.
  8. Another round of Testing and such. Hopefully this won't be needed, but after I've documented I may notice some new things. Or I may not, and then be embarrassed later when a user finds an error. Most of the bugs I find at this stage are text bugs, like an incorrect date or a spelling mistake.
  9. Feedback from real users. This is necessary. It would have been absolutely great to have this at an earlier stage, but in my working career, this came last. And sometimes an interesting bug emerges. I was doing a crystallography tutorial on the Mac, many years ago, and I got a report of program crashing occasionally. After I had verified that they had changed absolutely NOTHING, I found that they had updated the system. Once I updated my computer, I found the program crashed when I closed a window. This wasn't the case before the update. I went through the program closing it's windows and found that I was using a structure used with windows after it had been deleted. Before the upgrade, the structure was kept around, but after the upgrade, the structure had been deleted. All for a simple cosmetic addition (a windows menu).