1/22
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
procedural programming
writing programs made of functions that perform specific tasks
object-oriented programming
focused on creating objects
object
entity that contains data and procedures
encapsulation
combining data and code into a single object
data hiding
object’s data attributes are hidden from code outside the object
object reusability
the same object can be used in
different programs
data attributes
define the state of an object (clock object would have second, minute, + hour data attributes)
public methods
allow external code to manipulate the
object (set_time, set_alarm_time)
private methods
used for object’s inner workings
class
code that specifies the data attributes and
methods of a particular type of object (cookie cutter)
instance
an object created from a class (specific cookie)
class definition
set of statements that define a class’s
methods and data attributes (class Class_name:)
self parameter
required in every method in the class –
references the specific object that the method is working
on
new instance
call initializer method (My_instance=Class_Name()), then to call methods use My_instance.method()
initializer method
automatically executed when an
instance of the class is created (def __init__(self):)
hiding attributes
two underscores in front of attribute name (__current_minute)
instance attribute
belongs to a specific instance of a
class
object’s state
the values of the object’s attribute at a
given moment
__ str __ method
displays the object’s state, called when object is passed to the print function, vice versa
accessor methods
return a value from a class’s
attribute without changing it (get function)
mutator methods
store or change the value of a data
attribute (set function)
passing objects as arguments
sending an instance of a class (object) to a method
UML diagram
standard diagrams for graphically
depicting object-oriented systems (box divided into 3 sections)