Download Object Oriented Programming Introduction and more Study notes Object Oriented Programming in PDF only on Docsity! Computer Science Department Object Oriented Programming Introduction Computer Science Department About the course • Credit hours: 3 + 1 • Pre-requisites: Introduction to Programming • Textbook – Object Oriented Programming in C++ by Robert Lafore • Reference books – C++ How To Program, Deitel and Deitel – Thinking in C++ by Bruce Eckel – Attendance : Should be >= 80%. You will not be allowed to sit in examination otherwise. Computer Science Department Student Evaluation • Assignments (15 marks) – Assignments submitted after the due date will either be rejected altogether or heavily penalized • Quizzes (15 marks) – Quizzes (mostly unannounced) will be conducted quite frequently and any missed quizzes will not be re-conducted • MidTerm (45 marks) • Lab (50 marks) • Final (75 marks) Computer Science Department Plagiarism Policy • Plagiarism – “Using another person's ideas or creative work without giving credit to that person” – Copying and Pasting from the Internet without citing source • Copying an assignment from a friend and turning it in as your own • Policy – Zero tolerance! – Zero points in assignment/ quiz/ project/ exam Computer Science Department My expectations • Arrive on time • Maintain class discipline • Don’t Keep your mobile phones • Actively participate in class discussion Computer Science Department Unstructured Programming • This programming technique provides tremendous disadvantages once the program gets sufficiently large • For example, if the same statement sequence is needed at different locations within the program, the sequence must be copied • This has lead to the idea of extracting these sequences, naming them and offering a technique to call and return from these procedures Computer Science Department Procedural Programming • Combine returning sequences of statements into one single place • A procedure call is used to invoke the procedure • After the sequence is processed, flow of control proceeds right after the position where the call was made Computer Science Department Procedural Programming • With the introduction of procedures (Functions) programs can now be written more structured • The main program is responsible to pass data to the individual calls, the data is processed by the procedures and, once the program has finished, the resulting data is presented Computer Science Department Modular Programming • With modular programming procedures of a common functionality are grouped together into separate modules • A program therefore no longer consists of only one single part • It is now divided into several smaller parts which interact through procedure calls and which form the whole program Computer Science Department Modular Programming • Each module can have its own data and functions Computer Science Department Unstructured, procedural, modular programming Unstructured programming. The main program directly operates on data Procedural programming. The main program coordinates calls to procedures and hands over appropriate data as parameters Modular programming. The main program coordinates calls to procedures in separate modules and hands over appropriate data as parameters Computer Science Department Object-Oriented Terminology. ... • Classes and Objects major building blocks of OOP • A class is a definition of an object. It's a type just like int • A class is used as a template or pattern to create new objects (instances of the class) • a class describes the contents of the objects that belong to it. • object: an object is an element (or instance) of a class; objects have the behaviors of their class. Computer Science Department OOP Features : A Summary • Encapsulation • Inheritance and reuse • Creating new Data types • Polymorphism, overloading, overriding Computer Science Department Encapsulation • Both the data, and the functionality that could affect or display that data are included under a unified name (the object name itself). • In the classic definition, the data elements (or properties of the object) are not available to the outside world directly. Computer Science Department Polymorphism • At any level of an object hierarchy each object could have a method of the same name and because of the level at which the method resides in, it could know which of the procedures or functions to call • Hence you could have a Shape object that has a Draw method – Then you could define a Circle, Square and Triangle object as Shape objects and override the Draw method to draw specifically a Circle, Square or Triangle method respectively – All 4 objects would then have a Draw method but only the right method for the right object would be called Computer Science Department Overloading • When an existing operator such as + or = is given the capability to operate on a new data type such as our location object in the previous example