Tài liệu Bài giảng Chapter 1: Introduction to Object-Oriented Programming and Software Development: Chapter 1Introduction to Object-Oriented Programming andSoftware Development©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display.Chapter 1 ObjectivesAfter you have read and studied this chapter, you should be able toName the basic components of object-oriented programming.Differentiate classes and objects.Differentiate class and instance methods.Differentiate class and instance data values.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Chapter 1 Objectives, cont.After you have read and studied this chapter, you should be able toDraw program diagrams using icons for classes, objects, and other components of object-oriented programming.Describe the significance of inheritance in object-oriented programs.Name and explain the stages of the software life cycle.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.1.1 Classes and ObjectsObject-oriented programs use objects.An object is a thing, both tan...
32 trang |
Chia sẻ: honghanh66 | Lượt xem: 812 | Lượt tải: 0
Bạn đang xem trước 20 trang mẫu tài liệu Bài giảng Chapter 1: Introduction to Object-Oriented Programming and Software Development, để tải tài liệu gốc về máy bạn click vào nút DOWNLOAD ở trên
Chapter 1Introduction to Object-Oriented Programming andSoftware Development©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display.Chapter 1 ObjectivesAfter you have read and studied this chapter, you should be able toName the basic components of object-oriented programming.Differentiate classes and objects.Differentiate class and instance methods.Differentiate class and instance data values.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Chapter 1 Objectives, cont.After you have read and studied this chapter, you should be able toDraw program diagrams using icons for classes, objects, and other components of object-oriented programming.Describe the significance of inheritance in object-oriented programs.Name and explain the stages of the software life cycle.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.1.1 Classes and ObjectsObject-oriented programs use objects.An object is a thing, both tangible and intangible. Account, Vehicle, Employee, etc. are examples of possible objects.An object is comprised of data and operations that manipulate those data. ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.1.1 Classes and Objects To create an object inside the computer program, we must provide a definition for objects—how they behave and what kinds of information they maintain—called a class.An object is called an instance of a class.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Fig. 1.1A graphical representation of an object.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Fig. 1.2UML notation for objects and classes:Two Bicycle objects with the names Moto-1 and Moto-2 and one Customer object with the name Jon Java.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Fig. 1.3A graphical representation of a class.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.1.2 Messages and MethodsTo instruct a class or an object to perform a task, we send a message to it.You can send a message only to the classes and objects that understand the message you sent to them.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.1.2 Messages and MethodsA class or an object must possess a matching method to be able to handle the received message.A method defined for a class is called a class method, and a method defined for an object is called an instance method.A value we pass to an object when sending a message is called an argument of the message.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Fig. 1.4One-way communication: Sending the message walk to a Robot object.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Fig. 1.5Two-way communication: The result distance is returned to the sender of the message.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Fig. 1.6An example of a class method: The maximum possible speed of all Robot objects is returned by the class method getMaximumSpeed.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.1.3 Class and Instance Data ValuesAn object is comprised of data values and methods.An instance data value is used to maintain information specific to individual instances. For example, each Account object maintains its balance.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.1.3 Class and Instance Data ValuesA class data value is used to maintain information shared by all instances or aggregate information about the instances.For example, minimum balance is the information shared by all Account objects, whereas the average balance of all Account objects is aggregate information.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Fig. 1.7An example of an instance data value:Three Account objects possess the same data value current balance, but the actual dollar amounts differ.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Fig. 1.8Three Account objects sharing information (minimum balance = $100) stored as a class data value.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Fig. 1.9Three Cafeteria objects sharing the same opening and closing times, stored as class data values.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Fig. 1.10An example of inefficient program design: Three Account objects duplicating information (minimum balance = $100) in instance data values.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Fig. 1.11Four types of data values: class variable, class constant, instance variable, and instance constant.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.1.4 InheritanceIn object-oriented programming, we use a mechanism called inheritance to design two or more entities that are different but share many common features. ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.1.4 InheritanceFirst, we define a class that contains the common features of the entities. Then we define classes as an extension of the common class inheriting everything from the common class. ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.1.4 InheritanceWe call the common class the superclass and all classes that inherit from it subclasses. We also call the superclass an ancestor and the subclass a descendant.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Fig. 1.12A superclass Account and its subclasses Savings and Checking.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.Fig. 1.13An example of inheritance hierarchy among different types of students.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.1.5 Software EngineeringSoftware engineering is the application of a systematic and disciplined approach to the development, testing, and maintenance of a program. ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.1.5 Software Life CycleThe sequence of stages from conception to operation of a program is called software life cycle. Five stages areAnalysisDesignCodingTestingOperation and Maintenance©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.1.5 Software Life CycleAnalysis phase:Study the problem.Determine if a solution is possible.Develop a requirements specification describing the features of the program.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.1.5 Software Life CycleDesign phase:Turn the requirements specification into a detailed program design.Fully define all classes and objects, including how they behave and communicate between themselves.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.1.5 Software Life CycleCoding phase:Implement the detailed design into an actual program.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.1.5 Software Life CycleTesting phase:Run the program using different data sets to verify the program works properly.Unit testing: Test classes individually.Integration testing: Test that the classes work together correctly.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.1.5 Software Life CycleOperation phase:Program is put into use.Software maintenance accounts for approximately 70% of the cost of the software.©The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Các file đính kèm theo tài liệu này:
- chap_1_0651.ppt