Custom Entity classes are killing me.

  • Thread starter Thread starter Tom B
  • Start date Start date
T

Tom B

Hello all,

I just read Karl Seguin's article "On the Way to Mastering ASP.Net:
Introducing Custom Entity Classes"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/CustEntCls.asp

I realize it's about ASP.Net, but figured the same principles apply for
Windows Form classes..

Here's my question/problem

In the article he refers to a Person class and a Role class. Since a person
could have several roles, an array of Roles is in the Person class.

SO.... what about the fact that Roles would contain many Persons. If I load
a Person class with all of its roles (in the constructor) and load all of
the persons within the roles constructor it will go on forever.

How is this handled? Is this where the lazy load stuff I've heard of comes
from?

Thanks in advance.

Tom B
 
It really depends on what you are accomplishing. One idea is to have the role
membership null until you are actually pulling members of a role. For person,
you can do the same thing with roles, but it is not as critical if one can be
nullable.

You can work with objects that wrap DataSets to avoid some of the
complexity, but that would be slightly different than the suggestions in the
article.

Hope this helps, as I feel I am rambling a bit right now.


--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
Thanks.

That's kind of what I was thinking.
I'd really like to see a good example somewhere. Most MS examples use
datasets, and then there whitepapers tell you not too.

oh well.
Thanks again,

TOm B
 
Hey Tom,

This is the a pretty old idea. Though in .Net it may be something new.
This is a common J2EE way to do things in the web realm. Things like
Struts and JavaBeans follow this concept of coverting data into objects
or requests into objects for that matter dont think these can only be
used with the database. I use these to ecapsulate form data as well.

I understand your frustration with his example however you must
understand that all of this depends on what your system needs when
thinking about object relationships. I think you need not get hung up
on the example he gives. Just understand the idea of taking the data
from the data set and putting it into more abstracted domain type
objects.

Here is how I do almost all .net web apps.

Codebehind -> service class -> Dal classes

the serveice layer makes calls into the DAL layer and get the dataset
in return. The Service layer then creates the "Entity Objects" from the
datasets. The service then returns this to the code behind and it is
bound to controls there.

The reason I put Entity Objects in quotes is they are not really entity
objects. That is a term that java uses for persistant data. meaining
they are tied to a records in the database. This is not the case with
what he is describing in this artical. I call these "Entity Objects"
ValueHolders.

Thanks for posting this link it was a nice read. I really enjoyed it.

Thanks,
Brette
 
Back
Top