Re: Declaring a Constructor in an Interface?

From: Dennis Myrén (dennis_at_oslokb.no)
Date: 09/15/04


Date: Wed, 15 Sep 2004 12:49:58 +0200

Well, in that case I have to apologize if i was wrong.
However, i have read many places that an interface is faster than
an abstract class. This is one of them:
http://www.dotnetspider.com/Technology/KB/ShowSample.aspx?SampleId=492

I wont argue with You, but would You also claim that an abstract class
containing only abstract members
is faster than an interface as well? In that case, what is the benefit of
interfaces anyway?

I have always believed interfaces were superior to abstract classes.
I apologie for the misleading information i might have given.

-- 
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Dennis Myrén" <dennis@oslokb.no> wrote in message
news:bPT1d.7270$WW4.107246@news4.e.nsc.no...
> You need to create 2 class instances
> when creating an instance of a class which is derived from an abstract
> class.
>
> Creating an instance of an abstract class means performance overhead.
> I think that is especially true if the abstract class contains virtual
> methods.
>
> Virtual methods always means performance overhead.
> According to Microsoft they are two times as expensive as non-virtual
> methods.
>
> However, abstract members should be as fast as interface members i
believe.
>
> An abstract class containing no virtual methods should be nearly as fast
> as an interface, but still slower.
>
>
>
> -- 
> Regards,
> Dennis JD Myrén
> Oslo Kodebureau
> "Richard Blewett [DevelopMentor]" <richardb@develop.com> wrote in message
> news:%23E$QQEwmEHA.3852@TK2MSFTNGP10.phx.gbl...
> > What leads you to the conclusion that interfaces are faster than ABCs?
> >
> >  Regards
> >
> >  Richard Blewett - DevelopMentor
> >
> >  http://staff.develop.com/richardb/weblog
> >
> >
>
nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<2VS1d.7254$WW4.107148@news4.e.nsc.no>
> >
> >  Unfortunately this is not possible.
> >
> >  You may use an abstract class instead which exposes 1 constructor
> >  taking a UserToken though.
> >
> >  I really wished that this was possible, because interfaces are faster
> than
> >  abstract classes.
> >
> >  --
> >  Regards,
> >  Dennis JD Myr?n
> >  Oslo Kodebureau
> >  "Ole Hanson" <ole.hanson@ole.ole> wrote in message
> >  news:egAtlqvmEHA.3632@TK2MSFTNGP09.phx.gbl...
> >  > I am accessing my database through an interface, to allow future
> >  > substitution of the physical datastore - hence I would like to
declare
> in
> >  my
> >  > Interface that my DAL-objects implementing the interface and
accessing
> the
> >  > datastore MUST pass in a UserToken in the constructor of the object.
> >  >
> >  > Is this not possible?
> >  > Am I forced to add the UserToken as a property on the object instead?
> >  >
> >  > /Ole
> >  >
> >  >
> >  >
> >
> >
> >
> >  ---
> >  Incoming mail is certified Virus Free.
> >  Checked by AVG anti-virus system (http://www.grisoft.com).
> >  Version: 6.0.760 / Virus Database: 509 - Release Date: 10/09/2004
> >
> >
> >
> >  [microsoft.public.dotnet.languages.csharp]
>
>


Relevant Pages

  • Re: Java/J2EE Openings in RTP, NC
    ... JSP, EJB, DAO Developer ... An abstract class is declared with the keyword "class" and is an implementation, i.e., its methods can contain bodies. ... An interface is a declaration of public method signatures which taken together represent a type with a defined contract for interaction with other types. ... A "Type 1" JDBC driver is a bridge to an ODBC driver which in turn interacts with the data store. ...
    (comp.lang.java.programmer)
  • Re: Abstract class or interface?
    ... >derived classes can only inherit one abstract class. ... The interface properties/methods have no implementation. ... and rotate "things" along all three X, Y, and Z coordinate axis. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: public interface method Id rather not be
    ... > If I use an interface internally for my application, ... > I have a validation method which ordinarilly would be private. ... class can be extended by an inner class, ... method that returns the abstract class type when it creates ...
    (comp.lang.java.programmer)
  • Re: Abstract class or interface?
    ... I try to make the decision based on the relationship of the derived class to the base class. ... If the derived class "can act like" the type of the base class, I'd lean towards an interface. ... I understand the abstract class can have implementation in its methods and derived classes can only inherit one abstract class. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Using abstract class that implements interface
    ... colleges - that come from JAVA programming - says - it is redundant ... and interface is unnecessary... ... abstract class is in whether all instances must be required to share the ... The design permits future implementations that do not share the same base ...
    (comp.lang.java.programmer)