 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Bob Dawson Guest
|
Posted: Wed Jul 09, 2003 1:44 pm Post subject: Re: OO Newby - Class diagram problem |
|
|
"William Buchanan" wrote
| Quote: | which spans over a couple of tables. The users are going to be able to
open each email and edit all the data on it then save the data to the db.
|
Then we're reading and writing properties of the TEmail object, rather than
of a recordset or table drectory--good.
| Quote: | I was stuck on trying to decide if the GUI button to, for example load an
email, would call a method of the user to load the email, which would in
turn call a method of TEmail to load the data from the db, or would the
GUI
button call the load method of TEmail directly.... or am I completely on
the
wrong track.
|
For now, I'd say let the GUI call the email's load method. I don't see any
reason to couple the user object to the email object--they don't have to
know about each other. General rule of thumb here is that each object
touches/knows about the least number of other objects possible (called the
'Law of Demeter').
As for the GUI, first think about your application as a series of layers:
GUI
| Quote: |
business objects
storage |
Higher layers can know about lower layers, but not the reverse, so there's
really nothing wrong with having the a button call the AnEmail.Load()
method, so long as the TEmail object doesn't know about the GUI (The form
writes to the email object and reads from it, never the reverse.)
In a more formal/complex system, we create portal layers--
GUI
presenter or controller
//handles transfers between your business objects and
//your GUI, and may contain logic for dynamic object
//interaction
/
business objects
data access
//handles transfers between your business objects and
//your storage, and may contain optimizing logic (object
//caches, metadata objects, SQL generators, etc.)
/
persistence storage
The presenter or controller is part of a model-view-controller/presenter
(MVC or MVP) pattern, and the data access layer is the center of a similar
three-part pattern known as an OPF (object persistence framework)
Because user types may change viewing or editing rights, you need to think
about that as a general problem and write a security manager object to
handle how rights are negotiated. That object could provide you with either
a boolean or scaled response to the 'Can object X do Y to object C?'
question in a general way that might look something like this:
public
function HasRights(Actor : ISecurityRequestor;
DirectObject : ISecuredEntity;
const Activity : string) : boolean;
Any user, machine, or even program process could implement the
ISecurityRequestor interface, and any business object implementing
ISecuredEntity can be controlled for available behaviour. Using a rights
manager with interface (or could be ancestor) parameters allows your user
and email objects to determine security levels without any actual
dependencies on each other.
| Quote: | I hope this explains my problem (which i'm sure is a pretty stupid one).
|
It's a core question--not a stupid one at all. And I hope this helps to
answer it.
Here's an older paper about layered architecture that's pretty good:
http://members.aol.com/kgb1001001/Articles/LAYERS/appmod.htm
If you need information about MVC/MVP patterns or OPFs, they're sort of
favorite topics around here... :-)
bobD
|
|
| Back to top |
|
 |
William Buchanan Guest
|
Posted: Wed Jul 09, 2003 1:46 pm Post subject: Re: OO Newby - Class diagram problem |
|
|
Hi Phil
Again, many thanks.
That clears up my dilemma, and also answers a couple of things i've been
pondering over!
Regards
Will
"Phil Shrimpton" <phil (AT) nospam (DOT) co.uk> wrote
| Quote: | In article <3f0bc7f1$1 (AT) newsgroups (DOT) borland.com>, William Buchanan says...
Hi,
I am designing a system which will send marketing email to people who
subscribe to our service. I will have different levels of user with
different rights, e.g. designer, authoriser, progress tracker.
I was stuck on trying to decide if the GUI button to, for example load
an
email, would call a method of the user to load the email, which would in
turn call a method of TEmail to load the data from the db, or would the
GUI
button call the load method of TEmail directly.... or am I completely on
the
wrong track.
OK, so you TUser is a class that holds information about the current
'person' using the app?
If that is correct, I don't thing the loadEmail() method should be part
of the TUser class.
What I would do is call the TEmail.load() method from the UI, and
depending on how you have implemented your 'user rights' either pass it
a role or the TUser class itself. For instance...
If your TUser class has a 'Role' property (e.g. containing
'authoriser'), you could....
MyEmail := TEmail.load(CurrentUser.getRole());
If you have a separate 'rights management class', you could...
MyEmail := TEmail.load(CurrentUser);
..then in the load method, you could do...
CurrentRight = TRightsManager.getLevel(CurrentUser);
case CurrentRight of
rAuthoriser : DoSomething();
Cheers
Phil
|
|
|
| Back to top |
|
 |
