 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Gabriel GIbaut Guest
|
Posted: Thu Jan 06, 2005 1:02 pm Post subject: Nested Object Editions |
|
|
Hello,
I have this situation:
Iīm editing objects so if i call Edit on an instance, it shows a form to
edit itself (I.E: Employee.Edit). but some editions are nested, that is,
while editing an employee i can edit his salary, so there is code in some
place that class Salary.Edit( that shows another editor) and so on...
The problem is that i need to commit the changes right after the edition
(specs) but in the place where the first edition started, so depending if
iīm nested or not i need to commit the changes or not. Nowadays the old code
uses a property in the editor that says if itīs the first on the chain or
not, and that assignment propagates all over the chain.
I got this idea of a Transaction class with two sublasses: RealTransaction
and FakeTransaction (this does nothing), and depending use one of them
depending on the context. So the editing code is the same.
But my problem still remains, how can I in an OO-Way determine if iīm nested
or not?
TIA
Gabriel
|
|
| Back to top |
|
 |
Bob Dawson Guest
|
Posted: Thu Jan 06, 2005 3:09 pm Post subject: Re: Nested Object Editions |
|
|
"Gabriel GIbaut" wrote
| Quote: |
Iīm editing objects so if i call Edit on an instance, it shows a form to
edit itself (I.E: Employee.Edit). but some editions are nested, that is,
while editing an employee i can edit his salary, so there is code in some
place that class Salary.Edit( that shows another editor) and so on...
|
It's generally considered a bad idea for business objects to know anything
about displaying themselves. To a certain extent you can finesse this by
having a registration process (Salary knows that a editing class exists, and
if one is registered calls it), but even that becomes problematic if your
problem domain becomes complex. For example, one might often want to edit
collected objects in a frame on the collection owner's edit form, rather
than proliferating a bunch of sub-forms.
Question: what's the sequencing relationshp between the forms and the
transaction--when I finish with the Salary edit form (called from within
editing an employee), does anything get persisted at that point? Does the
salary edit form have both 'Ok' (accept the edits in memory but do nothing
else) and 'Save' (accept and persist the changes) options?
| Quote: | But my problem still remains, how can I in an OO-Way determine if iīm
nested or not?
|
My tendency is to say that the business object shouldn't care. That is, it
simply issues a BeginTransaction request to the persistence layer, and a
Commit when it's done. The persistence layer is then responsible for knowing
whether it's already in a transaction context and so determining whether to
issue an actual BeginTransaction call to the storage device or merely to
increase the current transaction nesting level.
bobD
|
|
| Back to top |
|
 |
Gabriel GIbaut Guest
|
Posted: Thu Jan 06, 2005 5:24 pm Post subject: Re: Nested Object Editions |
|
|
"Bob Dawson" <bdawson (AT) idtdna (DOT) com> escribió en el mensaje
news:41dd54c0$2 (AT) newsgroups (DOT) borland.com...
| Quote: | It's generally considered a bad idea for business objects to know anything
about displaying themselves. To a certain extent you can finesse this by
having a registration process (Salary knows that a editing class exists,
and
if one is registered calls it), but even that becomes problematic if your
problem domain becomes complex. For example, one might often want to edit
collected objects in a frame on the collection owner's edit form, rather
than proliferating a bunch of sub-forms.
|
I didnīt think about it, you are right. The other option was an editor
factory, but I suppose this is also going to get ugly when things become
complex.
But i donīt have much idea about what else can i do...Any idea?
| Quote: | Question: what's the sequencing relationshp between the forms and the
transaction--when I finish with the Salary edit form (called from within
editing an employee), does anything get persisted at that point? Does the
salary edit form have both 'Ok' (accept the edits in memory but do nothing
else) and 'Save' (accept and persist the changes) options?
|
As itīs implemented, the editor calls the persistence layer when itīs done,
so it has a variable that says if itīs nested or not to make the call
depending on the situation. Thatīs what i want to change. I tought about the
transaction class, but i still need to pass it all over the place, like the
variable. Iīm trying to avoid this.
| Quote: | My tendency is to say that the business object shouldn't care. That is, it
simply issues a BeginTransaction request to the persistence layer, and a
Commit when it's done. The persistence layer is then responsible for
knowing
whether it's already in a transaction context and so determining whether
to
issue an actual BeginTransaction call to the storage device or merely to
increase the current transaction nesting level.
|
The problem is the persistence layer as today, does no have nested
transactions.
TIA
Gabriel
|
|
| Back to top |
|
 |
