OOP - Intro Flashcards
Object-oriented programming
A programming paradigm based on “objects,” which contain state (attributes) and behavior (methods). Synonyms: OOP. Used in a Sentence: “OOP means we will define classes, and use classes to make objects”
Object
A collection of structured data along with the operations that can be performed on that data. An object is one instance of a class. Synonym: Instance. Used in a Sentence: “In OOP, we’ll be making a lot of objects,” “We should invoke the add_friend method on the User object,” “Each User object in the User list will have an ID”
Objects are things that represent concepts as data, hold their own distinct state, and carry out behaviors related to the concept they represent.
Objects are the primary building blocks for problem solving in object-oriented programming languages like Python.
Class
A template or blueprint used to create objects of a specific data type. Defines what concrete objects will look like. Synonym: Prototype. Used in a sentence “The String class defines all of the attributes and methods that String objects have.”
Instance
One particular object of a certain data type/class. Follows the format defined by its class, and has specific, individual state.. Synonym: Object. Used in a sentence “That specific User instance has an ID of 25,” “We should instantiate a new User instance here, then save it to the database,” “The method add_friend takes in one instance of User as a parameter”
State
A generic term for the data that an object “knows” at one point in time. Usually, state can change over time. Used in a sentence “When a User object sends a message, the program checks the state of online_status”
Attribute
A named property of a class. Attributes are used to keep track of state. Synonym: Property, field, “attr”. Used in a sentence “The User class defines the attribute online_status,” “The online_status attribute is a boolean,” “We check the online_status property before we send a message”
Behavior
A generic term for what an object can “do.” Used in a sentence: “The User class should have the behavior of adding a friend to the friend list”
Method
A function that is defined inside of a class. Methods are usually used to describe behavior. Synonym: Function Used in a sentence “We need to call the add_friend method on User,” “User’s send_message method checks the state of online_status at the beginning”