java - MVC and Swing in desktop application -
after realizing have ignored mvc pattern have tried utilize concept in application swing view. have read of posts on subject of mvc swing still bit confused, because complicated me grasp, , think need basic clarifications don't set off on wrong path.
i wonder how common use mvc in real projects. many online tutorials seem leave out controller , mix model, while confused xstl:s business logic capabilities. why want address datasource jsp view?
these thoughts aside, proper question this:
if have swing component, should event listener in swing class update component state through calling (static perhaps?) methods in pojo controller class, in turn gets appropriate business logic model, made pojo class hierarchy , associated persistence?
i've worked freelance long time , 90% of projects java swing (desktop applications). lot of projects involved migration languages visual fox pro java, pain, because hard part not think in logic done, hard part take code mess , turn good-looking code following practices , using design patterns, that's why idea make schema or map in mind how can separate code following concepts of model, view, controller.
mvc mentioned helps have good-looking, maintainable , easy read code, follow programming paradigms , practices.
view: obviously, part interacts user (user interface), in case of swing, windows, frames, panels , code involves graphic components need app.
controller: involves core or business logic stablish application, in "layer" should include functionality , "how application achieve goals?".
model: related data manage, example, entities , classes represents data want manage or give maintenance.
applying mvc not hard, mentioned, pain when have migrate code not-applying-mvc structure mvc structured application. easier start coding using mvc.
a way used using maven , separate application little "modules", of course, don't need maven, found useful in moment, in case can try practicing or used mvc separating application little projects, instance:
java project 1: application-data-model (contains code related data management: entities, dtos, beans, daos)
java project 2: application-core-controller (contains business logic , functionality, can use facade pattern here if want make code more "transparent" when relate view)
java project 3: application-view-ui (contains panels, frames , graphic components)
working way helped me (and forced me) used separate code , keep eye on matters project i'm working on. instance, if i'm on application-data-model i'm focused in data model, i'm not thinking in business logic nor graphic interface.
long explanation, maybe better, hope have helped or @ least gave hand this.
best regards.
Comments
Post a Comment