Bob Dawson Guest
|
Posted: Thu Jan 06, 2005 6:02 pm Post subject: Re: Nested Object Editions |
|
|
"Gabriel GIbaut" wrote
| Quote: | But i donīt have much idea about what else can i do...Any idea?
|
I generally think of application workflow as a layer separate from the
business objects, and don't try to do much in terms of the OPF design to
support it. That's an issue for the application programmer to address. For a
much more systematic approach visit Joanna's website and look at her MVP
stuff.
www.carterconsulting.org.uk
| Quote: | The problem is the persistence layer as today, does no have nested
transactions.
|
It's still going to be much easier to teach the persistence layer to handle
this than to try to have the individual business objects try to track or
figure out where they fit into the application's ongoing process.
By 'persistence layer' I don't mean the database itself, but rather a layer
of code behind the buisiness objects that receives all BO requests for
persistence actions and processes them. All persistence actions pass through
this layer, so it can easily remember what the current transaction state is.
bobD
|
|
| Back to top |
|
 |
Gabriel GIbaut Guest
|
Posted: Thu Jan 06, 2005 8:14 pm Post subject: Re: Nested Object Editions |
|
|
Bob, Thanks Again.
| Quote: | It's still going to be much easier to teach the persistence layer to
handle
this than to try to have the individual business objects try to track or
figure out where they fit into the application's ongoing process.
By 'persistence layer' I don't mean the database itself, but rather a
layer
of code behind the buisiness objects that receives all BO requests for
persistence actions and processes them. All persistence actions pass
through
this layer, so it can easily remember what the current transaction state
is.
The problem is I have no voice when it comes to the persistence layer we are |
using, i suppose iīll end up passing a transaction object everywhere, or the
Nested indicator variable, but iīm going to get forced to use one editor
after another with nothing in between ( because if I donīt the BOare going
to get polluted with the "nested" parameter)
Thanks
Gabriel
|
|
| Back to top |
|
 |
Bob Dawson Guest
|
Posted: Thu Jan 06, 2005 8:26 pm Post subject: Re: Nested Object Editions |
|
|
"Gabriel GIbaut" wrote
| Quote: | The problem is I have no voice when it comes to the persistence
layer we are using,
|
Bummer.
Are there ever multiple transactions open? If not you might simply create a
singleton transaction holder. When an object wants a transaction then it
just requests one from the holder, which returns a transaction token. The
holder can either create a new transaction (no tokens are out, so the item
is not nested) or else just inc() a counter when returning the token (the
item is nested in another's transaction). That way at least the BO doesn't
have to figure out what the current processing state is. When all tokens
have been returned, the holder singleton knows that we're back at the
outermost object and the transaction can be fired. That's essentially how
transaction nesting works in the persistence layer anyway.
bobD
|
|
| Back to top |
|
 |
Gabriel GIbaut Guest
|
Posted: Fri Jan 07, 2005 11:49 am Post subject: Re: Nested Object Editions |
|
|
Bob, thanks again.
The problem is they have plans to support multiple transactions, so I
suppose iīm going to need to program a multiple transaction mechanism, and
from there, call the persistence layer mechanism.
Gabriel
"Bob Dawson" <bdawson (AT) idtdna (DOT) com> escribió en el mensaje
news:41dd9eda$1 (AT) newsgroups (DOT) borland.com...
| Quote: | "Gabriel GIbaut" wrote
The problem is I have no voice when it comes to the persistence
layer we are using,
Bummer.
Are there ever multiple transactions open? If not you might simply create
a
singleton transaction holder. When an object wants a transaction then it
just requests one from the holder, which returns a transaction token. The
holder can either create a new transaction (no tokens are out, so the item
is not nested) or else just inc() a counter when returning the token (the
item is nested in another's transaction). That way at least the BO doesn't
have to figure out what the current processing state is. When all tokens
have been returned, the holder singleton knows that we're back at the
outermost object and the transaction can be fired. That's essentially how
transaction nesting works in the persistence layer anyway.
bobD
|
|
|
| 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
|
|