Design Patterns

What is Factory Method?

The Factory Method is a creational design pattern that provides an interface for creating objects in a superclass but allows subclasses to alter the type of objects that will be created. In addition to the use of polymorphism, it is possible to create either ProductA or ProductB, depending on which factory is being used. The…

Read More
Java

Why use Abstract Classes in Java?

Abstract classes in Java are templates that cannot be instantiated directly and may include abstract methods (without implementation) and concrete methods (with implementation). They are used to define common behaviors that subclasses must implement while sharing reusable code. Abstract methods act as placeholders, enforcing a contract that subclasses must fulfill. Let’s look at an example.…

Read More