Spaghetti Code
Before we can start delving deep into the world of oop we need to first revisit our code to date and understand its limitations. one very common name to procedural code is spaghetti code. we will explore why that names became so popular and why moving away from it will make your life easier.
Video Transcript
00:00First of all, let's talk about kind of like why did object oriented programming become such a big
00:06deal. And if any of you works in procedural coding, which is the name of the regular way of
00:11coding, one of the biggest challenges was with procedural coding is that the more things you have
00:17to do in your application, the more code you have. Now, that's kind of logical. But you get
00:25the scenarios where you have 500 lines, 100, 1000 lines, 2000 lines, and it goes on and on and on.
00:31And at some point, it becomes impossible to manage. At some point, you have so much code,
00:35and you have to be able to fix above or to be able to add a feature or to be able to do anything in
00:41your code becomes almost impossible. And that's why a lot of times procedural coding is kind of
00:46coined at the term spaghetti code, which is basically just because everything is intertwined
00:52with each other, as your application becomes bigger and bigger, it becomes harder and harder
00:56to actually manage your own application and your application slowly slowly becomes this
01:01beast that is uncontrollable. So nano in our slide, I wrote non object oriented programs are
01:10built per need, and grouped into functions mainly for repetition and need, the bigger
01:16the application, the more intertwined it gets and the harder it is to then unravel it,
01:21which is basically what I just said right now. So basically, and obviously, hopefully,
01:25you're familiar with functions, and you've worked with functions and variables. And basically,
01:30a lot of times, you're going to be using functions if you're not an object oriented coder,
01:34really, just so you can repeat some action a few times, or you can organize stuff into
01:39into buckets. So they're a little bit easier for you to work with.
01:45But even functions start getting overwhelming. So if you have 100 functions, 1000 functions,
01:5110,000 functions, suddenly, your code becomes, again, unmanageable, or really, really hard
01:57to manage. Not only that, it's also hard for you to share your code with other people because
02:01they have to actually know what you're coding on to actually know how to help you or how to
02:04understand what's going on. Alright, so now that we got our assumption, and we understand why we
02:10actually why traditional way of coding probably isn't the best way of coding, the procedural
02:17way of coding has its limitations. They're great when you're building a small application,
02:21that's like 100 lines of code, 500 lines of code, very simple, very easy to work with.
02:26But as your application becomes bigger, it becomes harder to work with, it's kind of the
02:30exact opposite with object oriented programming, object oriented programming, when you're building
02:34something small, doing it enough is relatively hard and cumbersome versus doing it in a procedural
02:41way, it's very easy when you're building a small application, and vice versa, building
02:46a very complicated application and object oriented programming becomes easier and easier,
02:50because you don't have to deal with as much issues as you would in a procedural way of coding.
