1. Daniel Vivier
  2. PowerBuilder
  3. Thursday, 5 September 2019 20:41 PM UTC

We have a common PBL used by two different applications. It is compiled separately and used as a PBD by those applications, so it has no access to objects or global variables etc. in the application PBLs.

I have a situation where I have a window in both applications, that is almost identical in each, except for small amounts of different code, where the different parts need to access global variables from the applications. I'd like to move that window to the common PBL, but have to have a good way to have it access the applications' code for those different bits.

Obviously one option is to have a base window with most of the code in the common PBL, and inherit it in each application PBL, overriding or extending some code. The thing I don't like about that is the way PB compiles inherited objects, by including all of the code from the ancestor object in the compiled inherited one, leading to compiled code bloat. (We sell our software to small churches, many in the countryside, and thus some of whom may still have very very slow Internet for downloading applications!)

One solution I have used in the past is to design a function to do the distinctive parts, put a no-op version of that function in the common PBL, and real implementations of it in each application's PBL, which will override it since they are earlier on the library list. That works, and would have very little code bloat, but seems a bit ugly.

For cases where groups of functions are needed, presumably I could do the same idea with an NVO, with several no-op functions in a copy of it in the common PBL, and real implementations of the required different code in each application's PBL.

Any better ideas? Thanks.

Daniel Vivier Accepted Answer Pending Moderation
  1. Friday, 6 September 2019 01:40 AM UTC
  2. PowerBuilder
  3. # 1

Actually Miguel that's quite a sensible solution, thank you! The different code has to live somewhere, so there's no harm it living in the common object. Thank you.

Comment
  1. Miguel Leeuwe
  2. Friday, 6 September 2019 02:27 AM UTC
Glad I could help, sometimes simple solutions are the best.
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Friday, 6 September 2019 01:26 AM UTC
  2. PowerBuilder
  3. # 2

If the differences are little, I'd just pass in a structure object with the values of all the global variables you need and have your code in that single window do different things depending on those values. This would only be a solution if the global values wouldn't be changed elsewhere, while running your common window, or if those possible changes after having entered your window are not important.

OpenWithParm and CloseWithReturn to get any changes back??

Another thing might be to use some table with the values of your global variables in a database and work with those values.

 

Not sure if this is what you mean, so I'm sorry if I missed the point.

 

regards

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.