Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

Sometimes when code is too complex, I break it down into parts.

Is there another kind of technique/visualisation to help have a more clear picture of the code?

share|improve this question

marked as duplicate by gnat, GlenH7, MetaFight, Tulains Córdova, Dan Pichelman Jan 27 '15 at 13:36

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Which Programming languages (PHP, Java, Delphi, plain C, Scala, whatever) and programming paradigm (Procedural, Object Oriented, Functional, combination of previous) are you using ? – umlcat Mar 8 '11 at 17:41
Possible duplicate: – gablin Mar 9 '11 at 9:55
Four years later and I can't believe that no one mentioned – Mawg May 6 '15 at 14:01
up vote 2 down vote accepted

SciTools Understand

Bits and pieces from comments: Why is this tool so good? What's not so good about it?

I don't know what to say really. I've been using it for, well, quite some time now (years) and it is really a tremendeously useful tool when analyzing large projects. It has replaced my IDE in a way. I don't rely on graphs that much; more on the mechanisms of restructuring and manipulating variables and such. Check their page.

enter image description here

share|improve this answer
@Rook why it doesn't support PHP? – janoChen Mar 8 '11 at 4:26
@janoChen - Why it doesn't support PHP? Uhmmm, you'll have to ask them that, not me. – Rook Mar 8 '11 at 11:03
@Rook - Providing a link is useful but doesn't offer as much value as your experience. Why is this tool so good? What's not so good about it? Please expand your answer. – Walter Mar 8 '11 at 14:00
@Walter - I don't know what to say really. I've been using it for, well, quite some time now (years) and it is really a tremendeously useful tool when analyzing large projects. It has replaced my IDE in a way. I don't rely on graphs that much; more on the mechanisms of restructuring and manipulating variables and such. Check their page. – Rook Mar 8 '11 at 22:26
@Rook - your comment should be part of your answer. That's exactly the feed back that adds significantly to the link and screenshot. – Walter Mar 8 '11 at 23:42

Within a complete project I find class diagrams most useful, with a machine-generated diagram handy if an existing project doesn't have documentation. There's a range of tools for generating class diagrams automatically, and generally they work fine for small projects. I like to split bigger projects out, either into layers or class groups, but this requires a certain minimum level of class coherence to be useful.

Within a single file two things for Visual Studio that I find handy are ctrl-wheel to zoom the code right out and the Code Map plugin from AX Tools. Both are quite good for getting a feel the structure of the file.

In my experience there are two quite different times when you want to do this. When you're designing software diagrams help you plan the structure and fit it to your requirements. For this almost any tool will do, because it doesn't need to be very interactive with the code, when the code eventually arrives. The other case, of course, is when you get a giant mess dumped in your lap and want to understand it. For that the quality of the reverse-engineering is key, and unfortunately I can't reccommend any specific tools. I find they all struggle once you get into hundreds of classes with high coupling and low cohesion.

share|improve this answer

In Visual Studio you can generate a class diagram from your code that is fairly helpful for getting an overview of classes, their contents, and their relationships. The best part is that it is a "live" and editable diagram, in that you can edit the diagram and the changes effect your code.

enter image description here

share|improve this answer
Sorry, I'm a bit beginner. I'm working with php code right now, and I don't use classes. Can this be applied to methods? – janoChen Mar 8 '11 at 4:23
Is something like this available for Netbeans or Eclipse? – Anto Mar 8 '11 at 4:54

Much like some of the others. You should look into learning UML There are some good tools out there that will auto generate these diagrams from your existing code, but I have found it very helpful to create these diagrams up front before I start a project and modify them as I go along.

share|improve this answer

Maybe is not what tool you use to visualize code, but how do you organize / split it.

Today there is a lot of applications done in Functional Programming and Object Oriented Programming, but, they are so messed up, something I call "Spaghetti Object Oriented Code".

Are your loops ("for", "foreach", "while") sentences or alternation ("if" / "switch" / "case") sentences too long (more than 6 lines) ? Perhaps, you should move that code into a new function / method.

Are you organizing your code in namespaces / modules / packages ?

Are your classes code too long ? maybe you should break a single class into a "grandparent" class, a "parent class", and a "child" class.

Classes usually have 4 groups of methods, initialization (constructor and helper methods), execution (methods you use when object is instantiated, and helper methods), finalization (destructor and helper methods), plus "accesors", methods to access properties.

Does your classes methods, are well defined, in which group belongs ?

If your code is messed up, your visualization, charts, flowcharts, U.M.L., whatever, will look messed up, also.

U.M.L. may help you organize your code. You don't need a U.M.L. application, for your scenario, a whiteboard and some markers will help you.

But, if you do diagrams of your code, you must think in reversing the process, modying the diagrams, and later, modifying your code upon the changes you do to your diagrams...

share|improve this answer

I guess my more simplistic, yet old-school approach is to write the code in pseudo-code.

Basically I create a new text file, and just write down via comments and/or pseudo-code the basic logic flow of the code I need to create.

I try to identify what sections are reusable or need to be executed or copied many times, and then convert those into the reusable format for my language, cfc's, custom tags, cfscript's etc. I am sure each of us has our own methods for our own languages.

I also try to identify huge chunks of sql code that can and should be moved to views and stored procedures...

I have been out of practice in doing this in the last year.

But it really helps in coding, if I pre-plan the code, to make sure I have a clear idea of what functional needs I am meeting or changing.

It get's especially hard when 99% of the time I am modifying someone else's code, and I don't always understand it. So it becomes a struggle to leave that code as is, to not interfere with it's functionality, while adding/changing functionality that is my assignment.

There is no 1 answer, just we all need to get better and more practice at planning our code.

share|improve this answer

I have a very large java code composed by multiple projects. The code is so big that a human brain can not handle it :-) The trick I do is to reverse engineer my code into an UML model and then create graphical views from my code using the UML model. Really powerful and amazing technology. My model can handle all my projects into a single UML model and I can describe project interactions directly at UML level of abstraction. I can also select to visualize only the relevant information. The graphical quality is so good that huge packages, composed by hundred of classes can be visualized inside a single class diagram !!

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.