如何选择要使用的编程范式?

发布于 2024-12-14 16:31:39 字数 135 浏览 2 评论 0原文

SO中有很多关于选择编程语言的问题。对我来说,我认为,如果我能够决定要使用哪种范式/模型,那么选择就会变得更容易。

但是,我的问题是,何时选择命令式、面向对象、函数式、逻辑和/或混合范式/模型?

哪种范例适合哪种类型的项目?

There are many questions in SO about choosing a programming language. To me, I think, the choice becomes easier if I can decide which paradigm/model I am going to work with.

But, my question is, When to choose Imperative, OO, Functional, Logic and/or mixed paradigm/model?

What paradigm is good for which type of projects?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

童话里做英雄 2024-12-21 16:31:43

问题

您可以在多种编程方法之间进行选择,但您不知道为特定项目选择哪一种。

解决方案

确定您的主要目标并选择最适合您目标的工具。

如果您不知道自己的目标,请从三个问题开始,这将帮助您集中精力和方向:

  1. 所讨论的主题是什么(问题领域);
  2. 谁可以帮助我学习(导师);
  3. 我可以找到哪些已有的项目和源代码——以及我如何最好地从中学习、理解和应用它们(示例);

讨论

这个问题可以稍微细化一下,因为您声明您想要一个项目的解决方案,但您没有指定该项目的目标。

例如:

  1. 你作为新手想学习如何成为一名程序员;
  2. 您想学习如何成为一名更好程序员,填补空白;
  3. 您是一位经验丰富的程序员,并且想要一些有趣的东西;
  4. 您是一名专业程序员,您需要适销对路的技能
  5. 您是一名杰出的程序员,您希望设计一种新语言,但不想重新发明轮子

基本原理

计算机编程中的术语有时非常具有误导性。例如,如果您向任何两个程序员询问 OO 与函数式的精确定义,您几乎肯定永远不会从他们那里得到相同的答案。

这本身就是编程和学习如何编程的重要一课。只见树木、见森林的能力,而不是过于迷恋方法或工具,以至于失去对潜在目标和动机(这些目标和动机会发生变化)的关注。

另请参见

有一篇文章更详细地介绍了 OOP 与函数式编程的行话。 (例如,参见 OOP 的无术语介绍)

简单解释 PHP OOP 与 Procedural?

PROBLEM

You have the choice between several programming methodologies, and you do not know which one to choose for a specific project.

SOLUTION

Determine your primary goals and pick whichever tool suits your goals most effectively.

If you do not know your goals, start with three questions that will help you focus your energies and direction:

  1. what is the subject matter at issue (problem-domain);
  2. who is available to help me learn (mentors);
  3. what pre-existing projects and source code can I find -- and how best can I learn, understand and apply from them (examples);

DISCUSSION

The question could be refined a bit, because you state that you want a solution for a project, but you do not specify the goals of the project.

For example:

  1. You want to learn how to be a programmer as a novice;
  2. You want to learn how to be a better programmer, filling in the gaps;
  3. You are an experienced programmer and you want something that will be fun;
  4. You are a professional programmer and you want marketable skills
  5. You are an exceptional programmer and you want to design a new language without re-inventing the wheel

RATIONALE

The jargon in computer programming is sometimes very misleading. For example, if you were to ask any two programmers for the precise definition of OO versus Functional, you will almost certainly never get the same answer from both.

This in itself is an important lesson in programming and learning how to program. The ability to see the forest for the trees and not get so enamored of methodologies or tools so much that one loses focus of the underlying goals and motivations (which change).

SEE ALSO

There is a write-up going into more detail about the Jargon of OOP versus Functional programming. (See e.g., Jargon-free introduction to OOP)

simple explanation PHP OOP vs Procedural?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文