当您说 C# 是面向组件的语言时,这是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1234283/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 14:01:16  来源:igfitidea点击:

What does it mean when you say C# is component oriented language?

c#

提问by AraK

I learned Java while ago. I just got bored of Java and returned to C++ after a while. I thought that C# was similar to Java. My assumption about the similarities between C# and Java was not correct after some reading about C#. I found many powerful concepts in C# that I love to see in Java. Anyway, much of what I read made sense to me except one thing. I keep hearing that C# is component oriented language! Wikipedia was really useless about this concept.

前阵子学过Java。我只是厌倦了 Java,过了一段时间又回到了 C++。我认为 C# 类似于 Java。在阅读了一些 C# 之后,我对 C# 和 Java 之间相似性的假设是不正确的。我在 C# 中发现了许多我喜欢在 Java 中看到的强大概念。无论如何,除了一件事之外,我读到的大部分内容对我来说都是有意义的。我一直听说 C# 是面向组件的语言!维基百科对这个概念真的没用。

What does it mean in simple terms when you say, C# is component oriented language?! A simple example would be appreciated.

当您说 C# 是面向组件的语言时,简单来说是什么意思?!一个简单的例子将不胜感激。

回答by Andrew Hare

I feel that the line between "component-oriented" and "object-oriented" is very blurry and in most cases it is safe to assume that they are the same thing.

我觉得“面向组件”和“面向对象”之间的界限非常模糊,在大多数情况下,可以安全地假设它们是同一回事。

That being said (and given the fact that I am unaware of your knowledge about object-oriented programming) I submit this excellent Wikipedia articlefor you to read:

话虽如此(考虑到我不了解您对面向对象编程的了解),我提交了这篇出色的维基百科文章供您阅读:

Object-oriented programming (OOP) is a programming paradigm that uses "objects" – data structures consisting of datafields and methods – and their interactions to design applications and computer programs. Programming techniques may include features such as information hiding, data abstraction, encapsulation, modularity, polymorphism, and inheritance. It was not commonly used in mainstream software application development until the early 1990s. Many modern programming languages now support OOP.

面向对象编程 (OOP) 是一种编程范式,它使用“对象”(由数据域和方法组成的数据结构)及其交互来设计应用程序和计算机程序。编程技术可能包括信息隐藏、数据抽象、封装、模块化、多态和继承等特性。直到 1990 年代初,它才在主流软件应用程序开发中普遍使用。许多现代编程语言现在都支持 OOP。

You may also want to read Component-based software engineeringwhich applies similar concepts across an entire system:

您可能还想阅读基于组件的软件工程,它在整个系统中应用了类似的概念:

Component-based software engineering (CBSE) (also known as component-based development (CBD)) is a branch of software engineering, the priority of which is the separation of concerns in respect of the wide-ranging functionality available throughout a given software system. This practice brings about an equally wide-ranging degree of benefits in both the short-term and the long-term for the software itself and the organisation that sponsors it.

Components are considered to be part of the starting platform for service orientation throughout software engineering, for example Web Services, and more recently, Service-Oriented Architecture (SOA) - whereby a component is converted into a service and subsequently inherits further characteristics beyond that of an ordinary component.

基于组件的软件工程 (CBSE)(也称为基于组件的开发 (CBD))是软件工程的一个分支,其优先级是对整个给定软件系统中可用的广泛功能的关注点分离. 这种做法为软件本身和赞助它的组织带来了同样广泛的短期和长期利益。

组件被认为是整个软件工程中面向服务的起始平台的一部分,例如 Web 服务,以及最近的面向服务的体系结构 (SOA)——其中一个组件被转换为服务,随后继承了超出一个普通的组件。

回答by Mike Dinescu

I'm sure that others here will be able to give a better explanation of what component oriented languages are (and if they won't, a thorough search on the internet should) but the way I see it the component oriented paradigm can be viewed as an embodiment of object oriented programming.

我相信这里的其他人将能够更好地解释什么是面向组件的语言(如果他们不这样做,应该在互联网上进行彻底的搜索)但是我看到它的方式可以查看面向组件的范式作为面向对象编程的一个体现。

That is to say that component oriented programming specializes Object Oriented Programming by strictly enforcing and implementing some OO concepts. Basically the whole idea is to create reusable code - in the form of components- that can be interchanged. So, component oriented programming heavily relies on: polymorphism, encapsulation, late binding, inheritance (through interfaces) and most importantly binary re-usability.

也就是说,面向组件的编程通过严格执行和实现一些 OO 概念来专门化面向对象编程。基本上整个想法是创建可重用的代码 - 以组件的形式- 可以互换。因此,面向组件的编程在很大程度上依赖于:多态性、封装、后期绑定、继承(通过接口)以及最重要的二进制重用性

A component is a software package that encapsulates data and functionality - much like an object in OOP - but at a higher level.

组件是封装数据和功能的软件包 - 很像 OOP 中的对象 - 但处于更高级别。

So, to say that C# is a component oriented language is basically to say that it is very well suited to be used to develop such software packages which we call components - but I feel that the fact that C# targets the .NET framework has a lot to do with the statement.

所以,说 C# 是一种面向组件的语言基本上是说它非常适合用于开发我们称之为组件的此类软件包 - 但我觉得 C# 面向 .NET 框架的事实有很多与声明有关。

In reflection we could probable say that Java can be considered a component oriented language as well - although I have to admit I don't have a broad knowledge of Java.

在反思中,我们可能会说 Java 也可以被视为面向组件的语言 - 尽管我不得不承认我对 Java 没有广泛的了解。

回答by Reed Copsey

I do not think of C# as a "Component oriented language". It is an object oriented language, which lends itself to being easily packaged into components.

我不认为 C# 是“面向组件的语言”。它是一种面向对象的语言,易于打包成组件。

I think it's more accurate to say that many of the development frameworks built upon .NET are component oriented frameworks. This makes C# development component oriented, ifyou're developing upon a component oriented framework. For example, ASP.NET and Windows Forms are heavily based upon a component conceptual model - everything is done via small components, worked together at design time.

我认为更准确地说,许多构建在 .NET 上的开发框架都是面向组件的框架。如果您在面向组件的框架上进行开发,这将使 C# 开发面向组件。例如,ASP.NET 和 Windows 窗体在很大程度上基于组件概念模型 - 一切都是通过小组件完成的,在设计时协同工作。

However, you can easily develop in C# using little or no component orientation. The language itself doesn't provide this - other than enabling this style of development if you chose to use it.

但是,您可以使用很少或不使用组件方向在 C# 中轻松进行开发。该语言本身不提供此功能 - 如果您选择使用它,则只能启用这种开发风格。

回答by Bastien Léonard

I may be wrong, but here is how I see it: it means that the various parts of a system are separated from each other and can easily be replaced.

我可能错了,但我的看法是这样的:这意味着系统的各个部分彼此分离,并且可以轻松更换。

In dynamic languages it's relatively easy because of their flexibility, but in languages such as C# and Java you need to use special techniques such as dependency injection.

在动态语言中,由于其灵活性,这相对容易,但在 C# 和 Java 等语言中,您需要使用特殊技术,例如依赖注入

回答by Kashish Khanna

MAYBE I AM WRONG BUT I THINK:

也许我错了,但我认为:

I have read the same statement in e balagurusamy first chapter but there are no description about it but there is a line. C# is first component oriented language and in another line it describes C# is the only component oriented language today according to me I think the languages C and C++ are com based languages. It means they are completely depend on our operating system and every program register itself in registry of our operating system

我在 e balagurusamy 第一章中读过同样的陈述,但没有关于它的描述,但有一行。C# 是第一个面向组件的语言,在另一行中,它描述了 C# 是当今唯一的面向组件的语言,据我所知,我认为 C 和 C++ 语言是基于 com 的语言。这意味着它们完全依赖于我们的操作系统,并且每个程序都会在我们的操作系统注册表中注册自己

In Java we don't have option to use C language (com based component) in our OOPs programming but if we talk about C# we can maybe that's why C# also called as a component oriented language

在 Java 中,我们没有选择在我们的 OOP 编程中使用 C 语言(基于 com 的组件)但是如果我们谈论 C# 我们可能这就是为什么 C# 也被称为面向组件的语言

How we use:

我们如何使用:

  1. Open visual studio.
  2. Create new project of any type.
  3. Open solution explorer.
  4. Right on your file name.
  5. Click on add reference.
  1. 打开视觉工作室。
  2. 创建任何类型的新项目。
  3. 打开解决方案资源管理器。
  4. 就在你的文件名上。
  5. 单击添加引用。

Here you can see com tab

在这里你可以看到com选项卡

These are the dll made in C language

这些是用C语言制作的dll

You can also add your C language dll by browse tab

您还可以通过浏览选项卡添加您的 C 语言 dll

回答by Rana_Maan

In just one line we can say it Component component-oriented programming means that C# has automatic ability of OOP, we cannot work in C# or Java without Object Oriented approch so such technique is built-in High level language. Thus this technique is called component-oriented.

一言以蔽之,面向组件的编程意味着C#具有OOP的自动能力,没有面向对象的方法我们无法在C#或Java中工作,因此这种技术是内置的高级语言。因此,这种技术称为面向组件。

回答by user1660007

C# is an object-oriented language, but C# further includes support for component-oriented programming. Contemporary software design increasingly relies on software components in the form of self-contained and self-describing packages of functionality. Key to such components is that they present a programming model with properties, methods, and events; they have attributes that provide declarative information about the component; and they incorporate their own documentation. C# provides language constructs to directly support these concepts, making C# a very natural language in which to create and use software components.

C# 是一种面向对象的语言,但 C# 进一步包括对面向组件的编程的支持。当代软件设计越来越依赖于自包含和自描述功能包形式的软件组件。这些组件的关键在于它们提供了一个具有属性、方法和事件的编程模型;它们具有提供有关组件的声明性信息的属性;他们合并了自己的文档。C# 提供了语言结构来直接支持这些概念,使 C# 成为一种非常自然的语言,可以在其中创建和使用软件组件。