Groups | Blog | Home
all groups > dotnet sdk > september 2004 >

dotnet sdk : "marker" interfaces. What are they good for?


Richard Blewett [DevelopMentor]
9/28/2004 12:36:32 PM
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



Richard Blewett [DevelopMentor]
9/28/2004 3:13:34 PM
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>

[quoted text, click to view]

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



Marina
9/28/2004 3:34:15 PM
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.

[quoted text, click to view]

James Curran
9/28/2004 5:24:54 PM
[quoted text, click to view]

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!)

Eran Kampf
9/28/2004 9:25:46 PM
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


Mattias Sjögren
9/28/2004 9:41:27 PM

[quoted text, click to view]

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
AddThis Social Bookmark Button