0
votes
0answers
33 views

Best practices for introducing testing to a large, stable, legacy Java application? [duplicate]

I'm working with a stable, but large legacy java application that is over 12 years old, maybe older. Although the code has been upgraded to java 6, it's lacks the features above java 1.4 for the most ...
1
vote
2answers
137 views

Query Language for Java Code Analysis

I want to write a refactoring tool for the Java programming language. For this reason I need to do structural queries against the abstract syntax tree. Given this AST how do I get answers to the ...
1
vote
0answers
289 views

Thoughts on refactoring a generic DAO

I have designed a generic DAO in Java and am having confusion about whether to refactor it to different design or not. PS Don't say to use already existing 3rd person framework. I know there are some ...
12
votes
7answers
2k views

Avoid too complex method - Cyclomatic Complexity

Not sure how to go about this method to reduce Cyclomatic Complexity. Sonar reports 13 whereas 10 is expected. I am sure nothing harm in leaving this method as it is, however, just challenging me how ...
0
votes
1answer
103 views

Get entities ids from two similar collections using one method

I've got two lists: List<Integer, ZooEntity> zoos; List<Integer, List<ZooEntity>> groupOfZoos; These operations will return collections of values: Collection<ZooEntity> cz ...
2
votes
2answers
376 views

Why delete method/field/function refactoring doesn't exist in Eclipse?

An operation in an interface is obsolete so I decided to delete it. It seems that there is no automatic support for such a "refactoring" in Eclipse. For me is a refactoring operation since the ...
2
votes
2answers
206 views

Refactoring two classes from third-party library that could have extended a base class

I have two Classes, with very similar behaviors, both from a third party library. Both needs to be populated with some value object and sent to specific queues in order for logging. Please note both ...
1
vote
1answer
271 views

JSP Include: one large bean or bean for each include

I want to refactor a webapp that consists of very distorted JSPs and servlets. Because we can't switch to a web framework easily we have to keep JSPs and Servlets, and now we are in doubt how to ...
1
vote
1answer
298 views

Refactoring the shipping application code to use DDD factories

I was trying to find examples for using DDD factories and I came across the shipping application from Eric Evans' book. However when I checked the BookingService the code to create a Cargo had this ...
3
votes
2answers
448 views

How to remove duplicate exception block code

I have good number of Service and DAO classes which has the same set of 30 line exception code block which gets repeated and it shows up in Code Duplication report. The approach which i can think of ...
0
votes
2answers
235 views

Question on refactoring and code design

Suppose, I have a class with a constant static final field. Then I want in certain situations that field to be different. It still can be final, because it should be initialized in constructor. My ...
6
votes
7answers
4k views

Use constructor or setter method?

I am working on a UI code where I have an Action class, something like this - public class MyAction extends Action { public MyAction() { setText("My Action Text"); ...
1
vote
2answers
310 views

Setting variable in constructor or within method

I have a class which contains two methods. These methods add & remove an object to a datastore. The class which contains these methods has a no arg constructor but each of the two methods takes ...
5
votes
3answers
185 views

When is 'cloning', rather than reusing, a module acceptable design solution?

For this question, I'll give an example module to facilitate the discussion, Let's say the module is a calculation engine, It currently servers its purpose for its current audience. The requirement is ...
10
votes
6answers
1k views

Self-documenting code vs Javadocs?

Recently I've been working on refactoring parts of the code base I'm currently dealing with - not only to understand it better myself, but also to make it easier for others who are working on the ...
2
votes
3answers
774 views

When to deprecate and when to delete in Java

As part of a refactoring effort or just ongoing development, a particular method or maybe an entire class may become obsolete in some sense. Java supports the @Deprecated annotation to indicate that ...
24
votes
10answers
12k views

How many lines per class is too many in Java? [closed]

In your experience, what is a useful rule of thumb for how many lines of code are too many for one class in Java? To be clear, I know that number of lines is not even close to the real standard to ...