Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAditya Puri
1,080 PointsI am having trouble keeping up...
I have spent a lot of time understanding this entire code and I understand it....but as this program gets more complicated and lengthy... every day when I come back to it..there are some blocks of code that I can't remember what they can do.
And I have to read them again to understand them again and this takes a lot of time...and the next day, I again forget what some other blocks of code do..
Is this common?
Also, can anyone tell me a way I can reduce all this work of understanding the same code again and again? Please give me suggestions, it will really help..
:D
2 Answers
Joe Rowe
2,225 PointsComment!
As you write blocks of code, add a comment in your own words that describes what the code does as you understand it. Even if your comment is something like "//not sure how this works but it has something to do with validation". Of course, an ever better strategy for when you arent sure exactly how an entire block works is to comment each line within it explaining simply what each line does.
Then, as you continue, you can come back to your comments when you have learnt more about how the program works and replace any fuzzy ones with a clearer explanation.
If you understand what the code does already, then still add a comment in your own words! You will find that as you progress you learn what particular blocks of code do and you wont need your comments as much (although you should still include them!)
Lastly, learning is an iterative process so if youre forgetting how the code works a lot i would recommend starting again from the beginning and following along coding by hand as you go. This will help to reinforce key concepts and while it takes time you will most likely be surprised by how much you do remember, and how much clearer things are when youre caught up to where you got lost.
Good luck :-)
jacobproffer
24,604 PointsHey Aditya,
As Joe suggested, comments can go a long way.
In your case, I'd suggest picking up a whiteboard or a large notebook. Hand-writing code, at least for me, is great for memorization. I spent months writing on whiteboards for two different courses in college that focused on Java. This was mainly because all of our exams were on paper but it forced me to become comfortable writing code without a computer. Even if it was writing arrays all day, it aided me in understanding and remembering the basic syntax of Java.
It may also be useful to take a step back and break-down the building blocks of a Java program. It's crucial to understand what you are writing so that you can explain your code to someone else if need be. Understand what a Java program is, what scope is, the difference between parameters and arguments, etc.
Most importantly, take it slow. Java is not a language you can master within a day or a month. It takes time.