attributed programming
-
Why Microsoft introduced this new "attributes" in its .NET programming? Can someone throw some useful information (links to definitions) on this attributed programming? Wondering what would be the advantage of having them as attributes and not properties inside a class (which needs these attributes to be setup)....? omkamal
-
Why Microsoft introduced this new "attributes" in its .NET programming? Can someone throw some useful information (links to definitions) on this attributed programming? Wondering what would be the advantage of having them as attributes and not properties inside a class (which needs these attributes to be setup)....? omkamal
omkamal wrote: Why Microsoft introduced this new "attributes" in its .NET programming? It's another proprietary extension to tie people into MS's compiler, and hides the details of writing COM classes from people who think it's too hard to do. --Mike-- "Everyone has figured out what 'service pack' really means, so they had to go and change the language. Perhaps this is what Bill was talking about in the 'security is top priority' letter." -- Daniel Ferguson, 1/31/2002 My really out-of-date homepage Sonork - 100.10414 AcidHelm Big fan of Alyson Hannigan.
-
Why Microsoft introduced this new "attributes" in its .NET programming? Can someone throw some useful information (links to definitions) on this attributed programming? Wondering what would be the advantage of having them as attributes and not properties inside a class (which needs these attributes to be setup)....? omkamal
Attributes allow you to decorate code with various properties at compile time. Then at runtime those properties can be examined and the data extracted. I'm thinking about writing an article for CP about this topic, I just need to come up with a different use for attributes so it doesn't clash with my commercial product :) An attribute can be nothing more than a flag,
SerializableAttribute
, or it can perform something useful,ToolboxBitmapAttribute
. I suppose, you could think of an attribute as a readonly property on a type. VS.NET uses attributes internally, if you design a usercontrol numerous attributes can be applied to the class and its properties to effect the visual and usage outcome. You can specify the toolbox bitmap, which properties show up in the properties box, whether those properties are readonly, and if it has an UI Editor. From what I've read COM doesn't let you specify many attributes, where .NET allows you to place an attribute on anything (even attributes have an attribute, AttributeUsage which specifies where it is valid to use an attribute) :) James Sonork ID: 100.11138 - Hasaki "My words but a whisper -- your deafness a SHOUT. I may make you feel but I can't make you think." - Thick as a Brick, Jethro Tull 1972 -
Attributes allow you to decorate code with various properties at compile time. Then at runtime those properties can be examined and the data extracted. I'm thinking about writing an article for CP about this topic, I just need to come up with a different use for attributes so it doesn't clash with my commercial product :) An attribute can be nothing more than a flag,
SerializableAttribute
, or it can perform something useful,ToolboxBitmapAttribute
. I suppose, you could think of an attribute as a readonly property on a type. VS.NET uses attributes internally, if you design a usercontrol numerous attributes can be applied to the class and its properties to effect the visual and usage outcome. You can specify the toolbox bitmap, which properties show up in the properties box, whether those properties are readonly, and if it has an UI Editor. From what I've read COM doesn't let you specify many attributes, where .NET allows you to place an attribute on anything (even attributes have an attribute, AttributeUsage which specifies where it is valid to use an attribute) :) James Sonork ID: 100.11138 - Hasaki "My words but a whisper -- your deafness a SHOUT. I may make you feel but I can't make you think." - Thick as a Brick, Jethro Tull 1972James T. Johnson wrote: I'm thinking about writing an article for CP about this topic, And I would be your first reader. :) I also read some of the msdn articles about this attributed programming. The key definition they give is... Attributes, a new feature in Visual C++, are designed to simplify COM programming and .NET Framework common language runtime development. When you include attributes in your source files, the compiler works with provider dynamic-link libraries (DLL) to insert code or modify the code in the generated object files. Unfortunately, I just got only a few information about attributes. But I am now wondering how I can apply attributes in my programming? What are the advantages of using attributes over properties... And finally how to create and use a owner-defined attributee??? Will your article cover these..........(Oh! please tell me yes):) omkamal
-
James T. Johnson wrote: I'm thinking about writing an article for CP about this topic, And I would be your first reader. :) I also read some of the msdn articles about this attributed programming. The key definition they give is... Attributes, a new feature in Visual C++, are designed to simplify COM programming and .NET Framework common language runtime development. When you include attributes in your source files, the compiler works with provider dynamic-link libraries (DLL) to insert code or modify the code in the generated object files. Unfortunately, I just got only a few information about attributes. But I am now wondering how I can apply attributes in my programming? What are the advantages of using attributes over properties... And finally how to create and use a owner-defined attributee??? Will your article cover these..........(Oh! please tell me yes):) omkamal
omkamal wrote: What are the advantages of using attributes over properties I don't like saying one technique is better than another; its really just personal preference, but I hope when I'm done you'll find where using attributes makes sense and where a static property makes sense :) omkamal wrote: Will your article cover these..........(Oh! please tell me yes) Right now I'm thinking of covering "Using existing attributes" and "Creating and using your own attributes", plus any glue that seems neccessary to blend the two topics. Plus I plan on including an example of writing and using your own attributes. :) James Sonork ID: 100.11138 - Hasaki "My words but a whisper -- your deafness a SHOUT. I may make you feel but I can't make you think." - Thick as a Brick, Jethro Tull 1972