Object-Oriented Programming

for RuBoard

At its core , the .NET Framework is built with object-oriented programming in mind. As mentioned previously, MSIL and metadata are stored in each assembly. Metadata in particular provides key object-oriented information. For instance, it shows if a given class method is public, private, or only available to subclasses.

Since what makes something "object-oriented" is somewhat controversial in the realm of computer science, here are some specific features of the .NET Framework that are generally seen as essentials that object-oriented languages must provide:

  • Encapsulation ”This refers to the use of classes/types to group together related data and functions. For instance, a payroll application needs to go through each employee in a company every pay period to determine how much to pay each person. To simplify the programming model, a programmer might define a class named "employee" to hold the employee name, ID, number of tax exemptions, and other employee data as well as methods that allow the application to calculate the paycheck amount for the current pay period. Without encapsulation, the programmer might have to track an employee as a separate set of data types ”a string for the employee name , an integer for the ID, another integer for the number of exemptions, and so on ”with a group of methods defined inside a mix of other functions. Encapsulation provides a clean and easy way to group related information and functionality so the programmer can more easily manage his codebase .

  • Information Hiding ”Information hiding can be seen as an extension of encapsulation where some information is deemed public and some is deemed non-public. In the case of a class for employees , a programmer would likely want to make the name and employee ID values public. However, the employee class might have internal data or methods it uses for debugging or to perform its public duties . For instance, an employee object might need to know what row in a database contains information on that employee.

  • Inheritance ”Inheritance allows hierarchies of types to be defined, where child types are more specialized than parent types. In the case of employees, the payroll application might want to create two subtypes of employee: hourly employees and salaried employees. This allows methods to be written that would perform differently for each type of employee. Without inheritance, the employee class would need to use something like if/then statements to differentiate between the types of employees.

  • Polymorphism ”This term can mean different things to different people. Generally, though, polymorphism means that a framework supports virtual calls, operator and method overloading, and other related functionality. In the case of hourly employees and salaried employees, each class may implement its own version of the method to calculate the paycheck amount for that period. However, if the payroll application just knows an object is a generic employee, it can simply call the method to calculate the paycheck amount. The runtime will determine which method implementation to call.

for RuBoard


. NET Framework Security
.NET Framework Security
ISBN: 067232184X
EAN: 2147483647
Year: 2000
Pages: 235

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