From my last 40 months of experience as a Java Developer, I am noting down some of the best practices I have observed: —

Image for post
Image for post
  1. There should not be more than 3 nested if-else/for/while. Ex. if() {if(){ while(){if()}}} is not allowed, because it will be hard to remember the logic.
  2. Don’t add any codes in the comment as comments also get executed.
  3. Don’t overshadow any field otherwise it will create confusion while reading the code.
  4. There should not be any empty catch block and exceptions should be logged always because the purpose should be fulfilled.
  5. Before writing any method or calling any method think of all exceptions/errors it can produce or consume. (Very helpful) It will help you to write bug-free code. …

#HashSet #EqualsAndHashCode

What will be the output?

Aham Brahmasami
A{a=2, name='Govinda'}

That means, If the set has already an entry with the same hash key then it does not replace the old entry, it discards the new entry.

I was surprised to see; why there is no replace() method for the set but we have in other collections. Let me know the reason in the comment box below.


A typical TDD(Test Driven Development) is literally a complex way because you need to think all cases prior to development and write the test case; let the test case to fail then do development till your test case passes.

It seems very hard, how can I think of all cases prior to development. In reality, most of the developers don’t know the whole scenario even after completing the development and this is the fact!!!

Have you ever thought, why TDD helps you to develop a great project which will not have any bugs???

What I think is — TDD does not help instead the process helps.

One of the greatest things that happened to Java8 is FunctionalInterface . It’s amazing. It makes java developer’s life so functional that you will love it. By name, we get some idea that it is an interface and it’s functional too. Ohh…
As far as I know, an interface can not have implementation and a function is nothing but implementation only.

Should we say that java creators have skimped while finding an appropriate name to this feature???

Image for post
Image for post

I would say, they were not skimping instead they were very clever to give it a name as FunctionalInterface . As we know, the interface provides you a way to implement your own version of the prototype. So they decided that they will give some prototype(here a predefined function(not a method)) to users and let them implement their own version and use it as they want… hurrrrrrah. …

It is a microservice architectural pattern. Remember, every pattern is discovered to solve a particular type of problem. So what type of problem it is going to solve?

Well, if you are familiar with microservice architecture, you definitely know there are many intercommunications between microservices. Let’s take an example: —

There are three microservices: —

  1. Contact Management Service(CMS)
  2. Survey Management Service(SMS)
  3. Sender Service(SS)

There is one aggregator service who is responsible to create contact using CMS and fetch survey information from SMS and send surveys to created users using SS. There are many requests to perform the above-mentioned actions. …

#Polymorphism #OverShadowing #StaticMethod

Try it yourself first without a machine compiler.

This will clear your polymorphism concept with methods and fields.

Here, it’s important to understand that polymorphism happens on methods/functions, not on fields/variables.

Food  food = new VegFood();

In the above code block, I am instantiating child class referencing to the parent class; so here, we need to understand what all things will be given to the child class from the parent???

All non-private methods and fields of parent class will be accessible to the child class, so child class can modify the value of the fields and can override all methods or can directly call the parent’s methods. …

finally block or return will get executed first?

We as Java developers have always doubt about finaly and returnstatements, what will happen in the following case?

So what do you think what will be the output?

1. Good Boy!

2. Bad Boy!

3. Intelligent Boy!

4. Not A Boy!

The answer is Intelligent Boy! According to oracle document about finally blocks .

The finally block always executes when the try block exits. This ensures that the finally block is executed even if an unexpected exception occurs. But finally is useful for more than just exception handling — it allows the programmer to avoid having cleanup code accidentally bypassed by a return, continue, or break. …


Try to solve it by yourself first.

It’s a very easy challenge and but sometimes we get confused when we use the same variable name. Within for-loop block, the scope of i will be within it and no other variable with the same name will not be used. So, it will print from i=0 to i=9 and then exit from the method. So the global variable is not used anywhere.

Let me know on what topic you want me to create a Java challenge.

My twitter handle:



Please try to solve it with your mind’s compiler first.

Image for post
Image for post
What will be the answer?
1. Printing A
2. Printing B
3. Printing C
4. Printing E

If you have followed my previous Java challenge, you will be able to solve this question too.

None of the above answers is true. For the compiler, the method call with C-parameter and E-parameter produces ambiguity, because both C and E are immediate parents for D, but definitely A and B will not produce ambiguity, so it produces compile time error.

That’s all for this challenge. I will be releasing the next challenge on 8th Aug 2020 at 1 PM.

Please, do share if you find this challenging. Thanks.

A very important theorem which helps you to design your distributed application. Ohhh, Please focus on the word “Distributed Application”.

Image for post
Image for post

Here distributed application means a cluster of servers that can host applications or databases. So what are the major problems you face in a distributed architecture?

There are many problems, but I will be mainly focusing on three major issues:

A. How we can make sure that whatever data we are writing or reading to/from nodes, it should be the same for/from all nodes.

B. If any request of reading or writing comes to the cluster it should always respond no matter what is in the response.

C. Let’s say one of the servers from cluster got corrupted so in that case how the architecture should respond?

Let’s understand each problem with an example: —

We have two database servers: S1, S2 and both are part of the same cluster(same type of data), so these are the possible combinations I can think of: —

C1: One server to read or another server to write but both will have same data.

C2: Both servers to read and write but can have different data.

C3: Both servers read and write but can have same data. …


Govinda Raj

Senior Software Developer. Tech Enthusiast and love coding. My portfolio:

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store