 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Luis Guest
|
Posted: Thu Dec 11, 2003 2:34 pm Post subject: How to pass external parameters to an object |
|
|
How should I pass external, non persistent, parameters to an object before
save?
I maintained information of the logged user, like his Username, person
identifier, and other session variables, and sometimes I need to validate
the object at Save method using these external parameters.
// StartData, EndData and ModifiedBy belong to the object (also they're
mapped to a phisical table)
Task.StartDate:= edStartDate.Date;
Task.EndData:= edEndDate.Date;
Task.ModifiedBy:= AppSession.UsernameStr;
Task.UserId:= AppSession.UserId; <--- Non TTask related field
Task.Save;
Currently I included UserId at the TTask class, but I think it is not ok,
because is occupying memory, is not related to the object lifetime, and it
is only needed for a specific operation (save).
Thanks for advices,
Luis.
|
|
| Back to top |
|
 |
Marc Rohloff Guest
|
Posted: Thu Dec 11, 2003 3:14 pm Post subject: Re: How to pass external parameters to an object |
|
|
Luis wrote on Thu, 11 Dec 2003 11:34:10 -0300 ...
| Quote: | I maintained information of the logged user, like his Username, person
identifier, and other session variables, and sometimes I need to validate
the object at Save method using these external parameters.
Task.Save;
Currently I included UserId at the TTask class, but I think it is not ok,
because is occupying memory, is not related to the object lifetime, and it
is only needed for a specific operation (save).
|
How do you do your saving? Does Task save itself or does it delegate to
some other object/class?
Generally you would want to make the userid available to the persistance
layers in some other way. Since this usually global to a session you
might want to set it on some sort of global object (The persistance
manager, provider or broker if you have one) Or maybe create a new
global session object for this sort of information.
Marc Rohloff
marc rohloff at bigfoot dot com
|
|
| Back to top |
|
 |
Luis Guest
|
Posted: Thu Dec 11, 2003 3:29 pm Post subject: Re: How to pass external parameters to an object |
|
|
"Marc Rohloff" <dont (AT) mailme (DOT) com> wrote
Hello Marc,
| Quote: | How do you do your saving? Does Task save itself or does it delegate to
some other object/class?
|
Task delegates the save operation to a persistance object (TDMObject ala
P.brown). I also call a Validate method, if the object requires 'BeforeSave'
validation:
procedure TTask.Save;
begin
Validate;
inherited Save; // it also delgates to the persistence layer
end;
| Quote: | Generally you would want to make the userid available to the persistance
layers in some other way. Since this usually global to a session you
might want to set it on some sort of global object (The persistance
manager, provider or broker if you have one) Or maybe create a new
global session object for this sort of information.
|
Ok, I think I will go to a 'FrameworkManager' global object. I don't want to
put those variables at the persistance layer, because they are not related
with them but the object problem domain.
But I think I'll have problems at future, because this time the framework is
being used in a traditional c/s application, when it upsizing to a web
application, my global FrameworkManager.UserId will not work ;)
Thanks,
Luis.
|
|
| 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
|
|