1. Aleš Vojáček
  2. PowerBuilder
  3. Saturday, 18 December 2021 21:00 PM UTC

Hi all,

what are best practices for comlex ui behaviors?

What I mean by that.

If you have form whith datawindow control and some buttons on that form (or some other ui elements). And you need to, enable/disable some columns in datawindow same as UI elements on form itself. Some rules depend on combinations of values from DataWindow. You need to behave on new record, retrieved record from DB, while editing form, and so on.

I know that this is possible control in ItemChanged event of DW, on RetrieveRow/RetrieveEnd and so on. I can do i using expressoins on DataWindow in script, ....

But It is really mess to have all logic spread over whole window, datawindow, ....

Are there some best practices for such a scenario?

 

Thank you Ales

Accepted Answer
Benjamin Gaesslein Accepted Answer Pending Moderation
  1. Monday, 20 December 2021 07:15 AM UTC
  2. PowerBuilder
  3. # Permalink

Hi Ales.

But It is really mess to have all logic spread over whole window, datawindow, ....

The way PB was designed makes it very easy to mix business logic and presentation logic into UI objects. You have to actively work against that. :) 

To avoid having your code cluttered all over various UI elements you could try to implement a variant of the Model-View-Presenter pattern. Set up a nonvisual object that works as presenter and redirect any UI events that react to user input to an event of this object. This way each part of your business logic can be appropriately encapsuled into its own object(s) that can then be called by the presenter without having to tightly couple UI elements to the business logic. If the UI needs to change based on user input/database activity, the presenter will do that. Your DW control can be completely passive, retrieves can be handled by a datastore object on the presenter and shared with the view DW.

 

Comment
  1. Aleš Vojáček
  2. Monday, 20 December 2021 09:13 AM UTC
"The way PB was designed makes it very easy to mix business logic and presentation logic into UI objects. You have to actively work against that. :) " Yes those are my feelings. It is simple make funcional app, but hard to maintain especially if there are more "right" ways how to achieve same result (dw expressions on columns, dw.modify, .....) and if those are spread over whole window code it is mess. Its working, but do change is a bit tricky :-)

I will try to use MVP pattern and will see how it goes.
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Monday, 20 December 2021 03:15 AM UTC
  2. PowerBuilder
  3. # 1

Hi, Aleš -

Tough question... and one that does not have a single, simple answer. Ask ten people, you'll likely receive ten different answers. Also, it's a little difficult to get a clear mental picture of your particular issue(s) from your description.

Here are some thoughts for you to consider:

  1. Consistency. Users get confused by an inconsistent user interface. If your app provides similar functionality in other places, consider implementing it in the same manner here.
  2. Simplicity. A complex interface is more difficult to understand and use than a simpler one. Sometimes a simpler interface is harder to code, but within reason, the user's needs should outweigh the needs of the developer(s). It's a terrific goal to have interface logic only coded in one place, but sometimes you may have to duplicate it.

In cases where some editable data columns are conditionally protected, I've added a column to the result set named "protected" or something similar, and the SELECT statement sets the value of this column to "N" (not protected). If any columns one or more rows need to be protected, then an object function in the window can set the value of the "protected" column to "Y". Conditional expressions protecting columns can be based on the value of the "protected" column. If you have more than two conditions, use additional values or a numeric datatype instead of a character.

I hope this helps you, and/or helps stimulate some additional discussion.

John

 

Comment
  1. Aleš Vojáček
  2. Monday, 20 December 2021 09:16 AM UTC
Hi John,

special column is nice Idea, may be this can clean mess a little, but still there wil be UI logic spread over whole window, but it will clean up dw column functions.

Thank you.
  1. Helpful
  1. Aleš Vojáček
  2. Thursday, 23 December 2021 19:09 PM UTC
I cannot accept as an answer more then one reply. If I it is possible I will mark both responses as answer. Thank you
  1. Helpful
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.