Introduction
As a software engineer you already might have run in the following situation: A legacy application needs to be extended, and most of the initial developers have either left or work on new projects. Documentation is sparse and the code base is huge - but you need to quickly understand the structure of the project, or at least the parts you're about to change. How can you possibly achieve that?
Structural analysis to the rescue
Under structural analysis we understand the analysis of:
- project structure
- project elements
- elements structure
- elements relations
We will have a general overview of those aspects below - the description refers mainly to two object oriented languages: Java and C#. The details we will present in a series of blog posts - so stay tuned for more!
Analysis of project structure
A typical project is composed of:
- modules
- packages / namespaces
- elements (classes)
- packages / namespaces
So first it is required to understand what modules are included in the project and what their roles are. Additionally one also has to understand how elements (classes) are organized within modules - what packages / namespaces are there and what elements do they contain.
Analysis of project elements
In Java and C# projects, elements of the following kinds/categories can be found:
- class
- interface
- annotation (Java)
- attribute (C#) - equivalent to annotation in Java
- enum
- throwable / exception 1)
- array
- delegate (C#)
- interface
- struct (C#)
1) logical category
Analysis of elements structure
Java and C# classes can contain the following members:
- attribute
- field
- constant 1)
- operation
- method
- constructor
finalizer / destructor2)
- property 1)
- indexer (C#)
- operator (C#)
- event (C#)
- nested element
1) logical category in Java, language-level category in C#
2) logical category in both languages - should not be used anymore
2) logical category in both languages - should not be used anymore
Analysis of element relations
An element can have any of the following relations:
- outbound
- generalization
- abstractions
- nestings
- associations
- uni-directional
- bi-directional
- aggregations
- compositions
- dependencies
- inbound
- specializations
- realizations
- nesting owner
- association usages
- aggregation usages
- composition usages
- aggregation usages
- dependency usages
Structural analysis of a sample Java project
Now imagine that you start working on an existing project: ScrumToys, an application to support conducting projects in SCRUM. Below you can see 2 screenshots from the application.
Figure 1b. ScrumToys application - editing of sample task.
Figure 1a shows stories and tasks. Tasks are grouped into 3 categories, according to their status: TODO, DOING, DONE. Figure 1b shows the task edit dialog.
Your role is to modify the application. You've received the following assignment:
- add next task status-category: APPROVED
- remove inconsistency in the name of task status: DOING (Figure 1a) and WORKING (Figure 1b) - it should be WORKING on all screens across the system (also on those not shown on screenshots)
- make task status changeable - currently it cannot be changed (Figure 1b)
In order to do your assignment correctly, you have to understand the structure of the application - at least of the parts related to the given tasks. Let's see a comparison on how popular software engineering tools can support you in your assignment.
Tools
The following software engineering tools are chosen to help us with the structural analysis:
- Class Visualizer 0.5.1 - free tool for structural analysis
- Free Java IDEs:
- Eclipse 4.3 - most popular IDE, first choice of most software engineers
- NetBeans 7.3 - second popular IDE
- IntelliJ IDEA 12.0 Community Edition - third popular IDE
- Eclipse plugins (working with v4.3)
- ModelGoon 4.4.1
- Javadoc As UML View 0.2.2 1)
- AmaterasUML 1.3.4
- ObjectAid 1.1.0
- nWire for Java (commercial, 30 days free trial available) 1)
1) officially not supported on Eclipse 4
Analysis
Project structure
First, we would like to have general overview of the project structure:
As shown in Figure 2, two out of four tools (IntelliJ IDEA and Class Visualizer) present graphical information about the kind of element (class, interface, enum, annotation) and one of them (Class Visualizer) presents the full list of project elements. All tools except Eclipse IDE show the structure of the element currently selected on the list.
The analysis of the element structure and its relations will be discussed in next parts of this series.