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

AI Thread Summary
Automatically programming can be surprising and rewarding, as it leads to the ability to solve complex puzzles, such as creating a blackjack program. However, a common challenge is forgetting the thought process behind the solutions. To mitigate this issue, it is essential to add comments to the code. Well-commented code not only aids in understanding the logic used but also serves as a valuable reference when debugging or making changes in the future. Starting with a written specification can further clarify the tasks and algorithms involved. Implementing detailed comment blocks can enhance clarity, making it easier to track down bugs and understand the structure of the program. This practice, while it may seem excessive, proves beneficial over time as it provides a roadmap of the code's functionality and intent.
shivajikobardan
Messages
637
Reaction score
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
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
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.
        '
 
Hey, I am Andreas from Germany. I am currently 35 years old and I want to relearn math and physics. This is not one of these regular questions when it comes to this matter. So... I am very realistic about it. I know that there are severe contraints when it comes to selfstudy compared to a regular school and/or university (structure, peers, teachers, learning groups, tests, access to papers and so on) . I will never get a job in this field and I will never be taken serious by "real"...
Yesterday, 9/5/2025, when I was surfing, I found an article The Schwarzschild solution contains three problems, which can be easily solved - Journal of King Saud University - Science ABUNDANCE ESTIMATION IN AN ARID ENVIRONMENT https://jksus.org/the-schwarzschild-solution-contains-three-problems-which-can-be-easily-solved/ that has the derivation of a line element as a corrected version of the Schwarzschild solution to Einstein’s field equation. This article's date received is 2022-11-15...

Similar threads

Replies
5
Views
1K
Replies
24
Views
2K
Replies
1
Views
1K
Replies
7
Views
3K
Replies
9
Views
2K
Replies
26
Views
5K
Replies
3
Views
2K
Back
Top