Representation of workpiece saved as a flag.

Patterns in Java
Collections for States
Kevlin Henney
Listing 1. Representation of workpiece saved as a flag.


public abstract class Workpiece
{
    public void save()
    {
        saveState();
        changed = false;
    }
    public boolean saved()
    {
        return !changed;
    }
    ...
    protected abstract void saveState();
    private boolean changed;
}

About the Author

Kevlin Henney is a Principal Technologist with QA Training in the UK.

Featured

Upcoming Events

AppTrends

Sign up for our newsletter.

I agree to this site's Privacy Policy.