Attribute Basics


Attributes are a new feature in Visual C++ .NET. You ve already seen what they look like ”attributes are included within square brackets before the definition of the class or method they affect. In this section, you ll take a brief look at what they are.

You can view attributes as compile-time wizards. The compiler uses them to inject code into your application to complete the functionality desired. You can view what the compiler injects by using the /Fx compiler switch. This switch will save the files the compiler generates (i.e., a generated file with plain C++ and no attributes).

Attributes are designed not only to simplify implementation details (by letting you focus on application logic), but also to improve the readability and maintainability of your code. One way that attributes do this is the way that they keep all your code in one place, which means that changes to the code occur in only one place (as opposed to your needing to go and change the map and the class it relates to). The use of attributes has enabled the introduction of inline IDL (for COM developers) and has made COM development in general a lot easier and faster, without developers having to give up control. The database attributes reduce the legwork in accessing databases, and the ATL Server attributes help with the creation of Web applications (as you ve seen) and Web services (as you ll see in Chapter 10).

Because attributes are new to Visual C++ .NET, we explain the code clearly whenever we use them in this book.




ATL Server. High Performance C++ on. NET
Observing the User Experience: A Practitioners Guide to User Research
ISBN: B006Z372QQ
EAN: 2147483647
Year: 2002
Pages: 181

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net