AppFrame

Frameworks

The Open-Closed Principle states:

Components should be open to extension but closed to modification.

This applies to components that range in size from single classes to entire systems.

The application of the principle to systems leads to the framework concept. A framework is an application that can be extended (customized) without being modified:

A framework for desktop applications can be customized into a word processor, a spreadsheet, an image editor, etc. In these cases the framework usually provides a GUI, a persistence mechanism, an error handling mechanism, and an architecture.

Design Model

We employ a variation of the Layers pattern:

We refine the multi-layer pattern with the Model-View-Controller pattern:

If our domain layer consists of many classes, we might want to introduce the Facade pattern to promote decoupling between the presentation package and the domain package.

To customize our framework, programmers will have to extend these three classes:

View Notification

How can the model notify all views when it has been updated without introducing a dependency on them? To solve this problem we can refine the Model-View-Controller pattern with the Publisher-Subscriber pattern:

Domain

Here's a sketch of Model.java.

Persistence

Most applications save objects to a relational database. We can use the Gateway pattern to hide and concentrate the SQL:

At this point we are using the Publisher-Subscriber pattern to refine the Model-View-Controller. We are using both the Model-View-Controller pattern and the Gateway pattern to refine the Layers pattern:

Next, let's take a detailed look at the Presentation layer.

When you are done following this trail, here's a little project.