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
/* 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
/* presenter.of_some_action() */
/* 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.