473,625 Members | 2,770 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Reflecti on 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 2674
"Stefan" <we******@dotne tovation.com> a écrit dans le message de news:
uc************* @TK2MSFTNGP09.p hx.gbl...

| I was hoping my fellow coders would give me some feedback on the article
| I wrote which makes use of the System.Reflecti on 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******@dotne tovation.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.Reflecti on 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
320
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
1690
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 info about) the "custom" interfaces InterfaceB
2
2157
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 that I use for acquiring the function names, scope, parameters, etc. Is there an "InheritedClassType" or "InterfaceType" property that I can query? I've tried using DeclaringType.BaseType, but that doesn't seem to give me what I want. ...
3
2322
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 through an external file in which case we can use reflection to create objects of that type at run time. Case 1: The methods of those types can be invoked through reflection. Case 2: The caller can publish certain events. The types (objects)...
1
2298
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 able to call methods and pass parameters normally in the dynamically loaded Form. Yesterday Nicholas Paldino's suggested this. Btw, thanks Nick! As hard as I tried without asking further questions, I need a little more help. :)
9
2559
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) example: In Project RoObjDefs: RoPerson.cls file: Public Property Get FirstName() as String Public Property Get LastName() as String <end of file RoPerson.cls> RoPersons.cls file Public Function Count() as Integer
5
1854
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. Here's a general outline of the architecture. It's oversimplified, but I think it's enough info to help: Assembly A.dll { interface IMyBase {}
4
1247
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 the path grabbing the sub-properties down to the "leaf" property at which point the value is returned. The basic concept is this: Function GetValue(ByVal FreightBill As IFreightBill, ByVal ValuePath As String) As Double Dim AssemblyName As...
1
1614
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 load the assembly with late binding and create an instance of the class with reflection. I try to cast the object to the class type of the interfact, but I get an invalid cast exception. It says that the object I am creating isn't a PeriodicJob. ...
0
8189
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8692
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8635
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8354
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8497
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7182
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4089
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1499
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.