Object Oriented Programming Spring Semester 2012-13 Introduction to Course Object Oriented Programming Spring Semester 2012-13 Dr. Malik Jahan Khan Department of Computer Science Namal College Malik Jahan Khan
Goals To introduce advance programming concepts and techniques used in problem solving including object oriented analysis, design and implementation To enable object oriented modeling of any unseen real life problem, and implementing the solution
Pre-Requisites Introduction to Programming Good problem solving abilities
General Policies Additional to disciplinary policies of the institute / university, plagiarism will be strictly dealt with. Cheating any assignment, quiz or exam from any one else may lead to severe penalty of grade. Violation of rules / disturbance in class / involvement in plagiarism may easily lead you to an “F” in the course. Both parties involved in the plagiarism will be equally punishable. Getting zero in a quiz, an exam problem or an assignment is much better than cheating it from any source. So avoid throwing yourselves in a very tensed and harmful situation.
General Policies (Cont.) Quizzes will be unannounced Project Deadlines Policy Detailed policies or changes in policies (if needed) will be communicated with passage of time. Sleeping in class is optional (not compulsory)! Latecomers? General Attitude Concern Zero tolerance policy on disciplinary issues
Recommended Textbook Robert Lafore. “Object Oriented Programming in C++”, 4th Edition, SAMS Publishing.
Grading Policy Quizzes 20% Programming Projects 20% Midterm Exam 25% Final Exam 35%
Structured Programming We write series of steps to solve a problem Take input Perform certain manipulations Throw output If complexity grows, divide the program into functions
Shortcomings! This project is too complex! The schedule slips More programmers added in team Complexity increases Costs skyrocket Schedule further slips And disaster ensues …. .... ….
Why All This Happens Functions have unrestricted access to all global data Unrelated functions and data Poor model of the real world In real world, we have to deal with entities like person, item, car, book, course, university etc None of these entities is like data None of these entities is like functions
Object Oriented Programming! But Why and How??? Solution Object Oriented Programming! But Why and How???
Real World Modeling We deal with objects in real world like: People Vehicles Computers Inventory Items By now, we know about data attributes (variables and arrays etc) We also know about functions But the real word objects are neither like attributes nor functions In fact, real word objects have both attributes and some behavior (functions)
Attributes Attributes are the characteristics of an object Examples People have eye color, name, job title, age, gender etc Cars have horsepower, number of doors, model, color etc Attributes are like data members (variables etc.) in a program, e.g. EyeColor (attribute) has value “blue” Age (attribute) has value “25” Model (attribute) has value “2003”
Behavior Behavior is something a real world object does in response to some stimulus Examples If you ask your boss for a raise, she will generally say “YES” or “NO” If you apply brakes in a car, it will stop Here, saying something and stopping are examples of behavior of two objects “boss” and “car” respectively Behavior is like function, you call a function to do something (e.g. stop the car, find factorial etc)
So….. Attributes are represented by data like variable, arrays, pointers etc Behavior is represented by functions But neither data nor functions, by themselves, represent or model real world objects
Object-Oriented Approach Fundamental idea behind OO approach is to combine into a single unit both data and functions that operate on that data Such a unit is called “object” Group of similar objects is called “class”
How does a computer work? Hardware Central Processing Unit Hard disk Processor RAM ROM Keyboard / Mouse Monitor Software System Software Operating Systems (MS Windows, Linux, Android etc) Device Drivers Application Software MS Office, Games, Internet Explorer, Your Programs…