473,836 Members | 1,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Empty Interface vs. Custom Attributes

Often you see code where an empty interface is used to
indicate something about the class that realizes it. In
the .NET world this can be done with custom attributes
too, so which is better:

public class SomeClass : IEmptyInterface

or

[Empty]
public class SomeClass

Nov 22 '05 #1
5 2652
I prefer custom attributes.
"Doug Holland" <do**********@p recisionobjects .com> wrote in message
news:01******** *************** *****@phx.gbl.. .
Often you see code where an empty interface is used to
indicate something about the class that realizes it. In
the .NET world this can be done with custom attributes
too, so which is better:

public class SomeClass : IEmptyInterface

or

[Empty]
public class SomeClass

Nov 22 '05 #2
I am tempted to agree, however I'm wondering about
performance or other implications which would affect the
decision.

Obviously custom attributes can take arguments which make
them more customizable than empty interfaces.

-----Original Message-----
I prefer custom attributes.
"Doug Holland" <do**********@p recisionobjects .com> wrote in messagenews:01******* *************** ******@phx.gbl. ..
Often you see code where an empty interface is used to
indicate something about the class that realizes it. In
the .NET world this can be done with custom attributes
too, so which is better:

public class SomeClass : IEmptyInterface

or

[Empty]
public class SomeClass

.

Nov 22 '05 #3

"Doug Holland" <do**********@p recisionobjects .com> wrote in message
news:07******** *************** *****@phx.gbl.. .
I am tempted to agree, however I'm wondering about
performance or other implications which would affect the
decision.

Obviously custom attributes can take arguments which make
them more customizable than empty interfaces.
Unless you are processing several million classes, their shouldn't be any
reason to consider performance. Remember, in most casts one in memory
operation is far faster than a single disk load, by orders of magnitude
actually. You only really need to concern yourselft with performance in the
fringe case.

I'd think more about customization and clarity, an attribute provides
metadata, an interface is supposed to provide an interface.

-----Original Message-----
I prefer custom attributes.
"Doug Holland" <do**********@p recisionobjects .com> wrote

in message
news:01******* *************** ******@phx.gbl. ..
Often you see code where an empty interface is used to
indicate something about the class that realizes it. In
the .NET world this can be done with custom attributes
too, so which is better:

public class SomeClass : IEmptyInterface

or

[Empty]
public class SomeClass

.

Nov 22 '05 #4
I think attributes are much more "cleaner", they provide you with a greate
flexibility. You need one interface for each "type", using attributes you
can reduce the number by reusing attributes (giving them a property), for
example

[Empty(CanDoThis )]
public class SomeClass

[Empty(CanDoSome thingElse)]
public class SomeClass
--
Greetz,
Jan
_______________ _______________ ____
Read my weblog: http://weblogs.asp.net/jan
"Doug Holland" <do**********@p recisionobjects .com> schreef in bericht
news:07******** *************** *****@phx.gbl.. .
I am tempted to agree, however I'm wondering about
performance or other implications which would affect the
decision.

Obviously custom attributes can take arguments which make
them more customizable than empty interfaces.

-----Original Message-----
I prefer custom attributes.
"Doug Holland" <do**********@p recisionobjects .com> wrote

in message
news:01******* *************** ******@phx.gbl. ..
Often you see code where an empty interface is used to
indicate something about the class that realizes it. In
the .NET world this can be done with custom attributes
too, so which is better:

public class SomeClass : IEmptyInterface

or

[Empty]
public class SomeClass

.

Nov 22 '05 #5
Thanks Guys

I had the same feelings about custom attributes but being
a recent father and being sleep deprived I wanted
to 'sanity-check' my thoughts ;)

- Doug
-----Original Message-----
I think attributes are much more "cleaner", they provide you with a greateflexibility. You need one interface for each "type", using attributes youcan reduce the number by reusing attributes (giving them a property), forexample

[Empty(CanDoThis )]
public class SomeClass

[Empty(CanDoSome thingElse)]
public class SomeClass
--
Greetz,
Jan
______________ _______________ _____
Read my weblog: http://weblogs.asp.net/jan
"Doug Holland" <do**********@p recisionobjects .com> schreef in berichtnews:07******* *************** ******@phx.gbl. ..
I am tempted to agree, however I'm wondering about
performance or other implications which would affect the decision.

Obviously custom attributes can take arguments which make them more customizable than empty interfaces.

>-----Original Message-----
>I prefer custom attributes.
>"Doug Holland" <do**********@p recisionobjects .com> wrote
in message
>news:01******* *************** ******@phx.gbl. ..
>> Often you see code where an empty interface is used

to >> indicate something about the class that realizes it. In >> the .NET world this can be done with custom attributes >> too, so which is better:
>>
>> public class SomeClass : IEmptyInterface
>>
>> or
>>
>> [Empty]
>> public class SomeClass
>>
>
>
>.
>

.

Nov 22 '05 #6

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

Similar topics

49
2857
by: Christopher J. Bottaro | last post by:
I find myself doing the following very often: class Struct: pass .... blah = Struct() blah.some_field = x blah.other_field = y ....
5
454
by: Doug Holland | last post by:
Often you see code where an empty interface is used to indicate something about the class that realizes it. In the .NET world this can be done with custom attributes too, so which is better: public class SomeClass : IEmptyInterface or
2
528
by: PatrickSA | last post by:
Hi, Am new to web services, so apologies for the basic nature of the question - and apologies in advance if this is the wrong newsgroup. We're building a new web service and I'm looking around for documentation on a number of issues, including versioning of web service interfaces... I've spent the last few hours looking through books, Google, MSDN and surprisingly I have found little or nothing that explains/shows how to practically...
1
8519
by: Microsoft | last post by:
Hello there, I have following situation , how can I solve this puzzle in C#. I have interface called IVendor with some custom attributes applied to it interface IVendor {
12
3212
by: Rick Strahl [MVP] | last post by:
Does anybody know of a tool of some sort that can generate a C# interface from a COM interface? I need to pull a ton of interfaces out of an existing application and it sure would be lot nicer to get at least a rough headstart with these interfaces. Is there such thing before I sit down and write somehting like this on my own? +++ Rick ---
2
9332
by: Microsoft | last post by:
I have Interface defined with custom attribute. My class implements the same interface , but I'm not able to see any attributes derived from interface.( I did set the inherited to true) .
10
2990
by: Brett | last post by:
I'm still trying to figure out concrete reasons to use one over the other. I understand the abstract class can have implementation in its methods and derived classes can only inherit one abstract class. The interface has implied abstract methods/properties and derived classes can inherit multiple interfaces. The interface properties/methods have no implementation. Besides definitions of the two, what are some conceptual reasons to use...
2
2536
by: prabhupr | last post by:
Hi Folks I was reading this article (http://www.dotnetbips.com/articles/displayarticle.aspx?id=32) on "Custom Attribute", written by Bipin. The only thing I did not understand in this article is the usage of "Custom Attribute" in real life project. Can somebody please help me understand where are these informations really helpful in Development Environment; may be a few example(s) will help me understand.
2
1112
by: jsh02_nova | last post by:
Has anybody ever used custom attributes to implement a custom interface for a user defined type? thx -jsh
5
2346
by: paul.hester | last post by:
Hi all, I have a custom control with an overridden Render method. Inside this method I'm rendering each control in its collection using their RenderControl method. However, I'm running into a problem in this scenario: <myprefix:mycontrol runat="server"> <%= SomeVariable %> </myprefix:mycontrol>
0
9825
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10560
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
10602
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
10260
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7795
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
6984
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5653
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...
1
4463
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
3
3116
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.