13

Something that really bothers me about the oop idea of "oop allows better code reuse" is the fact that I have yet to encounter a situation where I need to reuse old code for a new project.

And the code I do want to reuse I've put into a library and made genetic anyway. Something which can easily be done with any language supporting generic programming, object oriented or otherwise.

Comments
  • 2
    it is not just to reuse in other projects, but rather within the same project as well (I could be wrong tho).

    Also you say you wrote what you want to be reusable in a generic way, basically OOP advocates for doing all the code that way and just write application specific "glue" code to make it work the way you want...
  • 1
    Can't agree enough. You can get reuse by just putting things in functions. This argument seems to be comparing oop to programing in assembly or punch cards. Not any other usable paradigm.
  • 0
    @dev-nope how is that any different than making functions/procedures that work on many different kinds of data?

    The only real difference is perspective imo.
    Instead of having data with behaviour, you instead have behaviour that acts on data.

    If anything I'd argue, having a generic set of functions/procedures is far more reusable and composable than a limited amount of code that you 'diversify' by making more specific through inheritance.
  • 0
    @ElectricCoffee it is not only the perspective. OO provides a more fine grained scopes to implementation: Properties & Method visibility being example of such. Also the benefit of inheritance and polymorphism are not something to underestimate.

    That being said, you can definitely use structural/functional programming, but maintaining a large project will be hard, code will be a little more unreadable and will have a lot of repetition.

    When building a large project you will find yourself in situation where you need to nest a lot of functions to achieve a specific task if not for objects you will end with myFunctionThatDoesX_extended and what not. Also using contracts such as interfaces and allow swapping of implementations will be a pain in the back or ugly as hell (dependency injection). Also there are a lot of design patterns which help a lot to simplify a specific problems or ease maintainability.

    *I am sure I've missed something, just don't know what, bit feel free to ask*
  • 1
    @dev-nope most of the points you bring up aren't specific to oop at all
    And most if not all repetition is nearly avoided using higher order functions and higher kinded types. Heck if you move into the field of dependent typing you get even greater expressive power to a point where you can do away with a macro system
  • 0
    @ElectricCoffee well yeah you're right, but comparing them at the minimal with OO you get that automatically whereas in the functional and structured you have to do it yourself, also not always you will work alone and people tend to fuck up form time to time..

    Take a look at this link for some interesting descriptions applications and benefits of OO compared to others, although in context of 2 languages (C, C++) it is very descriptive.

    http://programmers.stackexchange.com/...
Add Comment