Domanda

I know that dynamic programming refers to an approach where we tend to break down a complex problem into smaller parts. In other words, it's a divide-and-conquer paradigm. Object-oriented programming also uses the concept of classes and modules, and therefore follows the separation of concerns (SoC) principle. Can we therefore say that OO is an example of dynamic programming?

Note: Dynamic here doesn't mean dynamic typing or dynamic scripting language. It refers to the general approach.

È stato utile?

Soluzione

Dynamic programming is an algorithm designing approach.

Object Oriented programming is more like a code organising methodology.

Comparing them is like comparing kilometre with kilogram.

(And Linear programming is also a totally different thing. It is for optimizing complex linear equations. It is more mathematics than programming. And Integer programming is a special case of it.)

Altri suggerimenti

As far as I can infer from the first few paragraphs of the Wikipedia article, dynamic programming is about identifying subproblems that were already solved to reduce the run time, which of course requires splitting a problem into smaller ones, but the point is that this "happens at runtime": you're not looking for problems that can be solved by the same approach, you're looking for equivalent problems that have the same solution.

OOP, or other programming paradigms are about recognizing problems that can be solved in the same manner, with the same algorithms. Dynamic programming is not a paradigm, it does not tell you how to structure your program. It tells you how an algorithm can be specified so that it can take advantage of solutions of subproblems.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top