Like This Site? 
 
RSS Feed Follow Us 

on Twitter! Be Our Fan!

Separating the GUI and Logic with a StateManager

Share this post!
 Vote this!

One of the biggest mistakes new programmers make, especially when beginning to work with GUIs, is to mix the business logic with the UI code. This is poor practice for a number of reasons. First, it makes it difficult to isolate the data to ensure it's integrity. There is a saying in this industry- if a piece of data is in two places at once, it is wrong at both places. Redundancy in this fashion makes it difficult to ensure data integrity. For example, if one class modifies a count variable, and a corresponding variable is contained in another class, that second variable may not be updated in the second location. By separating the business logic from the UI, this problem can easily be avoided.

A second reason not separating the business logic from the UI is that it makes it hard to move to another UI platform. For example, by separating the business logic, it is easily develop to use a Swing GUI, a console application, or an Android application without rewriting more portions of the framework than necessary.  more...

0 comments:

Post a Comment