你如何定义一个软件组件?

时间:2022-09-15 21:41:22

How do you define a software component and what kind of relationship is there between OOP and component programming? What are the pros and conns and what is the "golden ratio" of these paradigms?

如何定义软件组件以及OOP和组件编程之间存在何种关系?什么是优点和内容以及这些范例的“黄金比例”是什么?

4 个解决方案

#1


I think component programming is essentially the reinvention of oo.

我认为组件编程本质上是oo的重新发明。

oo aimed to be black box ... but isn't, component programming is trying to be black box.

oo旨在成为黑盒子......但不是,组件编程试图成为黑盒子。

as a result i think component programming implies over engineering (in a positive way) - because in order to be black box you have to anticipate future use cases and have already catered for them.

因此,我认为组件编程意味着过度工程(以积极的方式) - 因为为了成为黑盒子,你必须预见未来的用例并且已经为它们提供了帮助。

It also implies a psychology of documentation of thorough testing which in my experience at any rate seems to take a back seat in oo coding.

它还暗示了一种彻底测试文档的心理学,无论如何,根据我的经验,它似乎在oo编码中占据了一席之地。

So you would provide threading and async support. You would publish interfaces, documentation and unit tests. Have clear event structures and behaviours.

所以你会提供线程和异步支持。您将发布接口,文档和单元测试。有明确的事件结构和行为。

Essentially anything you can to allow someone to reuse it and help them do so.

基本上你可以允许某人重复使用它并帮助他们这样做。

The point is that a component has a well defined interface and a well defined function. The actual implementation details are not part of this because they are out of scope when considering how to use the component. Ie a component can be quite a complex set of objects.

关键是组件具有良好定义的接口和定义良好的功能。实际的实现细节不是其中的一部分,因为它们在考虑如何使用组件时超出了范围。即一个组件可以是一组非常复杂的对象。

#2


I think of a Component as being a rather higher level organising concept than an Object.

我认为Component是一个比Object更高级别的组织概念。

Components are often units of release and deployment. You would expect to define both the interfaces they expose and the depdencies they have on other components and infrastructure aspects. Different components in a system might well be developed using very different technologies, and indeed a single component need not be homogeneous.

组件通常是发布和部署的单元。您可能希望定义它们公开的接口以及它们对其他组件和基础结构方面的依赖性。系统中的不同组件可能使用非常不同的技术开发,实际上单个组件不需要是同构的。

If developing a component in some OO language you would then decompose responsibilities, and arrive an OO design for that component.

如果使用某种OO语言开发组件,则可以分解职责,并为该组件提供OO设计。

#3


The granularity of a software component should map to the granularity of reuse. If a lump of software is reused elsewhere then it should be versioned and released as it's own component. If it is not reused elsewhere then this adds little value.

软件组件的粒度应映射到重用的粒度。如果在其他地方重复使用了一块软件,那么它应该被版本化并作为它自己的组件发布。如果它没有在别处重复使用,那么这几乎没有增加价值。

It would be surprising if anything smaller than a complete class was considered a component and would anticipate a collection of classes would form a component.

如果任何小于完整类的东西被认为是一个组件并且预期一组类将构成一个组件,那将是令人惊讶的。

#4


I would think of a Component as a subsystem of an application that you can consider like a Black box.
So in OOD a group of classes and interfaces with a clear specification an ONE CLEAR purpose that allow you to perform some computation without having to know what the box is made of.

我会将Component视为应用程序的子系统,您可以将其视为黑盒子。因此,在OOD中,一组具有明确规范的类和接口具有ONE CLEAR目的,允许您执行一些计算而无需知道该框是由什么构成的。

Input -> [ BlackBox ] -> Output

输入 - > [BlackBox] - >输出

What furter identify a component is:

进一步确定组件的是:

  • High internal coesion
  • 内部高效率

  • No dependencies with respect to the rest of the application, so that a component can easily be imported in one or more project.
  • 没有与应用程序其余部分相关的依赖关系,因此可以在一个或多个项目中轻松导入组件。

Component programming I think is actually assembling components to build larger applications.
In a very "utopistic" view there should be public repositories where you can look for a component that fullfills your specification. Once you have found the component you can integrate it in your app.

