Refactoring

Knolders review of #venkat_50_50_tour at #DelhiJUG17 meetup

Dr. Venkat Subramaniam celebrates his 50th anniversary with distributing his smiles throughout the world’s Java User Groups (JUG) meetups, conferences, and events. Recently, he was in India and Delhi-NCR Java User Group organized one stop meetup for him. Needless to say, core to our culture of knowledge sharing caring,  Knolders were a part of the event. In meetup, Venkat spoke about Designing Functional Programs Java 8 streams and why functional programming is Continue Reading

Long Method? Move Accumulation to a Collecting Parameter

You would have definitely come across long bulky methods which accumulate information to a local variable and pass back that information. Here the local variable goes through a lot of changes throughout the logic of the method before it is finally returned back. Let us see how the combination of compose method, that we covered in the last post, and moving accumulation to a collecting Continue Reading

Long Methods? Try Compose Methods

We all have seen long winding code that goes on and on. By the time you have hit page down a couple of times, you forget what the method was doing. You forget because the method is doing a lot. It is failing the SRP principle and needs to be broken down into smaller pieces. According to me if you are looking at a method Continue Reading

Duplicate Code? Chain Constructors

After the ‘Introduction of Null Object’ and the ‘Replace One/Many Distinctions with Composite’ let us do an easy one this time. It is easy but of course it is present in a lot of code samples else we would not be discussing it here. If there are a lot of constructors which have duplicate code then see if there is a reasonable possibility to chain Continue Reading

Duplicate Code? Replace One/Many Distinctions with Composite

After the first post on how to introduce Null Object, in this second post on how to write clean(er) code, let us look at one of the very frequent occurrence. At least something that I have seen quite often. You too would have noticed that many APIs provide two methods to do the same thing. One of the methods expects one object and the other Continue Reading

Duplicate Code? Introduce Null Object

One of the most significant code smells is having duplicate code. There are primarily 2 forms of code duplications Explicit – These are the ones where there is blatant copy paste of the code. Methods are repeated within classes and it is easy for the CPD tool of PMD to figure out that lines are copied thus leaving us red faced. Subtle – This is Continue Reading

%d bloggers like this: