Category Archives: Data structures and Algorithms
We have an application and we want that only Single Instance should run for that Application. If the Application is already running then the second instance should never be started. How would you handle this in Java?
What makes a HashSet different from a TreeSet in java?
Association Aggregation and Composition in Java
Association, aggregation, and composition are three types of relationships that can exist between objects in Java. Association: It is a relationship between two or more objects where they are connected but not dependent on each other. This means that one object can exist without the other, but they can still interact with each other. For… Read More »
Liskov’s Substitution Principle (LSP)
This principle is a variation of the open-closed principle. It says: “Derived or subtypes must be completely substitutable for their base types” That means that the classes may be created by extending our class should be able to fit in the application without any failure. This requires the objects of your subclasses to behave in… Read More »
Dependency Inversion Principle (DIP)
This principle says the decoupling of software modules. This way, instead of high-level modules depending on low-level modules, both have to depend on abstractions The classical example of this principle of bean configuration in the Spring framework. Another very good example of this principle: When you go to a local store to buy something, and you decide… Read More »
Interface Segregation Principle (ISP)
This principle says: “Clients should not be forced to implement unnecessary methods which they do not use” Let’s take an example. A Developer is created an interface Reportable and added two methods generateExcelReport() and generatedPdfReport(). Now a client wants to use this interface but he intends to use reports only in PDF format and not in excel. Will he be… Read More »
Open-Closed Principle (OCP)
This principle says that a class should be written in such a way that it performs its job flawlessly without the assumption that people in the future will simply come and change or modify it. Hence, the class should remain closed for any modification, but it should be open to getting extended. Ways of extending… Read More »
Single Responsibility Principle
Single Responsibility Principle (SRP) In our application-level code, we define model classes to represent real-time entities such as Employee, Person, Admin etc. Most of these classes are examples of SRP or Single responsivity Principle because when we need to change the state of an Employee only then we will modify an Employee class and if… Read More »
SOLID Design Principles
Classes are mainly the building blocks of any Software or application. If these blocks are not designed properly, the application or software is going to face a tough time in the future in terms of maintenance. This essentially means that not so well-written classes can lead to very difficult situations when the application scope goes… Read More »