Hey y'all!
So I swear one of these assignments will actually be below 5 minutes, if I have to start making cuts! 🤣
Anyways, this week's assignment was all about Classes and the implementation of Object Oriented Programming!
So what is object oriented programming! Well friend here are a couple of highlights to explain to you just what that is!
What are the four pillars of Object-Oriented Programming? Explain each pillar.
Abstraction
Has to do with the removal of certain details of a program for the sake of simplicity or removing repeated code. Creating simplicity by pulling away the complexity into another reusable component.
Encapsulation
The pillar revolves around wrapping your code into it’s own private subsection that is capable of maintaining it’s own state. We do this again for code simplicity and also for including specific behaviors and values only where they are absolutely necessary. Essentially a categorization.
Inheritance
This pillar has to do with the ability of your programs to get certain behaviors and properties from larger parent classes, and those classes inherit from larger parent classes.
Polymorphism
The ability of our classes to take many forms and be able to implemented in different locations. We can grow and share common or unique behaviors throughout the program where necessary.
Resources:
https://www.freecodecamp.org/news/four-pillars-of-object-oriented-programming/
https://backend.turing.edu/module1/lessons/four_pillars_of_oop
What is the relationship between a Class and an Object?
A class is like a blueprint for an object, an object is an instance of a class and contains the properties and behaviors that are derived from its parent class.
https://caml.inria.fr/pub/docs/oreilly-book/html/book-ora140.html
What is an exception and what are best practices for handling them?
An exception is essentially an error that gets thrown by our code whenever something has gone awry with our code. This could be an unexpected value, using the wrong value, connection issues, time outs, etc etc. We can handle exceptions via couple of methods. We can use the try{}catch{} block that was recently added to catch any error and notify the user and our server of any issues that might have occurred, or if it’s apart of a promise chain, then we can use the .catch() method on the promise object.
So what did I do this week?
We were tasked with creating a menu applications using only classes and OOP patterns! I decided to create an implementation of a sandwich shop that not only took in special name but also their prices AND it was capable of adding multiple specials on it's initial creation!
My assessment of the difficulty of this project would probably be pretty low? It's not super complicated when you think of each class as almost like a blue print and each object it creates as essentially using that blueprint to create the new thing!
So what's my favorite part of this week? Good question....Hmm I like the portability of OOP, kinda write it here, take it anywhere mentality really rings true to me!
What's my most proud code block? Well I'm glad you asked! (Even if you didn't)
This little sucker right here did loops and array methods that are complicated and oop patterns all in one and it was genuinely entertaining to walk my way through it 🤣