Solved

How to understand new java web application

Posted on 2014-02-21
7
1,093 Views
Last Modified: 2014-03-10
Let us say main java program is in xyz.class(in package test1) which has A() method which has C() method inside that.

public void A() { C() ; }

but C() method is in different class say abc.class in different package say test2.

I keep changing to new projects every 3-6 months due to nature of my job.
If i go to new project to understand the java application esp. if one class is in service layer other classs is DAO layer etc it adds more complexity to remember.

Let us say if there are UI files(login.jsp. order.jsp, confirmation.jsp of shopping cart) from which we are doing some CRUD operation on the database with UI, SErvice, DAO etc layers is it is good idea to take paper and pen and write the flow from which package ,class, method, line which other package ,class, method, line getting called or put debug points on specific lines. Challenge is when code changes by other deveopers line numbers keep changing also.

How to understand and document the flow so that i remember al the time with quick glance wthout spending too much time.

I tried each step as screenshot and paste in word document and refer that and also take hard copy of printout. But some times that documet coming too long like 50-100 pages which is bit challenge.


please advise
Any links resources ideas highly appreciated. Thanks in advance
0
Comment
Question by:gudii9
  • 4
  • 3
7 Comments
 
LVL 26

Accepted Solution

by:
dpearson earned 500 total points
ID: 39877428
If you're dealing with an application that has multiple layers (e.g. a UI layer and a database layer) then I'd suggest using a combination of 2 different strategies.

First approach is to examine the code within a single layer.  When there is a call to a new layer, ignore it for now and try to infer what the classes and methods in the new layer will be doing from just the names and parameters to the methods.

E.g.

public void A() {
    int param1 = B() ;
    int param2 = C() ;
    DAO object = createDAOObject(param1, param2, ...) ;
    object.storeInDatabase() ;
}

If B and C are in the same layer/package as A then examine then as you are reading through A.

But if createDAOObject() and storeInDatabase() are in a different layer, then ignore them for now and assume they are doing what they say (in this case saving to the database).

Once you have a good understanding for what method A() does in the current layer, then you can come back to understanding what the next layer does.

This breaks the problem down into more manageable pieces.  But in the end, a project with a large code base will always be hard to understand unless the boundaries between the components are clearly defined and easy to understand.  That's part of the skill in designing a big project.

As to how to record this - I've never seen a good way to represent it as a set of images or text.  People have tried (e.g. flowcharts were designed to show just this) but they are almost always too large and unmanageable.  In the end it usually has to just live in your head.

Hope that helps,

Doug
0
 
LVL 7

Author Comment

by:gudii9
ID: 39878570
Adding to complexity some methods come from classes of jar files which do not open in eclipse. How to take them also into consideration?
0
 
LVL 26

Expert Comment

by:dpearson
ID: 39878818
Treat external JAR files the same way that you treat code from another layer.

Don't try to follow the code into those files (which for an external JAR without source, is of course impossible) and instead just understand the methods as best you can from the available documentation, names and parameters.

Doug
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 7

Author Comment

by:gudii9
ID: 39881490
Nothing to do with identifying the design patterns to understand the web application right. Otherwise that is also one other challenging task to identify different design patterns in different layers like UI, service, DAO etc. Please advise
0
 
LVL 26

Expert Comment

by:dpearson
ID: 39881636
Yes you generally don't need to worry about identifying design patterns when trying to understand a set of code.

You might very occasionally recognize that the code you are reading is following a specific design pattern, but design patterns are much more useful when writing code than when reading it.  They're a way to discuss and implement different designs, rather than a way to think about the code when reading it.  99.9% of the code you read will not be part of a design pattern.
0
 
LVL 7

Author Comment

by:gudii9
ID: 39893902
That makes more sense

99.9% of the code you read will not be part of a design pattern.

Above line is not clear. I thought other way. can you please elaborate?
0
 
LVL 26

Expert Comment

by:dpearson
ID: 39893927
Design patterns tend to be used to solve specific types of problems.  E.g. How do you write code to interface to another module - maybe I'll use the Adapter Pattern.  So the code you write to connect one interface to another could be said to be part of a design pattern, but the two sides of the connection are not.

In my experience, the vast majority of code in a system is not built to meet a specific design pattern.  It's largely code providing direct functionality - e.g. code to write to a database, code to verify input parameters in a request etc.

You learn design patterns so you have a set of tools to help solve hard problems.  But most of the code we write should not be solving hard problems - those should only come up occasionally, allowing most of what we write to be simple and easy to write.  If it all seems hard, then something is probably wrong with how you are doing it.

Doug
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now