CSCE 240 – Intro to Software Engineering Lecture 3.

Slides:



Advertisements
Similar presentations
Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
Advertisements

Solutions to Review Questions. 4.1 Define object, class and instance. The UML Glossary gives these definitions: Object: an instance of a class. Class:
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Object-Oriented.
Review of OO Introduction to Eclipse/Java September 6, 2005.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 2: Review of Object Orientation.
1 SWE Introduction to Software Engineering Lecture 23 – Architectural Design (Chapter 13)
Chapter 14 (Web): Object-Oriented Data Modeling
Contents Introduction Requirements Engineering Project Management Software Design Detailed Design and Coding Quality Assurance.
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
Object-Oriented Databases
1 Object-Oriented Design. 2 Objectives F To become familiar with the process of program development. F To the relationship types: association, aggregation,
ISE 582: Web Technology for Industrial Engineers University of Southern California Department of Industrial and Systems Engineering Lecture 4 JAVA Cup.
8.1 Classes & Inheritance Inheritance Objects are created to model ‘things’ Sometimes, ‘things’ may be different, but still have many attributes.
Chapter 14: Object-Oriented Data Modeling
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 2: Review of Object Orientation 1.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented Design.
UFCEUS-20-2 : Web Programming Lecture 5 : Object Oriented PHP (1)
Programming Languages and Paradigms Object-Oriented Programming.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 2: Modelling.
Chapter 6 Class Inheritance F Superclasses and Subclasses F Keywords: super F Overriding methods F The Object Class F Modifiers: protected, final and abstract.
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
11 1 Object oriented DB (not in book) Database Systems: Design, Implementation, & Management, 6 th Edition, Rob & Coronel Learning objectives: What.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
CISC6795: Spring Object-Oriented Programming: Polymorphism.
An Object-Oriented Approach to Programming Logic and Design
OBJECT ORIENTED PROGRAMMING CONCEPTS ISC 560. Object-oriented Concepts  Objects – things names with nouns  Classes – classifications (groups) of similar.
1 Understanding Inheritance COSC 156 C++ Programming Lecture 8.
1 Abstraction  Identify important aspects and ignore the details  Permeates software development programming languages are abstractions built on hardware.
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 20 Object-Oriented.
Unified Modeling Language, Version 2.0
Features of Object Oriented Programming Lec.4. ABSTRACTION AND ENCAPSULATION Computer programs can be very complex, perhaps the most complicated artifact.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Object-Oriented Software Development F Software Development Process F Analyze Relationships Among Objects F Class Development F Class Design Guidelines.
Chapter 9 Object-Oriented Software Development F Software Development Process F Analyze Relationships Among Objects F Class Development F Class Design.
Inheritance - Polymorphism ITI 1121 Nour El Kadri.
CHAPTER 13 (ONLINE): OBJECT-ORIENTED DATA MODELING © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition.
Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Object Oriented.
© 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 13 (Online): Object-Oriented Data Modeling Modern Database Management 10 th Edition.
Review of object Orientation Lecturer: Dr. Mai Fadel.
Object Oriented Software Development
Object-Oriented Data Modeling
Object-Oriented Programming Chapter Chapter
Object Oriented Programming
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 6: Using Design Patterns.
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 11 Object-Oriented.
1 Unified Modeling Language, Version 2.0 Chapter 2.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Lecture 2: Review of Object Orientation. © Lethbridge/La ganière 2005 Chapter 2: Review of Object Orientation What is Object Orientation? Procedural.
Object-Oriented Software Engineering Practical Software Development using UML and Java Modelling with Classes.
CSE 240 Lecture 7. © Lethbridge/Laganière 2001 Chapter 5: Modelling with classes2 Overview Hopefully return and discuss test 1 A brief discussion of Java.
Terms and Rules II Professor Evan Korth New York University (All rights reserved)
Polymorphism and Inheritance (CS-319 Supplementary Notes)
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
Basic Characteristics of Object-Oriented Systems
ISBN Chapter 12 Support for Object-Oriented Programming.
Notices Assn 2 is due tomorrow, 7pm. Moodle quiz next week – written in the lab as before. Everything up to and including today’s lecture: Big Topics are.
Inheritance a subclass extends the functionality of a superclass a subclass inherits all the functionality of a superclass don't reinvent the wheel – "stand.
Slide 1 Unified Modeling Language, Version 2.0 Object-Oriented SAD.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
Object-Oriented Modeling
Systems Analysis and Design With UML 2
Chapter 11 Object-Oriented Design
Systems Analysis and Design With UML 2
Object Oriented Programming in Java
SNSCT_CSE_PROGRAMMING PARADIGM_CS206
Understanding Inheritance
Chapter 20 Object-Oriented Analysis and Design
Object-Oriented PHP (1)
Chapter 2: Review of Object Orientation
Presentation transcript:

