freddo@feddit.nu to Programmer Humor@programming.devEnglish · 4 hours agoOOP at home:feddit.nuimagemessage-square16fedilinkarrow-up196
arrow-up196imageOOP at home:feddit.nufreddo@feddit.nu to Programmer Humor@programming.devEnglish · 4 hours agomessage-square16fedilink
minus-squaretiramichu@sh.itjust.workslinkfedilinkarrow-up65·4 hours agoI’ll say this now. Inheritance is the most misused capability of OOP which programmers think makes their code look smart, but most of the time just makes a giant fucking mess.
minus-squarered_tomato@lemmy.worldlinkfedilinkarrow-up42·edit-24 hours agoHold on, I’m in the middle of drawing an inheritance graph so I know how Dog is related to AircraftCarrier.
minus-squareblackn1ght@feddit.uklinkfedilinkEnglisharrow-up35·edit-24 hours agopublic interface ICanTravelThroughTheAir { } public class Flea : ICanTravelThroughTheAir { } public class AircraftCarrier { private readonly List<ICanTravelThroughTheAir> _aircraft = new(); public void AddAircraft(ICanTravelThroughTheAir flyingThing) { _aircraft.Add(flyingThing); } } public class Dog : AircraftCarrier { public void Woof() { Console.WriteLine("Bitch I'm an aircraft carrier!"); } } public static class Program { public int Main(string[] args) { var dog = new Dog(); for (var i = 0; i < 10000; i++) { dog.AddAircraft(new Flea()); } dog.Woof(); } }
minus-squarejenesaisquoi@feddit.orglinkfedilinkEnglisharrow-up27·3 hours agoNeeds more AbstractDefaultProxyBeanFactoryFactories
minus-squareFunkyCheese@lemmy.dbzer0.comlinkfedilinkEnglisharrow-up5·2 hours agoI learned about it in school and we didna few assignments for it But… never seen or heard anyone mention it outside of that I guess we can make up some nische vases I did hear it can be useful for video games though. But then again im sure people can manage fint without, as well
minus-squarevapeloki@lemmy.worldlinkfedilinkarrow-up3·3 hours agoAnd polymorphism is the only way you could expose those composite Interfaces as bindings on C API based languages. And polymorphism is part of OOP. If we take the text book definition of OOP, then the kernel is OOP …
I’ll say this now.
Inheritance is the most misused capability of OOP which programmers think makes their code look smart, but most of the time just makes a giant fucking mess.
Hold on, I’m in the middle of drawing an inheritance graph so I know how Dog is related to AircraftCarrier.
public interface ICanTravelThroughTheAir { } public class Flea : ICanTravelThroughTheAir { } public class AircraftCarrier { private readonly List<ICanTravelThroughTheAir> _aircraft = new(); public void AddAircraft(ICanTravelThroughTheAir flyingThing) { _aircraft.Add(flyingThing); } } public class Dog : AircraftCarrier { public void Woof() { Console.WriteLine("Bitch I'm an aircraft carrier!"); } } public static class Program { public int Main(string[] args) { var dog = new Dog(); for (var i = 0; i < 10000; i++) { dog.AddAircraft(new Flea()); } dog.Woof(); } }Needs more
AbstractDefaultProxyBeanFactoryFactoriesI learned about it in school and we didna few assignments for it
But… never seen or heard anyone mention it outside of that
I guess we can make up some nische vases
I did hear it can be useful for video games though. But then again im sure people can manage fint without, as well
And polymorphism is the only way you could expose those composite Interfaces as bindings on C API based languages. And polymorphism is part of OOP.
If we take the text book definition of OOP, then the kernel is OOP …