8

While I was reading The worst anti-patterns you have came across, I clicked on the link in this post to land on the web site about anti-patterns.

And the http://sourcemaking.com/antipatterns/functional-decomposition page got me wondering.

How bad this anti-pattern is, and is it an anti-pattern at all? Because, although I am doing mostly OOP programming nowadays, I still feel a reluctance against pure OOP-everything languages like Java, and also the design practices that they bring. And I guess, I still have some traits of the functional programming while I write the code.

And this brought up a question, am I doing wrong by sticking to OOP+Functional style, or is it common in industry and is not actually that bad.

What I do know from experience, is that OOP+Functional style is not completely compatible with pure OOP developers. But at the same time, while OOP developers have problems with OOP+Functional development, the counterargument is that OOP solutions are quite often over-engineered and too hard to use, and from my experience, were not even a single bit easier, and actually introduced some blind spots for VERY serious bugs to hide.

So, even though I had discussion with my colleague about these topics, I came to conclusion that none of the ways is actually perfect. And I still have the question unanswered.

The OOP problem was also reinforced by a link from another post in the same thread. The link looks at the Java style OOP http://chaosinmotion.com/blog/?p=622

So what is the general attitude toward mixing functional programming with OOP? And what is the balance a developer should strive to achieve?

4
  • 1
    Your title and question body are asking several related, but entirely different questions, some of which sound rhetorical. I'm having trouble figuring out what exactly you're asking here. Aug 25, 2011 at 23:08
  • Sorry, I'm not a native speaker, and I'm having a hard time thinking of a better title. Fixes are welcome.
    – Coder
    Aug 25, 2011 at 23:16
  • 1
    The question is clear. Don't listen to blueberryfields.
    – jojo
    Aug 25, 2011 at 23:22
  • 5
    Clearly, for the OOP zealots anything beyond the reach of OOP is an "antipattern". In fact, the worst possible antipattern is a heavy overuse of OOP itself.
    – SK-logic
    Aug 26, 2011 at 8:13

1 Answer 1

8

First of all, functional programming is currently what all the cool kids are doing. The Anti-Pattern was talking about procedural programming really (it would be clearer if the technique were called "procedural decomposition" but it's not), and I think you were too.

The anti-pattern talked about bad ways of writing procedural code in an object oriented language, the other page talked about bad was of writing Java - in truth there is no language so fantastic that you can do everything you want to do but can't write bad code.

In practice, I've seen a little more engineering in object oriented code than procedural -a little less under engineering and a little more over engineering.

In your case, it would depend on the specifics, and I'm not sure what you actually do in a procedural style. Is it correct, clear, testable, easy to modify, etc? The criteria to judge the code should be based on such practical concerns, and not on purity of one particular style. It sounds like in your case reasonable and knowledgeable people could disagree (and do!) about those concerns, and if so there is probably no objective way to determine the truth of the matter.

3
  • 2
    Your answer started off good, but then you got vague and non-committal. I read the article that the OP linked to functional decomposition, and it is a horrid antipattern, practiced by procedural developers trying to shoehorn their programming style into an object-oriented paradigm. So no, it doesn't depend on the specifics. Aug 25, 2011 at 23:38
  • but I don't think Coder believes that the anti-pattern is what he personally has done (nor do I have particular reason to doubt him). His question (one of them, really) was if procedural style programming can be O.K. in an object language (probably more like in the static Java function shown in the Java rant blog). And that depends on the specifics of what he coded. (I did preface with "In your case"). I think you are reading the question as basically "Should I program like in the anti-pattern?", which would clearly be bad - but Coder knows that, I think.
    – psr
    Aug 25, 2011 at 23:44
  • 4
    Even this way - procedural decomposition is a valid technique, and dismissing it as being not that much compatible with OOP is a pure fanaticism. Let all the flowers bloom. All the techniques are valid if used wisely. Sticking to one particular methodology is not wise at all.
    – SK-logic
    Aug 26, 2011 at 8:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.