Hi Stoyan,

>>> - just define a clear pattern and ask all the programmers to follow it
>
>Even if the programmers agree to that pattern, they can still forget to
>follow it
>

I totally agree.

I just wanted to point out that Interfaces (that express common
services/signatures exposed) and Inheritance (from a base class that
express common implementation) are both useful when do exists _code_ that
exploit them.
When the problem to address is a consistent coding style by _programmers_
instead should be used Patterns, Templates/Traits or Code Generators. As
you said this do not guarantee that programmers will do it right so
Attributes (that you suggested), Reflections, FixCop like tools or just
simple human code review came in help.

ciao, (luKa)

>
>-----Original Message-----
>From: Moderated discussion of advanced .NET topics.
>[mailto:[EMAIL PROTECTED] Behalf Of Luca Minudel
>Sent: 06/26/2003 15:30
>To: [EMAIL PROTECTED]
>Subject: Re: [ADVANCED-DOTNET] Shared Methods In Abstract Classes /
>Interfaces
>
>
>I would suggest to use an interface.
>
>Anyway ask yourself who need use that interface (or the GetList method from
>the abstract base class) without knowing which is the actual object type.
>If you are planning to write code that implements services/functions for
all
>your BO classes (derived from the Business Object Abstract Class and/or
that
>implement the interfaces you provided) it make sense to have an abstract
>base class or interfaces. If you do not (and probably you don't for
GetList
>methods because when you want to apply a filter  you need criteria that are
>specific to a single BO so you will need specific methods or you will need
>to give up type-safe programming), your problem is a problem of programming
>style, you just want that all BO code in your project follow a pattern.
>In this case you could:
>- just define a clear pattern and ask all the programmers to follow it
>- use a code generator (something like Gen<X>)
>- when C# will have generic programming you could define a template and use
>it as a trait (for  GetList kind methods)
>
>
>HTH (luKa)
>http://dev.luca.minudel.it
>
>P.S. Maybe these links interest you for implement your Business Object
>Abstract Class:
>- An Oid struct implementtion (I cn give NUnit tests if you need)
>http://www.eurosystem.it/ancom/v1/ANCOM-INS-NEW/ViewSourceCode.AspX?
path=Rie
>pilogo.src&file=..\IdentityAndPersistence\Identity.cs&font=14
>- An Oid Factory
>
>http://www.eurosystem.it/ancom/v1/ANCOM-INS-NEW/ViewSourceCode.AspX?
path=Rie
>pilogo.src&file=..\IdentityAndPersistence\OidFactory.cs&font=14
>- A persistent Object base class
>
>http://www.eurosystem.it/ancom/v1/ANCOM-INS-NEW/ViewSourceCode.AspX?
path=Rie
>pilogo.src&file=..\IdentityAndPersistence\Persistence.cs&font=14
>- CRUD methods signature
>  http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/ejb/EntityBean.html
>- IsNew, IsXXX methods signature
>http://java.sun.com/products/jdo/javadocs/javax/jdo/JDOHelper.html
>
>
>
>On Tue, 24 Jun 2003 20:38:20 -0400, Michael Wolfenden
><[EMAIL PROTECTED]> wrote:
>
>>I have a problem that I would appreciate any help with.
>>
>>I am creating a Business Object Abstract Class that all the business
>>objects in my application with inherit. This class contains common
>>functionality such as getting a business object given a unique identifier,
>>providing IsDirty - IsNew methods etc....
>>
>>The problem is that I want each business object to implements a shared
>>function GetList which will return a HashTable of all of those business
>>objects for populating list boxes etc...
>>
>>If I could provide this method in the Business Object Abstract Class or
>>define an Interface with this method then I could create a generic routine
>>to populate a list box for a Business Object. However as you know, you
>>cannot declare a shared method in an interface, and you cannot declare a
>>shared must override method in an Abstract Class.
>>
>>I don't understand why this restriction exists or how I can get around it.
>>All I can do is implement this method in each of the subclasses of the
>>Abstract Class, however there is no contract forcing other developers to
>>implement this method.
>>
>>Once again any help would be much appreciated, for this has bugged me no
>>end

Reply via email to