Connecting Tech Pros Worldwide Help | Site Map

"marker" interfaces. What are they good for?

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 16th, 2005, 11:31 AM
Eran Kampf
Guest
 
Posts: n/a
Default "marker" interfaces. What are they good for?

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, 11:31 AM
Marina
Guest
 
Posts: n/a
Default 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, 11:31 AM
Richard Blewett [DevelopMentor]
Guest
 
Posts: n/a
Default 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, 11:31 AM
Mattias Sjögren
Guest
 
Posts: n/a
Default 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, 11:31 AM
James Curran
Guest
 
Posts: n/a
Default 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, 11:31 AM
Richard Blewett [DevelopMentor]
Guest
 
Posts: n/a
Default 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]
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.