23
Object-Oriented Design Fall 2012 Kent Saxin Hammarström Teaching assistants: Stavros Aronis, David Klaftenegger

Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form

Object-Oriented Design Fall 2012

Kent Saxin Hammarström

Teaching assistants: Stavros Aronis, David Klaftenegger

Page 2: Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form

Lecture 1

• Practical matters (1 h)

• Subject introduction (1 h)

Page 3: Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form

Practical matters: Registration etc.

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

– Master’s students: Contact programme co-ordinator

– Exchange students: [email protected]

– Re-registration: IT student office ([email protected])

– Reserves: Wait for acceptance from IT office

• Register: studentportalen.uu.se

• Dropping course: Notify [email protected] within 3 weeks

Page 4: Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form

Course focus

• Pragmatic / applied

– Background

– Learning analysis/design

• Focus on design in software projects

• No actual programming

Page 5: Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form

Course structure

• Lectures

• Group project assignment

• Final examination as poster presentation/review of project

Page 6: Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form

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

Page 7: Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form

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…

Page 8: Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form

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

Page 9: Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form

Break?

Page 10: Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form

Object-oriented design

• Design

• Object-oriented

• Object-oriented design?

Page 11: Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form

Design

• Conceptual plan for “building”

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

– Linear or not? Feedback. Waterfall vs agile

• Motivations

– Handling complexity

– Communication

Page 12: Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form

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

Page 13: Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form

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

Page 14: Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form

OO concepts

• Objects, state, behaviour and identity

• Class

• Encapsulation

• Inheritance

• Polymorphism

• Static and Dynamic binding

• Composition and aggregation

Page 15: Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form

Objects, state, behaviour and identity

• Object

– State: instance variable values

– Behaviour: Messages trigger activity

– Identity: Identity != Equality

Page 16: Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form

Class

• Concept vs instance

– Design perspective

– (deductive reasoning)

• Classification of objects

– Analysis (and post hoc) perspective

– (inductive and abductive reasoning)

Page 17: Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form

Encapsulation

• No direct manipulation of instance variables

• Isolate representation of state from accessing

• [code example]

Page 18: Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form

Inheritance

• Classes as extensions of other classes: Subclassing

– (diagram)

– Specification inheritance

– Implementation inheritance

• Maintenance etc.

• Polymorphism

Page 19: Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form

Polymorphism

• Subtype/parametric polymorphism

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

• Cf inheritance above

– (code snippet)

• Ad hoc polymorphism (overloading)

Page 20: Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form

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)

Page 21: Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form

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)

Page 22: Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form

Why OO?

• Most common languages: Java & C++

• OO more a design approach

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

Page 23: Object-Oriented Design Fall 2012 · •For this course: OOA/D structures/decomposes a domain in terms of stateful communicating objects, with objects grouped into classes that form

Next lecture

• Object-oriented analysis