开发者

Netbeans: how to separate application logic from view?

When creating a desktop application in Netbeans,

what is the recomme开发者_如何学JAVAnded approach in separating application logic from the view (gui builder) ? The two files are generated by the gui builder in Netbeans.


You might want to read the Sun article about Java SE Application Design With MVC.

Here is an example: Model-View-Controller (MVC) Structure.


Well the short and general answer (for any object oriented language) is to use the Model View Controller or MVC design pattern.

What's so cool about this, is that in decoupling the view (the interface code) from the model (your app logic) you can easily add multiple interfaces (such as a command line and a GUI), or port to different platforms, while keeping your back end business logic the same.

Check out the book Design Patterns: Elements of Reusable Object-Oriented Software by the "Gang of Four". It is the canonical design pattern book. In addition to MVC, there are a ton of other really useful design patterns. Even skimming it will pay great dividends when you go to architect some software.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