组件编程我认为实际上是组装组件来构建更大的应用程序。在一个非常“乌托邦”的视图中,应该有公共存储库,您可以在其中查找满足您的规范的组件。找到组件后,您可以将其集成到您的应用中。

#1


I think component programming is essentially the reinvention of oo.

我认为组件编程本质上是oo的重新发明。

oo aimed to be black box ... but isn't, component programming is trying to be black box.

oo旨在成为黑盒子......但不是,组件编程试图成为黑盒子。

as a result i think component programming implies over engineering (in a positive way) - because in order to be black box you have to anticipate future use cases and have already catered for them.

因此,我认为组件编程意味着过度工程(以积极的方式) - 因为为了成为黑盒子,你必须预见未来的用例并且已经为它们提供了帮助。

It also implies a psychology of documentation of thorough testing which in my experience at any rate seems to take a back seat in oo coding.

它还暗示了一种彻底测试文档的心理学,无论如何,根据我的经验,它似乎在oo编码中占据了一席之地。

So you would provide threading and async support. You would publish interfaces, documentation and unit tests. Have clear event structures and behaviours.

所以你会提供线程和异步支持。您将发布接口,文档和单元测试。有明确的事件结构和行为。

Essentially anything you can to allow someone to reuse it and help them do so.

基本上你可以允许某人重复使用它并帮助他们这样做。

The point is that a component has a well defined interface and a well defined function. The actual implementation details are not part of this because they are out of scope when considering how to use the component. Ie a component can be quite a complex set of objects.

关键是组件具有良好定义的接口和定义良好的功能。实际的实现细节不是其中的一部分,因为它们在考虑如何使用组件时超出了范围。即一个组件可以是一组非常复杂的对象。

#2


I think of a Component as being a rather higher level organising concept than an Object.

我认为Component是一个比Object更高级别的组织概念。

Components are often units of release and deployment. You would expect to define both the interfaces they expose and the depdencies they have on other components and infrastructure aspects. Different components in a system might well be developed using very different technologies, and indeed a single component need not be homogeneous.

组件通常是发布和部署的单元。您可能希望定义它们公开的接口以及它们对其他组件和基础结构方面的依赖性。系统中的不同组件可能使用非常不同的技术开发,实际上单个组件不需要是同构的。

If developing a component in some OO language you would then decompose responsibilities, and arrive an OO design for that component.

如果使用某种OO语言开发组件,则可以分解职责,并为该组件提供OO设计。

#3


The granularity of a software component should map to the granularity of reuse. If a lump of software is reused elsewhere then it should be versioned and released as it's own component. If it is not reused elsewhere then this adds little value.

软件组件的粒度应映射到重用的粒度。如果在其他地方重复使用了一块软件,那么它应该被版本化并作为它自己的组件发布。如果它没有在别处重复使用,那么这几乎没有增加价值。

It would be surprising if anything smaller than a complete class was considered a component and would anticipate a collection of classes would form a component.

如果任何小于完整类的东西被认为是一个组件并且预期一组类将构成一个组件,那将是令人惊讶的。

#4


I would think of a Component as a subsystem of an application that you can consider like a Black box.
So in OOD a group of classes and interfaces with a clear specification an ONE CLEAR purpose that allow you to perform some computation without having to know what the box is made of.

我会将Component视为应用程序的子系统,您可以将其视为黑盒子。因此,在OOD中,一组具有明确规范的类和接口具有ONE CLEAR目的,允许您执行一些计算而无需知道该框是由什么构成的。

Input -> [ BlackBox ] -> Output

输入 - > [BlackBox] - >输出

What furter identify a component is:

进一步确定组件的是:

  • High internal coesion
  • 内部高效率

  • No dependencies with respect to the rest of the application, so that a component can easily be imported in one or more project.
  • 没有与应用程序其余部分相关的依赖关系,因此可以在一个或多个项目中轻松导入组件。

Component programming I think is actually assembling components to build larger applications.
In a very "utopistic" view there should be public repositories where you can look for a component that fullfills your specification. Once you have found the component you can integrate it in your app.

组件编程我认为实际上是组装组件来构建更大的应用程序。在一个非常“乌托邦”的视图中,应该有公共存储库,您可以在其中查找满足您的规范的组件。找到组件后,您可以将其集成到您的应用中。