计算机科学与技术外文翻译--详细解析java中抽象类和接口的区别(编辑修改稿)内容摘要:
now requires more filled with alarm function. How can we design according to the example of the class hierarchy? (in this case, it is mainly to show abstract class and with reflected in the design ideas, distinction, other aspect problem unrelated all did simplified or omitted)? Below will enumerate possible solutions, and from the design LiNianCeng face these different schemes for analysis. This method violated the objectoriented design of a core principles ISP (with flying Segregation), in the definition of filled the filled concept itself inherent behavior methods and another concept alarm behavior methods mix together. Such a problem is that those who cause depends only upon the concept of modules will be held because alarm this concept change (for example: modify the parameters) and alarm method, and vice still change. Since open and close and alarm belong to two different concepts, according to the ISP principle should consider them separately defined in representatives of these two concepts from the class abstraction. Definition means has: the two concepts are using abstract scaleup defined。 two concepts are used with defined。 a concept using abstract scaleup defined, another concept using with defined. Obviously, due to Java language does not support multiple inheritance, so two concepts are using abstract class defined is not feasible. The latter two ways are feasible, but for their choice actually reflected in problem in the field of concept nature39。 s understanding, whether for design intent reflect the correct and reasonable. We are a result analysis and description. If the two concepts are used with ways to define, then reflects two problems: 1, we may not understand clearly problem domain, AlarmDoor in concept essentially exactly is held or alarm? 2, if we in problem field understanding no problems, for example: we through for problem domain analysis found that AlarmDoor in concept in essence and filled is consistent, then we realize when he failed to correct reveal our design intention, because in these two concepts on the definitions (both use with defined) reflect reflected these meanings. If we in problem field understanding is: AlarmDoor in concept is essentially, at the same time it is filled with alarm function. How should we e to the design, realization to clear reflect what we mean by this? Front has said, in Java language abstract scaleup said in an inheritance relationship, and inheriting relationship is in nature is a relationship. So for held this concept, we should use abstract scaleup way to define. In addition, AlarmDoor has alarm functions, that it will be able to acplish alarm concept definition of behavior, so alarm concept can be through with defined. This realization basically can clearly reflect our for problem domain, the correct understanding of our design intent reveals. Actually the abstract scaleup says is is a relationship with said, was like a relationship, everyone when the choice can be used as a basis, which, of course, is based on understanding the problem domain, for instance: if we think AlarmDoor in concept is essentially alarm, have again at the same time, then held the function of the above definition way will in turn. Summary 1. Abstract scaleup in Java language suggests is a kind of inheriting relationship, a class can be used only once inheritance relationship. Howeve。计算机科学与技术外文翻译--详细解析java中抽象类和接口的区别(编辑修改稿)
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。
用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。