TAILIEUCHUNG - Interface-Oriented Design phần 5

Nhưng hãy để tôi cung cấp cho bạn một từ lập trình. Đây là những ngôn ngữ lập trình Fortran, C, C + + và Java. Làm thế nào nhiều người trong số các ngôn ngữ này liên quan đến nhau? a), b) Ba, c.) Bốn, d) Không Nếu bạn và nhóm của bạn đồng ý trên một câu trả lời, sau đó bạn có thể chia sẻ một cách tiếp cận chung tới sự gắn kết. | An Interface Alternative for Inputstream 76 using inheritance Advantage base classes can provide common implementations Disadvantage difficult to adapt to new situations. An Interface Alternative for Inputstream What do football players mammals and geometric shapes have in common We ve used them as examples to show the differences between inheritance and interfaces. Let s look at a real-life class hierarchy and see how an alternative organization with interfaces would appear. This is a concrete example of the concepts discussed in the previous sections. Java s class is an abstract Inputstream contains many methods defined as abstract such as read . Other methods are concrete but contain this statement in the documentation This method should be overridden by subclasses. a few other methods only suggest that they should be overridden. For example a method that reads an array of bytes is provided. Its code simply calls the read method for each byte but the documentation suggests that a concrete implementation could code this better. many methods in the class have an implementation that does nothing . close .9 To contrast an inheritance approach with an interface approach in a real-code example we will transform the InputStream hierarchy into an interface-based design. This transformation follows the concepts of the Replace Inheritance with Delegation Inputstream Interface Suppose we have a Custominputstream we developed by inheriting from Inputstream such as in Figure on the following page. We start our transformation by extracting an interface from the current methods of the abstract Inputstream class 8See http html api java io . 9This discussion ignores the additional methods that Inputstream inherits from the Object. Inputstream does not override any of those methods. Any implementation of the Inputstream interface will also inherit from Object and thus have those same .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.