| View previous topic :: View next topic |
| Author |
Message |
diktyo Guest
|
Posted: Wed May 11, 2005 6:19 pm Post subject: Design Questions First Steps |
|
|
First steps in OO design (literlly crawling through MVP,
Iterators etc).
Trying to design some simple Business Objects (not even
accustomed to the notation ...)
type
TCity = class(TObject)
fCityID : integer;
fCityDesc : string;
TCustomer = class(TObject)
fCustID : integer;
fCustName : string;
f...................
fCityID : integer;
fCityName : string ;//<======= should I put it here ????
CITY is kind of look-up object. In DB Normalization theory I should
NOT put CityDesc within Customer (record). Is there any BENEFIT (only
benefits please) so as to put it in TCustomer ?
Thanks
Petros
PS. I am (trying to) develop a simple application for
an association I am member to (no fees involved) and I have
"plenty" of time (till summer end), so I decided to give it
a try both ways , the old RAD way and the "new to me" OO way.
I also post to Database groups, but for the "old" way"
|
|
| Back to top |
|
 |
Peter Morris [Droopy eyes Guest
|
Posted: Wed May 11, 2005 10:21 pm Post subject: Re: Design Questions First Steps |
|
|
| Quote: | fCityID : integer;
fCityName : string ;//<======= should I put it here ????
|
You should have CityID or CityName there, you should only have
City: TCity;
You can get the ID from the City object itself if you need to.
If you are trying various approaches, you should try ECO.
--
Pete
====
ECO Modeler, Audio compression components, DIB graphics controls,
FastStrings
http://www.droopyeyes.com
Read or write articles on just about anything
http://www.HowToDoThings.com
My blog
http://blogs.slcdug.org/petermorris/
|
|
| Back to top |
|
 |
Joanna Carter (TeamB) Guest
|
Posted: Wed May 11, 2005 10:34 pm Post subject: Re: Design Questions First Steps |
|
|
"diktyo" <diktyo (AT) mail (DOT) gr> a ecrit dans le message de news:
[email]42824caf (AT) newsgroups (DOT) borland.com[/email]...
| Quote: | type
TCity = class(TObject)
fCityID : integer;
fCityDesc : string;
|
Of course you should never have published fields like this :-)
You should really not use the class name to prepend fields or properties
either :
TCity = class
private
fID: Integer;
fDescription: string;
...
public
property ID ...
property Description ...
...
end;
TCustomer = class
private
fID: Integer;
fName: string;
f...................
fCity: TCity;
public
property ...
end;
| Quote: | fCityName : string ;//<======= should I put it here ????
|
You should not have anything to do with the City, apart from a TCity object,
inside the Customer class.
Joanna
--
Joanna Carter (TeamB)
Consultant Software Engineer
TeamBUG support for UK-BUG
TeamMM support for ModelMaker
|
|
| Back to top |
|
 |
diktyo Guest
|
Posted: Thu May 12, 2005 9:05 am Post subject: Re: Design Questions First Steps |
|
|
| Quote: | You should not have anything to do with the City, apart from a TCity
object, inside the Customer class.
Joanna
|
It's so obvious when someone else tells you how
to do it !!!
Joanna, Peter thanks, but I think I need a much
stronger brainwash to get rid of old habits
(design database schema first etc.)
Can't teach an old dog new tricks.
Petros
|
|
| Back to top |
|
 |
Joanna Carter (TeamB) Guest
|
Posted: Thu May 12, 2005 10:09 am Post subject: Re: Design Questions First Steps |
|
|
"diktyo" <diktyo (AT) mail (DOT) gr> a écrit dans le message de news:
[email]42831c6d (AT) newsgroups (DOT) borland.com[/email]...
| Quote: | Joanna, Peter thanks, but I think I need a much
stronger brainwash to get rid of old habits
(design database schema first etc.)
|
Yes, it's a common problem :-)
Don't forget to look up things like how to manage aggregation vs.
composition :
Aggregation means just having a reference to an object like your City
example.
Composition means ensuring the that a containing class is totally
responsible for the items it contains. e.g. SalesOrder contains
SalesOrderLine items. In this case, you would expect a database to have a
reference to the SalesOrder in each of the SalesOrderLines.
But this is not how you design classes; you should have a read only list
property inside the SalesOrder class and only be able to add new lines by
addressing an AddLine method in the SalesOrder class.
Not aiming to confuse you; just making sure you don't let this one slip by
)
| Quote: | Can't teach an old dog new tricks.
|
Oh, I don't know - I went to Uni at age 37
Joanna
--
Joanna Carter (TeamB)
Consultant Software Engineer
TeamBUG support for UK-BUG
TeamMM support for ModelMaker
|
|
| Back to top |
|
 |
Bryan Crotaz Guest
|
Posted: Fri May 13, 2005 12:47 pm Post subject: Re: Design Questions First Steps |
|
|
| Quote: | Can't teach an old dog new tricks.
Oh, I don't know - I went to Uni at age 37
Joanna
|
So that makes you an old dog... Hmmm self esteem problems, J? ;-)
Bryan
|
|
| Back to top |
|
 |
Jim Cooper Guest
|
Posted: Fri May 13, 2005 1:27 pm Post subject: Re: Design Questions First Steps |
|
|
| Quote: | So that makes you an old dog...
|
Bitch, actually <vbg>
Oh bugger, I just remembered she knows where I live. Damn!!
Cheers,
Jim Cooper
__________________________________________
Jim Cooper [email]jcooper (AT) tabdee (DOT) ltd.uk[/email]
Tabdee Ltd http://www.tabdee.ltd.uk
TurboSync - Connecting Delphi to your Palm
__________________________________________
|
|
| Back to top |
|
 |
krisztian pinter Guest
|
Posted: Fri May 13, 2005 2:17 pm Post subject: Re: Design Questions First Steps |
|
|
you are going to have a VB3 project
Jim Cooper <jcooper (AT) tabdee (DOT) ltd.uk> wrote:
| Quote: | Bitch, actually
Oh bugger, I just remembered she knows where I live. Damn!!
|
|
|
| Back to top |
|
 |
Joanna Carter (TeamB) Guest
|
Posted: Fri May 13, 2005 2:25 pm Post subject: Re: Design Questions First Steps |
|
|
"Bryan Crotaz" <bryan (AT) no (DOT) spam.for.me.please.inspirationmatters.com> a écrit
dans le message de news: 4284a1ef$1 (AT) newsgroups (DOT) borland.com...
| Quote: | So that makes you an old dog... Hmmm self esteem problems, J?
|
That reminds me; wasn't I due to visit your kennel sometime this year ? )
Call me on my mobile.
Joanna
--
Joanna Carter (TeamB)
Consultant Software Engineer
TeamBUG support for UK-BUG
TeamMM support for ModelMaker
|
|
| Back to top |
|
 |
Jim Cooper Guest
|
Posted: Fri May 13, 2005 3:58 pm Post subject: Re: Design Questions First Steps |
|
|
| Quote: | you are going to have a VB3 project
|
I know, I've been bad :-)
Cheers,
Jim Cooper
__________________________________________
Jim Cooper [email]jcooper (AT) tabdee (DOT) ltd.uk[/email]
Tabdee Ltd http://www.tabdee.ltd.uk
TurboSync - Connecting Delphi to your Palm
__________________________________________
|
|
| Back to top |
|
 |
|