1. Concept library
  2. Java & Spring Boot
  3. Module 2: Object-oriented design

Concept

Interfaces and abstract classes

An interface declares what a type can do; an abstract class can also share state and partial implementation. Depend on interfaces in your signatures, and use abstract classes for shared machinery.

What a session covers

The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.

  1. Explain what an interface declares and what an abstract class adds
  2. Write an interface and depend on it in a signature
  3. Spot the interface with one implementation added for flexibility

In practice

A few lines that show Interfaces and abstract classes doing its job.

Java
public interface Notifier {
    void send(String to, String message);
    default void sendAll(List<String> to, String message) {
        to.forEach(t -> send(t, message));
    }
}

public abstract class RetryingNotifier implements Notifier {
    protected abstract void attempt(String to, String message) throws IOException;
    public void send(String to, String message) { /* retry around attempt() */ }
}

The common mistake

Watch for

Creating an interface with a single implementation "for flexibility" when nothing else will implement it. Add the interface when a second implementation, or a test double, needs it.

What to know first

Your roadmap puts these before Interfaces and abstract classes, unless you already know them.

How it stays learned

Once a session shows you understand Interfaces and abstract classes, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.

  1. Day 3First recall, while it is fresh
  2. Day 7Second, a week on
  3. Day 18Last, when it has settled

Where it leads

Topics that build on Interfaces and abstract classes.

Next in the moduleEncapsulation →