<p>My question is simple; is it possible to over object-orient your code? </p>

<p>How much is too much? At what point are you giving up readability and maintainability for the sake of OO? </p>

<p>I am a huge OO person but sometimes I wonder if I am over-complicating my code.... </p>

<p>Thoughts?</p>

[{'answer_id': 54304, 'author': 'viggity', 'author_id': 4572, 'author_profile': 'https://Stackoverflow.com/users/4572', 'pm_score': 6, 'selected': True, 'text': '<blockquote>\n  <p>is it possible to over object-orient your code</p>\n</blockquote>\n\n<p>Yes</p>\n'}, {'answer_id': 54311, 'author': 'Peter Ritchie', 'author_id': 5620, 'author_profile': 'https://Stackoverflow.com/users/5620', 'pm_score': 2, 'selected': False, 'text': '<p>If you find that the time needed to fully implement OO in your project is needlessly causing missed deadlines, then yes.</p>\n\n<p>There has to be a trade off between releasing software and full OO fidelity.  How to decide depends on the person, the team, the project and the organization running the project.</p>\n'}, {'answer_id': 54312, 'author': 'Joel Martinez', 'author_id': 5416, 'author_profile': 'https://Stackoverflow.com/users/5416', 'pm_score': 2, 'selected': False, 'text': '<p>Yes, of course there is :-) object oriented techniques are a tool ... if you use the wrong tool for a given job, you will be over complicating things (think spoon when all you need is a knife).</p>\n\n<p>To me, I judge "how much" by the size and scope of the project.  If it is a small project, sometimes it does add too much complexity.  If the project is large, you will still be taking on this complexity, but it will pay for itself in ease of maintainability, extensibility, etc.</p>\n'}, {'answer_id': 54314, 'author': 'Danimal', 'author_id': 2757, 'author_profile': 'https://Stackoverflow.com/users/2757', 'pm_score': 1, 'selected': False, 'text': "<p>Yes, it's definitely possible -- common, either. I once worked with a guy who created a data structure to bind to a dropdown list -- so he could allow users to select a gender. True, that would be useful if the list of possible genders were to change, but they haven't as yet (we don't live in California)</p>\n"}, {'answer_id': 54315, 'author': 'Jason Baker', 'author_id': 2147, 'author_profile': 'https://Stackoverflow.com/users/2147', 'pm_score': 2, 'selected': False, 'text': '<p>My advice is not to overthink it.  That usually results in over or under doing SOMETHING (if not OO).  The rule of thumb that I usually use is this:  if it makes the problem easier to wrap my head around, I use an object.  If another paradigm makes it easier to wrap my head around than it would be if I used an object, I use that.</p>\n\n<p>That strategy has yet to fail me.</p>\n'}, {'answer_id': 54319, 'author': 'Dan', 'author_id': 230, 'author_profile': 'https://Stackoverflow.com/users/230', 'pm_score': 0, 'selected': False, 'text': '<p>I guess it is possible, but its hard to answer your in abstract terms (no pun intended). Give an example of over OO.</p>\n'}, {'answer_id': 54323, 'author': 'Anthony', 'author_id': 5599, 'author_profile': 'https://Stackoverflow.com/users/5599', 'pm_score': 0, 'selected': False, 'text': '<p>Yes. See the concept of the "<a href="http://en.wikipedia.org/wiki/Golden_hammer" rel="nofollow noreferrer">golden hammer</a> <a href="http://sourcemaking.com/antipatterns/golden-hammer" rel="nofollow noreferrer">antipattern</a>"</p>\n'}, {'answer_id': 54336, 'author': 'Timothy Carter', 'author_id': 4660, 'author_profile': 'https://Stackoverflow.com/users/4660', 'pm_score': 0, 'selected': False, 'text': "<p>I think there are times when OO design can be taken to an extreme and even in very large projects make the code less readable and maintainable. For instance, there can be use in a footware base class, and child classes of sneaker, dress shoe, etc. But I have read/reviewed people's code where it seemed as though they were going to the extreme of creating classes beneath that for NikeSneakers and ReebokSneakers. Certainly there are differences between the two, but to have readable, maintainable code, I believe its important, at times, to expand a class to adapt to differences rather than creating new child classes to handle the differences.</p>\n"}, {'answer_id': 54346, 'author': 'Mendelt', 'author_id': 3320, 'author_profile': 'https://Stackoverflow.com/users/3320', 'pm_score': 2, 'selected': False, 'text': "<p>If you think more objects is more object-oriented then yes.</p>\n\n<p>When doing object oriented design there are a couple of forces you have to balance. Most of OO design is about reducing and handling complexity. So if you get very complex solutions you're not doing too much OO but you're doing it wrong.</p>\n"}, {'answer_id': 54358, 'author': 'Stu Thompson', 'author_id': 2961, 'author_profile': 'https://Stackoverflow.com/users/2961', 'pm_score': 1, 'selected': False, 'text': '<p>Yes, just as one can over-normalize a database design.  </p>\n\n<p>This seems to be one of those purist vs. pragmatic debates that will never end.  &lt;:S</p>\n'}, {'answer_id': 54363, 'author': 'Kyle Cronin', 'author_id': 658, 'author_profile': 'https://Stackoverflow.com/users/658', 'pm_score': 1, 'selected': False, 'text': "<p>A lot of people try to design their code for maximum flexibility an reuse without considering how likely that will be. Instead, break your classes up based on the program you're writing. If you will have exactly one instance of a particular object, you might consider merging it into the containing object.</p>\n"}, {'answer_id': 54366, 'author': 'Thomas Kammeyer', 'author_id': 4410, 'author_profile': 'https://Stackoverflow.com/users/4410', 'pm_score': 0, 'selected': False, 'text': '<p>Yes, and it\'s easy.  Code is not better simply because it\'s object-oriented, any more than it\'s better simply because it\'s modular or functional or generic or generative or dataflow-based or aspect-oriented or anything else.</p>\n\n<p>Good code is good code because it\'s well-designed in its programming paradigm.</p>\n\n<p>Good design requires care.</p>\n\n<p>Being careful takes time.</p>\n\n<p>An example for your case:  I\'ve seen horrific pieces of Java in which, in the name\nof being "object oriented", every class implements some interface, even when no other class will <em>ever</em> implement that interface.  Sometimes it\'s a hack, but in others it really is gratuitous.</p>\n\n<p>In whatever paradigm or idiom you write code, going too far, partaking of too much of a good thing, can make the code more complicated than the problem.  Some people will say, when that point is reached, that the code isn\'t even really, for example, object-oriented anymore.</p>\n\n<p>Object-oriented code is supposed to be better organized for the purpose of being simpler, more straight-forward, or easier to understand and digest in reasonably independent portions.  Using the mechanisms of object oriented coding antithetically to this goal does <em>not</em> result in object oriented <em>design</em> .</p>\n'}, {'answer_id': 54385, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': "<p>I think the clear answer is yes, but depending on the domain you are referring to, it could be REALLY yes, or less so yes.   If you are building high level .Net or Java apps, then I think this is the latter, as OO is basically built into the language.   On the other hand if you are working on embedded apps, then the dangers and likelihood that your are over OO'ing are high.   There is nothing worse than seeing a really high level person come onto a embedded project and over complicate things that they think are ugly, but are the most simple and fast ways to do things.</p>\n"}, {'answer_id': 54390, 'author': 'Allain Lalonde', 'author_id': 2443, 'author_profile': 'https://Stackoverflow.com/users/2443', 'pm_score': 1, 'selected': False, 'text': '<p>I think your question should read, "Can you over Architecture your application?"</p>\n\n<p>And of course the answer is yet.  OO is just an approach to design.  If you spend your time building unnecessary complexity into a system because "Polymorphism Rocks!".  Then yes maybe you\'re over OOing.</p>\n\n<p>The very XP answer is that <strong>Regardless of what approach you favor (OO, procedural, etc.) the design should only be as complex as is demonstrably necessary</strong>.</p>\n'}, {'answer_id': 54398, 'author': 'Bill the Lizard', 'author_id': 1288, 'author_profile': 'https://Stackoverflow.com/users/1288', 'pm_score': 1, 'selected': False, 'text': "<p>Yes, you can.  As an example, if you find yourself creating Interfaces or abstract classes before you have two subtypes for them, then you're over-doing it.  I see this kind of thinking often when developers (over)design up front.  I use Test-Driven Development and Refactoring techniques to avoid this behavior.</p>\n"}, {'answer_id': 54400, 'author': 'blowmage', 'author_id': 5627, 'author_profile': 'https://Stackoverflow.com/users/5627', 'pm_score': 1, 'selected': False, 'text': '<blockquote>\n  <p>is it possible to over object-orient your code?</p>\n</blockquote>\n\n<p>No. But it is possible to over complicate your code. For example, you can use design patterns for the sake of using design patterns. But you cannot over object-orient your code. Your code is either object-oriented or it is not. Just as your code is either well designed or it is not.</p>\n'}, {'answer_id': 54498, 'author': 'Kilhoffer', 'author_id': 5469, 'author_profile': 'https://Stackoverflow.com/users/5469', 'pm_score': 0, 'selected': False, 'text': '<p>I think anything can be "overdone". This is true with nearly every best practice I can think of. I\'ve seen inheritance chains so complex, the code was virtually unmanageable.</p>\n'}]
['https://Stackoverflow.com/questions/54299', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4144/']