Home » Author Archives: Mohamed Sanaulla (page 3)

Author Archives: Mohamed Sanaulla

Introduction to Default Methods (Defender Methods) in Java 8

We all know that interfaces in Java contain only method declarations and no implementations and any non-abstract class implementing the interface had to provide the implementation. Lets look at an example:                 public interface SimpleInterface { public void doSomeWork(); } class SimpleInterfaceImpl implements SimpleInterface{ @Override public void doSomeWork() { System.out.println('Do Some Work implementation ...

Read More »

Chain Of Responsibility Design Pattern Example

Avoid coupling the sender of a request to the receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it. The main intention in Chain Of Responsibility is to decouple the origin of the request and the handling of the request such ...

Read More »

Test Driven Development – A Win-Win strategy


Agile practitioners talk about Test Driven Development(TDD), so do lot of developers who care about their code quality and workability. And I once upon a time, not so long ago managed to read about TDD. The crux of TDD as I have understood is: Write Test, and fail Code, make the tests succeed Automate the tests Refactor the code to ...

Read More »

Another aspect of coupling in Object Oriented paradigm

I had previously written a post related to coupling and cohesion here and that was more of a basic definition of both the terms. In this post I would like to throw some light on the tight dependency on the type of the component in use. Generally we would aim to design classes such that they interact via the interfaces ...

Read More »

SOLID – Liskov Substitution Principle

Liskov Substitution principle (LSP) states that, Methods that use references to the base classes must be able to use the objects of the derived classes without knowing it This principle was written by Barbara Liskov in 1988. The idea here is that the subtypes must be replaceable for the super type references without affecting the program execution. This principle is ...

Read More »

SOLID – Open Closed Principle

Open Closed Principle (OCP) states that, Software entities (Classes, modules, functions) should be OPEN for EXTENSION, CLOSED for MODIFICATION. Lets try to reflect on the above statement- software entities once written shouldn’t be modified to add new functionality, instead one has to extend the same to add new functionality. In other words you don’t touch the existing modules thereby not ...

Read More »

SOLID – Single Responsibility Principle

The Single Responsibility principle (SRP) states that: There should never be more than one reason for a class to change. We can relate the “reason to change” to “the responsibility of the class”. So each responsibility would be an axis for change. This principle is similar to designing classes which are highly cohesive. So the idea is to design a ...

Read More »

Java 7: try-with-resources explained

This article examines the use of the try-with-resources statement. This is a try statement that declares one or more resources. A resource is as an object that must be closed after the program is finished with it. The try-with-resources statement ensures that each resource is closed at the end of the statement. Any object that implements the java.lang.AutoCloseable or java.io.Closeable ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns