1. 27
    Please send me examples of good OOP code programming dpc.pw
  1.  

  2. 26

    I’m a little bit suspicious of this plan. You specifically call out that you already have an anti-OOP bias to the point of even saying “no true Scotsman” and then say you plan to take anything someone sends you and denigrate it. Since no codebase is perfect and every practitioner’s understanding is always evolving, there will of course be something bad you can say especially if predisposed to do so.

    If you actually want to learn what OOP is like, why not pick up a known-good text on the subject, such as /99 Bottles of OOP/?

    1. 10

      I, for one, think this project seems very interesting. The author is correct that criticisms of OOP is often dismissed by saying “that’s just a problem if you don’t do OOP correctly”. Naturally, a response is to ask for an example of a project which does OOP “correctly”, and see if the common critiques still applies to that.

      Maybe the resulting article will be uninteresting. But I think I would love to see an article which dissects a particular well-written code-base, discusses exactly where and how it encounters issues which seem to be inherent in the paradigm or approach it’s using, and how it solves or works around or avoids those issues. I just hope the resulting article is actually fair and not just a rant about OOP bad.

      EDIT: And to be clear, just because there seems to be some confusion: The author isn’t saying that examples of good OOP aren’t “real OOP”. The author is saying that critiques of OOP is dismissed by saying “that’s not real OOP”. The author is complaining about other people who use the no true Scotsman fallacy.

      1. 7

        Explicitly excluding frameworks seems to be a bit prejudiced, since producing abstractions that encourage reuse is where OOP really shines. OpenStep, for example, is an absolutely beautiful API that is a joy to use and encourages you to write very small amounts of code (some of the abstractions are a bit dated now, but remember it was designed in a world where high-end workstations had 8-16 MiB of RAM). Individual programs written against it don’t show the benefits.

        1. 1

          Want to second OpenStep here, essentially Cocoa before they started with the ViewController nonsense.

          Also, from Smalltalk, at least the Collection classes and the Magnitude hierarchy.

          And yes, explicitly excluding frameworks is non-sensical. “I want examples of good OO code, excluding the things OO is good at”.

        2. 2

          Maybe the resulting article will be uninteresting. But I think I would love to see an article which dissects a particular well-written code-base, discusses exactly where and how it encounters issues which seem to be inherent in the paradigm or approach it’s using, and how it solves or works around or avoids those issues. I just hope the resulting article is actually fair and not just a rant about OOP bad.

          That’s exactly my plan. I have my biases and existing ideas, but I’ll try to keep it open minded and maybe through talking about concrete examples I will learn something, refine my arguments, or just have a useful conversation.

          1. 2

            The author is correct that criticisms of OOP is often dismissed by saying “that’s just a problem if you don’t do OOP correctly”.

            I know this may look like splitting hairs, but while “that’s only a problem if you don’t do OOP correctly” would be No True Scotsman and invalid, what I see more often is “that’s a problem and that’s why you should do OOP instead of just labelling random code full of if statements as ‘OOP’” which is a nomenclature argument to be sure, but in my view differs from No True Scotman in that it’s not a generalization but an attempt to make a call towards a different way.

            I agree that a properly unbiased tear-down of a good OOP project by someone familiar with OOP but without stars in their eyes could be interesting, my comment was based on the tone of the OP and a sinking feeling that that is not what we would get here.

            1. 1

              OOP simplifies real objects and properties to make abstraction approachable for developers, and the trade-off is accuracy (correctness) for simplicity.

              So if you would try to describe the real world in OOP terms adequately, then an application will be as complex as the world itself.

              This makes me think that proper OOP is unattainable in principle, with the only exception – the world itself.

            2. 3

              One could argue in favor of Assembly and still be right, which doesn’t make “everyone program should be written in Assembly” a good statement. It sounds, to me, like saying “English will never have great literature”. It doesn’t make much sense.

              Microsoft has great materials on Object-Oriented-Design tangled inside their documentation of .NET, Tackle Business Complexity in a Microservice with DDD and CQRS Patterns is a good example of what you want, but is not a repository I am afraid. Design Patterns has great examples of real world code, they are old (drawing scrollbars) but they are great Object-Oriented-Programming examples.

              Good code is good, no matter the paradigm or language. In my experience, developers lack understanding the abstractions they are using (HTTP, IO, Serialization, Patterns, Architecture etc.) and that shows on their code. Their code doesn’t communicate a solution very well because they doesn’t understand it themselves.

              1. 3

                you plan to take anything someone sends you and denigrate it.

                I could do that, but then it wouldn’t be really useful and convincing.

                If you actually want to learn what OOP is like, why not pick up a known-good text on the subject, such as /99 Bottles of OOP/

                Because no real program looks like this.

              2. 11

                I usually really enjoy your writing, but this seems totally disingenuous.

                You don’t even define what qualifies as “OOP” to you, so how could anyone NOT think that you’re going to “No true Scotsman” them if they show you what they believe to be good OOP?

                Does OOP have to use class inheritance? Does it have to involve mutable global state? Can you write OOP in the C language?

                Or, if you’re open to someone showing you a piece of code and you’ll just accept at face value that it’s OOP with no argument, then you should say THAT.

                You need to address that. But even then, I wouldn’t actually expect any replies because of the point(s) that @singpolyma raised- nobody is going to volunteer code to someone who is basically promising to (publically) criticize it.

                1. 5

                  so how could anyone NOT think that you’re going to “No true Scotsman” them if they show you what they believe to be good OOP?

                  I’m a bit confused. Usually it’s the other way around. I have some concrete criticism against OOP, and and I hear “Oh, that’s just because you don’t know OOP. That’s not a good OOP.” And that keeps on going forever, at which point it seems that the good OOP is everything that books and articles say, except all the things that people actually are doing in practice, but surely there somewhere must be some pristine OOP code.

                  I haven’t thought that I could pull a “no true Scotsman” the other way, though I guess you’re right. That’s not my intention though.

                  Does OOP have to use class inheritance? Does it have to involve mutable global state? Can you write OOP in the C language?

                  I guess I’m open minded about it. The thing with OOP is not well defined. Look - the code I write in Java is not very far from OOP: always uses a lot of interfaces, DI, and yet I don’t consider it OOP for various subtle reasons, which usually get lost in abstract discussion.

                  Having read and written many articles in OOP debate, I think we as a community are just talking past each other now, criticizing/defending something that is not well defined and subjective.

                  So I think it would be more productive to go through some actual code and talk about, in relation to OOP debate.

                  nobody is going to volunteer code to someone who is basically promising to (publically) criticize it.

                  You can volunteer someone else’s code, I don’t mind. :D

                  I actually thought that this is going to be a default, because people are usually too shy to think their code must be the best one.

                  That’s a thing with public OS projects. You put them out there, you have accept the fact that someone might… actually read the code and judge it.

                  I promise not to be a douche about it. There’s plenty of my own code on github, none of it pristine, anyone is free to retaliate. :D

                  1. 5

                    If you do find examples of good OOP code, I predict they will mostly be written in either Smalltalk, Erlang, and Dylan. I haven’t used Smalltalk or Dylan in earnest, and it’s been far too long since I used Erlang, or I’d find some examples myself.

                    Edit: thinking more about this, it feels like the only way to find good OOP code is to try to find that mythical domain in which inheritance is actually a benefit rather than the enormous bummer it normally is, and one in which polymorphism is actually justified. The only example which comes to mind is GUI code where different kinds of widgets could inherit off a class hierarchy, which is why I expect you’d have the best luck by looking in Smalltalk for your examples.

                    But overall it’s a misguided task IMO; merely by framing it as being about “OOP” in the first place you’ve already gone wrong. OOP is just a mash-up of several unrelated concepts like inheritance, polymorphism, encapsulation, etc, some of which are good and some of which are very rarely helpful. Talk instead about how to do encapsulation well, or about in what limited domains polymorphism is worth the conceptual overhead.

                    1. 2

                      But overall it’s a misguided task IMO; merely by framing it as being about “OOP” in the first place you’ve already gone wrong. OOP is just a mash-up of several unrelated concepts like inheritance, polymorphism, encapsulation, etc, some of which are good and some of which are very rarely helpful.

                      I have a very similar intuition, but the point of the exercise is to find whatever people would consider as good OOP and take a look at it.

                      If you do find examples of good OOP code, I predict they will mostly be written in either Smalltalk, Erlang, and Dylan.

                      I’m not sure about Dylan, but the rest fits my intuition of one “good” piece of OOP being message passing, which I tend to call actor based programming.

                      1. 1

                        which I tend to call actor based programming

                        Yes. “Actor” is another common word for “OOP”

                        1. 4

                          This is not quite true. OOP permits asynchronous message passing but actor-model code requires it. Most OO systems use (or, at least, default to) synchronous message passing.

                          1. 2

                            This conflation is really problematic. I get that this is what it was supposed to mean long time ago. And then OOP became synonymous with Java-like class oriented programming. So now any time one wants to talk about contemporary common “OOP” there’s a group of people coming and “oh, but look at Erlang and Smalltalk, yada, yada - real OOP”, which while technically do have a point, are nowhere close to what I’ve seen a real life OOP looked like.

                            1. 4

                              It’s also competely ahistorical. The actor model has almost nothing to do with the development of object-based programming languages, the actor model of concurrency is different from the actor model of computation, which is nonsensical (the inventor thinks he proved Turing and godel wrong with the actor model.) Alan Kay changed his mind on what “true oop was supposed to be” in the 1990s.

                              1. 1

                                Alan Kay changed his mind on what “true oop was supposed to be” in the 1990s.

                                Any link what do you mean exactly? I’m aware of http://userpage.fu-berlin.de/~ram/pub/pub_jf47ht81Ht/doc_kay_oop_en .

                                OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I’m not aware of them.

                                Is that what you have in mind?

                                1. 4

                                  “OOP means only messaging” is revisionism, his earlier writing was much more class-centric. I document some of this here: https://www.hillelwayne.com/post/alan-kay/

                                  1. 1

                                    I just read that article, twice, and I still can’t figure out what the point is that it is trying to make, never mind actually succeeding at making it.

                                    It most certainly isn’t evidence, let alone proof of any sort of “revisionism”.

                                    1. 4

                                      The point it’s trying to make is that if you read Alan Kay’s writing from around the time that he made Smalltalk, so 72-80ish, it’s absolutely not “just messaging”. Alan Kay started saying “OOP means only messaging” (and mistakenly saying he “invented objects”, though he’s stopped doing that) in the 90s, over a decade and a half after his foundational writing on OOP ideas. It’d be one thing if he said “I changed my mind / realized I was wrong”, but a lot of his modern writing strongly implies that “OOP is just messaging” was his idea all along, which is why I call it revisionism.

                                      1. 1

                                        I know what the point is that you (now) claim it makes. But that, to me, looks like revisionism, because the contents of the article certainly don’t support, and also don’t appear to actually make that claim in any coherent fashion.

                                        First, the title of the article makes a different claim: “Alan Kay did not invent objects”. Which is at best odd (and at worst somewhat slanderous), because he has never claimed to have invented object oriented programming, being very clear that he was inspired very directly by Simula and a lot of earlier work, for example the Burroughs machine, Ivan Sutherland’s Sketchpad etc.

                                        In fact, he describes how one of his first tasks, as a grad student(?), was to look at this hacked Algol compiler, and spreading the listing out in the hallway to try and grok it, because it did weird things to flow control. That was Simula.

                                        Re-reading your article, I am guessing you seem to think of the following quote as the smoking gun:

                                        I mean, I made up the term “objects.” Since we did objects first, there weren’t any objects to radicalize.

                                        At least there was nothing else I could find, and you immediately follow that with “He later stopped claiming…”. The interview you cite is from 2012. Even the Squeak mailing list quote you showed was from 1998, and it refers to OOPSLA ‘97. His HOPL IV paper The Early History of Smalltalk is from 1993. That’s where he tells the Simula story.

                                        So he “stopped” making the claim you insinuate him making, two decades before, at least according to you, he started making that claim. That seems a bit…weird. Of course, there were rumours on the Squeak mailing list that Alan Kay was actually a time-traveller from the future, partly fuelled by a mail sent from a machine with misconfigured system clock. But apart from that scenario, I have a hard time seeing how he could start doing what you claim he did two decades after he stopped doing what you claim he did.

                                        The simpler explanation is that he simply didn’t make that claim. Not in that 2012 interview, not before 2012 and not after 2012. And that you vastly mis- and over-interpreted an off-the-cuff remark in a random interview.

                                        Please read the first sentence carefully: “I made up the term ‘objects’”. (My emphasis). He is clearly, and entirely consistently both with the facts and his later writings, claiming to have coined the term.

                                        And he is clearly relating this to the systems that came later, C++ and Java, relative to which the Smalltalk “everything is an object” approach does appear radical. But of course it wasn’t a “radicalisation” relative to the current state of the art, because the current state of the art came later.

                                        Yeah, he could have mentioned Simula at that point, but if you’ve ever given a talk or an interview you know that you sometimes omit some detail in order to move the main point along. And maybe he did mention it, but it was edited out.

                                        But the question at hand was what OO is, according to Alan Kay, not whether he claimed to have invented it. Your article only addresses the second question, incorrectly it turns out, but doesn’t say anything whatsoever about the former.

                                        And there it helps to look at the actual artefacts. Let’s take Smalltalk-72, the first Smalltalk. It was entirely message-based, objects and classes being a second-order phenomenon. In order to make it practical, because Smalltalk was a means to an end for them, not an end in itself, this was made more like existing systems over time, culminating in Smalltalk-80. This is a development Alan has consistently lamented.

                                        In fact, in the very 2012 interview you misrepresent, he goes on to say the following:

                                        The first Smalltalk was presented at MIT, and Carl Hewitt and his folks, a few months later, wrote the first Actor paper. The difference between the two systems is that the Actor model retained more of what I thought were the good features of the object idea, whereas at PARC, we used Smalltalk to invent personal computing

                                        So Actors “retained more of the good features of the object idea”. What “good features” might that be, do you think?

                                        In fact, there’s Alan’s famous quip at OOPSLA ’97 keynote, The Computer Revolution hasn’t Happened Yet.

                                        Actually I made up the term “object-oriented”, and I can tell you I did not have C++ in mind.

                                        I am sure you’ve heard it. Alas, what he said next is hardly reported at all:

                                        The important thing here is, I have many of the same feelings about Smalltalk.

                                        And just reiterating the point above he goes on:

                                        My personal reaction to OOP when I started thinking about it in the sixties.

                                        So he was reacting to OOP in the sixties. The first Smalltalk was in the seventies. So either he thinks of himself as a time-traveller, or he clearly thinks that OOP was already invented, just like he always said.

                                        Anyway, back to your claim of “revisionism” regarding messaging. I still can’t get a handle on it, because all the sources you absolutely harp on the centrality of messaging. For example, in the “Microelectronics and the Personal Computer” article, the central idea is a “message-activity” system. Hmm…sounds pretty message-centric to me.

                                        The central idea in writing Small talk programs, then, is to define classes which handle communication among objects in the created environment.

                                        So the central idea is to define classes. Aha, smoking gun!! But what do these classes actually do? Handle communication among objects. Messages. And yes, in a manual describing what you do in the system, what you do is define classes. Because that’s the only way to actually send and receive messages.

                                        What else should he have written, in your opinion?

                                        1. 4

                                          Please read the first sentence carefully: “I made up the term ‘objects’”. (My emphasis). He is clearly, and entirely consistently both with the facts and his later writings, claiming to have coined the term.

                                          He didn’t coin the term, either. The Simula 67 manual formally defines “objects” on page 6.

                                          Anyway, you’re way angrier about this than I expected anybody to be, you’re clearly more interested in defending Kay than studying the history, and you’re honestly kinda scaring me right now. I’m bowing out of this whole story.

                                          1. 1

                                            OK, you just can’t let it go, can you?

                                            First you make two silly accusations that don’t hold up to even the slightest scrutiny. I mean, they are in the “wet roads cause rain” league of inane. You get shown to be completely wrong. Instead of coming to terms with just how wrong you were, and maybe what your own personal motivations were for making such a silly accusations, you just pile on more silly accusations.

                                            What axe do you have to grind with Alan Kay? Because you are clearly not rational when it comes to your ahistorical attempts to throw mud at him.

                                            As I have clearly shown, the only one who hasn’t adequately studied history here is you. Taking one off-the-cuff remark from 2012 and defining that has “having studied history” is beyond the pale, when the entire rest of history around this subject contradicts your misinterpretation of that out-of-context quote.

                                    2. 1

                                      Thanks! It was a good read.

                                2. 2

                                  I’m sympathetic, but I mean, at some point you have to just give up and admit that the word has been given so many meanings that it’s no longer useful for constructive discussion and just switch to more precise terminology, right? Want to talk about polymorphism? Cool; talk about polymorphism. Want to talk about the actor model? Just say “actor”.

                                  1. 2

                                    no longer useful for constructive discussion and just switch to more precise terminology, right?

                                    I guess you’re right.

                                    It’s just there’s still so many books, articles, talks mentioning and praising OOP, that it’s hard to resist. (Do schools still teach OOP?) It’s not useful to use for constructive discussion, but the ghost of vague amalgamate of ideas of OOP is still hunting us, and I can see some of these ideas in the code that I have to work with sometimes. People keep adding pointless getters and setters in the name of encapsulation and so on. Because that’s in some OOP book.

                                    Ironically… when talking about OOP critically, in a way I’m only proliferating its existence. But talking about these ideas in isolation doesn’t seem like it’s making any damage to the ghost of OOP. Everyone keep talking about inheritance being tricky, and yet I keep seeing inheritance hierarchies where they shouldn’t be.

                                  2. 1

                                    And this is what I was talking about in my top-level comment. It sounds like you’re requiring class inheritance as part of your definition of OOP. Which I think is bunk. I don’t care what Java does or has for features. Any code base that is architected as black-box, stateful, “modules” (classes, OCaml modules, Python packages, JavaScript modules, etc) should count as OOP. Inheritance is just a poor mechanism for code-reuse.

                                    There’s no actual reason to include class inheritance in a definition of OOP anymore than we must include monads in our definition of FP (we shouldn’t).

                                    1. 1

                                      I would say modules rendered black box by polymorphic composition, with state being optional but allowed it the definition of course.

                                      1. 1

                                        I feel like mutable state is actually important for something to be an “object”.

                                        And when I say mutable state, I’m also including if the object “represents” mutable state in the outside world without having its own, local, mutable fields in the code. In other words, an object that communicates with a REST API via HTTP represents mutable state because the response from the server can be different every time and we can issue POST requests to mutate the state of the server, etc. So, even if the actual class in your code doesn’t have mutable properties, it can still be considered to “have” mutable state.

                                        Anything that doesn’t have mutable state, explicitly or implicitly, isn’t really an “object” to me. It’s just an opaque data type. If you disagree, then I must ask the question “What isn’t an object?”

                                        1. 1

                                          It’s just an opaque data type.

                                          A data type rendered opaque by polymorphism, specifically. A C struct with associated functions is not an object, even if the fields are hidden with pointer tricks and even if the functions model mutable state, because I can’t make something another object out of something else where I can use those functions safely.

                                          1. 1

                                            So are you saying that “objects” have some requirement to be polymorphic per your definition?

                                            Polymorphism is orthogonal to my definition. Neither an opaque data type, nor an “object” need to have anything to do with polymorphism in my mind. An opaque data type can simply be a class with a private field and some “getters”.

                              2. 1

                                it feels like the only way to find good OOP code is to try to find that mythical domain in which inheritance is actually a benefit rather than the enormous bummer it normally is

                                Oof. Inheritance is definitely not a feature I’d call out as a “good idea” part. I’ve been known to use it from time to time, but if you use it a lot and end up being “good OOP” that would be nothing short of a miracle.

                            2. 1

                              so how could anyone NOT think that you’re going to “No true Scotsman” them if they show you what they believe to be good OOP?

                              I’m a bit confused. Usually it’s the other way around. I have some concrete criticism against OOP, and and I hear “Oh, that’s just because you don’t know OOP. That’s not a good OOP.” And that keeps on going forever, at which point it seems that the good OOP is everything that books and articles say, except all the things that people actually are doing in practice, but surely there somewhere must be some pristine OOP code.

                              I haven’t thought that I could pull a “no true Scotsman” the other way, though I guess you’re right. That’s not my intention though.

                              Does OOP have to use class inheritance? Does it have to involve mutable global state? Can you write OOP in the C language?

                              I guess I’m open minded about it. The thing with OOP is - it’s vague and not well defined. The real OO is what I would call actor programming, with real message passing, and OOP we do now is class-oriented programming, and that just starts the confusion.

                              Look - the code I write in Java is not all that much different from OOP: always uses a lot of interfaces, DI, and yet I don’t even consider it OOP for various subtle reasons.

                              Having read and written many articles in OOP debate, I think we as a community are just talking past each other now, criticizing/defending something that is not well defined and subjective.

                              So I think it would be more productive to go through some actual code and talk about, in relation to OOP debate.

                              nobody is going to volunteer code to someone who is basically promising to (publically) criticize it.

                              You can volunteer someone else’s code, I don’t mind. :D

                              I actually thought that this is going to be a default, because people are usually too shy to think their code must be the best one.

                              That’s a thing with public OS projects. You put them out there, you have accept the fact that someone might… actually read the code and judge it.

                              I promise not to be a douche about it. There’s plenty of my own code on github, none of it pristine, anyone is free to retaliate. :D

                            3. 9

                              I hereby submit UIKit (let’s limit it to older APIs <= iOS 6, back when Apple cared about polishing APIs, instead of cranking them faster than they document them.)

                              The object model is based on Objective-C. It’s inspired by Smalltalk-style message passing, so Alan Kay shouldn’t be objecting to it.

                              “TextView extends View” makes a lot of sense for GUIs. OO/message-passing enables nice things like bindings and responder chains. It also has a concept of delegates, which allow customization of behavior without needing inheritance. Another way to look at them is richer, type-safe event handling.

                              1. 3

                                Unfortunately, he explicitly excluded frameworks. I wouldn’t go as far as UIKit though, Foundation has some beautiful abstractions. Even simple things, such as NSString, are simple to use and very powerful. You can provide your own string implementation by implementing two methods (three if you care about performance). Bridging this to ICU’s internal string types, for example, is trivial. The GNUstep implementation of NSRegularExpression provides a bridge between ICU’s UText and Foundation’s NSString interfaces and delegates entirely to ICU. With good abstractions, you can compose very different implementations.

                              2. 6

                                Aha, a strong sense of deja vu is not incidental! You might want to take a look at https://github.com/leontrolski/call-to-arms.

                                1. 2

                                  Exactly! Seems pretty empty so far. :)

                                  1. 5

                                    Welcome to lobsters! A couple of community etiquette notes:

                                    • You don’t need to tell us you’re the author, it says “authored by” under the link 🙂
                                    • New users (accounts under 90 days) can’t use the ask tag. This case is a little fuzzy because you’re also submitting a story, but that story is basically an ask, so I think it falls slightly under the “wait until you’re past 90 days before doing” bin.
                                    1. 4

                                      For as long as people respond in comments here (instead of private email only OP can see) I think this can spark an insightful conversation. So I vote to keep it.

                                      1. 2

                                        I’m new here too. Is there anywhere I can see a full list of things like “you can use the ask tag after 90 days”?

                                        1. 1

                                          The only way I know of is to look through the source code.

                                          1. 1

                                            Thanks, found the relevant code: looks like I need 50 karma to invite other people https://github.com/lobsters/lobsters/blob/6faa5d37d2fdf8e4d1accbdcd4ffbe28c1db7088/app/models/user.rb#L137

                                        2. 1

                                          You don’t need to tell us you’re the author, it says “authored by” under the link 🙂

                                          Oh, I wasn’t aware of the meaning of authored vs via. I’m pretty new here, and wasn’t paying attention to it before.

                                          so I think it falls slightly under the “wait until you’re past 90 days before doing” bin.

                                          Oh, OK, fair enough. Do I delete it? Or it just gets removed?

                                        3. 4

                                          I’ve heard the Linux VFS layer called a good example of OOP in C.

                                          1. 4

                                            I’m going to submit my project, wcp: https://github.com/wheybags/wcp, blog post explaining it here: https://wheybags.com/blog/wcp.html

                                            It is a medium sized c++ project with limited scope. I don’t think it’s perfect, and there’s no fancy inheritance stuff going on. It does use c++ RAII to its advantage, and the main concepts are tracked by objects for the most part. Most classes are what I would call only moderately messy, so I think it’s a decent example.

                                            I await your roast :p

                                            1. 2

                                              I await your roast :p

                                              I’m thinking about recording some YT videos in the future, so wanted to check recording HW&software, and the format. I must say I’m not very pleased with my recording but if you’re interested how did my reviewing went: https://youtu.be/6dqBUPWLDWM

                                              If you don’t have time to watch a half an hour of a rather slow video with a tired mumbled voice, the TL;DR:

                                              • There are some rather poor quality things that you might not bothered but have to be addressed to make this anywhere near production ready like handling errors properly. And comments.
                                              • There is plenty of stuff that is I don’t like that are plain results of using C++; you should really switch to Rust, I promise. :)
                                              • The higher level structure is meh - low level code mixed with high level code everywhere; probably my biggest complain. Having a decent high-level structure is of most importance for software development. Not to mention that it made reviewing so much more difficult, especially that there are no comments, my C++ is Rust, and I was using text editor that is not my main one.
                                              • There isn’t much of OOPism here, and where there is I’m generally OK with it.

                                              Anyway, thanks for providing me with something I was able to practice.

                                              1. 1

                                                So, I had a watch of your video, but I think I probably missed most of your points, as the audio was broken (high pitched whine drowning out what you’re saying) more often than it was working, so I’ll mostly respond to your text comments.

                                                handling errors properly

                                                This is concerning to me, as I went to a great deal of effort to handle errors. Can you point out anywhere in specific?

                                                comments

                                                Not sure I agree here, if a newcomer isn’t getting things immediately, that doesn’t necessarily mean there should be a comment. What specifically did you feel needed commenting?

                                                you should really switch to Rust

                                                Naaaah :p

                                                low level code mixed with high level code everywhere

                                                This is a difficult one, I think there’s a balance with abstraction, where too much can do more harm than good. I don’t think religiously including everything in your wrapper layer is always the best idea, but I thought I struck a decent balance here. On the whole though, the point of the project is to facilitate a very low level access to the system, so there is inherently a lot of low level code. I would consider the API of CopyQueue to be the “public” api, so looking at the code in wcpMain that uses it, I don’t think there’s a layer violation there. There is some low level code (statx, kernel version checking) going on in wcpMain also, but that is stuff that CopyQueue is not, and should not be responsible for. Everything that happens inside CopyQueue is “inside” the low level layer, so I guess I don’t see what the problem is.

                                                For me, the main messy part is the progress update code. Since it’s running in parallel, there needed to be a bunch of messy stuff done to make the communication between the work thread and progress thread safe, and I think it probably could have been better. I think you mentioned that in the video, and I can only agree.

                                                1. 1

                                                  as the audio was broken

                                                  I’m sorry for that, and I’m frustrated myself. I’m still debugging why is this happening. I made plenty of prior tests, and then the one video that was supposed to be “production” I get broken sound parts. So frustrating. Makes me want to stick with text.

                                                  This is concerning to me, as I went to a great deal of effort to handle errors.

                                                  Generally I’m used to a style where every possible error is a variant in a enum of some kind, and they bubble up to the top level where they are handled and reported on, either through try-catch or just reporting Result like variables.

                                                  Random assert s aborting/exiting/throwing that check valid user input is definitely not the right thing to do, IMO.

                                                  Not sure I agree here, if a newcomer isn’t getting things immediately, that doesn’t necessarily mean there should be a comment.

                                                  I used to be a slacker about comments, but as I spend more years in the craft, often having to jump into random codebases (sometimes even mine from the past), ability to quickly get into, navigate around an understand code is more and more important to me.

                                                  Right now a top level comment before every class/object and datastructure explaining in few sentences what something really is, more or less how it’s used (pattern it fits to, etc.) and some reasoning behind it, I considered an absolute bare minimum. One less on importance level is a comment for every non-trivial function.

                                                  This is a difficult one, I think there’s a balance with abstraction

                                                  Putting some code in a function and naming it is hardly an abstraction. :)

                                                  Like bool areWeRunninginTTy() in if (someFlag || areWeRunninginTTy()) instead of if (someFlag || istty(some_fd) || someoTherLowLevleCheck(lowlevelThing). Trivial change that makes the code self-descriptive and read like prose.

                                                  It’s not always possible in complex functions but you have plenty of functions that are multiple-screens long, that have obvious parts that could be moved to a named sub-functions, helping the reader understand the higher-level picture first, before looking at the exact details.

                                                  you should really switch to Rust Naaaah :p

                                                  I don’t want to get too much into evangelism right now, but I looked at how you parse the src & dst arguments, and I couldn’t help but to think that it’s some stone age of programming, and it’s sad that people still do it this way in 2020. For comparison, consider how nice and features parsing can be: https://github.com/dpc/rust-bitcoin-indexer/blob/8a9b041928a7c8c4d267a810f582cf3906ed511b/src/main.rs#L104 , https://github.com/dpc/rust-bitcoin-indexer/blob/8a9b041928a7c8c4d267a810f582cf3906ed511b/src/opts.rs#L5 . And you get all the niceness, colors, nice formatting and so on, because just using a library is not chore like in C++.

                                                  Anyway, I don’t want to argue more, as I have very limited time. That’s all the roast and opinion I have. It’s OK if you think most of it is nonsense. Maybe you’re right. :D

                                              2. 1

                                                I await your roast :p

                                                I’m thinking about recording some YT videos in the future, so wanted to check recording HW&software, and the format. I must say I’m not very pleased with my recording but if you’re interested how did my reviewing went: https://youtu.be/rEr8fzWjU8c

                                                If you don’t have time to watch a half an hour of a rather slow video with a tired mumbled voice, the TL;DR:

                                                • there are some rather poor quality things that you might conciously not bothered with like handling errors properly
                                                • the higher level structure is meh - low level code mixed with high level code everywhere
                                                • there isn’t much of OOPism here, and where there is I’m generally OK with it

                                                Anyway, thanks for providing me with something I was able to practice.

                                              3. 2

                                                It seems we’re allowed to submit our own projects, so I’d like to propose Lark. It’s written in Python, it’s around 7500 LOC in total, and while it has a few functional elements, it is primarily object-oriented, and all the better for it. I’m proud of it, of course, but I welcome all scrutiny.

                                                1. 2

                                                  OT-ish, but I tried out Lark in 2018 (I was stubbing out some ideas that are stuck in not-enough-time-in-the-year limbo) and really enjoyed it. Nice to see you here.

                                                  1. 1

                                                    Thanks! It’s actually improved a lot since then.

                                                2. 2

                                                  I’d be interested to hear your take on https://github.com/skinny85/goos-book-code. It’s the code from the book ‘Growing Object-Oriented Software, Guided by Tests’ - well regarded by many as a recent-ish example of OOP ‘done right’ (it’s in an old version of Java, which makes that more effort than in other languages).

                                                  1. 1

                                                    I’d be interested to hear your take on https://github.com/skinny85/goos-book-code.

                                                    Hey, I have a blogpost for you! :) https://lobste.rs/s/iizjtx/growing_object_oriented_software_vs_what

                                                    1. 1

                                                      By the looks of it, it looks very much reasonable. DI everywhere, objects used for doers and not data, the state expressed with enums. It does however looks somewhat light on state, which is where from my PoV usually problems with OOP happen. It’s hard for me to judge some design decisions well without any comments or the book… So I just went ahead and ordered the book.

                                                    2. 2

                                                      Ok, I’ll suggest Metalsmith. Go ahead, roast it.

                                                      1. 1

                                                        With all due respect, but unless I’m missing something, this example is tiny (1 class), and I can’t find anything OOP about it, other than using a class. By the looks of it, seems like a reasonable, well documented JS code.

                                                        1. 1

                                                          Ok, I can go bigger. How about Jenkins, or Roslyn, or Jekyll ? I’m guessing you’re not after Erlang code.

                                                      2. 2

                                                        Author of “Elegant Objects” book gives award to projects that match his type of good OOP https://www.yegor256.com/award.html

                                                        1. 1

                                                          Oh, wow. This is great! Thanks a lot!

                                                          I might buy the book, but do I get it right that it’s two volumes, each $40? Worth it?

                                                          Edit: Oh well, I ordered the first one and will see how it goes.

                                                          1. 1

                                                            Author of “Elegant Objects” book gives award to projects that match his type of good OOP https://www.yegor256.com/award.html

                                                            OMG, @nbardiuk this is so great! Thank you so much! Well worth the $40. I’m on page 35 and I can already see that this is the most idiotic and ridiculous book about OOP I’ve ever read. Expect a fun blog posts as soon as I finish!

                                                        2. 1

                                                          Payroll Example Two is a simplified implementation of Canadian payroll tax calculations; I’d like to see a procedural or functional version of it.

                                                          1. 1

                                                            Apparently the Erlang systems used in telephone exchanges are the pinnacle of what OOP should be like. Don’t ask me where to get the source for them though.

                                                            Also, define ‘good’.

                                                            1. 1

                                                              Also, define ‘good’.

                                                              No, you do. :)

                                                              (the whole point is for people to come up with judgments like this)

                                                              1. 3

                                                                But because all you’re effectively requiring of yourself is to sit back and say “that’s bad, and that, and that too” about every submission without ever presenting a counterexample of something you’d consider good, you’ve pre-determined the outcome.

                                                                That sort of lazy and unadventurous criticism is never useful or constructive.

                                                                1. 1

                                                                  I haven’t reviewed a single thing yet, and I’m already accused of lazy criticism of submitted projects. :D

                                                                  I can give examples of non-OOP projects like that which are worth reviewing. Anytime anyone asks Rust community for a good project to learn from people point to https://github.com/BurntSushi/ripgrep/ (not mine). I could come up with more.

                                                                  If I was to show something I wrote I would probably pick https://github.com/dpc/rdedup or https://github.com/crev-dev/cargo-crev . Not too polished, but good enough for spare-time project. High level design is actor oriented and inside actors data-oriented, as I describe in https://dpc.pw/how-i-structure-my-apps-in-rust-and-other-languages .

                                                            2. 1

                                                              I feel the point about “not libraries or frameworks” needs to be more clearly adressed (already brought up in a sibling comment) - most practical, current OOP programs are likely to be in a class-oriented language: ruby, python, smalltalk, objective-c, Java, c++ and c# all fall into that group AFAIK. Possibly there’s some OOP in common lisp that does not? (and potentially in Javascript, I suppose; using prototypes, not the new classes).

                                                              In any project one would generally find useful abstractions that fit the problem domain, then use these to solve the problem. Ideally the main program is a trivial combination of appropriate abstractions.

                                                              For OOP languages, that would typically be a set of classes and interfaces in the form of a library or framework?

                                                              So that would be the interesting part?

                                                              Maybe the author can give an example of “good” structured/procedural/functional code?

                                                              1. 1

                                                                OOP banter aside, what’s the point of individual examples of code? OOP is just one tool of many and you should pick the best tool for the use case.

                                                                I’d like to submit https://hub.spigotmc.org/javadocs/bukkit/. It’s oss Minecraft server code and this example is wonderfully relatable to even non-programmers.

                                                                1. 1

                                                                  Do you have link to the code handy? This seems to be generated documentation. Also, it seems it’s a framework, and not the e2e app. I’m not strict about it, just double checking.