Escolar Documentos
Profissional Documentos
Cultura Documentos
What is programming?
Programming is taking A problem Find the area of a rectangle A set of data length width A set of functions area = length * width Then, Applying functions to data to solve the problem
2
Assembly code
Procedural Programming
The main program coordinates calls to procedures and hands over appropriate data as parameters.
10
Disadvantages
y Unrestricted Access y Data is exposed to whole program, so no security for data. y Difficult to relate with real world objects. Separate data y y y y y
and functions. Importance is given to the operation on data rather than the data. Increases complexity when program becomes large. A change in global data may necessitate rewriting all the functions that access that item. Doesn t emphasize on what to do to solve a problem. Difficult to modify.
OOPs treats data as a critical element in the program development and does not allow it to flow freely around the system. It ties data with the function that operate on it and protects it from accidental modification from outside functions. OOPs allows decomposition of data into number of entities called objects, and then builds data and function around it. The data of object can be accessed only by the functions associated with that object.
Object-Oriented Concept
Definition of OOPs
Object-oriented programming (OOP) is a programming language model organized around "objects" rather than "actions" and data rather than logic. Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Object-oriented programming (OOP) is a programming paradigm that uses "objects" data structures consisting of datafields and methods together with their interactions to design applications and computer programs.
Object
Objects are run time entities in object oriented system. They may represent a person, a place, a bank account that program has to handle. Programs objects should be chosen such that they match closely with real world objects.
What is an object?
Tangible Things Roles Incidents Interactions Specifications as a car, printer, ... as employee, boss, ... as flight, overflow, ... as contract, sale, ... as colour, shape,
Representing an Object
Class
Class is a collection of objects of similar type. Classes are user defined data types and behave like built in type of programming language. Eg:- Mango, apple ,orange are the members of same class fruit.
Classification
Animal Mammal Reptile
Rodent
Primate
Cats
Mouse
Squirel
Rabbit
DATA ABSTRACTION It refers to the act of representing essential features without including the background details or explanations. ENCAPSULATION The wrapping up of data and functions into a single unit (called class) is known as encapsulation. DATA HIDING The data is not accessible to the outside world and only those functions which are wrapped in the class can access it. This insulation of data from access by the program is called data hiding INHERITANCE It is the process by which objects of one class acquire the properties of objects of another class. i.e. deriving a new class from the existing one. POLYMORPHISUM Polymorphism means having many forms . It allows different objects to respond to the same message in different ways, the response specific to the type of the object.
MESSAGE PASSING: An object oriented program consists of a set of objects that communicate with each other with messages. A message for an object is a request for execution of a procedure and will invoke a function in the object that generates the desired result. It involves: specifying - the name of object, - the name of function(message) and - information to be sent.