Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Objects (Retired) Creating the MVP Current Progress

Aditya Puri
Aditya Puri
1,080 Points

I 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
Joe Rowe
2,225 Points

Comment!

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 :-)

Hey 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.