Last Updated:

CodeLogic for Java and C# 

Sorting out your code, written in a creative impulse months, or even years ago, is an unpleasant occupation. Dismantling someone else's code, even if it is not written by Hindus, is ten times worse. Therefore, a tool that will help to understand someone else's code is simply invaluable. It is about such a tool that I will now tell.

What's the problem?

Someone, of course, can say that someone else's code is not a problem for him at all, that he repeatedly had to deal with it, and that the disassembly was completed successfully. And in order to understand how the code works, and to fix or optimize it, there is no need for special tools at all: it is enough to know the programming language used and the libraries used in the code, as well as to imagine the general logic of the program and carefully delve into the comments. In general, indeed, what can I say, with a burning desire or severe need, you can understand, if not any, then almost any program code. What one person wrote, another person will be able to read - sooner or later, one way or another. However, this is the "sooner or later" problem. If it takes less time to write new program code than to disassemble and "fix" the old one, then the programmer will be absolutely right if he immediately starts writing a new one. And if it takes more time, many will still prefer to write their own code than dig into someone else's. So, unfortunately, not everything is as cloudless as it might seem at first.

Of course, a tool that could understand someone else's code, and then explain to you that yes how, and put everything on the shelves, unfortunately, does not exist. As well as the one who would correct all the errors in someone else's code and save you from having to delve into this very code. If such tools existed, it would hardly be good for you and me - the whole meaning of the very existence of the profession of a programmer would be lost. Nevertheless, a software product can help to understand someone else's code, which will extract the logic of work from the code, and then present it in the form of diagrams and diagrams understandable to everyone. With them, it is much easier and faster to get an idea of why a particular class is present in the program code, because most people still belong to visuals; that is, it is easier for them to receive and process information visually.

Since the Java and C# programming languages are now very common, thanks to the efforts of Microsoft and Sun Corporations, the tool I will tell you about knows how to work with them. Someone can say that C++ is also very common, to which I can only answer by saying that with all questions about supported programming languages you need to contact not me, but the authors of this extremely useful and convenient software product. About which, by the way, it is high time to start a conversation, and then the introduction seems to have been somewhat delayed.

CodeLogic Overview

As it is easy to guess thanks to the title of this article, the software product that will be discussed is called CodeLogic. Or rather, there are two products: CodeLogic for Java and CodeLogic for C#. It's just that they are, let's say, quite similar, and therefore it would hardly make sense to talk about each of them separately. To be honest, I did not even download them both, but limited myself only to the one that is for Java (somehow this language is closer to me, after all). But everything about the Java version is true for the C# version, if you believe the product descriptions on the website of their developer, Logic Explorers. 

As I have already said, the task of CodeLogic is to analyze the program and present it in the form of visual diagrams. You do not need any preliminary preparation of the project for this: you run CodeLogic, specify the directory in which the project is located, and then enjoy the fact that the program will analyze and draw everything for you. You will only have to figure out what exactly she drew there, but according to the schemes generated by CodeLogic, you can understand the logic of work and the internal structure of the program code incomparably faster than with a simple reading of it.

Despite the fact that the diagrams in CodeLogic comply with all the rules for building UML diagrams, the user can perfectly understand them without any special knowledge in the field of UML. In total, the program generates three types of diagrams: Class Diagram, Sequence Diagram and Flow Diagram. Looking at them, you can easily distinguish one from the other, as well as understand what exactly each of them illustrates. Despite this, and the fact that I have already told on the pages of "KV" about the wisdom of different types of UML diagrams, I think it will not be superfluous to say a few words about each of the types of diagrams supported by CodeLogic.



So, the first type is a Class Diagram, or, in Russian, a class diagram. As written on Wikipedia, "it describes the structure of a system, showing its classes, their attributes and operators, and also the relationships of these classes." Of course, a lot of stuff has been written on Wikipedia, and there is enough outright nonsense too, but in this case everything is one hundred percent true. In this diagram, classes are depicted as blocks, and the arrows between them, respectively, depict their relationships. In CodeLogic, in order to move from the abbreviated display of classes to the full, that is, in addition to the names of the classes, the program will also display a list of their methods with parameters. Of course, for a full reading of diagrams of this type, it is better to have some ideas about UML diagrams in general and about class diagrams, in particular. You can read more about them.

The next type of diagram is a Sequence Diagram, or, in Russian, a sequence diagram. What is depicted in this diagram? And it depicts a sequence of interactions of objects unfolding in time. Here we have objects (also in the form of rectangles) with vertical lines extending down from them. These lines show the passage of time, and the arrows departing from them indicate the directions of interaction. 


And finally, the third type of diagrams that are found in CodeLogic is the Flow Diagram, or execution chart. This is not quite UML - we are familiar with this thing under the name of a flowchart, and it is taught to compile it in school, when algorithms are told in computer science. Here everything is quite simple: in a schematic form, the execution of a particular method of a particular class is shown, which allows you to quickly understand how a small piece of code works, and not the application as a whole. However, the flowchart is already, so to speak, a bonus, and many will be quicker to read the code than to see what, yes how, with its help. Although, of course, its usefulness increases rapidly with the increasing complexity of the very method for which it is built, so I think it would be foolish to deny the fact that it is not superfluous in CodeLogic.

In general, as you can see, all the diagrams that CodeLogic builds really help to understand the internal structure of the program.

Something that hasn't been talked about yet

Now let's see what else I haven't said about CodeLogic. First, it is worth saying that this software product comes both as a separate application and as a plug-in for popular development environments such as Eclipse, IntelliJ IDEA, JBuilder, JDeveloper (for Java) and Microsoft Visual Studio (for C#). At the same time, the developers on their website warn in large red letters that the product does not support IntelliJ version 5, which, in my opinion, looks somewhat strange.

As for CodeLogic for Java as a separate application (this version I downloaded myself and it was with it that I "played"), its most important disadvantage, in my opinion, is a somewhat ill-conceived user interface. Of course, it is difficult to write a beautiful and functional interface using standard Java libraries, but at least you could at least add a toolbar so that you do not have to get into the menu every time to show a piece of code corresponding to a particular chart element. Well, scaling the charts on the screen could also be done better, and not make rigidly stitched "zooms" of 25%, 50%, 75%, 100%, 150% and 200%. Also annoying is some of the thoughtfulness of the program, which apparently regenerates the chart every time you switch between displaying different types of charts.

If you need to apply a diagram built with CodeLogic somewhere else, you can export it to PNG or Microsoft Visio format, as well as to UML XML. And you can print directly from CodeLogic if you need to have a chart on paper.


Well, let's sum up all of the above. First, CodeLogic is, of course, far from perfect and not always easy to use, but terribly useful. Secondly, due to the fact that it is available as a plug-in for many popular development environments, it is very easy to combine code exploration and its editing. And, thirdly, thanks to the export of diagrams in pictures and in Visio CodeLogic turns into a powerful tool for reverse charting for many different purposes.

I want to note once again that, despite its not so small cost ($ 300 per developer), CodeLogic helps in many cases and therefore pays off. You can use this powerful tool in a variety of situations: to fix and maintain someone else's code, to introduce a new developer to the project, to document already written code and to explain how much you have done to project managers ... Of course, it may be possible to understand any program code without such tools, which create a real guide to the labyrinth of its structure and logic. But, to be honest, I would prefer to use CodeLogic in such cases. It's just really convenient.