473,325 Members | 2,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Utillizing Reflection and Interfaces

Hello,

I was hoping my fellow coders would give me some feedback on the article
I wrote which makes use of the System.Reflection namespace and
Polymorphism to demonstrate how you can create dynamic and scalable
business objects.

http://www.developersdex.com/gurus/articles/739.asp

Thanks for your feedback, it's much appreciated.

Stefan
C# GURU
www.DotNETovation.com

*** Sent via Developersdex http://www.developersdex.com ***
Jan 7 '06 #1
2 2660
"Stefan" <we******@dotnetovation.com> a écrit dans le message de news:
uc*************@TK2MSFTNGP09.phx.gbl...

| I was hoping my fellow coders would give me some feedback on the article
| I wrote which makes use of the System.Reflection namespace and
| Polymorphism to demonstrate how you can create dynamic and scalable
| business objects.

Hi Stefan, Please don't take this as outright criticism of *how* you've
written the code, but I do have concerns about this approach of including
database behaviour in business class; it simply isn't necessary.

If you really want to create dynamic and scalable business objects then you
need to design an Object Persistence Framework or Data Access Layer. This
then completely separates the business concepts from the domain of
databases. Why do developers assume that the only method of storage, even
for small numbers of instances of classes should be a database ?

In a well-designed multi-tiered framework, business classes should only ever
be concerned with business logic; how they are to be persisted should be a
non-concern, from the business logic point of view.

Certainly, you need a means of examining an object in order to persist it,
and also a means of being able to create instances and populate them from
persisted state; but this should not impose one particular way of connecting
with the persisted state, however that is achieved.

..NET reflection allows you to interrogate the state of objects without any
special interfaces or base classes. If you require special treatment of
certain fields in a class, then you can apply attributes, but you could also
have a mapping hierarchy inside the OPF or DAL which allows you to specify
which fields are or are not persistable which fields in which table that
field is to be persisted in.

Your base class includes things that are relevant to lists of objects, but
they are defined as instance methods. This implies you need an instance of a
Customer in order to access a list of Customers !!?? At the very least, any
methods that relate to lists of the given class should be static so that
they can be used without an instance.

The only special features that need adding to a base business class are: a
dirty flag to indicate whether the object has been modified, possibly a
persisted flag to indicate whether this instance was retrieved from storage,
although even this can be deduced from the other "special" feature of a base
business class, which is the ID of the instance - if the ID is null then the
instance has not been persisted, as soon as it is persistent, the ID is set
to a valid value.

I have written a series of articles that discuss OPF techniques; they are
not complete, but should give you a good idea of some of the problems and
how they can be solved. www.carterconsulting.org.uk

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Jan 7 '06 #2
Stefan,

You ask for comments on your article. I have read it and my conclusion
might not be of your liking, I am sorry. Since you ask for it I will
nontheless give a few very short comments on your rather trivial
article.

1. If you want to build some sort of O/R mapper with reflection you
might take a look at the code of NHibernate which does what you
intend to do with even less coupling( for what that means see the
reaction of Joanna)

2. If you want to make a real good O/R mapper try without reflection(
reflection beats any oo principle) and for instance create it like
COAD suggested in his appendix of Object Models. The essence being
almost independent PDObjects which might have a persistence interface
which in turn uses a singleton DMObject for their persistant
operations.

3. Be sure to study .net 2.0 since what you are doing is also probably
partly duplicating table adapters since table-object might in a lot of
cases be a 1-1 relation.
Rick


On Sat, 07 Jan 2006 03:40:22 -0800, Stefan
<we******@dotnetovation.com> wrote:
Hello,

I was hoping my fellow coders would give me some feedback on the article
I wrote which makes use of the System.Reflection namespace and
Polymorphism to demonstrate how you can create dynamic and scalable
business objects.

http://www.developersdex.com/gurus/articles/739.asp

Thanks for your feedback, it's much appreciated.

Stefan
C# GURU
www.DotNETovation.com

*** Sent via Developersdex http://www.developersdex.com ***


Jan 10 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: ichor | last post by:
hi i have read a few examples that use the System.Reflection api , but i cant understand in what way is it helpful. i mean its practical use in the real world thanx
3
by: Cezar | last post by:
Hello, Can anyone please help me with this matter. I try to find the interfaces implemented by a class using Reflection. e.g: public class A : InterfaceB, InterfaceC how can I get (the...
2
by: Rob | last post by:
I'm using reflection to inspect a class and its methods. Is is possible to determine if the class is a derived class or an interface implementation? I'm using the MethodInfo object for relfection...
3
by: HL | last post by:
The requirement is to send some information to other objects. The objects to whom the information has to be sent is not available at compile time. The names of the types (objects) will be provided...
1
by: John F | last post by:
Hello All, I'm dynamically loading a form through reflection. I have this working. What I'd like to do is implement an interface so that I can cast my instance to that interface. I want to be...
9
by: Terry | last post by:
I am converting (attempting) some vb6 code that makes vast use of interfaces. One of the major uses is to be able to split out Read-only access to an obect. Let me give you a simple (contrived)...
5
by: | last post by:
I am having problems with casting or converting a class to to an interface from which it derives. I'm certain that it's due to how it's being loaded, but I'm not sure how to get past the problem....
4
balabaster
by: balabaster | last post by:
I've got a hierarchy of interfaces that I need passed into a method to return a value given a value path. For instance: Class.Property.SubProperty.Value I'm using reflection to iterate through...
1
by: Big Daddy | last post by:
I have an interface called PeriodicJob. In a DLL, I declare the interface and then create a class that implements the interface. In a different executable, I also declare the interface. I then...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.