Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in...

Preview:

Citation preview

Object-Oriented Design Fall 2012

Kent Saxin Hammarström

Teaching assistants: Stavros Aronis, David Klaftenegger

Lecture 1

• Practical matters (1 h)

• Subject introduction (1 h)

Practical matters: Registration etc.

• Apply (www.antagning.se (Sen anmälan)) Except

– Master’s students: Contact programme co-ordinator

– Exchange students: Ulrika.Jaresund@it.uu.se

– Re-registration: IT student office (it-kansli@it.uu.se)

– Reserves: Wait for acceptance from IT office

• Register: studentportalen.uu.se

• Dropping course: Notify it-kansli@it.uu.se within 3 weeks

Course focus

• Pragmatic / applied

– Background

– Learning analysis/design

• Focus on design in software projects

• No actual programming

Course structure

• Lectures

• Group project assignment

• Final examination as poster presentation/review of project

Course structure: Lectures

• 2 lectures / week

• No compulsory text book

– 9 articles

• http://www.it.uu.se/edu/course/homepage/ood/ht12 (+ link from the Student Portal course page)

• Kent only available on lecture days

Course structure: Project

• Weekly (obligatory) TA meetings – Bonus for satisfactory progress

• Mid-course poster presentation of analysis in half-class

• Final poster presentation of design with 3 groups at a time

• Hand-in of analysis and design (4 credits) for grading

• Presentations: 1 credit. Pass/Fail, but…

Project groups

• Form groups before Thursday lunch – We will create groups for those who haven’t by

then

• As soon as groups finalized, there’ll be sign-up lists for the projects

• Two projects (one per TA) – Vote 2 out of 3 on Wednesday lecture

• First TA meeting next week; sign-up lists for 1st occasion

Break?

Object-oriented design

• Design

• Object-oriented

• Object-oriented design?

Design

• Conceptual plan for “building”

• SE: Requirements – analysis – design (system & object) – implementation

– Linear or not? Feedback. Waterfall vs agile

• Motivations

– Handling complexity

– Communication

Object-orientation

• No universal definition

• Encapsulation – inheritance – dynamic binding

• In A/D contrasted with top-down structured and data-driven

• In OOP one dimension of several

Object-oriented design 2

• OO as a property of design?

• Pragmatic OOD: Design intended to be implemented in an OOP – Minimizes gap

• For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form an inheritance hierarchy

OO concepts

• Objects, state, behaviour and identity

• Class

• Encapsulation

• Inheritance

• Polymorphism

• Static and Dynamic binding

• Composition and aggregation

Objects, state, behaviour and identity

• Object

– State: instance variable values

– Behaviour: Messages trigger activity

– Identity: Identity != Equality

Class

• Concept vs instance

– Design perspective

– (deductive reasoning)

• Classification of objects

– Analysis (and post hoc) perspective

– (inductive and abductive reasoning)

Encapsulation

• No direct manipulation of instance variables

• Isolate representation of state from accessing

• [code example]

Inheritance

• Classes as extensions of other classes: Subclassing

– (diagram)

– Specification inheritance

– Implementation inheritance

• Maintenance etc.

• Polymorphism

Polymorphism

• Subtype/parametric polymorphism

– Subtype p: Any subclass can be substituted for its superclass(es)

• Cf inheritance above

– (code snippet)

• Ad hoc polymorphism (overloading)

Static and Dynamic binding

• Static b: Names acquire their values before run-time. E.g. C and C++

• Dynamic b: Names acquire their value during run-time. E.g. Java and Python

– Hooks for future code, as objects can be sub-classed for changed behaviour

• (code snippet)

Composition and aggregation

• Objects as members/attributes of other objects

• Strength of association / ownership

• Composition: ”owns a”, ”consists of”; 1-to-1 or 1-to-many

• Aggregation: ”has a”; many-to-many

• + general relation: ”uses a”

• Life cycle management

– (cf. cascade-on-delete)

Why OO?

• Most common languages: Java & C++

• OO more a design approach

– OOP provide features to support OO, but don’t enforce it

Next lecture

• Object-oriented analysis

Recommended