Architecture, entity states, the meaning of life?

M

Martin Platt

Hi,

I've been working on designing new architecture to be
used for future development using C#.

We're going quite well with the architecture, having
originally decided not to use the dataset, datatable,
dataadapter type implementation. Instead we are using
our own implementation using business entities,
controlling processes, etc., so we have definite
business, data and presentation layers. We're happy with
this, but the further on we go, the more out
implementation seems like an alternative version of the
dataset. What I'd like to know is how does the dataset
compare to other implementations for large distributed
systems, as well as small desktop ones?

Part of the architecture would involve having the
business entities (the classes containing the data)
having their own internal representation of state
(unchanged, insert, update, delete) Any thoughts on how
this might be accomplished? I had a thought that be
could call a set method from a base class that would
compare, and set the values in they're different, and
also manage the state information. However, that becomes
a problem when trying to pass a property as a ref value.
Any ideas on how else this might be accomplished, or
should we just get the users of the subsystems to set the
mode manually (not my preference)
It would be great with the above to be able to override
how the set part of a property works, so we can always
make the property perform a check and keep internal state
up to date, but there seems no way of doing this that I
can find.

There must be a simple way of doing this - I can't be the
first person to have this problem, surely!

Any thoughts, suggestions, etc. would be gladly accepted.

Cheers,

Martin.
 
T

Thomas Tomicek [MVP]

Martin Platt said:
Hi,

I've been working on designing new architecture to be
used for future development using C#.

Hm. Well, why do so many people do this? No wonder the jobs go to india :)
We're going quite well with the architecture, having
originally decided not to use the dataset, datatable,
dataadapter type implementation. Instead we are using
our own implementation using business entities,
controlling processes, etc., so we have definite
business, data and presentation layers. We're happy with

Well, but do you do everything right? Sorry to ask, but I work on this as a
product for about 4 man years now, and we are just getting the second
iteration to our customers. This is a HUGH undertaking when you want to do
it right.
this, but the further on we go, the more out
implementation seems like an alternative version of the
dataset. What I'd like to know is how does the dataset

Sounds like you have an architectural fudge here. It should not.
compare to other implementations for large distributed
systems, as well as small desktop ones?

Well, some like it, some dont. Mostly the ones which like architeture do not
like it.
Part of the architecture would involve having the
business entities (the classes containing the data)
having their own internal representation of state
(unchanged, insert, update, delete) Any thoughts on how
this might be accomplished? I had a thought that be

Yes, tons of - I did one year of research on this. Try looking up O/R
mapping papers on the net, like from Scott Ambler
(http://www.ambysoft.com/).
could call a set method from a base class that would
compare, and set the values in they're different, and
also manage the state information. However, that becomes

Sort of :) Our implementation in the EntityBroker (propably way cheaper to
buy than do roll your own) has all data in a hidden data container that does
all the checks.
a problem when trying to pass a property as a ref value.

You should never ever do this. This is a broken design per definition.
Properties should never return refs (is this even possible?) as this would
bypass the set logic. The can return references to classes, but then the
class would also be a busienss object and have the logic.
Any ideas on how else this might be accomplished, or
should we just get the users of the subsystems to set the
mode manually (not my preference)

Nope. Read design papers on busienss object frameworks, there are a ton in
the java world.
It would be great with the above to be able to override
how the set part of a property works, so we can always
make the property perform a check and keep internal state
up to date, but there seems no way of doing this that I
can find.

There is. You could go to our website and have a look at our EntityBroker
2003.0, get a trial license and read the documentation. This should give you
some ideas.

We work with abstract poperties for which we emit subclasses (with
implementing bytecode) at program start.

Another way (2003.1, next version) is a code generator generating the
properties in a stub base class from which the real business object inherits
and just verrides the logic.
There must be a simple way of doing this - I can't be the
first person to have this problem, surely!

Really? You SHOULD not solve it but go out and see whether there is a tool
for this. Otherwise ou waste your companie's ressources. You would not start
coding a grid either, or? SOme compaines (like ours) specialize on providing
exactly the layer you seem to strive for.

--
Regards

Thomas Tomiczek
THONA Software & Consulting Ltd.
(Microsoft MVP C#/.NET)
 
R

Robert Zurer

Although I agree with the excellent response from Thomas Tomicek, I still
think that using third party tools can be problematic, the DataSet being a
good example.

I have a few additions to what he said. Mainly

Read Martin Fowler's "Patterns of Enterprise Application Architecture"
http://www.amazon.com/exec/obidos/ASIN/0321127420/103-6852016-8379852

how does the dataset compare to other implementations for large distributed
systems, as well as small desktop ones?

For what it's worth I found the DataSet bloated and rigid. I think it was
one of Microsoft's compromises to RAD developers.
Part of the architecture would involve having the
business entities (the classes containing the data)
having their own internal representation of state
(unchanged, insert, update, delete) Any thoughts on how
this might be accomplished?

One way, which I am looking into now, is the aspect-oriented programming
(AOP) approach. Things like transactions, security, concurrency and logging
muddy the code in the business objects. At present AOP can be implemented in
C# using ContextBoundObject descendants and MessageSinks to intercept calls.
I haven't started trying to implement this yet. It's pretty deep. I have
also heard that ContextBoundObject carries a performance penalty.

It would be great with the above to be able to override
how the set part of a property works, so we can always
make the property perform a check and keep internal state
up to date, but there seems no way of doing this that I
can find.

You could put code in each and every set method of each property of the
business object. This code would register the object with a "UnitOfWork"
(see Fowler). Then let the UnitOfWork take care of applying business rules,
transactions, calls to the DataAccess or Persistence Layer etc. The problem
here, and I haven't found a way around it, is having to put the same code in
every set method. The business objects should not have to worry about this
kind of plumbing.


Robert Zurer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top