Apply MVP pattern in PowerBuilder Application
Posted by Frank Mao on February 21, 2008
Lack of interface, it is very hard to implement MVP design pattern in PB application, so I created a variation like this:
All the objects expect UI are non-visual objects. ViewBinded is inherited from view object. UI will be tightly coupled with viewbinded nvo, (they are acting more like a partial class in dotNet word) but UI doesn’t couple with either of view or presenter, so unit-test presenter becomes possible.
A code demo will look like this:
/*w_demo.open event */
inv_view = create n_cst_viewbinded_demo
inv_view.of_init(this)/* viewbinded. of_init(aw_ui) */
inv_presenter = create n_cst_presenter_demo
f_init( aw_ui, inv_presenter )/* viewbinded.of_init(aw_ui, anv_presenter) */
iw_ui = aw_ui
inv_presenter = anv_presenter
inv_presenter.inv_view = this
inv_presenter.of_some_action( )/* presenter.of_some_action() */
inv_model.of_call_base_on_view_properties(inv_view.Property1)
//…process…
inv_view.event ue_after_process()/* viewbinded.event ue_after_process */
aw_ui.st_statuts.text = “Jon finished.”
I tried to unit-test pb app by setting up some fake UI, like lw_1 = create w_1, like I found out before, PB won’t complain but the open and close event won’t be triggered. Today I found another bad thing, this fake action can also cause a unable-reload problem in my handy unit-test tool, PowerUnit/PBUnit. Once I remove those fake creation of UI object in my unit-test code, this problem won’t away.

Apply unit-test to PFC application « maonet technotes said
[...] had to adopt MVP pattern (kind of, becuase PB doesn’t support interface) to my userobject/window to make unit-test possible. The new term of MVP, Passive View, makes more sense for pattern [...]