473,396 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Attribute/Base Class Naming

Hello All,
I am fairly new to creating custom attributes, and want to get a
better feel for how they should be named.

We have a class hierarchy, with a base class called "SequenceCommand".
This class has a couple static functions and an embedded class, all of
which are referenced in code like "SequenceCommand.Create()" or
"SequenceCommand.ArgumentDef". There is also a fairly rich hierarchy
of classes under it (maybe 10-15 intermediate classes and about 30
concrete/instantiable classes).

We recently created a custom attribute, to which we would apply to the
concrete classes in the hierarchy that we intend to "use" (allowing
them to be used in reflection). This makes our reflection code, which
finds usable classes by name, quite a bit cleaner. Classes without
this attribute are not used, even if they are otherwise capable of
being instantiated, etc.

We want to call this custom attribute class
"SequenceCommandAttribute". This would lead to code like...

[SequenceCommand("MY_COMMAND")]
public class MySequenceCommand : SequenceCommand
{
// implementation
}

There is no conflict here, but it just looks odd that you see
"SequenceCommand" in two places -- one of which is actually referring
to the SequenceCommandAttribute class.

Question: Is this bad practice?
I have found two similar classes in .NET:
System.Runtime.Remoting.Activation.UrlAttribute and
System.SecurityPolicy.Url. These are in two different namespaces, but
perhaps, with the right combination of "using" statements, could lead
to the same syntax I am describing.

Two alternatives:
1. Change the base class to "SequenceCommandBase"
I don't like this because of the references to the embedded class
"ArgumentDef" and the static functions.

2. Change the attribute class to "ExecutableSequenceCommandAttribute"
I don't like this because it is a little bit verbose, and the
attribute will be applied in many places.
Is there an official position on this sort of thing?
TIA for your help!
- Chris

Jun 20 '07 #1
0 1108

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

Similar topics

2
by: Gabriel Genellina | last post by:
Hi In the following code sample, I have: - a Worker class, which could have a lot of methods and attributes. In particular, it has a 'bar' attribute. This class can be modified as needed. - a...
7
by: svilen | last post by:
hello again. i'm now into using python instead of another language(s) for describing structures of data, including names, structure, type-checks, conversions, value-validations, metadata etc....
2
by: Greg | last post by:
Hi. I have a rather large xml document (object) that can have one or more nodes with a certain attribute throughout (at ANY depth, not at the same level necessarily). I need to find this...
5
by: Russell Warren | last post by:
I just ran across a case which seems like an odd exception to either what I understand as the "normal" variable lookup scheme in an instance/object heirarchy, or to the rules regarding variable...
2
by: gary.goodwin | last post by:
HI I am trying to understand Attribute usage. For example the class SerializableAttribute is a class correct? So why when it is actually u sed the "Attribute" portion of the name is dropped. The...
5
by: crystalattice | last post by:
I've finally figured out the basics of OOP; I've created a basic character creation class for my game and it works reasonably well. Now that I'm trying to build a subclass that has methods to...
6
by: noel.hunt | last post by:
I have a base class, PadRcv, with virtual functions. User code will derive from this class and possibly supply it's own functions to override the base class virtual functions. How can I test that...
1
by: chris.bahns | last post by:
Hello All, I am fairly new to creating custom attributes, and want to get a better feel for how they should be named. We have a class hierarchy, with a base class called "SequenceCommand". This...
1
by: mrstephengross | last post by:
I've got a Base class with an attribute "foo" (of type Foo), and a Derived class (derived from Base). In Derived's constructor, I try to refer to Base.foo, but python complains: AttributeError:...
1
by: Florian Paulus | last post by:
Hi group, i'm wondering how to assign an attribute to a field that a class inherited from a base class. Say base class has a field protected string message, so in the derived class i want to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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,...

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.