Design models in object-oriented programming signal systemic problems of the OO paradigm?

Possible duplicate:
Are design patterns truly language flaws?

After spending many years shedding books on OOP and OOP methods, and lately getting more involved in functional programming styles, it would be fair to extrapolate that design patterns are pointers to system problems with object-oriented programming like everyone else. Is there a fundamental flaw in object-oriented programming (not to be confused with design), because when processing state through encapsulation, more and more models solve problems with such a paradigm.

I did not draw any conclusions about this, but my sense of gut is that there can be something more serious with the OOP paradigm.

It is the very idea of ​​encapsulation, causing more problems than they solve.

+7
source share
5 answers

Very good question and what I thought about a while ago. This is my conclusion / opinion:

  • The idea of ​​object-oriented programming is not without flaws, but it provides the most complete constructive paradigm. If the problem area is correctly expressed, a clearly defined object that knows its responsibilities can interact quite elegantly, which is very close to the real interaction of the objects. (or ideas).

  • To make some of the more abstract specific concepts, OOP makes some affirmative statements. (Like encapsulation, not disclose more than you should and be responsible).

  • Like all general assumptions, there would be exceptions when what would normally be a good idea might not correspond to a specific problem. This also does not help the fact that OOP covers almost the entire conceived problem (unlike AOP or even more complex semantic modeling that satisfies a specific problem).

  • So, in situations where you need to make exceptions and move away from OOP claims, designers need a way to stay in good design so that they do not deviate too much from accepted design practices.

  • Thus, design patterns for me are just case studies of problems that will not be satisfied with some of the basic statements of OOP. In addition to working together and mapping solutions, the design pattern also helps to increase OOP. (especially for new designers).

Note. In most cases, design patterns are not needed. There should be a clear rationale for using templates. I know some greenhorns, trying to implement some kind of design pattern, just because they know them (and sometimes not so green);). Its square snap, round hole problem

+6
source

Good question, I started to wonder about it myself, a few weeks ago, while more and more in Python and Scala.

I think yes and no. There are definitely some internal problems with OOP and state encapsulation, but this does not mean that OOP itself is, in fact, a bad way to do something. I think the problem is that when all you have is a hammer, everything becomes a nail. OOP is great for some things, GUIs come to mind first, but functional programming also has very clear advantages.

It is worth noting that new functional programming languages, such as Scala, did not throw objects away.

I did not think about this problem in great detail, but I certainly agree that OOP has some problems that I did not consider, except in the form of design templates that really eliminate the symptoms, and not the diseases.

+1
source

Not. Although you see several different design patterns, you certainly still see design patterns in functional code. The main difference is small (if at all) due to the absence of a state. Rather, it is mainly associated with (most) functional languages, which provide a sufficiently large flexibility in creating functions that will be a "design pattern" in another language, simply become functionality in a functional language.

If you provide (approximately) a similar level of versatility in a language that has state, you can get the same effect. For example, most of the introduction to Modern C ++ Design defends the position that a design pattern can be encoded as a pattern (and most of the book is design patterns implemented as patterns).

+1
source

I think there will always be problems when you try to apply one programming paradigm to a problem. That's why I like C ++: it's a multi-paradigm; it does not force you to a single set of decisions.

0
source

I repeat my basic theory, but models are only those models. The OOP-defined model is a very effective way of structuring a program for many areas of applied programming. For some problem spaces, the model may become less efficient (or less efficient, or both).

There is a potential metaphor with physics. Over the years, Newtonian physics has done (and in fact, as before) wonderful work on modeling the laws of motion, time and space (with some help from Euclidean and complex geometry). But when science began to study the micro- and macro-aspects of the problem space, Newtonian physics (AND euclidian / Spherical geometry) began to collapse. Therefore, now we have the Relativity and Quantum Mechanism. They do a fantastic job of modeling the universe at the macro and micro levels, respectively, but are too complicated to use as descriptors of everyday events at the human level.

OOP is very effective for application programming in many cases when it is considered in the context of the complexity associated with modeling real problems and human interactions for consumption and processing by a linear machine. As noted above, there are no silver bullets. And my impression (never using C ++) is that languages ​​that try to be multi-paradigm also become more complex and not necessarily equally effective for small tasks that are easier to handle with a higher level, more oriented language. Like quantum mechanics and / or relativity (I mean, is anyone really interested in the relationship between mass and speed when traveling 60 miles per hour on the freeway? Or the likelihood that Los Angels will be where you are expect when this happens?).

In my experience, commitment to a particular model is important, as long as the model is suitable for the problem space. The moment it ceases to be true, the model may have to evolve, and this will be a resistance to this. There will be attempts to make the problem space of the model unsuitable (to revise the history of physics again or check the evolution of the heliocentric model of the solar system and include the keyword "epicycles").

All of the above is just MY best understanding of the state of things, and if I missed somewhere, I'm glad to hear some breaking news.

0
source

All Articles