The Problem with Object-Oriented Programming

NeetCodeIO · Intermediate ·⚡ Algorithms & Data Structures ·2y ago

Key Takeaways

The video discusses the limitations and drawbacks of Object-Oriented Programming (OOP), highlighting how it can lead to abstraction, complexity, and over-optimization, and how it may not always be the best approach to solving real-world problems. It also touches on the SOLID principles and their role in OOP.

Full Transcript

so let's see what he has to say about object oriented and I technically pre-at this but it's interesting what one of the big problems with software right is that starting in the 80s prior to the 80s everybody was just trying to solve real problems and trying to get computers to solve real problems right and then start I hate to interrupt like 13 seconds into the video but this is partially what I was saying and I hate too much abstraction in the older days there was obviously less distraction because as more time goes on we get better ways of doing things higher level programming languages right like Java has more abstraction than something like C where you are closer to the hardware layer that's what I mean by the word abstraction and so this is especially prevalent in front-end development where you hardly even know what's going on under the hood anymore I bet a lot of front-end developers hardly even know like what a web API is but anyways let's continue starting around the 80s computers got fast enough that you had a lot more leeway around how you solve the problems and people started making all these theories about how to uh how to solve problems in the best way and so object-oriented programming is like one of those theories right oh on the list of things in C++ that are wrong objectoriented is wrong right because of course um uh Alan K invented the term object-oriented and it meant something else it meant small talk not C++ I'm not sure what he's talking about there I mean I believe him I assume he's right anybody who's older in programming is usually right the inventor of the term object oriented he's often quote as saying what we call is not what he metant I made up the term and I can tell you I didn't have C++ in mind okay well I'll just believe him so like even the term objectoriented is wrong the way people use it anyway so people came up with all these ideas about how to program and then the problem is those ideas require entire belief structures right so if you go to program in C++ object-oriented World representation style then you start to believe from the way that you're taught that programming work is about building the hierarchy of objects in the right way or something but that's not actually solving a problem it's just conforming to a belief structure that you've been given after you've decided on that hierar of objects you still don't have a program that solves any problems now you have to go write the program within that framework that you decided on right so I watched this video the other day I don't even remember what he says in the rest of it but regardless of what you believe and what programming Paradigm you ascribe to what he just said is 100% correct right object-oriented programming itself doesn't solve a problem it's just away and and he's right you get to a point where now you're not actually dealing with like the code that solves a problem now you're dealing with the higher level thing and maybe I'm using this word wrong but I don't think I am the abstraction now you add that layer of objectoriented programming abstraction on top of everything and you're making your functions dance behind classes to have this weird hierarchy you can't program like that unless you actually understand the world of object oriented programming all the principles open close this that it does take you away from being able to solve those problems in some way it adds like a layer of complexity now the reason it was created in the first place there is a reason because some problems are hard and object oriented programming can simplify a lot of really complex problems it makes sense that it does exist and so the problem is as we get further and further away from real actual problems more and more of what is taught to people as programming is actually not doing anything it's just shuffling papers around on your desk right and so like the question of how do I do an interface that blah blah blah is just shuffling the papers around on your desk because it's not actually solving a problem like what I would say is write the editor and then write the plugins or whatever write the functionality make all the functionality work and then if you're dispatching between them with an if statement and it feels kind of hacky and you need more abstraction for a very concrete reason then put in a function pointer but I wouldn't even do that I would just have an if statement that turns them on or off for a long time because it's it's actually a relatively that part of writing an editor is so small and so another thing I agree with with what he said and I was actually reading an article about like solid principles this is why I'm going to make this point but people talk a lot about the dependency inversion principle like you should depend on abstractions and all that even even if there's only one implementation of an interface or just one instance of a class that's going to be a dependency basically what I'm getting at is like if you've ever programmed in Java before like an existing codebase you see that a class has dependency a you go to the definition of dependency a it's an interface okay so you actually want to see the implementation you want to see the actual functions in the code for class A then you have to find okay what implements Class A you find a class it's an abstract class you're just trying to look for the damn like implementation just the actual code not all these empty interfaces and Abstract classes sometimes it's just so annoying first of all people feel the need to like over optimize or prematurely optimize things everything needs to be extensible even though I just have like five classes why does it everything have to be abstracted like what if 10 years from now I want to adds a different dependency to this class well I got to make it extensible why not just refactor it at that point point I'm not saying there's a perfect solution depending on how big your codebase is what the company standards are and all that fine but I think people do like especially like the way it's taught in school the way it was taught to me it's like these are like the principles and you shall not break these programming principles but if you're going to be like practical sometimes it's better to sometimes it simplifies the code in terms of what it solves that I wouldn't even bother for a long time um on the other hand if you buy into a weird structure or many weird structures which is what happens in order to preemptively solve this very small problem before it becomes a problem you end up taking on all these very large belief structures that are actually very hard to conform to and you have to conform to those belief structures all the time because that's what that's what you made your program be and it actually gives you a much bigger job to do than you actually have to do to solve the actual physical problem that you have in the objective world world all right so that's that's the the best thing that I can say about this I mean it's just so true like how can anybody disagree with this video because he's right like what if you wrote some code that perfectly solves a problem but there's some violations of the solid principle sprinkled in there well that could be an indication that your code just kind of sucks fine and true that can happen like you can there is a such thing as just really badly written code but you have code that solves the problem now you have a second problem you have to make sure your code follows certain principles like he said they're not always easy to conform to it's not easy to make your code follow all the objectoriented programming principles I saw this mentioned in another video before we won't watch the whole video cuz it's 45 minutes but I would recommend anybody go watch this video if you want to learn more about why object oriented programming is bad and when I say bad I I use object orent programming I've used it I don't think it's like the devil but the way he describes it it's basically assembly line programming developers are too dumb to make code that works so you got to give them like building blocks and rules to make sure that they follow so that code can always be readable and extendable by like a new Dev team that joins and things like that

