Before the advent of object oriented programming, the design of the system was done by breaking the system into modules and then integrating the entire functionality by making calls to the functions. The concept of reusability was bleak.
Then software development ventured into object oriented programming, where reusability and scalability were targeted. Normally, a design of any application is thought in terms of componentizing the entire application for further reuse. In a distributed web application the UI tier, the business tier and the data tier is what comes to our mind. But the paradigm shift to object oriented programming or component based development was not helpful to a very good extent as objects were glued to code. In a method “ Save “ of a class File the code written would be , instantiating a sequence of objects for establishing a connection , execute a command , log the transaction , close connection . These sequences of object creation would have to be written in all the methods where data is going to be saved. A developer is thus doing some kind of re-writing of code. In C++ the constants, attributes and operations were annotated with public, private or protected. This annotation is interpreted by the C++ compiler to add special meaning for each annotation there by giving access and security to data. Attribute based programming helps to annotate classes, constructors, properties, methods to add more meaning to them during runtime. The attributes can be added or removed from the code conveniently and the duplication of code across methods is eliminated. The runtime uses these attributes to compose an object stack when the object is created. When the client makes method call each attribute gets a chance to execute its part and transfer control until finally the actual method is invoked. During the stack wind up each attribute is again given a chance to wind up and the final stack wind up takes place. This means that the sequence of operations that you wrote is now handled by the runtime. Usage of attributes gives flexibility to code and avoids duplication of code. Lets us look into the recipe of .NET to design attributes, write custom attributes and use pre-defined attributes.