Functions, classes, methods Flashcards
How do you get a function to run within source code?
You “call” it.
How are functions represented in pseudocode?
functionName()
What is the difference between a function declaration and a function
definition?
Function declaration = only names a function and its arguments
(def greet(name):
print(“Hello, “ + name + “!”)
greet(“Alice”))
(“Alice” is the argument passed to the greet function)
Function definition = the function as a whole
How is a class different to an object?
A class is a blueprint for an object, similar to architectural plans for a house. An object, on the other hand, is an instance of a class with specific state, like a house built from those plans.
What is the relationship between a method and an event?
An event is a specific method that gets “triggered” when an object’s state changes, It is designed to react to changes within an object.
How are methods represented in pseudocode?
objectName.methodName()