# What are the advantages of object oriented programming for a lone hobbyist coder?

**URL:** <https://boards.straightdope.com/t/what-are-the-advantages-of-object-oriented-programming-for-a-lone-hobbyist-coder/811110>\
**Category:** Factual Questions\
**Created:** [March 24, 2018, 10:42am UTC](https://boards.straightdope.com/t/what-are-the-advantages-of-object-oriented-programming-for-a-lone-hobbyist-coder/811110 "2018-03-24T10:42:18Z")\
**Posts on this page:** 16\
**Page:** 2

<div class="post-metadata">

**Author:** ![dropzone](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dropzone/32/7515_2.png) [@dropzone](https://boards.straightdope.com/u/dropzone)\
**Post date:** [March 25, 2018, 4:52pm UTC](https://boards.straightdope.com/t/what-are-the-advantages-of-object-oriented-programming-for-a-lone-hobbyist-coder/811110/21 "2018-03-25T16:52:52Z")

</div>

> [@TwoCarrotSnowman](#):
>
> What are the advantages of object oriented programming for a lone hobbyist coder?

It teaches you a useful job skill.

> [@SmartAlecCat](#):
>
> OOP will result naturally from well organized code. Encapsulation will eventually result, but you’ll end up with better code if you think it through at the start.
> 
> Even in a non-OOP language without the syntactic constructs you will find yourself grouping together data and functions that operate on that data. You’ll end up with a thing\_create(), thing\_dosomething() thing\_dosomethingelse(), etc.
> 
> Native language OOP support just makes that sort of thing easier, and cleaner.
> 
> Eventually you’ll be writing another program and need that “thing” functionality. Being able to just pull it in as an “Object” at once is much easier than trying to separate the spaghetti strands from the other program.

I use structured programming with QuickBASIC and QBASIC. Fast, easy to learn, much more legible than C++, and QuickBASIC has libraries.

---

<div class="post-metadata">

**Author:** ![RaftPeople](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@RaftPeople](https://boards.straightdope.com/u/RaftPeople)\
**Post date:** [March 25, 2018, 5:26pm UTC](https://boards.straightdope.com/t/what-are-the-advantages-of-object-oriented-programming-for-a-lone-hobbyist-coder/811110/22 "2018-03-25T17:26:48Z")

</div>

> [@SamuelA](#):
>
> There is basically no overhead any more. By overhead I mean developer effort, not execution time.

It’s true that python makes many of these things very simple and easy from a code perspective, but it doesn’t solve the much more difficult problem of figuring out how to model the larger system to use OO or how to add value using OO for existing systems that are not already modeled with OO.

For the types of software I assume **aceplace57** is working on based on his description (business systems), there are a few issues that would complicate his adoption of OO:  
1 - His existing systems (typically large) are probably not modeled with OO currently but rather a typical mixed state of relational storage along with some object/entity organization where it fits nicely plus a collection of functional/action/verb oriented where that is more natural. Which means that any new dev can’t just make use of an existing OO model and code, so adding objects into that mix can be a challenge, and unless it all gets rewritten would only be for low level (inside the program) elements or things that are somewhat independent.

2 - The methodologies used in #1 are well known with existing solutions that work, whereas an OO approach has some challenges that have not really been solved yet. The initial naive thought was that we can just store objects and everything is great, but there are problems with ad-hoc queries, how to load only the information needed for specific action (as opposed to loading into memory every bit of linked info for that object, which can get extensive), and various other things.

Object DB’s never really amounted to much (other than for specific problem spaces) due to these problems and now we have ORM (object relational mapping) which is a partial not very good solution.

There are significant benefits to OO for some parts of business systems problems and there are significant benefits to relational storage (and a functional model) for some parts of business systems problems and we do not yet have a good marriage of the two.  
It’s not really very easy to identify how **aceplace57** could get much benefit from OO given that he is working with an existing system with an existing model.

---

<div class="post-metadata">

**Author:** ![Do\_Not\_Taunt](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/do_not_taunt/32/2968_2.png) [@Do\_Not\_Taunt](https://boards.straightdope.com/u/Do_Not_Taunt)\
**Post date:** [March 25, 2018, 6:08pm UTC](https://boards.straightdope.com/t/what-are-the-advantages-of-object-oriented-programming-for-a-lone-hobbyist-coder/811110/23 "2018-03-25T18:08:36Z")

</div>

I’ve written a bunch of scripts over the years that are in the \< 30 lines of code range. Unless there’s a compelling reason to (reuse), I rarely even write functions for these. It’s just a series of steps.

I’ve written a bunch of scripts over the years that are \> 30 lines but \< 200 or so lines. For these, I’ll organize code into functions, but not classes.

I’ve written and maintained systems in the (and I’m just guessing here) \> 50 kilolines where I wrote 90%+ of the code, and for that, I’ve organized it into classes. And of course, I’ve contributed to projects that are in the millions of lines, where we’d have been insane not to organize code into classes.

So those would be my rules of thumb. Functions help you organize code well - if the functions are well defined, you get a rigorous interface where you can reduce your chances of introducing bugs when you make a single isolated change. And you get reuse, so if you do make a change to fix a bug, it’s fixed for all users of that code instead of having to remember how many places you made a similar logic error and go fix them all. Classes do the same thing, but moreso (the reason being that in addition to isolating chunks of behavior, you are also isolating chunks of data, which gives you increased confidence that you can be aware of all the places that use that data when you need to make changes.)

Spend a short amount of time upfront reasoning about how big the project is going to be, and choose the right approach. Don’t worry too much if you get it wrong. It’s quick to refactor 50 lines into functions, or 300 lines into classes.

---

<div class="post-metadata">

**Author:** ![ftg](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ftg/32/2801_2.png) [@ftg](https://boards.straightdope.com/u/ftg)\
**Post date:** [March 25, 2018, 7:49pm UTC](https://boards.straightdope.com/t/what-are-the-advantages-of-object-oriented-programming-for-a-lone-hobbyist-coder/811110/24 "2018-03-25T19:49:54Z")

</div>

Some responses above give the impression (or directly state) that classes are organized around data.

That is true some of the time, but not always.

I’ve dealt with classes where the “data” within them are fairly trivial. It’s the _effects_ that the functions have that are the core of the class.

There’s a _lot_ more to programming than just “This function does this to some data”.

The key is to think abstractly. You figure out what the idea behind something is and you make it abstract. That helps tremendously to break things into reasonable pieces. E.g., classes, function, etc.

One of the brick walls I kept butting my head into over my years as a CS prof was trying to get students to think abstractly about a problem. All too many of them were taught from an early age that abstraction = useless.

---

<div class="post-metadata">

**Author:** ![dropzone](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dropzone/32/7515_2.png) [@dropzone](https://boards.straightdope.com/u/dropzone)\
**Post date:** [March 25, 2018, 7:59pm UTC](https://boards.straightdope.com/t/what-are-the-advantages-of-object-oriented-programming-for-a-lone-hobbyist-coder/811110/25 "2018-03-25T19:59:20Z")

</div>

> [@ftg](#):
>
> One of the brick walls I kept butting my head into over my years as a CS prof was trying to get students to think abstractly about a problem. All too many of them were taught from an early age that abstraction = useless.

So, how would you do that?

---

<div class="post-metadata">

**Author:** ![Do\_Not\_Taunt](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/do_not_taunt/32/2968_2.png) [@Do\_Not\_Taunt](https://boards.straightdope.com/u/Do_Not_Taunt)\
**Post date:** [March 25, 2018, 8:11pm UTC](https://boards.straightdope.com/t/what-are-the-advantages-of-object-oriented-programming-for-a-lone-hobbyist-coder/811110/26 "2018-03-25T20:11:38Z")

</div>

> [@ftg](#):
>
> Some responses above give the impression (or directly state) that classes are organized around data.
> 
> That is true some of the time, but not always.
> 
> I’ve dealt with classes where the “data” within them are fairly trivial. It’s the _effects_ that the functions have that are the core of the class.

Classes without data are basically just namespaces. Sure, that’s useful, but you’re missing out on a lot of the value if that’s all you’re using them for.

---

<div class="post-metadata">

**Author:** ![wolfpup](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/wolfpup/32/10618_2.png) [@wolfpup](https://boards.straightdope.com/u/wolfpup)\
**Post date:** [March 25, 2018, 8:30pm UTC](https://boards.straightdope.com/t/what-are-the-advantages-of-object-oriented-programming-for-a-lone-hobbyist-coder/811110/27 "2018-03-25T20:30:05Z")

</div>

> [@dropzone](#):
>
> So, how would you do that?

Abstraction is essentially the process of generalizing and classifying, the recognition that some functional module is just a particular instance of something more generic, which leads to a generalized way of thinking about the functional architecture of a complex system. One way to teach it is by example. One could examine the architecture of a moderately complex software system that had been designed that way, and show how it leads to clean modularity and facilitates understanding and debugging.

One could examine the structure of network protocols, which are classic examples of layers of abstraction with well-defined interfaces between them, so that each layer performs a specific function and only a specific function, and talks to layers above and below only through well-specified documented interfaces. One could show how each layer can have different implementations without having any effect on the layers above or below. But in order to build that kind of structure, network designers had to think long and hard in abstract terms about all the things that a network protocol must accomplish, from the lowest signaling layer to the highest levels of application functionality. Defining abstractions is really the very heart of the process of system design.

---

<div class="post-metadata">

**Author:** ![ftg](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ftg/32/2801_2.png) [@ftg](https://boards.straightdope.com/u/ftg)\
**Post date:** [March 25, 2018, 9:24pm UTC](https://boards.straightdope.com/t/what-are-the-advantages-of-object-oriented-programming-for-a-lone-hobbyist-coder/811110/28 "2018-03-25T21:24:13Z")

</div>

> [@Do\_Not\_Taunt](#):
>
> Classes without data are basically just namespaces. Sure, that’s useful, but you’re missing out on a lot of the value if that’s all you’re using them for.

I didn’t say no data, just a virtually trivial amount. The main purpose of such a class is to have _effects_ rather than maintain data.

---

<div class="post-metadata">

**Author:** ![Francis\_Vaughan](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/francis_vaughan/32/3093_2.png) [@Francis\_Vaughan](https://boards.straightdope.com/u/Francis_Vaughan)\
**Post date:** [March 26, 2018, 1:10am UTC](https://boards.straightdope.com/t/what-are-the-advantages-of-object-oriented-programming-for-a-lone-hobbyist-coder/811110/29 "2018-03-26T01:10:14Z")

</div>

Probably part of the problem is that the word “data” is overloaded. It means something different to a computer scientist than ordinary conversation. If I am being more precise I will talk of “state”. Objects encapsulate state. But to a CS person’s thinking there is often no semantic difference - which is confusing when talking generally. (Worse is when you start talking about “information” which has a very precise theoretical definition that is quite different to its use in ordinary conversation.)

I am reminded of my old undergraduate text - Algorithms + Data Structures = Programs. Long time ago.

Back when I taught undergraduate CS one course I taught was Algorithms & Data Structures to the second years. Really not much had changed, however the thing I tried really hard to do was - ironically - to divorce what was taught from the OO paradigm. This was a battle - there were other staff members who viewed the course as primarily a course in OO methodology, not one of algorithms. I once set a class exercise in algorithm complexity and got the students to code and measure different search algorithms to look for the different break points in scaling, a couple of years later another staff member had added a whole raft of OO cruft to the same exercise, IMHO obscuring the core point.

In general an OO paradigm encapsulates the state of an abstraction, and provides the mechanisms for accessing and mutating that state as part of the encapsulation. Add the subclassing mechanism and you have OO. After that you just need to codify the binding resolution rules and you have your almost your entire language.

---

<div class="post-metadata">

**Author:** ![dropzone](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dropzone/32/7515_2.png) [@dropzone](https://boards.straightdope.com/u/dropzone)\
**Post date:** [March 26, 2018, 1:28am UTC](https://boards.straightdope.com/t/what-are-the-advantages-of-object-oriented-programming-for-a-lone-hobbyist-coder/811110/30 "2018-03-26T01:28:52Z")

</div>

> [@wolfpup](#):
>
> Abstraction is essentially the process of generalizing and classifying, the recognition that some functional module is just a particular **instance** of something more generic, which leads to a generalized way of thinking about the functional architecture of a complex system. One way to teach it is by example.

Thanks! When I was taking a class in C I used Turbo C++ while reading a sort of OOP for dummies. Instance entered my vocabulary and I had to force it out of my vocabulary so civilians could understand me, though in context its meaning is obvious.

---

<div class="post-metadata">

**Author:** ![TwoCarrotSnowman](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/twocarrotsnowman/32/15879_2.png) [@TwoCarrotSnowman](https://boards.straightdope.com/u/TwoCarrotSnowman)\
**Post date:** [March 26, 2018, 11:31am UTC](https://boards.straightdope.com/t/what-are-the-advantages-of-object-oriented-programming-for-a-lone-hobbyist-coder/811110/31 "2018-03-26T11:31:48Z")

</div>

> [@Blue\_Blistering\_Barnacle](#):
>
> Which online course are you using? Do you like it?

Hi all, a poorly relative kyboshed my weekend and I’m still working through the thread. I really appreciate all the responses, even if I haven’t been that vocal in the thread.

I will just answer this, though. I’m using Treehouse, working through the Python track. I like that there’s a mix of video tutorials, quizzes and coding exercises. You do all the coding right in the browser, so nothing is required except for an internet connection.

---

<div class="post-metadata">

**Author:** ![Blue\_Blistering\_Barnacle](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/blue_blistering_barnacle/32/3386_2.png) [@Blue\_Blistering\_Barnacle](https://boards.straightdope.com/u/Blue_Blistering_Barnacle)\
**Post date:** [March 26, 2018, 12:06pm UTC](https://boards.straightdope.com/t/what-are-the-advantages-of-object-oriented-programming-for-a-lone-hobbyist-coder/811110/32 "2018-03-26T12:06:48Z")

</div>

> [@TwoCarrotSnowman](#):
>
> …snipped…  
> I will just answer this, though. I’m using Treehouse, working through the Python track. I like that there’s a mix of video tutorials, quizzes and coding exercises. You do all the coding right in the browser, so nothing is required except for an internet connection.

Thanks.

---

<div class="post-metadata">

**Author:** ![Mijin](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/mijin/32/9369_2.png) [@Mijin](https://boards.straightdope.com/u/Mijin)\
**Post date:** [March 26, 2018, 12:30pm UTC](https://boards.straightdope.com/t/what-are-the-advantages-of-object-oriented-programming-for-a-lone-hobbyist-coder/811110/33 "2018-03-26T12:30:15Z")

</div>

> [@SmartAlecCat](#):
>
> OOP will result naturally from well organized code. Encapsulation will eventually result, but you’ll end up with better code if you think it through at the start.
> 
> Even in a non-OOP language without the syntactic constructs you will find yourself grouping together data and functions that operate on that data. You’ll end up with a thing\_create(), thing\_dosomething() thing\_dosomethingelse(), etc.
> 
> Native language OOP support just makes that sort of thing easier, and cleaner.
> 
> Eventually you’ll be writing another program and need that “thing” functionality. Being able to just pull it in as an “Object” at once is much easier than trying to separate the spaghetti strands from the other program.

This.

Complex problems of all kinds, not just software, are very often solved via modularization – breaking down a problem into smaller, manageable chunks.  
Software engineering has always involved modularization, but it turns out when you break problems up in a casual way it’s possible to lose a lot of the benefits of modularizing, and end up with code that’s difficult to understand, difficult to build on and generally error-prone.

OO is just a set of principles for breaking up problems in a strict, consistent way such that you can fully enjoy the benefits of modularization.  
For implementing a non-trivial program, it just makes sense to use OO, or some equivalent paradigm.

That’s my avoiding-jargon explanation.

Another thing I like, is when I occasionally get “writer’s block” and don’t know where to start with implementing something, I can just start with classes that reflect the real world system, and a program quickly takes shape.

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [March 26, 2018, 1:07pm UTC](https://boards.straightdope.com/t/what-are-the-advantages-of-object-oriented-programming-for-a-lone-hobbyist-coder/811110/34 "2018-03-26T13:07:02Z")

</div>

> [@](#):
>
> Quoth **ftg** :
> 
> I didn’t say no data, just a virtually trivial amount. The main purpose of such a class is to have effects rather than maintain data.

By the same token, in procedural programming, there are often functions with no return value, or a trivial return value that you almost never care about (when was the last time you set something equal to a printf() ?).

---

<div class="post-metadata">

**Author:** ![Squink](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@Squink](https://boards.straightdope.com/u/Squink)\
**Post date:** [March 27, 2018, 8:35pm UTC](https://boards.straightdope.com/t/what-are-the-advantages-of-object-oriented-programming-for-a-lone-hobbyist-coder/811110/35 "2018-03-27T20:35:04Z")

</div>

Been coding since 1979.  
Started with assembly language.  
OOP is nice for big projects.  
Don’t like so much for small things like interfacing with hardware.  
What should be small and linear tends to get bloated and difficult to comprehend.  
Objects also bring with them whole new classes of bugs, as what you’ve defined as a canonical rectangle may not work so well when called by something that is close to a rectangle, but really a parallelogram. OOP changes the whole scope of error propagation.

---

<div class="post-metadata">

**Author:** ![Crane](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/crane/32/3495_2.png) [@Crane](https://boards.straightdope.com/u/Crane)\
**Post date:** [March 28, 2018, 2:28pm UTC](https://boards.straightdope.com/t/what-are-the-advantages-of-object-oriented-programming-for-a-lone-hobbyist-coder/811110/36 "2018-03-28T14:28:10Z")

</div>

The professional programming environment today is OOP. Modern computers are less limited by execution speed and memory size than were their predecessors. Even if you are programming Arduino or Android for fun, it’s all OOP. I’d say that anyone entering the field today has to start with OOP.

However, home projects are a matter of degree. I use Texas Instruments MSP430 family for instruments and gadgets. My library of assembly language subroutines suffices in place of classes. When gadgets are linked to the PC, VB6 works great for the GUI to get data into files and Excel does the rest.

I began programming at IBM in 1957. We used octal object code to write diagnostics. The advantage being that the bits were closely associated with the computer (IBM704) and its’ operation. COBOL and FORTRAN were useless for trouble shooting. Assemblers made things easier, but were one level removed from the operation of the system. That was another time. We did things different there.

Crane

[Previous page](https://boards.straightdope.com/t/what-are-the-advantages-of-object-oriented-programming-for-a-lone-hobbyist-coder/811110.md?page=1)
