CSE 425: Object-Oriented Programming I Object-Oriented Programming A design method as well as a programming paradigm –For example, CRC cards, noun-verb.

Slides:



Advertisements
Similar presentations
Lecture 10: Part 1: OO Issues CS 540 George Mason University.
Advertisements

Chapter 1 OO using C++. Abstract Data Types Before we begin we should know how to accomplish the goal of the program We should know all the input and.
CSE 332: C++ copy control I Copy Control (Part I) Copy control consists of 5 distinct operations –A copy constructor initializes an object by duplicating.
CSE 425: Semantic Analysis Semantic Analysis Allows rigorous specification of a program’s meaning –Lets (parts of) programming languages be proven correct.
CSE 425: Semantics II Implementing Scopes A symbol table is in essence a dictionary –I.e., every name appears in it, with the info known about it –Usually.
CSE 425: Logic Programming I Logic and Programs Most programs use Boolean expressions over data Logic statements can express program semantics –I.e., axiomatic.
ITEC200 – Week03 Inheritance and Class Hierarchies.
Object-Oriented PHP (1)
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Software Testing and Quality Assurance
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Rossella Lau Lecture 8, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 8: Polymorphism & C++ pointer  Inheritance.
16/22/2015 2:54 PM6/22/2015 2:54 PM6/22/2015 2:54 PMObject-Oriented Development Concept originated with simulating objects and their interactions. Adapted.
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
Abstract Data Types and Encapsulation Concepts
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
OOP Languages: Java vs C++
Comparison of OO Programming Languages © Jason Voegele, 2003.
Programming Languages and Paradigms Object-Oriented Programming.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
CSE 425: Object-Oriented Programming II Implementation of OO Languages Efficient use of instructions and program storage –E.g., a C++ object is stored.
CISC6795: Spring Object-Oriented Programming: Polymorphism.
CSM-Java Programming-I Spring,2005 Objects and Classes Overview Lesson - 1.
CSE 332: C++ templates This Week C++ Templates –Another form of polymorphism (interface based) –Let you plug different types into reusable code Assigned.
CSC3315 (Spring 2009)1 CSC 3315 Programming Languages Hamid Harroud School of Science and Engineering, Akhawayn University
1 Chapter 10: Data Abstraction and Object Orientation Aaron Bloomfield CS 415 Fall 2005.
CSE 425: Data Types II Survey of Common Types I Records –E.g., structs in C++ –If elements are named, a record is projected into its fields (e.g., via.
Programming Languages and Paradigms Object-Oriented Programming (Part II)
Programming Languages and Paradigms Object-Oriented Programming.
Inheritance in the Java programming language J. W. Rider.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13: Introduction to Classes.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
1 SystemVerilog Enhancement Requests Daniel Schostak Principal Engineer February 26 th 2010.
Java Objects and Classes. Overview n Creating objects that belong to the classes in the standard Java library n Creating your own classes.
CSE 425: Data Types I Data and Data Types Data may be more abstract than their representation –E.g., integer (unbounded) vs. 64-bit int (bounded) A language.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 7 Structured Data and Classes.
C++ Memory Overview 4 major memory segments Key differences from Java
Objects & Dynamic Dispatch CSE 413 Autumn Plan We’ve learned a great deal about functional and object-oriented programming Now,  Look at semantics.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
CSE 425: Control Abstraction I Functions vs. Procedures It is useful to differentiate functions vs. procedures –Procedures have side effects but usually.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 26 - Java Object-Based Programming Outline 26.1Introduction.
Chapter 12 Support for Object-Oriented Programming.
Object-Oriented Programming Chapter Chapter
(1) ICS 313: Programming Language Theory Chapter 12: Object Oriented Programming.
© 2007 Lawrenceville Press Slide 1 Chapter 8 Objects  A variable of a data type that is a class. Also called an instance of a class.  Stores data  Can.
Object Oriented Programming
CSci 162 Lecture 10 Martin van Bommel. Procedures vs Objects Procedural Programming –Centered on the procedures or actions that take place in a program.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
ISBN Object-Oriented Programming Chapter Chapter
Copyright © 2005 Elsevier Object-Oriented Programming Control or PROCESS abstraction is a very old idea (subroutines!), though few languages provide it.
CSE 425: Control Abstraction II Exception Handling Previous discussion focuses on normal control flow –Sometimes program reaches a point where it cannot.
1 CS Programming Languages Class 22 November 14, 2000.
Overview of C++ Polymorphism
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 13: Introduction to Classes.
C++ General Characteristics: - Mixed typing system - Constructors and destructors - Elaborate access controls to class entities.
ISBN Chapter 12 Support for Object-Oriented Programming.
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Names and Attributes Names are a key programming language feature
Abstract Data Types and Encapsulation Concepts
Behavioral Design Patterns
Types of Programming Languages
Introduction to Classes
Abstract Data Types and Encapsulation Concepts
Java Programming Language
More Object-Oriented Programming
Support for Object-Oriented Programming
Overview of C++ Polymorphism
Jim Fawcett CSE687 – Object Oriented Design Spring 2014
Presentation transcript:

CSE 425: Object-Oriented Programming I Object-Oriented Programming A design method as well as a programming paradigm –For example, CRC cards, noun-verb parsing of requirements Hinges on inheritance-based polymorphism –Classes define behaviors and structures of objects –Subclasses may refine or extend base classes –Extensions external to classes may be supported (e.g., C#) Distinct objects (class instances) interact –The sets of objects (and behaviors) may vary dynamically OO paradigm introduces several key ideas –Independent objects with separate state –Encapsulate all but the most necessary details (e.g., public/private/protected access in C++) –Abstraction, polymorphism, substitution, extensibility

CSE 425: Object-Oriented Programming I Design Trade-Offs in OO Languages Classes must declare all information compiler needs –E.g., sizes of by-value member variables, public interfaces –E.g., definitions of any methods the compiler should inline Inlining copies method’s code to each place it’s called –Saves performance overhead of a function call each time –But requires more space for duplicate copies of instructions How classes interact with the type system –Can exclude classes from type checking (not very safe) –Can use classes as type constructors (as in C++) –Can express entire type system as classes (as in Smalltalk) Controlled violations of encapsulation may be allowed –E.g., C++ friend declaration to support symmetric operators

CSE 425: Object-Oriented Programming I OO Language Example: Smalltalk A purely object-oriented language –Classes, constants, etc. are all objects Powerful but somewhat elaborate execution model –Send a message to a receiver, which dispatches a method –Useful for event handling, simulation, similar applications Methods read or modify objects’ state –I.e., accessor and mutator methods Method calls are performed using reference semantics –Passes an alias to an object rather than copying its value An object may refer to itself in a method Objects are constructed via the class object –Send the new message to the class type

CSE 425: Object-Oriented Programming I OO Language Example: Java An almost purely object-oriented language –E.g., integers are not objects, but can be wrapped with them Much more common execution model –Call a method directly –Preserves flexibility but with a more understandable style Methods again read or modify objects’ state –I.e., accessor and mutator methods Method calls again use reference semantics –Passes an alias to an object rather than copying its value –But, Java may bind a call statically if possible for efficiency Classes declare object constructor methods –Default constructors, constructor chaining are supported

CSE 425: Object-Oriented Programming I OO Language Example: C++ Classes declared, objects instantiated (similar to Java) –Except, can instantiate an object directly on the stack as in EvenIntegerPredicate eip; // default ctor –Also can instantiate heap object via new (returns ptr) as in TruePredicate * tpp = new TruePredicate; Object destructors managed differently for these cases –Return from a function calls local stack object destructors automatically –The program itself (or “smart pointer” it declares) must call delete directly ( delete tpp; or shared_ptr tppsp (tpp); ) –C++11 smart pointers implement reference counting and other object lifetime management semantics C++ allows object methods to be defined (in.cpp files) separately from their class declarations (in.h files) –Also can define within declaration, which inlines the method Class methods are passed implicit this parameter (arity is +1)

CSE 425: Object-Oriented Programming I Today’s Studio Exercises We’ll code up predicate classes for logic programming –Developing a class hierarchy with abstract/concrete methods –Please see slides for next studio (and/or read ahead in the text book for more about abstract vs. concrete classes) –E.g., C++ methods are polymorphic only if declared virtual Today’s exercises are all in C++ –Logic programs fit well within object-oriented features –As always, please ask us for help as needed When done, your answers with subject line “Object-Oriented Programming Studio I” to the course account