tailieunhanh - Interface-Oriented Design phần 3

hoặc thiệt hại mà có thể là kết quả của việc sử dụng thông tin (bao gồm cả danh sách chương trình) ở đây. Các khóa học thực dụng, hội thảo của chúng tôi, và các sản phẩm khác có thể giúp bạn và nhóm của bạn tạo ra phần mềm tốt hơn và có nhiều niềm vui hơn. Để biết thêm thông tin, cũng như | Chapter 3 Interface Ingredients Now that we ve covered the basics of interfaces it s time to examine the ingredients of interfaces. Almost every interface you employ or develop has a combination of these ingredients so understanding them helps you appreciate the whole pie. In this chapter we ll look at the spectrum of interfaces from data-oriented to service-oriented and cover the tradeoffs in three distinct approaches to data-access interfaces. You can always adapt an interface paradigm from one type to another to make it more amenable to your project so we ll explore how to adapt a stateful interface to a stateless one. Then we ll look at transforming a textual interface into a programmatic one and creating an interface from a set of existing related methods. Data Interfaces and Service Interfaces There is a spectrum between data interfaces and service interfaces. We use the term data interface when the methods correspond to those in a class that contains mostly attributes. The methods in the interface typically set or retrieve the values of the We use the term service interface for a module whose methods operate mostly on the parameters that are passed to it. One example of a data interface is the classic Customer class. Customer usually has methods like set_name String name 1Data interfaces also correspond to JavaBeans or pretty much any class that is a wrapper around attributes with a bunch of getter setters. Data Interfaces and Service Interfaces 33 Customer data interface name billing_address Address current balance Dollar OrderEntry service interface submit_an_order an_order Order cancel an order an order Order Figure Data vs. service interface set_billing_address Address billing_address get_current_balance . Each of these methods affects or uses an attribute in the class. Implementations of data interfaces have state which consists of the set of values of all attributes in the class. Service interfaces have .