Skip to content

pattern

Progress Object Pattern

When a user executes a long running background task an application usually wants to report progress about the task to the user. Application developers often do this by passing a ProgressListener to the background task’s  method and the method uses the ProgressListener to report it’s progress. But you can also design it in another way and I would like to introduce another pattern here. At least I would like to show an example of how to implement a progress object pattern with Javas Swing. The complete example code is available at gitthub: https://github.com/link-intersystems/blog/tree/master/progress-object-pattern. But before I introduce the progress object patten let us take a look at the progress listener concept. Progress listener A progress listener is conceptually a callback that… Read More »Progress Object Pattern

Singleton implementation pitfalls

In this blog I want to show implementation pitfalls of the singleton pattern and show you why enums are the better singletons. The singleton pattern is widely known and discussed a lot of times. Developers often prefer to implement a singleton using a final static field. But this approach has some pitfalls or rather malicious code can compromise the singleton pattern. In the next sections I will show you the possible attacks on singleton implementations that compromise the pattern. Maybe you will use this techniques to implement a kind of workaround some day, but I hope you will not. Static Final Field Singleton The purpose of a singleton is that only 1 instance of a… Read More »Singleton implementation pitfalls

The MVC pattern implemented with java swing

MVC Pattern Basics The MVC pattern describes a way to organize the components of a graphical user interface. Therefore it must cover all aspects of a user’s interaction with an application. If we take an analytic look at a graphical user interface we will understand why the MVC pattern is composed of the 3 elements model, view and controller. Model A model is an abstraction of something that you want to present the user in a view. Therefore there are two stereotypes of models: UI-model A ui model is an abstraction of a ui component’s state. Therefore it has properties like: focus, enablement, selection and so on. A good example… Read More »The MVC pattern implemented with java swing

GDPR Cookie Consent with Real Cookie Banner