java - Getting rid of GWT MVP boilerplate -
following documentation on places & activities + mvp, each page have create:
- a place
- an activity
- a tokenizer (i have implement tokenizing logic)
- an interface presenter (the activity implements interface)
- an interface view
- the view implementation
- the ui binder xml view implementation
- a node in app activity mapper
- a node in gin module binding view interface view implementation
i created app basic functionality(5 pages , navbar) , have more 1500 lines of code , ~40 files. think unmaintainable, haven't found on solving this. there couple of frameworks(eg gwtp) implement mvp need same amount of boilerplate well.
i achieve same functionality in ~200 lines using spring mvc or play.
what doing wrong , how solve it?
i think unmaintainable
i not agree you. large number of small files better maintenance couple large files. agree gwt much more verbose spring mvc:
- you not need these interfaces because of dynamic nature of jsp
- jsp in sppring mvc case not strictly typed , give abilities many low level things automatically (for example data binding).
- and not things @ (no need clean view between requests, view stateless).
in case of gwt due strict nature of java , statefull view must lot of additional work. maintenable (if done correctly). main advantage can add unit tests presentation layer. due fact more maintenable for long running projects complex ui, large codebase , big team. if not case project (screens simple , not plan add unit tests ui layer) may better to:
- use more lightweight presentation technology (spring mvc example).
- or simplify policy (for example allow presenter -> view interactions without interfaces). lose ability unit test presenters in case. mentioned @andrea boscolo can use gwtmockito workaround problem!
two advantages of interfaces between view , presenters:
- you can easy switch view implementation (famous case making desctop ui -> mobile ui switch unfortunately never saw implemented)
- for me kind of barrier keep presentation logic in presenter. presenter know necessary things. concept. helps me write pieces in right places.
what annoing these files takes time setup 1 activity. simplify it:
- ensure use uibinder template in eclipse
- even more, can write code generator take activity name , package parameters , generate necessary things. need modify activitymapper , start writing important ui logic. done current project , makes me happy.
another source of boilerplate data binding. consider using editor framework.
Comments
Post a Comment