Re:Why Are So Many Developers Hating on Object-Oriented Prog...
by jplayer01 on Saturday August 24, 2019 @05:02AM
(#20786089)
Except there's no book or course or whatever that can teach somebody these things. Instead, everybody has to figure it out on their own, and usually they just don't. Engineering disciplines don't work this way. I don't understand why it's okay for software development.
Re:Why Are So Many Developers Hating on Object-Oriented Prog...
by csande17 on Saturday August 24, 2019 @02:06PM
(#20788660)
University curricula often try to expose students to a wide variety of programming paradigms. I'm not sure how you could walk out of Berkeley's CS 61 series thinking that there's One True Way to write all programs, for example.
Re:Why Are So Many Developers Hating on Object-Oriented Prog...
by fanf2 on Saturday August 24, 2019 @09:21AM
(#20786966)
There are books and courses that try, eg https://www.info.ucl.ac.be/~pvr/book.html
A good rule of thumb is that your code should be as close as possible to a plain-English description of what you want the code to do.
So if you're trying to write a program like "When you click the button, it turns grey, and then sends the message, and then turns blue when the message is done being sent", imperative programming is probably your best bet. If you're writing "find all the posts that contain the word 'donut'", something like SQL or functional programming is probably a good fit. You can usually tell when you made the wrong choice when you end up needing to think really hard about how to fit the behavior you want into your paradigm, or when you have to write a big long comment saying, "This isn't very clear from the code, but here's what it's trying to do..."
And as GP says, there isn't any one paradigm that's good for everything, so well-written programs will often use a mix of them. If someone tries to tell you that one size fits all (all programs should be imperative C! all programs should be object-oriented Enterprise Java Beans! all programs should be functional TypeScript!), that's usually because they aren't a very good programmer.