Connecting Tech Pros Worldwide Help | Site Map

"marker" interfaces. What are they good for?

  #1  
Old November 16th, 2005, 12:31 PM
Eran Kampf
Guest
 
Posts: n/a
I was wondering why MS defined "marker" interfaces (empty interfaces) in the
..NET framework(interfaces such as such as INamingContainer,
IRequiresSessionState etc...).
Why not use attributes?

Eran Kampf
http://www.ekampf.com



  #2  
Old November 16th, 2005, 12:31 PM
Marina
Guest
 
Posts: n/a

re: "marker" interfaces. What are they good for?


For frequent operations (such as naming asp.net controls or getting session
state), it is probably faster to check whether or not a class implements an
interface, then to go dig up its attributes.

"Eran Kampf" <eran@ekampf.com> wrote in message
news:%23JBadEZpEHA.1152@TK2MSFTNGP11.phx.gbl...[color=blue]
> I was wondering why MS defined "marker" interfaces (empty interfaces) in[/color]
the[color=blue]
> .NET framework(interfaces such as such as INamingContainer,
> IRequiresSessionState etc...).
> Why not use attributes?
>
> Eran Kampf
> http://www.ekampf.com
>
>
>[/color]


  #3  
Old November 16th, 2005, 12:31 PM
Richard Blewett [DevelopMentor]
Guest
 
Posts: n/a

re: "marker" interfaces. What are they good for?


The only reason I can think of is that its faster to perform a type check than go to the custom attributes via reflection

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<#JBadEZpEHA.1152@TK2MSFTNGP11.phx.gbl>

I was wondering why MS defined "marker" interfaces (empty interfaces) in the
.NET framework(interfaces such as such as INamingContainer,
IRequiresSessionState etc...).
Why not use attributes?

Eran Kampf
http://www.ekampf.com




---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.770 / Virus Database: 517 - Release Date: 27/09/2004



[microsoft.public.dotnet.languages.csharp]
  #4  
Old November 16th, 2005, 12:31 PM
Mattias Sjögren
Guest
 
Posts: n/a

re: "marker" interfaces. What are they good for?


[color=blue]
>Why not use attributes?[/color]

I don't know about Microsofts design decisions behind this. But I know
that last time I looked, testing if an object implements a certain
interface was significantly faster than using Reflection to check for
the presence of an attribute.



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
  #5  
Old November 16th, 2005, 12:31 PM
James Curran
Guest
 
Posts: n/a

re: "marker" interfaces. What are they good for?


"Mattias Sjögren" <mattias.dont.want.spam@mvps.org> wrote in message
news:Ogw82LZpEHA.536@TK2MSFTNGP11.phx.gbl...[color=blue]
>[color=green]
> >Why not use attributes?[/color]
>
> I don't know about Microsofts design decisions behind this. But I know
> that last time I looked, testing if an object implements a certain
> interface was significantly faster than using Reflection to check for
> the presence of an attribute.[/color]

um.... but doesn't testing if an object implements a certain interface
also require using Reflection?

--
Truth,
James Curran
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
(note new day job!)


  #6  
Old November 16th, 2005, 12:31 PM
Richard Blewett [DevelopMentor]
Guest
 
Posts: n/a

re: "marker" interfaces. What are they good for?


Type checking has its own IL opcode ininst so is faster than reflection

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<uaZO0GapEHA.1460@TK2MSFTNGP12.phx.gbl>

"Mattias Sj?gren" <mattias.dont.want.spam@mvps.org> wrote in message
news:Ogw82LZpEHA.536@TK2MSFTNGP11.phx.gbl...[color=blue]
>[color=green]
> >Why not use attributes?[/color]
>
> I don't know about Microsofts design decisions behind this. But I know
> that last time I looked, testing if an object implements a certain
> interface was significantly faster than using Reflection to check for
> the presence of an attribute.[/color]

um.... but doesn't testing if an object implements a certain interface
also require using Reflection?

--
Truth,
James Curran
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
(note new day job!)



---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.770 / Virus Database: 517 - Release Date: 27/09/2004



[microsoft.public.dotnet.languages.csharp]
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
final version of PEP-318 "Decorators for functions and methods" Anthony Baxter answers 0 July 18th, 2005 03:53 PM