Programming is coming to me but I forget how I solved the problem...

In summary, the author describes how to program more effectively by commenting and providing a detailed specification of the code.
  • #1
shivajikobardan
674
54
I'm surprised that automatically programming is coming to me. It blows my mind. I could not think of any logic in the past months and now I am able to solve puzzles in programming. But the toughest part is I forget how I solved the problem too quickly.
For example, the blackjack program. I forgot what thinking process I used to solve that problem. How do I avoid this issue?
 
  • Like
Likes symbolipoint
Physics news on Phys.org
  • #2
That's a reason to be adding comments to your code.

In addition to well-commented code, in real-world programming, you will generally start with a written specification for the code, which documents the tasks to be completed and the algorithms that will be used.
 
  • Like
  • Informative
Likes dlgoff, shivajikobardan and symbolipoint
  • #3
berkeman said:
That's a reason to be adding comments to your code.
what he said (very small).jpg


When you write a new program, I recommend putting in a comment block that describes what it is that you are doing. Here's what appears to be a rather extreme example. It may seem like overkill to do this kind of stuff, but You would not BELIEVE how useful this kind of thing has been to me over the years as I have tracked down bugs and made changes. Small comment blocks in front of each section of code repeats what is said in this long header comment. This block shows the complete action of this section of a particular subroutine in what is a very large overall program.

Code:
       '   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
        '
        ' for each thumb
        '   1) if the thumb file in the thumb file folder differs from the one in
        '      the active thumb file directory, copy the one in the thumb folder
        '      over on top of it. If they're the same then do nothing.
        '
        '   2) GONE (reorganized out of existence but left in to avoid having
        '      to renumber all the rest of what follows)
        '
        '   (this 3 replace old 3 and 4)
        '
        '  3a) if a folder does not exist for that wood, create one and move all
        '      of the appropriate JPEG files to it
        '  3b) else if the folder exists, check to see if all JPEG files are
        '      the same and if so, you're done but if not, then copy over any that
        '      are not already there and remove any that shouldn't be there
        '
        '   4) GONE (reorganized out of existence but left in to avoid having
        '      to renumber all the rest of what follows)
        '
        '   5) create a <name>.htm file for that wood
        '           5.1) if file already exists, kill it
        '           5.2) create new file
        '           5.3) put appropriate text at the beginning
        '           5.4) insert a reference to the fact sheet if there is one
        '               (and if there is one, copy it over)
        '           5.5) add pointers to all of the JPEG files and add further
        '                HTML files for each HREF in the original and add an
        '                entry for each referenced JPEG file
        '           5.6) put the appropriate text at the end
        '           5.7) if this is a new letter, put in a reference tag for it
        '
        '   6) if there are any "see also" names that come before this name,
        '      then insert them into the _@02 main page index.htm file being created
        '
        '  7a) put an href and an img src reference to the
        '      thumbnail into _@02 main page index.htm (USED TO BE more complex
        '      with two smaller index files)
        '
        '  7b) save the wood name and number of pictures (without enlargements)
        '
        '   8) if there is a corresponding htm file in "HTML with comments",
        '      then analyze it and the new one and make sure they have exactly
        '      the same set of href's and img src's and if they do, then
        '      copy over the one from "HTML with comments" to replace the new
        '      one but if they don't then copy over the "HTML with comments"
        '      one with an underscore at the front of the name, and do a
        '      debug.print of that name to alert the user.
        '
 
  • Like
Likes berkeman

FAQ: Programming is coming to me but I forget how I solved the problem...

Why do I forget how I solved a programming problem after some time?

Forgetting how you solved a programming problem is common and can occur due to a lack of repetition, insufficient documentation, or the complexity of the problem. Our brains tend to retain information better when it is frequently revisited or when it is documented in a way that makes it easy to recall.

How can I improve my memory retention for programming solutions?

To improve memory retention, you can practice regularly, write detailed comments and documentation, and use tools like version control systems to track changes and solutions. Additionally, discussing solutions with peers or teaching the concepts to others can reinforce your understanding and memory.

Should I keep a programming journal or log?

Yes, keeping a programming journal or log can be very beneficial. Documenting your thought process, solutions, and any challenges you face can serve as a valuable reference for future problems and help reinforce your learning.

Are there any tools that can help me remember my programming solutions?

Several tools can help you remember your programming solutions, including note-taking applications like Evernote or OneNote, code snippet managers like SnippetsLab or GitHub Gists, and project management tools like Trello or Asana. These tools can help you organize your thoughts and solutions in a structured manner.

How can I efficiently revisit and review past programming problems and solutions?

To efficiently revisit and review past programming problems and solutions, you can set aside regular intervals for review sessions, categorize your problems by topic or difficulty, and use spaced repetition techniques. Additionally, participating in coding challenges or contributing to open-source projects can provide opportunities to apply and reinforce past solutions.

Similar threads

Replies
5
Views
1K
Replies
24
Views
1K
Replies
1
Views
915
Replies
7
Views
2K
Replies
9
Views
647
Replies
26
Views
4K
Replies
3
Views
2K
Replies
11
Views
1K
Back
Top