Hello again, reader and fellow Dev. If you've been here before, you know I've been a Flatiron School student for the last few months. It's been some time since I wrote a piece here on dev.to, but I'm back at it now, writing blogs as an alumn!
I'm actively job hunting at the moment and so it's a great time to review some foundational concepts that will certainly be asked about during the interview process.
Today, we'll start at the beginning...
Why objects?
Objects, as you might guess, are incredibly important in Object Oriented Programming, otherwise known as OOP. They're important because by creating objects we eliminate the need to write redundant and repetitive code. When we create an object it can be called from anywhere within a program instead of having to be recreated every time it is needed.
What are objects, and what do objects have?
Objects are the basic units of object-oriented programs and have two basic things- state and behaviors.
The state reflects that objects current state, which is stored in variables. The behaviors associated with that object are typically called methods, and can be called on that object.
A simple example would be your car. As an object, it has a current state- it can be on, running, or off. Some methods you might be able to call on your car object would be things like:
turnOn(); drive(); reverse(); and so on.
The most important thing about objects is that they are little packages of information. An object knows its own properties and carries its methods with it. Unlike procedural programming, where a variable is declared and a function is written separately from it, in object-oriented programming we are able to call methods on the object itself. Additionally, having objects makes it possible for objects to interact with other objects.
Top comments (0)