tags:

views:

135

answers:

4

Hi,

I'm about to start an application which will have both console and GUI interfaces. What I wan't to achieve is COMPLETE decoupling of application logic from interface. In future, I may also add web interface, and I don't want to change anything in my application.

Is there a good example (perhaps some open source project) where I can learn how this should be done properly.... also I'd appreciate advices/guidelines on how to do this.

Thanks

+1  A: 

Build your core functionality (1) and your command line version (2) first (to the point where they are more or less functionally complete). Take care to carefully design / document your API. This way you can't intermingle logic and GUI parts early on.

An example for a good decoupled command line / GUI application would be mplayer for example (although one could argue that's it feels like a command line application with a GUI stuck on).

ChristopheD
+2  A: 

a good technique for logic and ui decoupling is the Model View Presenter patterns and its variants (Passive View and Supervising Controller). There are writings by martin fowler and also many blog posts that present these patters.
I also suggest you to look for another variation of MVP, called Presenter First. theres a good article about it, and also a good java code sample (look for java example)

Asaf David
+1  A: 

Fowler has a great overview of GUI architectures: http://martinfowler.com/eaaDev/uiArchs.html

I personally use the PresentationModel construct throughout my apps - it keeps the presentation side of things completely separate from the business logic.

Kevin Day
Any good example that I could have a look?
A: 

Crank Software's Storyboard Suite is architected with MVC (model-view-controller) at the core, which allows you to easily separate your gui logic from your business logic. Storyboard isn't open source but there is a free 30 day evaluation available on the home page www.cranksoftware.com

Jason

Jason