473,508 Members | 2,168 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 2612
I prefer custom attributes.
"Doug Holland" <do**********@precisionobjects.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**********@precisionobjects.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**********@precisionobjects.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**********@precisionobjects.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(CanDoSomethingElse)]
public class SomeClass
--
Greetz,
Jan
__________________________________
Read my weblog: http://weblogs.asp.net/jan
"Doug Holland" <do**********@precisionobjects.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**********@precisionobjects.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(CanDoSomethingElse)]
public class SomeClass
--
Greetz,
Jan
__________________________________
Read my weblog: http://weblogs.asp.net/jan
"Doug Holland" <do**********@precisionobjects.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**********@precisionobjects.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
2757
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: ...
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...
1
8452
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
3187
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...
2
9240
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
2945
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...
2
2509
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...
2
1094
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
2305
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...
0
7127
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7331
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,...
0
7391
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...
0
5633
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,...
1
5056
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...
0
4713
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...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1564
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 ...
1
768
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.