java自下而上和自上而下_编程中自上而下和自下而上方法的区别

java自下而上和自上而下_编程中自上而下和自下而上方法的区别_第1张图片

java自下而上和自上而下

Here you will learn about difference between top-down and bottom-up approach.

在这里,您将了解自顶向下和自底向上方法之间的区别。

Today we are going to have a comparative study of the two approaches being used in field of structured and object oriented programming. We shall start with a brief understanding of the both followed by comparison and conclusion.

今天,我们将对结构化和面向对象编程领域中使用的两种方法进行比较研究。 我们将从对两者的简要了解开始,然后进行比较和结论。

java自下而上和自上而下_编程中自上而下和自下而上方法的区别_第2张图片

Image Source

图片来源

When talking in terms of computer science and programming, the algorithms we use to solve complex problems in a systematic and controlled way are designed on the basis of two approaches that is Top-down and Bottom-up approach. The ideology behind top-down approach is, a bigger problem is divided into some smaller sub-problems called modules, these modules are then solved individually and then integrated together to get the complete solution to the problem. In bottom-up approach on the other hand, the process starts with elementary modules and then combining together to get the desired result. Let us now quickly see in brief what these two approaches has to offer, how they differ from each other and what are the similarities.

在谈论计算机科学和程序设计时,我们基于自上而下和自下而上两种方法设计了用于系统地,受控地解决复杂问题的算法。 自顶向下方法背后的思想是,将一个较大的问题分为一些称为模块的较小子问题然后分别解决这些模块,然后将其集成在一起,以解决该问题。 另一方面,在自下而上的方法中,该过程从基本模块开始,然后组合在一起以获得所需的结果。 现在让我们快速简要地看一下这两种方法必须提供的内容,它们之间的区别和相似之处。

自上而下的方法 (Top-Down Approach)

The basic idea in top-down approach is to break a complex algorithm or a problem into smaller segments called modules, this process is also called as modularization. The modules are further decomposed until there is no space left for breaking the modules without hampering the originality. The uniqueness of the problem must be retained and preserved. The decomposition of the modules is restricted after achieving a certain level of modularity. The top-down way of solving a program is step-by-step process of breaking down the problem into chunks for organising and solving the sole problem. The C- programming language uses the top-down approach of solving a problem in which the flow of control is in the downward direction.

自顶向下方法的基本思想是将复杂的算法或问题分解为称为模块的较小段,此过程也称为模块化。 模块将进一步分解,直到没有剩余空间可以折断模块而又不影响其独创性。 问题的唯一性必须保留和保留。 在达到一定程度的模块化之后,将限制模块的分解。 自上而下解决程序的方法是将问题分解为大块的步骤,以组织和解决唯一的问题。 C编程语言使用自上而下的方法来解决控制流朝下的问题。

自下而上的方法 (Bottom-Up Approach)

As the name suggests, this method of solving a problem works exactly opposite of how the top-down approach works. In this approach we start working from the most basic level of problem solving and moving up in conjugation of several parts of the solution to achieve required results. The most fundamental units, modules and sub-modules are designed and solved individually, these units are then integrated together to get a more concrete base to problem solving.

顾名思义,这种解决问题的方法与自上而下的方法完全相反。 在这种方法中,我们从解决问题的最基本层面开始,然后逐步扩展解决方案的多个部分,以实现所需的结果。 最基本的单元,模块和子模块是单独设计和解决的,然后将这些单元集成在一起,可以为解决问题提供更具体的基础。

This bottom-up approach works in different phases or layers. Each module designed is tested at fundamental level that means unit testing is done before the integration of the individual modules to get solution. Unit testing is accomplished using low-level functions, that is another topic we will talk about later.

这种自下而上的方法可在不同的阶段或层中工作。 设计的每个模块都在基础级别上进行了测试,这意味着在集成各个模块以获取解决方案之前就已经进行了单元测试。 单元测试是使用低级功能完成的,这是我们稍后将讨论的另一个主题。

Let us now see a comparative study of both the strategies and try to understand what are common and odds among them.

现在让我们看一下这两种策略的比较研究,并尝试了解它们之间的共同点和不足之处。

自上而下与自下而上方法的区别 (Difference between Top-down and Bottom-up Approach)

Top-Down Approach Bottom-Up Approach
Divides a problem into smaller units and then solve it. Starts from solving small modules and adding them up together.
This approach contains redundant information. Redundancy can easily be eliminated.
A well-established communication is not required. Communication among steps is mandatory.
The individual modules are thoroughly analysed. Works on the concept of data-hiding and encapsulation.
Structured programming languages such as C uses top-down approach. OOP languages like C++ and Java, etc. uses bottom-up mechanism.
Relation among modules is not always required. The modules must be related for better communication and work flow.
Primarily used in code implementation, test case generation, debugging and module documentation. Finds use primarily in testing.
自上而下的方法 自下而上的方法
将问题分成较小的单元,然后再解决。 从解决小模块并将它们加在一起开始。
此方法包含冗余信息。 冗余可以轻松消除。
不需要良好的通信。 步骤之间的通信是强制性的。
各个模块都经过了彻底的分析。 研究数据隐藏和封装的概念。
C等结构化编程语言使用自上而下的方法。 诸如C ++和Java等OOP语言使用自下而上的机制。
模块之间的关系并不总是必需的。 模块必须相互关联,以实现更好的沟通和工作流程。
主要用于代码实现,测试用例生成,调试和模块文档。 主要用于测试中。

结论 (Conclusion)

After having a sound discussion on this we all should now have got a clear understanding of the two approaches. The top-down approach is the conventional approach in which decomposition of higher level system into lower level system takes place respectively. Talking about the bottom-up mechanism for algorithm designing, starting from designing lower abstraction modules and then integrating them to higher level provides better efficiency.

在对此进行了充分讨论之后,我们现在都应该对这两种方法有了清楚的了解。 自上而下的方法是常规方法,其中分别发生将较高级别的系统分解为较低级别的系统。 讨论算法设计的自下而上的机制,从设计较低的抽象模块开始,然后将它们集成到较高的级别提供了更高的效率。

We have seen the modules in top-down approach aren’t connected in a manner so that they can communicate well, so giving rise to redundancies, whereas in the later case the redundancies are omitted to large extent. The feature of information hiding and reusability provided by bottom-up approach makes this mechanism even more popular.

我们已经看到,自顶向下方法中的模块未以某种方式连接在一起,以便它们之间可以很好地通信,从而产生了冗余,而在后一种情况下,冗余被大量省略。 自下而上的方法提供的信息隐藏和可重用性功能使此机制更加流行。

Comment below if you have doubts regarding difference between Top-down and Bottom-up approach.

如果您对“自上而下”和“自下而上”方法之间的差异有疑问,请在下面评论。

翻译自: https://www.thecrazyprogrammer.com/2018/10/difference-between-top-down-and-bottom-up-approach.html

java自下而上和自上而下

你可能感兴趣的:(算法,java,python,人工智能,编程语言)