I'm new in PB World. using PB9. Non-PFC
PB is Object Oriented Programming Language.
How to digging the advantage of OOP.
All the programmmers want to modular-design and can be
RE-USE.
I'm still not understanding its concept, so I have lots of
questions.
Lets says the Application becomes bigger and bigger,
contains 50 windows, and some PBLs.
and of course, not makes sense if the programmers writing
script into each window's as below :
HOW MANY "BETTER WAY" TO SOLVE IT ?
as i know there is :
The first is :
To create Global Function, create user event on each
windows. the user event call the global function.
The second is :
To create window base class, so all the windows inherit from
it.
But, How to do it ?
Is there any way ?
Please advice and show me the script.
Regards,
Steven
No matter how you code it, an application will become complex and somewhat
hard to understand as it grows and ages.
The biggest advantage of OOP is encapsulating functionality. Inheritance is
great too, and at first appears to be of most value, but I'd rate it 2nd to
above. The third element typically mentioned is polymorphism, which is
useful, but harder to imagine/possibly to understand and though very
valuable as well the last thing of the 3 I'd focus on understanding.
The first is most important to removing the complexity you're worried about,
but possibly the hardest to attain, because you have to DESIGN for it. You
must understand the boundaries between data and business logic and enforce
the concept that an object serves a purpose and the things it serves should
be done within the object by the object and returned to the requestor. The
requestor should never operate directly on the objects variables/data but
let the object get/set the data for them. The object should never go
outside the object and do anything it wasn't designed to do. Following this
concept leads to loosely coupled code which is quite modular, reusable and
flexible.
Writing tightly-coupled code that violates the above general principles, by
direct requestor/object linkages/interaction is what leads to code that is
hard to maintain, inflexible and that becomes a bigger nightmare as time
goes by.
Inheritance comes in two forms in PB, first is visual inheritance which is
useful but of limited real value and should be kept (in my opinion) to three
or maybe four levels of inheritance at the most, with typically two levels
at a minimum (in my opinion). Trying too hard here to get everything to be
inherited and reused generally will get you into trouble because you'll end
up with too many special cases where you have to branch off and inherit,
making for confusion.
Second is non-visual object inheritance where you have a non-visual object
containing usually events, functions, and variables. If you have looked at
the PFC, these are frequently called services, which are a collection of
functions and events that are containerized and designed to handle a
specific set of functionality and perhaps operate on a specific set or type
of data.
To learn how to understand and use the above, I'd suggest NOT using PB to
learn it, but rather get a good book, the more basic the better probably, to
try and grasp the real world use of the concepts. I'd even go as far to say
you might want to ignore it and write your first app without consideration
for it using plain PB, just to learn the mechanics of windows, controls,
functions, events, variables, variable scoping, data access and the
datawindow/datastore. Assume you'll throw it away and rewrite it, so don't
spend more than 3 months doing this. Once you've done this, and read the
book, if you don't have a clue where to go, hire some professional help for
a week, to come in and hand guide you through it. If you get it, the go
back and look at the app you built and try to decipher the pattterns
(commonality) you've built and see where you've lots of code to do the same
thing in several places, each with separate copies of similar code.
The PFC can actually be used to learn some of this, though as a newbie, I'd
find it hard to navigate and may prove frustrating. If you can get the
navigation down beforehand though, try picking apart a service in the pfc
and try to follow it all the way through. The most difficult, and probably
hardest to do this with is the logical unit of work/linkage services, so I
wouldn't start there. Perhaps look at the datawindow sort, filter, report,
find, selection services would be good places to start.
Though I don't know why you want to use ESC to close a window (non-windows
standard approach), you could put a command button on your base window
class, set tab order to 0, set ESCAPE property to TRUE and put the button at
a high x/y location well off of any visual screensize (say 7500,7500). Then
when anyone hits the ESCAPE key it would TRY to close the window (and would
unless you have other code in the closequery/close events to stop it from
closing).
The X in the upper right corner and Alt-F4 are the standard means other than
a Close or Cancel button for closing a window.
Good Luck!
Jim
<Better way to implement key ESC to close window ?> wrote in message
news:47883a46.542...@sybase.com...
That's right, learning PFC is going to frustation.
Just my opinion,
Larry
"steven" <stv...@yahoo.com> wrote in message
news:478b32eb.248...@sybase.com...