Abstraction and modularisation
Abstraction
Abstraction is to ignore details of parts of a problem to be able to understand and describe a problem on a high level.
Link to original
Modularisation
Modularisation is the process of dividing a whole into well-defined parts, which can be built and examined separately, and which interact in well-defined ways.
Link to original
A debugger is a software tool that helps in examining how an application executes.
Java operators
The ‘division’ operator, , when applied to int operands, returns the result of an integer division.
The ‘modulo’ operator, , returns the remainder of an integer division.
You can abuse this to create a rollover, e.g. .
Classes as types
Data can be classified under many different types: such as primitive types like integer, boolean, floating-type. Each class is also a unique data type: e.g. String, TicketMachine, Display.
Hence, data types are composites and not just values.
Variables of object types store references to objects hence are passed by reference.
Primitive types
Primitive types in Java are ==non-object types.
Examples include int, boolean, char, double, long==.
Primitive types have no methods and are passed by value.
null operator
null is a special value in Java, all object variables are by default initialised to `null`.
You can both assign and test for null.
private ClassName obj;
if (obj == null) { ... }
obj = null;Object interaction
Two objects interact when one object calls a method on another. The interaction is typically in one direction. One object can ask another object to do something or ask for data.
public class ClassName {
private Display a;
public ClassName() {
a = new Display();
}
public void inc() {
a.increment();
}
}The general form for external method calls is `object.methodName(params);`
Internal method calls do not require the object name: `updateSelf();` but it is preferred to write `this.updateSelf();`
Overloading
Overloading means that a class may contain more than one constructor, or more than one method of the same name, as long as each has a distinct set of parameter types.