A component is a class designed to fit into some preexisting class framework. It may do so through inheritance or by implementing one or more interfaces, but it must follow the rules of components for the environment in which it is being developed.
The more common examples of components include the controls and beans found and used in modern Integrated Development Environments ( IDEs ). Java development tools and .NET Framework tools usually implement some type of form designer, where you can drag and drop controls such as buttons from a tool palette onto a form.
The items that appear in the tool palette are examples of the types of components we are talking about, and they are often written in the language of the IDE itself. For example, the JButton class in Java can be displayed in the tool palette of most modern Java IDEs because it was written to meet the requirements of doing so. You can drag the button from the tool palette, drop it on a form or panel, and then view the source code and see the declaration and initialization of the JButton object added to your source code automatically.
These types of components are a key aspect of Rapid Application Development (RAD) and have been popular for a number of years . The simplicity of the visual interface is very attractive for its speed and simplicity. You may even work with components visually at design time (while you build the application) even if they have no visual appearance at run time (while the program is executing).
An example might be an FTP component that provides File Transfer Protocol support but doesn t have a specific display at run time (too many things must be done to be wrapped up neatly in a user interface). In such a case, you still see a benefit to just dragging the component onto the form because this action is quicker and less prone to mistakes than manual typing. You can also normally use such components as normal classes (because they are, after all, classes) and manually declare and initialize them a needed.
Therefore, components typically implement the following types of behavior, using inheritance and/or interfaces specific to the language:
Support for introspection Allows an IDE to analyze how a component works.
Support for customization Allows a programmer to alter the appearance and behavior of a component.
Support for events Allows components to fire events and inform IDEs about the events they can fire.
Support for properties Allows components to be manipulated programmatically as well as to support any customization.
Support for persistence Allows components that have been customized in an application builder to have their state saved and restored. Typically persistence is used with an IDE s Save and Load menu commands to restore any work that has gone into constructing an application.
For Java, the component type is JavaBeans, whereas C# simply has components.