CSCE 240 – Intro to Software Engineering Lecture 3

Quote of the Day “Politics is war without bloodshed while war is politics with bloodshed.” -Mao Tse-tung

Overview Finish Chapter 2 More about classes/objects Polymorphism Inheritance Important 0-0 Concepts Homework 1 (due Monday, June 9 th )

Instance Varibles Attribute – “a simple piece of data used to represent the properties of an object.” – variables declared inside a class Association – “the relationship between instances of one class and instances of another.” – lots more of this when we get into UML (Person has Supervisor)

Polymorphism Definition – “a property of O-O software by which an abstract operation may be performed in different ways, typically in different classes.” (see next slide)

Polymorphism (continued)

Inheritance “If several classes have attributes, associations or operations in common, it is best to avoid duplication by creating a separate class that contains these common aspects.” It can also be used to break up complex classes into more manageable classes.

Inheritance (continued) Generalization – a two level hierarchy with one super class and an number of subclasses. Inheritance Hierarchy – has more than two levels. Sometimes called an isa hierarchy.

Inheritance (continued) Definition – “the implicit possession by a subclass of features defined in a superclass. Features include variables [attributes] and methods.”

Checks for good generalization If subclass or superclass have ambiguous names(bus instead of NightlyBusRoute) If subclass doesn’t remain distinctive throughout lifetime (ex. OverdrawnAccount as a subclass of account – an account won’t always remain overdrawn) Inherited features make sense.

Inheritance terms Leaf Class – classes at bottom level of inheritance hierarchy (may not be abstract, must be concrete) Abstract Class – can never have any instances (shown in italics) Concrete Class – can have instances

More Inheritance Terms Abstract Operation – no method exists for operation exists in class, but is logical for class to have it. Any class with an abstract operation is ALWAYS and abstract class. Overriding – a method in a class replaces a method it inherited from a superclass.

Reasons to Override Restriction – to prevent a violation of a constraint present in subclass but not in the superclass. Extension – to add a new feature (capability) to an inherited method. Optimization – overriding method has same effect as inherited method, only does it more efficiently.

From Textbook

A few more Inheritance Terms Immutable Object – an object where no operation may change the variables of an instance. If an operation would change these variables, then it must create a totally new object with the new values. Variables are only set when object is first created.

Dynamic Binding Definition – program decides what method to run ‘on the fly’. Procedure for Dynamic Binding 1. Check for concrete method in current class. If found, use, otherwise, 2. Check immediate superclass for concrete method, if found run. Otherwise repeat 2 until concrete method found. If none found, return error.

What make a language Object Oriented Identity – programmer can refer to an object without referring to instance variables contained within. All objects are unique. Objects with same variables are still recognized as different objects. Classes – must be able to organize code into classes, which describe the structure and function of a set of objects.

WMaLOO (continued) Inheritance – classes must be able to be organized into inheritance hierarchies where class features inherit from superclasses to subclasses. Polymorphism – methods in related classes can have the same name and implement the same abstract operation. Must allow dynamic binding and overloading.

Other OO Concepts Abstraction Object -> something in the world Class -> objects Superclass -> subclasses Operation -> methods Attributes and associations -> instance variables Modularity Code can be constructed entirely of classes Encapsulation Details can be hidden in classes This gives rise to information hiding: Programmers do not need to know all the details of a class (from authors slide)

Risks in Programming language choice and O-O programming Language Evolution – programming languages change, and some of these changes will make programs developed with older versions either not function or have unforeseen results. Efficiency concerns – java being a language usually run using a virtual machine tends to make it less efficiently than C++. Lots of dynamic binding or object allocation also hurts efficiency.

The next few slides are from the authors slides. These discuss useful program style guidelines.

Programming Style Guidelines Remember that programs are for people to read Always choose the simpler alternative Reject clever code that is hard to understand Shorter code is not necessarily better Choose good names Make them highly descriptive Do not worry about using long names

Programming style … Comment extensively Comment whatever is non-obvious Do not comment the obvious Comments should be 25-50% of the code Organize class elements consistently Variables, constructors, public methods then private methods Be consistent regarding layout of code

Programming style … Avoid duplication of code Do not ‘clone’ if possible [cut and pasting] Create a new method and call it Cloning results in two copies that may both have bugs When one copy of the bug is fixed, the other may be forgotten

Programming style... Adhere to good object oriented principles E.g. the ‘isa rule’ Prefer private as opposed to public Do not mix user interface code with non-user interface code Interact with the user in separate classes This makes non-UI classes more reusable (end author slides)

For Next time Read Chapter 5, UML Class diagrams

Homework 1 Due Monday, June 9 th Chapter 1 – E1.1, E1.2, E1.3 Chapter 2 – E2.1, E2.8, E2.10 a, f, E2.17