包应该具有接口类还是边界类,有什么区别? [英] Should packages have an interface class or boundary class, and what is the difference?

查看:235
本文介绍了包应该具有接口类还是边界类,有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计一个只有4个软件包的小型系统,其中2个仅包含一个类(其中一个是GUI软件包).我不确定所有这些软件包是否都应具有一个接口类和一个实现类以使其他软件包能够访问它们,或者该软件包是否仅具有一个边界类.

我不确定边界和接口类之间的区别-它们都需要实现类吗?如果我使用接口类,应该是单例吗?

在此先非常感谢您提供任何建议:)

I am designing a small system with only 4 packages, 2 of which have only one class in (one of which is the GUI package). I am not sure whether all these packages should each have an interface class and an implementation class to enable other packages to access them, or should the package just have a boundary class.

I am not sure of the difference between a boundary and interface class - do they both need an implementation class? If I use an interface class, shoud it be a singleton?

Many thanks in advance for any advice :)

推荐答案

您正在尝试将马与马鞍进行比较.接口类比较技术性;它等效于.NET或COM接口;在C ++中,它作为没有数据的类实现,仅具有纯虚函数.尽管编译类型可以是接口类,但在运行时它们由运行时实现类表示.

边界类的作用是这样称呼的.它们可能是用户界面,系统界面或设备界面(例如).参见 http://en.wikipedia.org/wiki/Class_diagram#Boundaries [
我还要指出,您的问题有点缺乏主题.您最好将设计事项与您的项目相关联;因此,您需要分享最终的项目目标并参考自己的建议.与数学和纯计算机科学相比,代码设计艺术绝不是一门严格的数学学科;设计原则没有成功的理论价值;如果没有用,就考虑从其应用中抽象出来的设计原理,通常会导致虚假和无用的原理图.

—SA
You''re trying to compare horses to saddles. Interface class is more technical; it is equivalent to .NET or COM interfaces; in C++ it is implemented as a class without data with only pure-virtual functions. While compile-types can be interface classes, during run time they are represented by run-time implementation classes.

Boundary classes are called so by their role. They might be user interfaces, system interfaces or device interfaces (for example). See http://en.wikipedia.org/wiki/Class_diagram#Boundaries[^] for more information.

I would suggest you avoid questions "what is the difference", as correct single answer is impossible. Ask about each thing separately and their relationships.

I would also note that your question kind of lacks subject. You should better associate design matter with you project; so you need to share your ultimate project goals and refer to your own suggestions. In contrast to mathematics and pure computer science, the art of code design is no way a mathematically strict subject; design principles does not have their win theoretical value; considering design principles abstracted from their application if fruitless and often leads to artificial and useless schematic.

—SA


这篇关于包应该具有接口类还是边界类,有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