William Buchanan Guest
|
Posted: Wed Jul 09, 2003 2:00 pm Post subject: Re: OO Newby - Class diagram problem |
|
|
Hi Bob
Again, many thanks for taking the time to reply....
That's very interesting, and as a result I will need to do some major
changes! I have just linked classes together as needed but can see that a
good structure is required. Will have a go at that!
Regards
Will
"Bob Dawson" <bdawson (AT) idtdna (DOT) com> wrote
| Quote: | "William Buchanan" wrote
which spans over a couple of tables. The users are going to be able to
open each email and edit all the data on it then save the data to the
db.
Then we're reading and writing properties of the TEmail object, rather
than
of a recordset or table drectory--good.
I was stuck on trying to decide if the GUI button to, for example load
an
email, would call a method of the user to load the email, which would in
turn call a method of TEmail to load the data from the db, or would the
GUI
button call the load method of TEmail directly.... or am I completely on
the
wrong track.
For now, I'd say let the GUI call the email's load method. I don't see any
reason to couple the user object to the email object--they don't have to
know about each other. General rule of thumb here is that each object
touches/knows about the least number of other objects possible (called the
'Law of Demeter').
As for the GUI, first think about your application as a series of layers:
GUI
|
business objects
|
storage
Higher layers can know about lower layers, but not the reverse, so there's
really nothing wrong with having the a button call the AnEmail.Load()
method, so long as the TEmail object doesn't know about the GUI (The form
writes to the email object and reads from it, never the reverse.)
In a more formal/complex system, we create portal layers--
GUI
presenter or controller
//handles transfers between your business objects and
//your GUI, and may contain logic for dynamic object
//interaction
/
business objects
data access
//handles transfers between your business objects and
//your storage, and may contain optimizing logic (object
//caches, metadata objects, SQL generators, etc.)
/
persistence storage
The presenter or controller is part of a model-view-controller/presenter
(MVC or MVP) pattern, and the data access layer is the center of a similar
three-part pattern known as an OPF (object persistence framework)
Because user types may change viewing or editing rights, you need to think
about that as a general problem and write a security manager object to
handle how rights are negotiated. That object could provide you with
either
a boolean or scaled response to the 'Can object X do Y to object C?'
question in a general way that might look something like this:
public
function HasRights(Actor : ISecurityRequestor;
DirectObject : ISecuredEntity;
const Activity : string) : boolean;
Any user, machine, or even program process could implement the
ISecurityRequestor interface, and any business object implementing
ISecuredEntity can be controlled for available behaviour. Using a rights
manager with interface (or could be ancestor) parameters allows your user
and email objects to determine security levels without any actual
dependencies on each other.
I hope this explains my problem (which i'm sure is a pretty stupid one).
It's a core question--not a stupid one at all. And I hope this helps to
answer it.
Here's an older paper about layered architecture that's pretty good:
http://members.aol.com/kgb1001001/Articles/LAYERS/appmod.htm
If you need information about MVC/MVP patterns or OPFs, they're sort of
favorite topics around here... :-)
bobD
|
|
|
| Back to top |
|
 |
Bob Dawson Guest
|
Posted: Wed Jul 09, 2003 2:54 pm Post subject: Re: OO Newby - Class diagram problem |
|
|
"William Buchanan" wrote
| Quote: | That's very interesting, and as a result I will need to do some
major changes! I have just linked classes together as needed
but can see that a good structure is required. Will have a go
at that!
|
Last piece of advice--OO and architectural thinking are there to help manage
and contain complexity--don't go overboard making everything exactly
'correct' if the actual problem is really simple--building the Library of
Congress cataloging system helps keep a library managable, but it's a bit
much to undertake if what you really have is the bookshelf next to your
desk. Pragmatics always.
Happy to help, and good luck.
bobD
|
|
| Back to top |
|
 |
Phil Shrimpton Guest
|
Posted: Wed Jul 09, 2003 4:11 pm Post subject: Re: OO Newby - Class diagram problem |
|
|
In article <3f0c1c96 (AT) newsgroups (DOT) borland.com>, William Buchanan says...
Hi,
| Quote: | That clears up my dilemma, and also answers a couple of things i've been
pondering over!
|
At least it does not create more questions <g>
Phil
|
|
| Back to top |
|
 |
Marjan Venema Guest
|
Posted: Wed Jul 09, 2003 5:19 pm Post subject: Re: OO Newby - Class diagram problem |
|
|
| Quote: | At least it does not create more questions <g
|
Just wait a bit longer...
Marjan
____________________________
Marjan Venema - BJM Software
http://www.bjmsoftware.com
http://www.bjmsoftware.nl
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|