representation of a real world entity (book, car, student, etc)
When designing a new system identify all objects that you need to deal with (student, parent, alumni, donation, etc)
OR
a particular instance of a class where the object can be a combination of variables or data structures and functions, procedure, or methods.
a template for creating the objects. It identifies what data needs to be stored (in fields) for the objects of this type and what methods are available to allow access to this data
Constructor method of the class has the same name as the class.
OR
an extensible program-code-template for creating objects, providing initial values for states, and implementations of behaviors.
Declaration: a variable declaration with a variable name with an object type.
Instantiation: the ‘new’ keyword is used to create the object.
Initialization: the ‘new’ keyword is followed by a call to a constructor, this call initializes the new object.
Instantiating objects uses RAM
Every time a new object is instantiated from a base class a space equivalent to the whole object is reserved in RAM
RAM can be wasted as it is reserved but not used
Use the most memory efficient variables
Creating a linked list (dynamic data type) of objects is good because only memory actually being used is reserved.
It is bad to create an array (static data type) of objects because potential memory could be wasted in reserving space that might not be needed.
Data (or states) are variables or data structures like arrays/lists
Actions (or behaviour) which can be methods
Object - refers to a particular instance of a class, where the object can be a combination of variables or data structures (called states) and functions, procedures, or methods (behaviors).
Class - an extensible program-code-template for creating objects, providing initial values for states (variables) and implementations of behaviors.
Associations are shown with lines or arrows.
Shows the objects, variables, and methods.
The possible number of classes that can be had in the relationship
For example for each user class there can be many recipes
Exactly one (1)
Zero or one (0..1)
Zero or more (*)
One or more (1…*)
Ordered (ordered)
Part of relationship
When class 2 is a part of class 1
But they still have separate lifetimes
A type of aggregation where the parts are destroyed when the whole is destroyed
Class 2 cannot stand by itself, it dies and lives with class 1
An object of one class might use an object of another class in the code of a method
If the object is not stored in any field other than this it is modeled as a dependency relationships
Exists between two classes - changes to the definition of one may cause changes to the other (but not vice versa)
Class 1 depends on class 2
A relationship between the blueprint class and the object containing the respective implementation level details
Eg: the owner interface might specify methods for acquiring property and disposing of property. Both the person and corporation classes implement these methods but in different ways
Integer
Real (double)
String
Boolean
Data is stored as a combination of binary values in the computer.
Data types are used to store different kinds of data.
They are needed because they specify to the computer how to interpret the binary values in the storage.
Boolean 1 byte
Integer 4 bytes
Real 8 bytes
String - multiple the number of characters by two then add 38, then round up to the next multiple of 8
Parameters allow information or instructions to be passed into functions and procedures
Parameters are the names of information that we want to use in a function or procedure
Return type
Function name
Parameters
Int product (int x, int y)
Pass an int to the method change() and as a result the change in the value of that int is not reflected in the main method
Java creates a copy of the variable being passed in the method and then does the manipulations
Hence the change is not reflected in the main method