Goodbye, Object Oriented Programming
medium.com
Goodbye, Object Oriented Programming
1–10 of 355 posts
Re: Goodbye, Object Oriented Programming
#2I'm at a loss as to what this has to do with encapsulation, and even less able to understand how any language with user-defined data types is going to be able to avoid it.
Re: Goodbye, Object Oriented Programming
#3Apple calls Swift a "protocol-oriented" programming language, and with the addition of first class value types, tries to solve these problems in their own way.
I'd definitely suggest people frustrated by the problems outlined in this post to check out the Apple talk on protocol-oriented programming in Swift.
Re: Goodbye, Object Oriented Programming
#4The author's beef with encapsulation seems to be that when an object A is used as an argument in the constructor to object B, the latter needs to do a deep copy (as keeping a pointer is not "safe"), which is of course not always possible. I'm at a loss as to what this has to do with encapsulation, and even less able to understand how any language with user-defined data types is going to be able to avoid it.
Re: Goodbye, Object Oriented Programming
#5Functional came before OO and there are reasons why it became much more popular- it had much better, easier and simpler solution to the most common problems of the 90's and early 2000's, namely handling GUI and keeping single process app state (usually for a desktop app).
It fares much worse in today's world of SaaS and massive parallel computing.
Frankly I think the discussion will be much better if we debate the merrits of each paradigm in the problem domain you are facing, rather then blindly bashing on a paradigm that is less suited to your problem domain.
For instance I have yet to see an easy and simple to use (and as such maintainable) functional widget and gui library.
Re: Goodbye, Object Oriented Programming
#6I think the functional vs OO debate is being done with a very narrow point of view. Functional came before OO and there are reasons why it became much more popular- it had much better, easier and simpler solution to the most common problems of the 90's and early 2000's, namely handling GUI and keeping single process app state (usually for a desktop app). It fares much worse in today's world of SaaS and massive parall…
Like react?
Re: Goodbye, Object Oriented Programming
#7Interesting. I almost though this was going to be an advertisement for Swift, since I saw this exact argument in a WWDC talk. Apple calls Swift a "protocol-oriented" programming language, and with the addition of first class value types, tries to solve these problems in their own way. I'd definitely suggest people frustrated by the problems outlined in this post to check out the Apple talk on protocol-oriented progra…
Re: Goodbye, Object Oriented Programming
#8Interesting. I almost though this was going to be an advertisement for Swift, since I saw this exact argument in a WWDC talk. Apple calls Swift a "protocol-oriented" programming language, and with the addition of first class value types, tries to solve these problems in their own way. I'd definitely suggest people frustrated by the problems outlined in this post to check out the Apple talk on protocol-oriented progra…
If you're writing a Mac or iOS app, you're generally writing Cocoa with either Swift or ObjC syntax. Cocoa is unbearably stateful. For a simple app, you not only don't get to work with value types, you typically don't even get functions or methods which return anything.
Obviously for something more complex, your non-UI code can absolutely be written with the principles described in that video in mind, but if you try to apply those principles to Cocoa APIs directly, you're going to be fighting against its stateful nature constantly.
Re: Goodbye, Object Oriented Programming
#9OOP has its benefits, I've been using it judiciously for 20+ years, and I've made an entire career out of it. Functional Programming has its benefits as well, but it also has its drawbacks (gasp!) much like everything else.
There is no One True Way. Nothing is infallible. You write code to solve problems, end of story. Some methodologies make some problems easier to solve, and others made other problems easier to solve. Getting hung up on the religious aspect of coding is entirely masturbatory.
Re: Goodbye, Object Oriented Programming
#10Class Copier { Scanner scanner; Printer printer; function start() { printer.start(); } }
---
Placing a Start() in a PoweredDevice base class doesn't make sense in the real world. There are plenty of "powered devices" that don't have start buttons. A phone, a fish tank pump, a smoke alarm, none have a "start." A powered device should have just that, a PowerOn() and PowerOff() or SetPower(bool isOn). I wouldn't even create a PoweredDevice base class unless you have a reason. This is the main fault in your design.
Scanner.Start() should return a byte[] which is the result of the scan: byte[] Scanner.Start(); A scanner is an input device.
Printer.Start() should take an argument of byte[] as to what it is to print: void Printer.Start(byte[] byteArr); A printer is an output device.
Having said that, your Copier class would look like this:
Class PoweredDevice
{
void SetPower(bool isOn)
{
...
}
// Start() doesn't belong here.
}
Class Copier : PoweredDevice
{
Scanner scanner;
Printer printer;
void override SetPower(bool isOn) {
printer.SetPower(isOn);
scanner.SetPower(isOn);
base.SetPower(isOn);
}
void Start()
{
byte[] document = scanner.Start();
printer.Start(document);
}
}
This can easily be enhanced to handle copy counts: void Start()
{
byte[] document = scanner.Start();
for (int x = 0; x
Ideally you wouldn't even make an inheritable Start() method. The Scanner class would have a byte[] Scan() method and the Printer class would have a Print(byte[] byteArr) method. You're trying to ram a square peg into a round hole. Use inheritance when it is convenient and makes sense to do so. Don't force it. Think, what does a scanner and a printer have in common that works the same, then put that in your base class. A power button is about it.A lot of inheritance is done backwards. You make your classes then find commonalities and put that in your base class. Only create a base class first if you've thought about your object model and you know the commonalities.
Also, there is no reason to make your inheritance chain deep, just because. Build your objects in a way that makes sense. Don't write code or base objects you will never use. You can always insert a class in the chain when necessary.
Mastering OOP is hard, and people who have mastered it get paid a lot of money for their skill. It took me a few years to really understand how to design with it. It's invaluable though. A good object model is a thing of beauty, and a hell of a lot of fun to design.
Edit: I don't know why the editor won't keep the CR's.