BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

delayed loading of BO's properties

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OO design
View previous topic :: View next topic  
Author Message
Magnus Jungsbluth
Guest





PostPosted: Mon Jul 07, 2003 1:25 pm    Post subject: delayed loading of BO's properties Reply with quote



Hi,

is there any easy approach to load BO's properties when they are needed
withouth much causing overhead?
My Objects use an Attribute-approach:
i.e. TIntegerAttribute
- prop Value
- function IsNul: Boolean

so I could easily add an "loaded" flag that is checked, when "Value" is
accessed .... BUT
My problem ist how to define which Fields should be loaded if I use lets say
5 properties in an operation I want them to be loaded all at once(if
persisted from database), so I don't have 5 issued selects.
The only way I can imageine is to add methods to my BO that take care of
this
i.e. BO.LoadAdressProps, BO.LoadAccountInfo, BO.LoadDescriptiveProps...

So. is there any easy pattern to solve this ?

best regards,
Magnus



Back to top
Dan Downs
Guest





PostPosted: Mon Jul 07, 2003 2:18 pm    Post subject: Re: delayed loading of BO's properties Reply with quote



Here's how I've done it in the past:

TSomeAttribClass = class;

TMyClass = class
protected
FPropVar : TSomeAttribClass;
function GetSomeAttribClass: TSomeAttribClass;
procedure SetSomeAttribClass(const Value: TSomeAttribClass);
public
constructor Create;
published
property PropVar : TSomeAttribClass read GetSomeAttribClass write
SetSomeAttribClass;
end;

constructor TMyClass.Create;
begin
FPropVar := nil;
end;

function TMyClass.GetSomeAttribClass: TSomeAttribClass;
begin
if Assigned(FPropVar) then
begin
Result := FPropVar;
exit;
end;
FPropVar := TSomeAttribClass.Create;
FPropVar.LoadSomethingFromSomewhereSomehow;
Result := FPropVar;
end;

procedure TMyClass.SetSomeAttribClass(const Value: TSomeAttribClass);
begin
if Value = nil then
// Handle nil case
if Value <> FPropVar then
FPropVar.Assign(Value);
end;


It can be a bit tendious, but it can be applied to nearly every property.

DD


Back to top
John Herbster
Guest





PostPosted: Fri Mar 03, 2006 8:03 pm    Post subject: Re: Evangelizing Reply with quote



Quote:
How do you evangelize OOP without coming across as
"this is the *right way* to write software", and so forth?

Then have good, defensible reasons for the changes that
you are promoting. We don't need more people out there
pushing for changes that they themselves cannot understand
or explain to others. --JohnH
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OO design All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.