Leaving Pastafarianism

Apr 09, 2024

FlyingSpaghettiMonster

Using Procedural Programing is when you write out every line of code and link procedures together to compete functions while the computer works from top to bottom as needed to complete the lines of code. This is not only inefficient, but it is very difficult to read and begins to look like matrix spaghetti. 

Procedural Programming is one of the earliest ways to write code and languages like Fortran and Cobol relied nearly exclusively on this type of programming. This type of programming becomes difficult to work with when attempting to increase the number of relationships and the level of complexity in our code. At a certain point it begins to resemble the plot to the Back To The Future trilogy jumping from procedures to functions and back again and creating a spaghetti of confusion that is difficult to read, comprehend, or make changes to.

Thankfully there is Object Oriented Programing (OOP). OOP is a way to split up complex programs into more manageable chunks by dispersing them into separate modules and creating separate classes that can be turned into Objects so they can work together to complete a singular objective.

Modules, Classes, and Objects:

The easiest way to explain how OOPs function is to use the metaphor of a restaurant. Can one person run an entire restaurant by themselves? Yes, but it would be a very small restaurant and it would limit the restaurant greatly. This would be the equivalent of Procedural Programing. OOP in the metaphor of this restaurant is the use of a chef, a waiter, a cleaner, and a manager, multiple people working together to create a functional restaurant. Each person has their role based on their area of expertise; this would be their module. The difference between a Class and an Object is a Class is the blueprint and the Object is the fruition of the blueprint. Think of the difference between a job posting for a waiter and an actual waiter. The job posting is just the idea of a waiter and broken down to its base parts and the actual waiter can be used in the restaurant and has the capability to affect the world around them.

Attributes and Methods:

The difference between an attribute and a method is very simple, it’s the difference between something an object has and what an object does. Attributes are like saying the dog has four legs and a tail. The dog doesn’t do anything to give himself a tail or four paws, they are attributes of the dog. If the dog barks or runs then those are methods. Methods are any action the Object is taking and all methods must be defined and can even alter attributes of Objects.

Multiple Objects From One Class:

To create a Class one must initialize it and define its attributes, but to create an object one must call the class and tie it to a variable that will then become an object. The class itself can be used indefinitely to create an endless amount of Objects and any attributes placed onto the Object itself will be specific and unique to that object only.

class Car:
    def __init__(self):
        self.doors = 4
        self.seats = 5
        self.wheels = 4
car1 = Car()
car2 = Car()
car3 = Car()
car1.color(“red”)
car2.color(“green”)
car3.color(“purple”)
The result is three separate cars; car1 will be red, car2 will be green, car3 will be purple, and all three cars will have four doors, four wheels, and five seats. To see another example of generating multiple Objects from a single Class click here.

Justin.TadrosJustin Tadros is a Project Manager and Data Analyst at The Training Boss. Justin has a bachelor degree in Theater performance from Rollins College and currently pursuing his Masters in business at the University of Center Florida.  Justin is certified on Microsoft Power BI and Progress Sitefinity Sales accreditation with on going training on Python and CMS technologies.  Justin performs in theaters in Orlando, Boston, Alaska and stand up comic whenever the opportunity arises.  His passion for performing and bringing incredible customer service to any industry he approaches is second to his commitment, dedication and hard work.

Tags:

Playlist for Sitefinity on YouTube

 

Playlist for Microsoft Fabric on YouTube

 

Playlist for AI on YouTube

Copyright © 2024 The Training Boss LLC

  Developed with Sitefinity 15.1.8321 on ASP.NET 8