Abstraction
Abstraction is the ability to generalize an object as a data type that has a specific set of characteristics and is able to perform a set of actions.
Object-oriented languages provide abstraction via classes. Classes define the properties and methods of an object type.
Examples:
You can create an abstraction of an Employee with characteristics, such as FirstName, LastName, Department, Experience etc. and actions such as AssignTask, PerformTask and ReportTo etc. The characteristics are called properties, and the actions are called methods.
Encapsulation
Once you have your class properly design then you can create an object out of it. Object now contains the data and behaviors defined in the class, so a client application can treat this object like a black box accessible only through its interface (which mean its properties, methods/functions etc). This is a key object-oriented concept called Encapsulation.
The idea is that any programs that make use of this object won't have direct access to the behaviors or data – but rather those programs must make use of our object's interface.
Examples:
Employee objEmp = new Employee();
objEmp.FirstName = "Vidya Vrat";
objEmp.LastName= "Agarwal";
objEmp.AssignTask(objEmp.FirstName, objEmp.LastName);
Note: - consider that this function will do so check on your time availabilty and the allocate you some task to the employee provided to this function as an argument.
Friday, April 23, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment