473,241 Members | 1,580 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,241 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 2657
"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: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
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
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...

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.