Apply MVP pattern in PowerBuilder Application

Lack of interface, it is very hard to implement MVP design pattern in PB application, so I created a variation like this:

pb_mvp.gif

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.

Advertisements

One thought on “Apply MVP pattern in PowerBuilder Application

  1. Pingback: Apply unit-test to PFC application « maonet technotes

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s