编程范式、设计模式和应用程序架构之间的区别?
我没有编程背景,经常遇到编程范式、设计模式和应用程序架构等术语。虽然我认为我对这些术语的含义有一个模糊的理解,但如果有人能够澄清每个术语是什么、它们与其他术语有何不同以及这些概念如何应用于 Objective C,我将不胜感激。
I'm from a non-programming background and have often come across the terms like Programming Paradigm, Design Pattern and Application Architecture. Although I think I have a vague understanding of what these terms mean, I'd appreciate if someone could clarify what each is, how it is different from the other and how these concepts apply to Objective C.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
编程范式:类似“函数式编程”、“过程式编程"和"面向对象编程”。编程范式和使用它们的语言决定了代码的编写方式。例如,在面向对象编程中,代码被分为类(有时是语言功能,有时不是(例如 javascript)),并且通常支持继承和某种类型的多态性。程序员创建类,然后创建类的实例(即对象)来执行程序的操作。在函数式语言中,计算机上的状态变化很大程度上受语言本身的控制。函数是第一类对象,尽管并非所有函数是第一类对象的语言都是函数式编程语言(这个主题是一个很好的争论)。使用函数式语言编写的代码涉及大量嵌套函数,几乎程序的每一步都是新函数的调用。对于过程编程,C 程序和 bash 脚本是很好的例子,您只需说执行步骤 1、执行步骤 2 等, 无需创建类等。
设计模式:设计模式是一种有用的抽象,可以用任何语言实现。它是一种做事的“模式”。就像如果您想要实现一堆步骤一样,您可以使用“复合”和“命令”模式,以便使您的实现更加通用。将模式视为以通用方式解决常见编码任务的既定模板。
应用程序架构:考虑如何构建系统来执行任务。因此,对于 Web 应用程序,该架构可能涉及负载均衡器后面的 x 个网关,这些网关异步馈送队列。消息由运行在 z 台机器上的 y 个进程获取,有 1 个主数据库和一个备份从数据库。应用程序架构涉及选择所使用的平台、语言和框架。这与软件架构不同,软件架构更多地说明如何在给定软件堆栈的情况下实际实现程序。
Programming Paradigm: Something like "Functional Programming", "Procedural Programming", and "Object Oriented Programming". The programming paradigm and the languages that use them inform how the code gets written. For example, in Object Oriented programming the code is divided up into classes (sometimes a language feature, sometimes not (e.g. javascript)), and typically supports inheritance and some type of polymorphism. The programmer creates the classes, and then instances of the classes (i.e. the objects) to carry out the operation of the program. In functional languages, the state changes on the computer are very heavily controlled by the language itself. Functions are first class objects, although not all languages where functions are first class objects are functional programming language (this topic is one of good debate). Code written with a functional languages involves lots of nested functions, almost every step of the program is new function invocation. For procedural programming, C programs and bash scripting are good examples, you just say do step 1, do step 2, etc, without creating classes and whatnot.
Design Pattern: A design pattern is a useful abstraction that can be implemented in any language. It is a "pattern" for doing things. Like if you have a bunch of steps you want to implement, you might use the 'composite' and 'command' patterns so make your implementation more generic. Think of a pattern as an established template for solving a common coding task in a generic way.
Application Architecture: Takes into consideration how you build a system to do stuff. So, for a web application, the architecture might involve x number of gateways behind a load balancer, that asynchronously feed queues. Messages are picked up by y processes running on z machines, with 1 primary db and a backup slave. Application architecture involves choosing the platform, languages, frameworks used. This is different than software architecture, which speaks more to how to actually implement the program given the software stack.
一些快速定义,
应用程序架构描述了软件的整体架构。例如,基于 Web 的程序通常使用分层架构,其中功能分为多个层,例如用户界面(html 生成、处理用户命令)、业务逻辑(规则如何执行软件功能)和数据库(对于持久数据)。相反,数据处理应用程序可以使用所谓的管道和过滤器架构,其中一段数据通过管道,不同的模块对数据进行操作。
设计模式是一个低得多的级别工具,提供了关于如何组织代码以获得特定功能而不损害整体结构的经过验证的模型。简单的示例可能包括单例(如何保证代码的单个实例的存在)或外观(如何为更复杂的系统提供简单的外部视图)。
另一方面,范式是另一个极端,指导代码实际布局的原则,并且它们各自需要完全不同的思维方式来应用。例如,过程式编程主要关注将程序逻辑划分为函数并将这些函数捆绑为模块。面向对象编程的目的是将数据和操纵数据的操作封装成对象。函数式编程强调使用函数而不是一个接一个的单独语句,从而避免副作用和状态更改。
Objective-C 主要是 C 的面向对象扩展,设计模式和体系结构不是特定于语言的构造。
Some quick definitions,
Application Architecture describes the overall architecture of the software. For instance a web-based programs typically use a layered architecture where functionality is divided to several layers, such as user interface (html generation, handling commands from users), business logic (rules how the functions of the software are executed) and database (for persistent data). In contrast, a data processing application could use a so-called pipes and filters architecture, where a piece of data passes through a pipeline where different modules act on the data.
Design Patterns are a much lower level tool, providing proven models on how to organize code to gain specific functionality while not compromising the overall structure. Easy examples might include a Singleton (how to guarantee the existence of a single instance of a code) or a Facade (how to provide a simple external view to a more complex system).
On the other hand paradigms are the other extreme, guiding the principles on how code is actually laid out, and they each require quite different mindsets to apply. For instance, procedural programming is mainly concerned about dividing the program logic into functions and bundling those functions into modules. Object-oriented programming aims to encapsulate the data and the operations that manipulate the data into objects. Functional programming emphasizes the use of functions instead of separate statements following one another, avoiding side-effects and state changes.
Objective-C is mostly an object-oriented extension to C, design patterns and architecture are not language-specific constructs.
编程范式是计算机编程的基本风格。
软件设计模式 - 是常见软件设计问题的最佳实践解决方案。针对常见问题有许多设计模式。要了解有关设计模式的更多信息,您可以阅读此列表中的一些书籍 学习设计模式的 5 本最佳书籍
应用程序架构 - 应用程序架构是一门科学和艺术,它确保组织用来创建组合应用程序的应用程序套件是可扩展的、可靠的、可用且可管理。
我想这些术语中的任何一个都适用于所有编程语言。设计模式存在于所有编程语言中。
这些是定义为创建更高抽象级别的逻辑术语。
希望这有帮助
A programming paradigm is a fundamental style of computer programming.
Software Design Pattern - are best practice solutions to common software design problem. There are many design patterns for common problems. To learn more about design patterns you can read some books from this list 5 Best Books for Learning Design Patterns
Application Architecture - Applications Architecture is the science and art of ensuring the suite of applications being used by an organization to create the composite application is scalable, reliable, available and manageable.
I guess any of these terms would apply to all programming languages. Design patterns exists in all programming languages.
These are logical terms defined to create higher level of abstraction.
Hope this helps
想想这些术语的白话解释(即计算机科学领域之外的解释)。
Objective-C 主要将 OO 范式的元素添加到命令式语言 C 中。模式和体系结构在很大程度上与该语言正交。
Think of the vernacular interpretation of those terms (i.e., outside of the field computer science).
Objective-C primarily adds elements of the OO paradigm to the imperative language, C. Patterns and architecture are largely orthogonal to the language.
简单的英语单词
范式是编程时的一种思维方式,其中使用一流的概念来组织软件。 Ex oop 使用类作为一等公民,函数或 lambda 演算使用函数及其组合,方面使用系统的方面......等等。在考虑解决方案时,您首先想到的是头等公民。目标是将解决方案组织成软件组件。
设计模式是软件组件的常见成功使用。
应用程序架构是一组为了实现用例场景而组合在一起的设计模式。
Simple English words
A paradigm is a way of thinking when programming, where first class concepts are used to organize the software. Ex oop use classes as first class citizens, functional or lambda calculus use functions and their compositions, aspect uses aspects of a system .... And so on. When thinking a solution the first thing that comes to your mind are the first class citizens. The objective is to organize the solution into software components.
A design pattern is a common successful use of software components.
An application architecture is a set of design patterns put together in order to realize use case scdnarios.
范式:一种编程风格或方法。例如,在OOP中,我们使用对象、类的概念来整体编程。这些对象包含数据和行为与我们将它们逻辑地连接起来以完成任务。
设计模式:针对我们在日常编程中遇到的问题,经过尝试或测试的解决方案,而且是可重用的解决方案。例如,如果我们采用 OOP 范式,则不存在。帮助我们解决特定问题的模式。
Paradigm: a style or approach to programming. For example, In OOP, we use the concept of objects, classes to overall program. These objects contain data & behaviours & we connect them logically to complete the task.
Design Patterns: tried or tested solution, moreover reusable solutions, to the problem we encounter while everyday programming. For example, if we approach OOP paradigm, there are no. of patterns to help us solve specific problem.