Clean code

What is the Correct Caching Strategy?

Reading Time: 3 minutes While uncovering ways to speed up our application on the Google App Engine, we decided to use Memcache. This led us to an interesting discussion which I am reproducing here to get your inputs. As you would observe, if you are following our blog, that there are 2 potential ways to cache, invasive and non-invasive. May be there is a third way which you would Continue Reading

Google App Engine: Understanding Non-Invasive Caching

Reading Time: 3 minutes In the last post on understanding caching we talked about the general support of GAE for caching and how we could easily incorporate caching in our application. You would also recollect that we talked about the invasive form of caching in which the business layer was aware about the caching framework. In this post let us talk about the non-invasive way to cache. Since caching Continue Reading

Duplicate Code? Chain Constructors

Reading Time: 2 minutes 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

Reading Time: 3 minutes 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

Reading Time: 3 minutes 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

Open Closed Principle in Action

Reading Time: 4 minutes Ivar Jacobson stated that all software entities change during their life cycle and this must be borne in mind when developing systems which are expected to last longer than the first version. A design principle which helps you with long lasting software is OCP (Open Closed Principle). Open Closed Principle was coined by Bertrand Meyer. It states that “Software entities should be open for extension Continue Reading

Excellent Code Quality is Also an Issue

Reading Time: 2 minutes We all know the importance of good clean code. Meaningful names, ubiquitous language, one level of abstraction per function, SRP, OCP etc etc. It is not debatable that good code would lead to better reuse, maintenance, enhancements etc etc. Have you ever encountered the scenario where the code was too good and that was an issue? I was reading the book, The Pragmatic Programmer: From Continue Reading