Trang 1
goupee.vn TRƢỜNG ĐẠI HỌC BÁCH KHOA HÀ NỘI goupee.com KHOA ĐIỆN TỬ VIỄN THÔNG PHÂN TÍCH THIẾT KẾ HƢỚNG ĐỐI TƢỢNG CHƢƠNG 4. Thiết kế Bộ môn Điện tử tin học fb.com/goupee.vn04/2007 CuuDuongThanCong.com https://fb.com/tailieudientucntt
goupee.vn TRƢỜNG ĐẠI HỌC BÁCH KHOA HÀ NỘI goupee.com KHOA ĐIỆN TỬ VIỄN THÔNG PHÂN TÍCH THIẾT KẾ HƢỚNG ĐỐI TƢỢNG CHƢƠNG 4. Thiết kế Bộ môn Điện tử tin học fb.com/goupee.vn04/2007 CuuDuongThanCong.com https://fb.com/tailieudientucntt
goupee.vn goupee.com Chƣơng 4. Thiết kế 4.1. Chuẩn bị thiết kế 4.2. Thiết kế lớp và phƣơng thức 4.3. Thiết kế lớp quản lý dữ liệu 4.4. Thiết kế giao diện giao tiếp ngƣời-máy 4.5. Thiết kế kiến trúc vật lý fb.com/goupee.vn October 20 OOD - DEI.FET.HUT 2 CuuDuongThanCong.com https://fb.com/tailieudientucntt
goupee.vn goupee.com Key Concepts Low-level or detailed design is critical despite libraries and components Pre-existing classes need to be understood and organized Some, if not all code, is generally still needed to instantiate new classes fb.com/goupee.vn October 20 OOD - DEI.FET.HUT 3 CuuDuongThanCong.com https://fb.com/tailieudientucntt
goupee.vn goupee.com Levels of Abstraction fb.com/goupee.vn October 20 OOD - DEI.FET.HUT 4 CuuDuongThanCong.com https://fb.com/tailieudientucntt
goupee.vn goupee.com REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION fb.com/goupee.vn CuuDuongThanCong.com https://fb.com/tailieudientucntt
goupee.vn goupee.com Elements Classes Objects Attributes States Methods Messages fb.com/goupee.vn October 20 OOD - DEI.FET.HUT 6 CuuDuongThanCong.com https://fb.com/tailieudientucntt
goupee.vn goupee.com Encapsulation Combine attributes and methods into a single object fb.com/goupee.vn October 20 OOD - DEI.FET.HUT 7 CuuDuongThanCong.com https://fb.com/tailieudientucntt
goupee.vn goupee.com Information Hiding Only information needed to use the object is available outside the object This is the Public Interface Everything else is hidden Communication only through object’s methods Key to reusability fb.com/goupee.vn October 20 OOD - DEI.FET.HUT 8 CuuDuongThanCong.com https://fb.com/tailieudientucntt
goupee.vn goupee.com Polymorphism Same message triggers different methods in different objects Dynamic binding means specific method is selected at run time Implementation of dynamic binding is language specific Need to be very careful about run time errors Need to ensure semantic consistency fb.com/goupee.vn October 20 OOD - DEI.FET.HUT 9 CuuDuongThanCong.com https://fb.com/tailieudientucntt
goupee.vn goupee.com Inheritance Single inheritance -- one parent class Multiple inheritance -- multiple parent classes Redefinition and inheritance conflict Most inheritance conflicts are due to poor classification fb.com/goupee.vn October 20 OOD - DEI.FET.HUT 10 CuuDuongThanCong.com https://fb.com/tailieudientucntt
goupee.vn goupee.com Rumbaugh’s Rules Query operations should not be redefined Methods that redefine inherited ones should only restrict the semantics of the inherited ones The underlying semantics of the inherited method should never be changed The signature (argument list) of the inherited method should never be changed fb.com/goupee.vn October 20 OOD - DEI.FET.HUT 11 CuuDuongThanCong.com https://fb.com/tailieudientucntt
goupee.vn goupee.com Additional Inheritance Conflicts Two inherited attributes or methods have same name and semantics Two inherited attributes or methods have different name, but same semantics Two inherited attributes or methods have same name and different semantics fb.com/goupee.vn October 20 OOD - DEI.FET.HUT 12 CuuDuongThanCong.com https://fb.com/tailieudientucntt
Inheritance Conflicts with Multiple goupee.vn goupee.com Inheritance fb.com/goupee.vn October 20 OOD - DEI.FET.HUT 13 CuuDuongThanCong.com https://fb.com/tailieudientucntt
goupee.vn goupee.com Design Criteria fb.com/goupee.vn CuuDuongThanCong.com https://fb.com/tailieudientucntt
goupee.vn goupee.com Coupling Indicates the interdependence or interrelationships of the modules Interaction coupling Relationships with methods and objects through message passage fb.com/goupee.vn October 20 OOD - DEI.FET.HUT 15 CuuDuongThanCong.com https://fb.com/tailieudientucntt
Types of Interaction Couplinggoupee.vn goupee.com Level Type Description Good No Direct Methods don't call each other Coupling Data Calling method passes object, called method uses the entire object Stamp Calling method passes object, called method uses only part of the object Control Calling method passes a control variable whose value controls the execution of the called method Common or Methods refer to a "global data area" that is outside of the individual Global objects Bad Content or A method of one object refers to the hidden part of another object. Pathological fb.com/goupee.vn October 20 OOD - DEI.FET.HUT 16 CuuDuongThanCong.com https://fb.com/tailieudientucntt
goupee.vn goupee.com Cohesion “Single-mindedness of a module” Method cohesion A method should do just a single task Class cohesion A class should represent just one thing Generalization/specialization cohesion Addresses inheritance Should represent "a-kind-of" or "is-a" fb.com/goupee.vn October 20 OOD - DEI.FET.HUT 17 CuuDuongThanCong.com https://fb.com/tailieudientucntt
goupee.vn goupee.com Types of Method Cohesion Level Type Description Good Functional A method performs a single task Sequential Method performs two tasks, the output of the first is the input of the second Communicational Method combines two functions that use the same attributes (calc current and final GPA) Procedural Method supports many loosely related functions (calc current GPA, print, calc final GPA, print) Temporal or Classical Method supports multiple functions related in time (initialize all variable, print all reports) Logical Method supports many functions controlled by a passed control variable Bad Coincidental Method's purpose cannot be determined, or it supports multiple unrelated functions fb.com/goupee.vn October 20 OOD - DEI.FET.HUT 18 CuuDuongThanCong.com https://fb.com/tailieudientucntt
goupee.vn goupee.com Types of Class Cohesion Level Type Description Good Ideal Class has none of the mixed cohesions Mixed-Role Class has some attributes that relate to other classes on the same layer, but the attributes are unrelated to the semantics of the class Mixed- Class has some attributes that relate to classes on a different layer. Domain Worse Mixed- Class represents two different types of objects. Should be decomposed into two Instance classes. fb.com/goupee.vn October 20 OOD - DEI.FET.HUT 19 CuuDuongThanCong.com https://fb.com/tailieudientucntt
goupee.vn goupee.com Ideal Class Cohesion Contain multiple methods that are visible outside the class Have methods that refer to attributes or other methods defined with the class or its superclass Not have any control-flow coupling between its methods fb.com/goupee.vn October 20 OOD - DEI.FET.HUT 20 CuuDuongThanCong.com https://fb.com/tailieudientucntt
Hiển thị 20 trang đầu. Tải tài liệu để xem đầy đủ.
Chưa có bình luận nào. Hãy là người đầu tiên!
Bình luận (0)
Chưa có bình luận nào. Hãy là người đầu tiên!