Содержание
- 2. Object-Oriented Programming and Java Instructor: M.Sc. Erkki Mattila, lecturer Office: C136 Office hours: according to the
- 3. Object-Oriented Programming and Java COURSE CODE 504D24A DURATION 3 CU (+5 CU = 8 CU) TEACHING
- 4. Object-Oriented Programming and Java OBJECTIVES The main objective of the first part of the course is
- 5. Object-Oriented Programming and Java COURSE MATERIAL Lecture notes, available at O:\Opettajat\Erkki Mattila\Object-oriented Programming and Java 504D24A
- 6. Object-Oriented Programming and Java ASSESMENT Mid-term exam, which will be graded on a scale from 1
- 7. Student level assesment Which programming courses have you participated earlier? How familiar are you with the
- 8. Course Contents Part I: Concepts and Principles of Object-Oriented Programming Part II: Object-oriented Programming Closer look
- 9. Part I Contents Abstraction The concept of abstraction, data and process abstraction, abstract data types Concepts
- 10. 1. Abstraction
- 11. Object-oriented Programming Paradigm OOP is a common programming paradigm. A programming paradigm is a way to
- 12. C Data Types Revisited Which built-in, primitive data types the C programming language has? What are
- 13. Definition: Abstract Data Type An abstract data type is a data type that satisfies the following
- 14. Abstract Data Types (ADT) ADTs are defined by the user (user-defined type) ADTs should provide the
- 15. Scope A class consists of data fields (attributes) and operations, which manipulate the data The data
- 16. Group Work Define a new abstract data type Name of the type Attributes (Data fields) Operations
- 17. Relation of Abstract Data Types to Object-oriented Programming Object-oriented programming (OOP) is an outgrowth of the
- 18. 2. Concepts of Object-oriented Programming
- 19. Class Classes are reusable software components that model items in the real world A class encapsulates
- 20. Object An object is an instance of a class Objects are created during program execution –
- 21. Classes and Objects OOP, Rovaniemi University of Applied Sciences An object is an instance of a
- 22. Attributes People have features including date of birth, name, height and eye colour Physical objects have
- 23. Methods A class encapsulates data and the algorithms that process that data. These algorithms are called
- 24. Messages (Method Calls) Messages are the means by which objects interact. A message stimulates some behaviour
- 25. Constructor A specialized method used to instantiate an object The constructor function has the same name
- 26. A Class Definition in Java Language public class Shape { private static int a_numberOfShapes=0; private Color
- 27. A Class Definition in Java Language public class Circle extends Shape // Class header { private
- 28. Group Work Your task is to design an ATM (Automatic Bank Teller Machine) system Which classes
- 29. OOP - Rovaniemi University of Applied Sciences Class Relationships Generalization (Inheritance) Aggregation Special case: composition Association
- 30. OOP - Rovaniemi University of Applied Sciences Inheritance (“is a”) Relationship Classes may be arranged in
- 31. OOP - Rovaniemi University of Applied Sciences Generalization (Inheritance)
- 32. Group work Define a rectangle and a square as classes. Can they be modelled with a
- 33. OOP - Rovaniemi University of Applied Sciences Aggregation (“part of“) Relationship Shows how classes that are
- 34. OOP - Rovaniemi University of Applied Sciences Composition (“has a “) Relationship Composition is a special
- 35. OOP - Rovaniemi University of Applied Sciences Composition vs. Aggregation Composition is a stricter relationship than
- 36. OOP - Rovaniemi University of Applied Sciences Association (“uses”) Relationship One entity uses another entity as
- 37. OOP - Rovaniemi University of Applied Sciences Attributes and Associations Attributes and associations are exchangeable! When
- 38. Group Work Draw an UML class diagram containing the following classes: Car, Bicycle, Motorcycle, Steamship, Sailboat,
- 39. 3. Principles of Object-oriented Programming
- 40. Encapsulation A class encapsulates together data (attributes), methods, constants, and other related information Encapsulation means that
- 41. Encapsulation: Example OOP, Rovaniemi University of Applied Sciences G. Booch, “Object-oriented analysis and design with applications”
- 42. Benefits of Encapsulation Data structures and the methods that manipulate them are merged in a single
- 43. Data Abstraction and Information Hiding DA isolates how a compound data object is used from the
- 44. Data Abstraction and Information Hiding Classes normally hide the details of their implementation from their clients.
- 45. Data Abstraction and Information Hiding From the definition of an abstract data type: The declarations of
- 46. Information Hiding A type's internal form is hidden behind a set of access functions Values of
- 47. Benefits of Information Hiding The internal implementation details of data and procedures are hidden from the
- 48. Inheritance Inheritance is a mechanism that enables the responsibilities of one object to be propagated to
- 49. Class Hierarchy OOP, Rovaniemi University of Applied Sciences
- 50. Class Hierarchy Direct superclass Inherited explicitly (one level up hierarchy) Indirect superclass Inherited two or more
- 51. Benefits of Inheritance Inheritance occurs throughout all levels of a class hierarchy. Changes at the higher
- 52. OOP, Rovaniemi University ofApplied Sciences Group Work Consider the following classes: Building (properties: address, in use,
- 53. Additional Material: Forms of Inheritance Specialization The child class is a special case of the parent
- 54. Additional Material: Forms of Inheritance Construction The child class makes use of the behaviour provided by
- 55. Additional Material: Forms of Inheritance Extension The child class adds new functionality, but does not change
- 56. Additional Material: Forms of Inheritance Combination The child class inherits features from more than one direct
- 57. Benefits of OOP Characteristics of OOP software: Natural Instead of programming in terms of an array
- 58. Benefits of OOP Reusable OOP introduces inheritance to allow you to extend existing classes and polymorphism
- 60. Скачать презентацию