6 ms·
OOP. I’m a self-taught programmer, so have probably missed lots that might help, but every time I come across anything OO, it always seems unnecessarily compli
by mft_ 5y ago
OOP.
I’m a self-taught programmer, so have probably missed lots that might help, but every time I come across anything OO, it always seems unnecessarily complicated and awkwardly structured. It always seems (to me) that everything could be done more simply procedurally. I don’t get why.
Further, while I can follow OO code that others have written, as a beginner, how to structure something simple I’m writing de novo in an OOP style has a very steep learning curve.
- andrei_says_ 5y agoWhat made OO click for me is watching some of the talks of Sandi Metz and reading her book POODR - Practical Object Oriented Programming in Ruby
- nopenopenopeno 5y agoAre there any GUI frameworks that are not OOP?
- pubby 5y agoI mean React is pretty popular. And then there's stuff like immediate mode UIs and FRP UIs.
- kristov 5y agoDear ImGui
- prewett 5y agoDear ImGUI keeps a bunch of state under the hood, based on the name of the object. It's not object-oriented, per se, but each object has its set of functions that operate on it, except that the object reference is not a pointer but a string. Kind of like object-oriented C (NOT Objective-C), but with strings instead of pointers.
- psyc 5y agoFWIW, after I learned/memorized the semantics of C++, it did take me at least 3 years of writing lousy code to develop a sense of how to structure a program, e.g. what ‘should’ be a class, when inheritance is appropriate, etc. As for the why, I find it a useful formalism for how to organize (as in, group and associate) code and data, as well as a way to create mental-cycle-freeing guarantees (invariants).
- giraffe_lady 5y agoIn my opinion one of the weaknesses of OOP is just how hard it is to actually model those real world relationships in any concrete form. It's choosing to professionally have a fight with "the map is not the terrain." Some people are really good it but it's a skill for sure and learning it is rough. It is some really abstract thinking shit, and difficult even to evaluate how well it has been done until much time has passed with it. I think when people joke about naming in programming this is what they mean. Needing to clearly define relations that are not necessarily clear yet. OOP does demand a lot of that so is hard and exhausting in a particular way. That said nothing against OOP I use it every day and Sandi Metz is the code book writer I learned the most useful stuff from. Just it's hard in a different way from most of the rest of coding.
- drpixie 5y agoAbsolutely. I'm continually amazed as how much and how hard people have tried to push everything into their OO framework. Android development is the classic example - it's ALL OO - and most of the time, that's pushing the proverbial uphill. Instead of just initialise something, everything is pushed into constructors. The model works sometimes, but for many things it just adds work. AND ADDS ENORMOUS AMOUNTS OF BOILERPLATE. Aarrgghhh.
- coward123 5y agoTake a weekend to learn Smalltalk, then it will all make sense. Objects composed of other objects, all passing messages to each other. Whether you can then take that knowledge and have it make sense in a Java, a Python, a C++, etc is hard to say...
- mrfusion 5y agoIt sounds like you do understand it.
- eternityforest 5y agoSomeone will probably chime in with Smalltalk and the original intent or something. But in modern OOP, understanding and simplicity are not what it's all about. It's all about pushing the complexity into the language runtime stuff where it is no longer your problem. OOP is popular because we can do stuff like port=DBConnection(); port.connect("foo.baz") and document= port.request("x"). Then, later on, when port and document are inaccessible, garbage collection will get them. An OOP programmer doesn't think "Oh, the port.connect must make a socket and do a handshake and then..." they just think "It does all the port connect stuff". As a student when the goal is to understand, OOP makes no sense, because encapsulation literally is all about making it so you don't need to think about things. It lets you treat objects the same way we treat physical devices. Black boxes someone else built. There's no beautiful reasoning or amazing objective logic saying OOP is better than I know of, or anything that even makes any sense at all if you think about it. It just happens to work pretty well when people with a wide range of skill levels do large projects and nobody understands anything beyond their tiny part, and nobody really cares if things are simple under the hood. If you want beauty and logic, learn a pure functional language or go study math. And if you want to structure stuff in an modern OOP style, you just stop thinking in terms of simplicity and unified wholes and start thinking in terms of black boxes to be used by people who would be annoyed if they actually had to read the code. Any entity you would talk about when describing the code is something that could be represented as an object. Any collection of a variable number of a ton of entities like customers is something you could do as some kind of database connection object. Any periodic task might be a "Machine" that is a class that manages a thread. It's(In theory) a 1 to 1 mapping of ideas to classes, although some things just aren't worth a whole inventing object for and should probably be a data dict+procedural. But, some would say this whole thing is nonsense for idiots who can't think, so maybe if you find yourself actually able to do procedural well you should try something more logical like haskell.
- jnash 5y agoYou are right. Here is procedural: doX(data, args) Here is OO: data.doX(args) The only difference is that you can stop doX(data, args) from modifying parts of data. However you can do the exact same thing in non-OO languages like C or Haskell by using void* (in C) or (in Haskell) modules with hidden constructors. The only true OO language out there is Erlang. C++/Java/C# etc. are not OO languages. The idea that OO is modelling the world is BS. You don't ask your shoe to tie itself or ask a tree to chop itself. And you don't ask an integer to display itself in a dialog in an "OO" language unless you are a bad software designer.
- mettamage 5y agoIMO OOP is simply procedural programming with structs. Except, that whole "struct thing" is much more elaborate and fleshed out and has a much more emphasized philosophy behind it.