In my network monitoring system it should be possible to easily configure the network layout.
So we will have something like the following layout:
It is no really useful to have the definitions when it is not possible to tell the user which definitions are available. This can be solved by creating classes for the definition types. All these classes do is holding a static instance of themselves, hold the name of the type and create a new definition of that type. Since the definition type can not be changed by anyone and we need it to create the real definitions, it is not necessary to construct them our self, that's why we use the singleton pattern here. Another advantage is that we can use this instance to show it to the user as well.
Using the definitionsWe can now make a user interface to make it easy to create the definitions and configure them. Therefore we need some extra patterns. Let's say our user interface will look like this:
The window on the right is a property grid, which can be used to change the properties of an object, so whenever one clicks on an item in the listview, the property grid will show the properties which can be changed.
At this point we don't add the definitions to the repository, because
we want to be able to cancel the changes we made. When we push the Save
button, we register all changes to the Repository and the data will be persisted.