Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / September 2004

Tip: Looking for answers? Try searching our database.

"marker" interfaces. What are they good for?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Eran Kampf - 28 Sep 2004 20:25 GMT
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
Marina - 28 Sep 2004 20:34 GMT
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.

> I was wondering why MS defined "marker" interfaces (empty interfaces) in the
> .NET framework(interfaces such as such as INamingContainer,
[quoted text clipped - 3 lines]
> Eran Kampf
> http://www.ekampf.com
Richard Blewett [DevelopMentor] - 28 Sep 2004 20:36 GMT
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






[microsoft.public.dotnet.languages.csharp]
Mattias Sj?gren - 28 Sep 2004 20:41 GMT
>Why not use attributes?

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

Signature

Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

James Curran - 28 Sep 2004 22:24 GMT
> >Why not use attributes?
>
> 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.

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

Signature

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

Richard Blewett [DevelopMentor] - 28 Sep 2004 23:13 GMT
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...

> >Why not use attributes?
>
> 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.

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





[microsoft.public.dotnet.languages.csharp]

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.