I’ve been working on a little utility project, and I’ve been using port/adapter/simulator on both the server-side parts and on the UI parts. It has been working nicely, though it took me a while to get there.
Initially, I started with a single UI class. After a bit of extension, it looked a bit ugly, so I decided to break it apart by functional area – there’s a main working area, there’s a favorites area, there’s an executing area, and there’s a config area. For each area, it looks something like this:
-> UIFavoritesSimulator (really more of a mock than a simulator)
FavoritesManager(IUIFavorites, IUIStore, etc. )
The UI side handles just that – the UI – and the manager part handles the business logic. The UI part exposes events for user actions a properties and methods for modification.
There was one slightly sticky part of this. There are times when the working area manager needs to add itself to the favorites. Options I thought of:
1) Passing the UIWorking object to the favorites manager.
2) Passing the working manager to the favorites manager.
3) Hooking the UIworking event to a favorites manager method in the main creation code.
4) Hooking a working manager event to a favorites manager method in the main creation code.
I didn’t like #1 or #2, so I ended up doing #4. #3 also seemed okay.