Clean code

Building Quality into Scala Development

Reading Time: 3 minutes The argument and debates regarding writing quality code have mostly rested in the favour of writing clean code. Cleanliness fosters quality. Clean code is straightforward, direct, reads like a story and makes it very understandable. As a rule that we have at Knoldus, if your code does not read like a story and we have to interrupt in between to understand wtf is going around Continue Reading

Style Guide for Scala

Reading Time: 1 minute Reading Scala code is easy once you get used to it. However, it is always good to have a well defined set of guidelines so that the code which is readable for an individual is also readable by the other person as well as maintainable by the client. At Knoldus, we strive to write code which is clean and beautiful. At one of the Knolx Continue Reading

Code Smell : Primitive Obsession

Reading Time: 2 minutes Primitive Obsession is when the code relies too much on primitives. What this means is that a primitive value controls the logic in a class and this primitive value is not type safe. For example, there are multiple situations in which we might consider the use of String for comparison and driving the logic even though we are fully aware that it might result in Continue Reading

Respecting Open Closed Principle with Visitor Pattern

Reading Time: 3 minutes One of the common principles in the bouquet of SOLID principles is the Open Closed Principle (OCP) which states that software entities should be open for extension but closed for modification. This means that if we have to add any new functionality then ideally, we should be able to extend the current set of software entities by adding a new entity rather than creating a Continue Reading

Long Method? Move Accumulation to a Collecting Parameter

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

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

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

Knoldus Pune Careers - Hiring Freshers

Get a head start on your career at Knoldus. Join us!