Global variables are evil, so in your PFC app, you should try to reduce the global variables to only one: n_cst_appmanager.
Then, in your objects, add a function called of_set_appmanager to set this global variable to it’s instance one. Unfortunately PB’s constructor doesn’t take parameters, we cannot use constructor injection for PowerBuilder objects. Unfortunately, object constructor in PB does not take any parameters, yet. So constructors cannot be used to accomplish dependency injection in PB. (Thanks Kpu for helping me out of this weird Engrlish expression.)
Visual objects can not be unit-tested, actually, if you try
ldw_1 = create ldw_1
PowerBuilder doesn’t report any compile errors, but, datawindow’s constructor event won’t be triggered in this scenario. Same thing will happen if you try any (visual) userobject.
I tried 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 newbies. Your UI should not bee too smart, which means don’t put too many logic in it. So, you have to extract all retrieve functions into the presenter behind this UI/view. In another word, SetTransObject(SQLCA) won’t need in UI.