Classes, Methods And Attributes Flashcards
What is a “Class”?
It is the thing you make in a program that represents a physical thing in the world. Or rather, a category of digitalised versions of specific things in the world.
For example, “Animal” can be a class containing specific reptiles, amphibians, fishes and land mammals in a program.
It’s important to remember that these are digitised versions of our concepts of the world.
What is a method?
It’s what describes what actions a class or object can do. In computer science, this is a piece of code that does something specific, and usually leads to changing the value of an attribute.
What is an attribute?
An attribute describes the properties of an object or class. As a rule of thumb, try to make a method for every attribute. The values an attribute has better be changed by methods.
What are some elements of an attribute?
Visibility modifier, data type, attribute name, default value, semicolon.
What are the elements of a method?
Visibility modifier, return type, method name, parameter list, method body.
What does the visibility modifier private mean for an attribute?
For a class Customer with attributes lastName, firstName, sex and birthDate with private as a visibility modifier, this means that the attributes are “visible” or “accessibile” only inside the class.