OO organises code into classes, properties, and methods. The simplest way to explain is with examples:.
Class: The definition of a Reddit account.
As part of my class, I need to define:
Properties: The information I need to store against a RedditAccount. I need a user name and an email address.
Methods: What I can do with a RedditAccount. I can create a post, reply to a post, or edit a post.
So what’s an object? It’s what I get when I actually use my class for something. Also referred to as an “instance”. AlterEdward is my RAccount object. It’s had all its properties populated, which means I can use its methods to make posts.
Latest Answers