473,804 Members | 2,202 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"marker" interfaces. What are they good for?

I was wondering why MS defined "marker" interfaces (empty interfaces) in the
..NET framework(inter faces such as such as INamingContaine r,
IRequiresSessio nState etc...).
Why not use attributes?

Eran Kampf
http://www.ekampf.com

Nov 16 '05 #1
5 5024
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" <er**@ekampf.co m> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
I was wondering why MS defined "marker" interfaces (empty interfaces) in the .NET framework(inter faces such as such as INamingContaine r,
IRequiresSessio nState etc...).
Why not use attributes?

Eran Kampf
http://www.ekampf.com

Nov 16 '05 #2
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.publi c.dotnet.langua ges.csharp/<#J************ **@TK2MSFTNGP11 .phx.gbl>

I was wondering why MS defined "marker" interfaces (empty interfaces) in the
.NET framework(inter faces such as such as INamingContaine r,
IRequiresSessio nState 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.publi c.dotnet.langua ges.csharp]
Nov 16 '05 #3
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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #4
"Mattias Sjögren" <ma************ ********@mvps.o rg> wrote in message
news:Og******** *****@TK2MSFTNG P11.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!)
Nov 16 '05 #5
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.publi c.dotnet.langua ges.csharp/<ua************ **@TK2MSFTNGP12 .phx.gbl>

"Mattias Sj?gren" <ma************ ********@mvps.o rg> wrote in message
news:Og******** *****@TK2MSFTNG P11.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!)

---
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.publi c.dotnet.langua ges.csharp]
Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
12219
by: Sybren Stuvel | last post by:
Hi there, Is it possible to use an assignment in a while-loop? I'd like to do something like "loop while there is still something to be read, and if there is, put it in this variable". I've been a C programmer since I was 14, so a construct like: while info = mydbcursor.fetchone(): print "Information: "+str(info)
0
2354
by: Anthony Baxter | last post by:
To go along with the 2.4a3 release, here's an updated version of the decorator PEP. It describes the state of decorators as they are in 2.4a3. PEP: 318 Title: Decorators for Functions and Methods Version: $Revision: 1.34 $ Last-Modified: $Date: 2004/09/03 09:32:50 $ Author: Kevin D. Smith, Jim Jewett, Skip Montanaro, Anthony Baxter
5
6345
by: Maett | last post by:
Hi. When I try to compile this piece of Code with VC.NET 2003 // code start #include <vector> template< class T > struct Marker { public:
14
3776
by: spike | last post by:
Im trying to write a program that should read through a binary file searching for the character sequence "\name\" Then it should read the characters following the "\name\" sequence until a NULL character is encountered. But when my program runs it gets a SIGSEGV (Segmentation vioalation) signal. Whats wrong? And is there a better way than mine to solve this task (most likely)
21
13854
by: Helge Jensen | last post by:
I've got some data that has Set structure, that is membership, insert and delete is fast (O(1), hashing). I can't find a System.Collections interface that matches the operations naturally offered by Sets. - ICollection cannot decide containment - IList promises indexability by the natural numbers, which is not achievable (since i hash elements, not sort them). - IDictionary is definatly not setlike. Although I can, of course, define...
12
2054
by: spibou | last post by:
Why is a pointer allowed to point to one position past the end of an array but not to one position before the beginning of an array ? Is there any reason why the former is more useful than the later ? Spiros Bousbouras
4
2088
by: jojoba | last post by:
hello all, does anyone know if, for a 2-state checkbox, you can use the "fill in" marker from the 3-state checkbox, instead of a checkmark i just like the look of the "fill-in" instead of the checkmark Thanks, jojoba
3
2238
by: Jukka K. Korpela | last post by:
Some time ago in this group, someone suggested that we should develop a "different" user style sheet to demonstrate what a user style sheet or a browser style sheet _could_ do. I guess the idea was that the style would be rather different from common browser defaults, yet sensible and potentially useful. Partly for that reason, partly to demonstrate the idea that web page rendering _could_ be different from what people are used to, I...
18
2463
by: Stephan Beal | last post by:
Hi, all! Before i ask my question, i want to clarify that my question is not about the code i will show, but about what the C Standard says should happen. A week or so ago it occurred to me that one can implement a very basic form of subclassing in C (the gurus certainly already know this, but it was news to me). What i've done (shown below) seems to work all fine and well, and does exactly what i'd expect, but i'm asking about
0
10600
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10352
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10354
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9175
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7642
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5535
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3835
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.