Hello Arindam,

>  But there i may not require all those abstract method inside the
> abstract class.
>  but i MUST override all those method [ irritating..... ],
Then probably you have the wrong abstraction! If your new classes
don't need all those methods than maybe they're NOT a EProduct.


>  my question is where is actuall fun of using abstract class ?

If you're not using your class polymorphically, nor putting any code
into the abstract class, then there's really no advantage in using it.
http://c2.com/cgi/wiki?AbstractClass

How would you use it polymorphically?

Well, you could have a UI controls that manipulated products, and for
those controls it wouldn't matter if it was a "DBTrans" or a
"XmlTrans", it would just be a EProduct.

So my advice is drop the abstract class for now, and if you feel the
need for it latter refactor to add it back in.


>  comparatively if i use interface instead of abstract class in the same
>  scenario........ how that is going to help me ?

Abstract classes have 2 main advantages over interfaces:

1- The obvious one, you can attach code to it. If there's a "default"
implementation that you think makes sense.

2- They "version" better. Ie, if you have an interface and decide to
add another method, you are going to break every "client". So normaly
you end up with Interface, then Interface2, then Interface3
But you can add another NON ABSTRACT method to a abstract class, and
it won't brake anything


I can see 2 advantages on using interfaces:

1- It's a way to "achieve" multiple inheritance in .NET
2- Is more loosely coupled. By using interfaces normally what you say
is what something DOES, not what it IS, ie, you say that your class
CanSave, Load, etc, not that your class IS a EProduct.


But again, on your situation, if you're not going to have several
class inherit or implement the abstract class or interface, they're
just crud on your design, dead weight!


Best regards,
Joao Paulo Carreiro


Monday, July 4, 2005, 8:12:16 PM, you wrote:

> Hey Champs,
> I am little confused while implementing abstract class in my project,
> please read the issue till the end.


> This is the abstract class i have written with 4 abstract method

> public abstract class EProduct 
>  {
>   public EProduct()
>   {
>    //
>    // TODO: Add constructor logic here
>    //
>   }
>    public abstract void AddProduct(string UID);
>   public abstract bool DeletProduct(string UID,string ProjectId);
>   public abstract DataView ViewProductStatus(string UID);
>   public abstract void DownloadProduct(string UID,string ProjectId );
 
>  }

 

> This is the class where i have inherited EProduct abstract class 

>  public class DBTrans:EProduct 
>  {
>   public DBTrans()
>   {
>   }

>   DBConn objDBCon=new DBConn(); 

  
>   public override void AddProduct(string UID)
>   {
  
>   }


>   public override bool DeletProduct(string UID,string ProjectId)
>   {
>   return true;
>   }


>   public override DataView ViewProductStatus(string UID)
>   {
>   DataView DV=new DataView();
>    return DV;
>   }


>   public override void DownloadProduct(string UID,string ProjectId )
>   {
  
>   }
  
>  }


>  Now the question is how the abstact class is going to help me ?
>  you may say this is a common place where method declaration of 
>  any object is done.
 
>  but that's not sufficient !!

>  Yes tomorrow i may need to use those method with another class like
> DBTrans (above),

>  But there i may not require all those abstract method inside the 
> abstract class.
>  but i MUST override all those method [ irritating..... ],

>  my question is where is actuall fun of using abstract class ?

>  comparatively if i use interface instead of abstract class in the same
>  scenario........ how that is going to help me ?


> Thanks for patience
> Arindam





> Thanks & Regards

> Arindam 
> Web Designer & Developer  





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to