Lec3_intro_to_OOP - ITI 1121 Introduction to Computing II...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
ITI 1121. Introduction to Computing II * Marcel Turcotte School of Information Technology and Engineering Version of January 13, 2010 Abstract Object-oriented programming Encapsulation * These lecture notes are meant to be looked at on a computer screen. Do not print them unless it is necessary.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Object-Oriented Programming — OO OO and programs design encapsulation information hiding the interface of class an object has a state composing with objects classes vs objects anatomy of class (class implementation) variables: instance variables, class variables, local variables and parameters (formal and effective/actual) methods: class methods and instance methods constructors -1- ad hoc polymorphism (method overloading) inheritance (software re-use) constructors -2- polymorphism: inheritance, abstract classes and interfaces
Background image of page 2
Object-Oriented Programming and software design What is object-oriented programming? The design of a software system is an abstract activity , in the sense that you cannot see or touch the product that is being built. The design of software systems in terms of classes and objects, makes this process more concrete , you can actually draw diagrams that correspond to classes and objects, or imagine the classes and objects as physical entities. This conceptualization allows us to think about the interactions amongst parts of the software more easily (naturally).
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Abstraction An abstraction allows us to ignore the details of a concept and to focus on its important characteristics. The term “ black-box ” is often used as an analogy for an abstraction.
Background image of page 4
Procedural Abstraction The programming methodology used throughout most of CS I is called “structured programming”. Its main mean of abstraction is a procedure (called routine or function in some languages, or method in Java). If the method is well designed, and depends only on its formal parameters, than a method can be used as a black box — you shouldn’t be concerned about its implementation. For example, one can use a sorting method without knowing about the particular algorithm that it uses — in most circumstances. This way to structure a program works best when the data and the number of types are small.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Data abstraction Records and structures were amongst the first forms of data abstraction. They allow to model the data and to handle the data as a unit. The classic example is a Student record which regroups a name, a student number and so on.
Background image of page 6
Data abstraction A point could be declared as follows: class Point { int x; int y; } which would be used as follows: static Point add( Point a, Point b ) { Point result = new Point(); result.x = a.x + b.x; result.y = a.y + b.y; return result; } Calling the method add: p3 = add( p1, p2 );
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Data abstraction Imagine writing a program to keep track of students information. Without data abstraction, every time the information about a particular student
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 37

Lec3_intro_to_OOP - ITI 1121 Introduction to Computing II...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online