• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

How to wrap your head around large code?

 
Ranch Hand
Posts: 56
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 17125
298
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 76450
366
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 115
11
IntelliJ IDE Clojure Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ).
 
Don't count your weasels before they've popped. And now for a mulberry bush related tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic