“方法"与“消息"与“功能"与"???"

编程入门 行业动态 更新时间:2024-10-25 14:30:58
本文介绍了“方法"与“消息"与“功能"与"???"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我最近问了一个有关我所谓的方法调用"的问题.答案是消息".作为一个自学成才的业余程序员,我试图表达那些不会让我看起来像个白痴的问题,因此我意识到,我所使用的术语在很大程度上揭示了我如何学习编程.

方法/消息/等的各种术语之间是否有区别?在OO编程中?这是不同的编程语言使用不同的术语来描述相似概念的区别吗?

我似乎记得在OO之前的语言中,有时会根据是否期望返回值来区分子例程"和函数",但是即使那样,这仍是一种语言对语言的区分. ?

解决方案

我发现这是一种语言和编程范例.一种范例-OOP-指的是带有成员方法的对象,从概念上讲,它们是您如何向这些对象发送消息的方式(例如,该视图反映在UML中).

另一个范式-功能性-可能涉及对象类别,也可能不涉及对象类别,但是功能是工作的基本单元.

在结构化编程中,您具有子例程(请注意,前缀"sub"表示结构).

在命令式编程中(与结构化结构有很多重叠,但是看待事物的方式略有不同),您对世界的看法更加公式化,因此函数"表示某种操作(通常是数学上的). /p>

听起来像卢布一样,您要做的就是将语言参考所使用的​​术语用于您所使用的语言.

I recently asked a question about what I called "method calls". The answer referred to "messages". As a self-taught hobby programmer trying to phrase questions that don't make me look like an idiot, I'm realizing that the terminology that I use reveals a lot about how I learned to program.

Is there a distinction between the various terms for methods/messages/etc. in OO programming? Is this a difference that comes from different programming languages using different terminology to describe similar concepts?

I seem to remember that in pre-OO languages, a distinction would sometimes be made between "subroutines" and "functions" based on whether a return value was expected, but even then, was this a language-by-language distinction?

解决方案

I've found this to be a language and programming-paradigm thing. One paradigm — OOP — refers to objects with member methods, which conceptually are how you send messages to those objects (this view is reflected in UML, for example).

Another paradigm — functional — may or may not involve classes of objects, but functions are the atomic unit of work.

In structured programming, you had sub-routines (notice that the prefix "sub" implies structure).

In imperative programming (which overlaps with structured quite a lot, but a slightly different way of looking at things), you have a more formulaic view of the world, and so 'functions' represent some operation (often mathematical).

All you have to do to not sound like a rube is to use the terminology used by the language reference for the language you're using.

更多推荐

“方法"与“消息"与“功能"与"???"

本文发布于:2023-11-05 06:14:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1560118.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:消息   功能   方法   quot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!