Original Description

🚀 https://neetcode.io/ - A better way to prepare for Coding Interviews Clip from the video: https://www.youtube.com/watch?v=04ksL1hf_p8 I stream on my main YT channel: @NeetCode 🧑‍💼 LinkedIn: https://www.linkedin.com/in/navdeep-singh-3aaa14161/ 🐦 Twitter: https://twitter.com/neetcode1 #neetcode #leetcode #python
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from NeetCodeIO · NeetCodeIO · 0 of 60

← Previous Next →
1 Leetcode 149 - Maximum Points on a Line - Python
Leetcode 149 - Maximum Points on a Line - Python
NeetCodeIO
2 Design Linked List - Leetcode 707 - Python
Design Linked List - Leetcode 707 - Python
NeetCodeIO
3 Minimum Time to Collect All Apples in a Tree - Leetcode 1443 - Python
Minimum Time to Collect All Apples in a Tree - Leetcode 1443 - Python
NeetCodeIO
4 Design Browser History - Leetcode 1472 - Python
Design Browser History - Leetcode 1472 - Python
NeetCodeIO
5 Number of Good Paths - Leetcode 2421 - Python
Number of Good Paths - Leetcode 2421 - Python
NeetCodeIO
6 Flip String to Monotone Increasing - Leetcode 926 - Python
Flip String to Monotone Increasing - Leetcode 926 - Python
NeetCodeIO
7 Maximum Sum Circular Subarray - Leetcode 918 - Python
Maximum Sum Circular Subarray - Leetcode 918 - Python
NeetCodeIO
8 Find Closest Node to Given Two Nodes - Leetcode 2359 - Python
Find Closest Node to Given Two Nodes - Leetcode 2359 - Python
NeetCodeIO
9 Concatenated Words - Leetcode 472 - Python
Concatenated Words - Leetcode 472 - Python
NeetCodeIO
10 Data Stream as Disjoint Intervals - Leetcode 352 - Python
Data Stream as Disjoint Intervals - Leetcode 352 - Python
NeetCodeIO
11 LFU Cache - Leetcode 460 - Python
LFU Cache - Leetcode 460 - Python
NeetCodeIO
12 N-th Tribonacci Number - Leetcode 1137
N-th Tribonacci Number - Leetcode 1137
NeetCodeIO
13 Best Team with no Conflicts - Leetcode 1626 - Python
Best Team with no Conflicts - Leetcode 1626 - Python
NeetCodeIO
14 Greatest Common Divisor of Strings - Leetcode 1071 - Python
Greatest Common Divisor of Strings - Leetcode 1071 - Python
NeetCodeIO
15 Shortest Path in a Binary Matrix - Leetcode 1091 - Python
Shortest Path in a Binary Matrix - Leetcode 1091 - Python
NeetCodeIO
16 Insert into a Binary Search Tree - Leetcode 701 - Python
Insert into a Binary Search Tree - Leetcode 701 - Python
NeetCodeIO
17 Delete Node in a BST - Leetcode 450 - Python
Delete Node in a BST - Leetcode 450 - Python
NeetCodeIO
18 Shuffle the Array (Constant Space) - Leetcode 1470 - Python
Shuffle the Array (Constant Space) - Leetcode 1470 - Python
NeetCodeIO
19 Fruits into Basket - Leetcode 904 - Python
Fruits into Basket - Leetcode 904 - Python
NeetCodeIO
20 Number of Subarrays of size K and Average Greater than or Equal to Threshold - Leetcode 1343 Python
Number of Subarrays of size K and Average Greater than or Equal to Threshold - Leetcode 1343 Python
NeetCodeIO
21 Naming a Company - Leetcode 2306 - Python
Naming a Company - Leetcode 2306 - Python
NeetCodeIO
22 As Far from Land as Possible - Leetcode 1162 - Python
As Far from Land as Possible - Leetcode 1162 - Python
NeetCodeIO
23 Shortest Path with Alternating Colors - Leetcode 1129 - Python
Shortest Path with Alternating Colors - Leetcode 1129 - Python
NeetCodeIO
24 Minimum Fuel Cost to Report to the Capital - Leetcode 2477 - Python
Minimum Fuel Cost to Report to the Capital - Leetcode 2477 - Python
NeetCodeIO
25 Count Odd Numbers in an Interval Range - Leetcode 1523 - Python
Count Odd Numbers in an Interval Range - Leetcode 1523 - Python
NeetCodeIO
26 Contains Duplicate II - Leetcode 219 - Python
Contains Duplicate II - Leetcode 219 - Python
NeetCodeIO
27 Path with Maximum Probability - Leetcode 1514 - Python
Path with Maximum Probability - Leetcode 1514 - Python
NeetCodeIO
28 Add to Array-Form of Integer - Leetcode 989 - Python
Add to Array-Form of Integer - Leetcode 989 - Python
NeetCodeIO
29 Unique Paths II - Leetcode 63 - Python
Unique Paths II - Leetcode 63 - Python
NeetCodeIO
30 Minimum Distance between BST Nodes - Leetcode 783 - Python
Minimum Distance between BST Nodes - Leetcode 783 - Python
NeetCodeIO
31 Design Hashmap - Leetcode 706 - Python
Design Hashmap - Leetcode 706 - Python
NeetCodeIO
32 Range Sum Query Immutable - Leetcode 303 - Python
Range Sum Query Immutable - Leetcode 303 - Python
NeetCodeIO
33 Binary Tree Zigzag Level Order Traversal - Leetcode 103 - Python
Binary Tree Zigzag Level Order Traversal - Leetcode 103 - Python
NeetCodeIO
34 Middle of the Linked List - Leetcode 876 - Python
Middle of the Linked List - Leetcode 876 - Python
NeetCodeIO
35 Course Schedule IV - Leetcode 1462 - Python
Course Schedule IV - Leetcode 1462 - Python
NeetCodeIO
36 Single Element in a Sorted Array - Leetcode 540 - Python
Single Element in a Sorted Array - Leetcode 540 - Python
NeetCodeIO
37 Capacity to Ship Packages - Leetcode 1011 - Python
Capacity to Ship Packages - Leetcode 1011 - Python
NeetCodeIO
38 IPO - Leetcode 502 - Python
IPO - Leetcode 502 - Python
NeetCodeIO
39 Minimize Deviation in Array - Leetcode 1675 - Python
Minimize Deviation in Array - Leetcode 1675 - Python
NeetCodeIO
40 Longest Turbulent Array - Leetcode 978 - Python
Longest Turbulent Array - Leetcode 978 - Python
NeetCodeIO
41 Last Stone Weight II - Leetcode 1049 - Python
Last Stone Weight II - Leetcode 1049 - Python
NeetCodeIO
42 Construct Quad Tree - Leetcode 427 - Python
Construct Quad Tree - Leetcode 427 - Python
NeetCodeIO
43 Find Duplicate Subtrees - Leetcode 652 - Python
Find Duplicate Subtrees - Leetcode 652 - Python
NeetCodeIO
44 Sort an Array - Leetcode 912 - Python
Sort an Array - Leetcode 912 - Python
NeetCodeIO
45 Ones and Zeroes - Leetcode 474 - Python
Ones and Zeroes - Leetcode 474 - Python
NeetCodeIO
46 Remove Duplicates from Sorted Array II - Leetcode 80 - Python
Remove Duplicates from Sorted Array II - Leetcode 80 - Python
NeetCodeIO
47 Maximum Twin Sum of a Linked List - Leetcode 2130 - Python
Maximum Twin Sum of a Linked List - Leetcode 2130 - Python
NeetCodeIO
48 Concatenation of Array - Leetcode 1929 - Python
Concatenation of Array - Leetcode 1929 - Python
NeetCodeIO
49 Symmetric Tree - Leetcode 101 - Python
Symmetric Tree - Leetcode 101 - Python
NeetCodeIO
50 Check Completeness of a Binary Tree - Leetcode 958 - Python
Check Completeness of a Binary Tree - Leetcode 958 - Python
NeetCodeIO
51 Construct Binary Tree from Inorder and Postorder Traversal - Leetcode 106 - Python
Construct Binary Tree from Inorder and Postorder Traversal - Leetcode 106 - Python
NeetCodeIO
52 Find Peak Element - Leetcode 162 - Python
Find Peak Element - Leetcode 162 - Python
NeetCodeIO
53 Accounts Merge - Leetcode 721 - Python
Accounts Merge - Leetcode 721 - Python
NeetCodeIO
54 Binary Tree Preorder Traversal (Iterative) - Leetcode 144 - Python
Binary Tree Preorder Traversal (Iterative) - Leetcode 144 - Python
NeetCodeIO
55 Binary Tree Postorder Traversal (Iterative) - Leetcode 145 - Python
Binary Tree Postorder Traversal (Iterative) - Leetcode 145 - Python
NeetCodeIO
56 Number of Zero-Filled Subarrays - Leetcode 2348 - Python
Number of Zero-Filled Subarrays - Leetcode 2348 - Python
NeetCodeIO
57 Minimum Score of a Path Between Two Cities - Leetcode 2492 - Python
Minimum Score of a Path Between Two Cities - Leetcode 2492 - Python
NeetCodeIO
58 Sqrt(x) - Leetcode 69 - Python
Sqrt(x) - Leetcode 69 - Python
NeetCodeIO
59 Successful Pairs of Spells and Potions - Leetcode 2300 - Python
Successful Pairs of Spells and Potions - Leetcode 2300 - Python
NeetCodeIO
60 Optimal Partition of String - Leetcode 2405 - Python
Optimal Partition of String - Leetcode 2405 - Python
NeetCodeIO

