If all classes can inherit from IROLE, then the GETDATA
function should take
parameters so that if it is inherited into a person or say,
an employee, it
could use the parameter to differentiate what table it would
need to talk to
based on some other property
So: (vb)
Public Class IRole
Function GetSomeData(SomeParam As SomeType) As Dataset
'do database stuff
End Function
Public Class User
Inherits IRole 'this class would expose the
GetSomeData function to the
calling code
'calling code - simplified inheritance
Dim usr As New User
Dim ds As New Dataset
ds = usr.GetSomeData(123)
>From: "Bill Swartz" <bswartz bubbyzone.com>
>Reply-To: aspnet-databases aspadvice.com
>To: aspnet-databases aspadvice.com
>Subject: [aspnet-databases] RE: Objects versus
performance
>Date: Thu, 14 Sep 2006 11:54:29 -0700
>
>Pete, you are correct in enterpreting what I was trying
to say. But you
>didn't solve my problem <grin>. While this is
a little example, let's
>say
>I have a hundred classes that are abstracted the same
way. If each makes
>its own call to the database, that would be terrible.
>
>You diagramed the classes perfectly below.
>
>Is there maybe a better way to do this architecturally?
Ie, possibly have
>different class that gets all the data in a logical
fashion from the db and
>then each of these classes request information from the
objects in memory??
>I'm assuming it would have to be a dataset since the
reader would need to
>stay connected.
>
>As you mentioned, I'm trying to find a best practices
or balance between
>maintainability and performance. (Steven suggests
correct or maintainable
>is the top priority... I struggle with this because my
background is on
>the
>database side and I want performance) I want the cake
<grin>
>
>Bill
>
>
>-----Original Message-----
>From: bounce-aspnet-databases-58376 aspadvice.com
>[mailto:bounce-aspnet-databases-58376 aspadvice.com] On Behalf Of Peter
>O'Hanlon
>Sent: Thursday, September 14, 2006 11:15 AM
>To: aspnet-databases aspadvice.com
>Subject: [aspnet-databases] RE: Objects versus
performance
>
>It looks as though Bill is stating that the classes
inherit, rather than
>implement. So you would have something like:
>
>public class User : Person
>{
> public virtual DataSet GetData()
> {
> DataSet ds = GetSomeData();
> }
>}
>
>public class Person : IRole
>{
> public virtual DataSet GetData()
> {
> DataSet ds = GetSomeData();
> }
>}
>
>public class IRole
>{
> public virtual DataSet GetData()
> {
> DataSet ds = GetSomeData();
> }
>}
>
>Now, if the classes each implement DB routines, then
they are not going to
>be as efficient as if this was handled in one go. This
would be three
>separate accesses. One call would be more efficient, but
you have to ask
>yourself if the efficiency is more important than
maintainability. That's a
>call that only you can make.
>
>You need to ask yourself what the usage is going to be
like. Is any of the
>data going to be cached? Is this going to be heavily
hit? Sometimes you can
>use a bit of cleverness to get round performance issues.
>
>Sorry if that's not as much help as you want, but
hopefully that will give
>you some food for thought.
>
>Regards,
>
>Pete
>
>-----Original Message-----
>From: Paul Mehner [mailto:paul soundex.com]
>Sent: 14 September 2006 00:48
>To: aspnet-databases aspadvice.com
>Subject: [aspnet-databases] RE: Objects versus
performance
>
>Tim Curtin [mailto:tjc_tek hotmail.com] said:
>Incidently, C# and VB only support single inheritance.
>So, Security inherits User
>User inherits Person
> >User inherits IRole *** NOT SUPPORTED
>
>Just to offer a couple of clarifying points: normally
the letter "I" (as in
>IRole) denotes an interface and not a class. Although
the CLR only allows
>single inheritence, an object can implement any number
of interfaces. While
>I understand your point, when I read this thread, I
assumed that poster
>intended to say that User class implements IRole
(because of the "I"). If
>my
>interpretation of his post was correct, this would mean
that User would
>inherit from Person and also implement the IUser
interface (which would be
>perfectly legal).
>
>Of course in C# syntax, Implements and Inherits are
written the same way
>(using a colon). I prefer the C# syntax, but to some,
the VB syntax makes
>the distinction clearer. But suddenly I find myself
digressing....
>
>Cheers!
>
>--Paul Mehner
>
>
>-----Original Message-----
>From: Tim Curtin [mailto:tjc_tek hotmail.com]
>Sent: Wednesday, September 13, 2006 9:34 AM
>To: aspnet-databases aspadvice.com
>Subject: [aspnet-databases] RE: Objects versus
performance
>
>Incidently, C# and VB only support single inheritance.
>So,
>Security inherits User
>User inherits Person
> >User inherits IRole *** NOT SUPPORTED
>Replace with Person Inherits from IRole.
>Put the validation or DBcode in IRole, that way it will
be inherited up the
>heep
>
>
> >From: "Steven Archibald"
<steven.archibald sa-consult.com>
> >Reply-To: aspnet-databases aspadvice.com
> >To: aspnet-databases aspadvice.com
> >Subject: [aspnet-databases] RE: Objects versus
performance
> >Date: Tue, 12 Sep 2006 23:34:47 -0700
> >
> >Well, after 30 years of development experience:
> >
> >If something is correct but slow, I can always make
it faster. If
>something
> >is fast, but incorrect, it's almost impossible to
make it "correcter".
> >
> >Presumably the 3 reads will be done once per
session; when the user first
> >signs on. After that, it would make sense to store
the Security object in
> >Session. You don't need to read it on every page
load. Assuming a session
> >with a user last 10 minutes, your relative
difference per user is 3 reads
> >per 10 minutes vs. 1 read per 10 minutes for the
Security object. Seems
> >like
> >a very small difference ...
> >
> >If your Security object has 3 reads, why not have
it do them and return 1
> >dataset with 3 tables? It doesn't save the reads,
but it does save some
> >overhead on instantiating datasets, etc.
> >
> >-----Original Message-----
> >From: Bill Swartz [mailto:bswartz bubbyzone.com]
> >Sent: Tuesday, September 12, 2006 9:56 PM
> >To: aspnet-databases aspadvice.com
> >Subject: [aspnet-databases] Objects versus
performance
> >
> >I'm designing a complex web application that has a
number of classes.
>I'm
> >using Sparx Enterprise Architect tool. When sit
back and look at the
> >classes, I'm asking myself if I'm not trading
"correct object design" for
> >performance.
> >
> >For example.
> >Security inherits User
> >User inherits Person
> >User inherits IRole
> >
> >Now, because these are all classes, they are
independent and are going to
> >make 3 separate calls to a database versus if I
lumped everything
>together
> >into one class, I could more efficiently make 1
call to the database and
> >return 3 sets.
> >
> >Any experience / thoughts on this subject.
> >
> >Thanks
> >Bill
> >
> >
> >
> >Need SQL Advice? http://sqladvice.com
> >Need RegEx Advice? http://regexadvice.com
Need XML Advice?
> >http://xmladvice.com
> >
> >
> >Need SQL Advice? http://sqladvice.com
> >Need RegEx Advice? http://regexadvice.com
> >Need XML Advice? http://xmladvice.com
>
>
>
>Need SQL Advice? http://sqladvice.com
>Need RegEx Advice? http://regexadvice.com
>Need XML Advice? http://xmladvice.com
>
>
>
>
>Need SQL Advice? http://sqladvice.com
>Need RegEx Advice? http://regexadvice.com
>Need XML Advice? http://xmladvice.com
>
>--
>No virus found in this incoming message.
>Checked by AVG Free Edition.
>Version: 7.1.405 / Virus Database: 268.12.3/446 -
Release Date: 12/09/2006
>
>
>--
>No virus found in this outgoing message.
>Checked by AVG Free Edition.
>Version: 7.1.405 / Virus Database: 268.12.3/446 -
Release Date: 12/09/2006
>
>
>
>Need SQL Advice? http://sqladvice.com
>Need RegEx Advice? http://regexadvice.com
>Need XML Advice? http://xmladvice.com
>
>
>Need SQL Advice? http://sqladvice.com
>Need RegEx Advice? http://regexadvice.com
>Need XML Advice? http://xmladvice.com
Need SQL Advice? http://sqladvice.com
Need RegEx Advice? http://regexadvice.com
Need XML Advice? http://xmladvice.com
|