• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to wrap your head around large code?  RSS feed

 
Ahmad Auada
Ranch Hand
Posts: 56
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!
Was just wondering, how do you guys go about to wrapping your head around massive code?
I have this little queue program in my book, it has 4 classes with an interface, and the algorithms are just so interlocked I find my self lost while reading it!
I had to go through similar code before, took me about 3 days to really comprehend it ! am I taking too much time?
 
Junilu Lacar
Sheriff
Posts: 11434
176
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Same answer to the question "How do you eat an elephant?" Answer: "One bite at a time."

If the code is huge and not well factored, if it doesn't reveal its intent very well, then I would say your experience is about par for the course.
 
Campbell Ritchie
Marshal
Posts: 56209
171
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

If it is that large, find who wrote it and wrap their head round a lamp‑post
 
Jason Bullers
Ranch Hand
Posts: 115
11
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What usually helps me is a mixture of pen and paper, and walking through the code with a debugger. The pen and paper part can be whatever helps you get a handle on it. Sometimes, I'll draw a simple box diagram with the different parts to help me see at a glance what talks to what and how they are related. Sometimes, I'll just note down what I interpret the algorithm to be and I'll work through it with some sample numbers or data structures (such as lists).

The debugger is especially helpful for this last part as it makes it very easy to see if what you think is happening actually is happening. If you aren't familiar with all the features of the debugger in your favourite dev environment, I highly recommend taking the time to learn how to use it. It's one of your best friends for really understanding what's going on inside your program. (Detailed logging can also provide a window into the application, but in the code I regularly work with logging is.... sub-optimal to say the least ).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!