The video teaches viewers to critically evaluate the use of Object-Oriented Programming in system design and to consider the potential drawbacks of over-optimization and abstraction. It highlights the importance of code readability and extendability in designing systems. Viewers will learn to apply the SOLID principles to improve code quality and to design systems with flexibility in mind.

Key Takeaways
  1. Evaluate the problem you're trying to solve and consider whether OOP is the best approach
  2. Consider the trade-offs between complexity and simplicity in system design
  3. Apply the SOLID principles to improve code quality
  4. Design systems with readability and extendability in mind
  5. Avoid over-optimization and abstraction when they're not necessary
💡 Object-Oriented Programming is not always the best approach to solving real-world problems, and developers should consider the potential drawbacks of over-optimization and abstraction when designing systems.

Related AI Lessons

Bloom Filters, Explained Properly
Learn how Bloom filters work and their benefits, including tiny memory and blazing speed, in exchange for potential false positives.
Dev.to · Daksh Gargas
Prefix Sums: The Preprocessing Trick That Makes Range Queries Instant
Learn how prefix sums enable instant range queries in arrays, boosting performance in various applications
Medium · Programming
I Thought I Was Ready for the Interview — Then One Simple Math Question Destroyed Me
A simple math question can destroy a developer's interview, highlighting the importance of being prepared for unexpected questions
Medium · Programming
Week 2(Day 10): LeetCode Two Pointers(slow & fast): Remove Duplicates from Sorted Array (Brute…
Learn to remove duplicates from a sorted array using the two pointers technique, improving from brute force to optimized solutions
Medium · Python
Up next
Stump Grinder Carbide Wheel Grinds Hardwood To Chips
Innoforge Studio
Watch →