|
|
|
Data abstraction: |
|
introductory concepts |
|
|
|
|
How to build components of a software system. |
|
Foundational notions of value/type and object/class. |
|
Java primitives. |
|
Reference values. |
|
|
|
|
|
|
value: a fundamental pieces of information that
can be manipulated in a program. |
|
type: a set of related values along with the
operations that can be performed with them. |
|
|
|
|
|
2 kinds of values: |
|
simple (atomic): integers, characters |
|
composite: date(day, month, year),
string(several characters) |
|
Values are abstractions used to model various
aspects of a problem. |
|
|
|
|
Values grouped together according to how we use
them and what operations we perform on them. |
|
Example:Integers use +,-,<,>, etc. |
|
|
|
|
Built-in types. |
|
Java primitives: byte, short, int, long, float,
double, char, and boolean. |
|
Java has no built-in composite primitives. |
|
|
|
|
|
Integers: |
|
byte (1 byte) |
|
short (2 bytes) |
|
int (4 bytes) |
|
long (8 bytes) |
|
Used for counting (whole numbers). |
|
|
|
|
|
Floating point: |
|
float (4 bytes) |
|
double (8 bytes) |
|
Used to represent things we measure (anything
with a decimal point). |
|
The computer’s representation may not be exact. |
|
|
|
|
char includes upper case and lower case letters,
digits, punctuation marks, and other special characters. |
|
Characters contained in the Unicode character
set. |
|
Used for input/output. |
|
|
|
|
Only 2 values: true or false. |
|
|
|
|
The fundamental abstractions from which we build
software systems. |
|
Designed to support the functionality of the
system. |
|
Responsible for performing specific tasks. |
|
|
|
|
Furnish relevant information about what the
object represents. |
|
properties: characteristics about which the
object provides information. |
|
Each property has an associated value. |
|
queries: requests for information concerning
properties. |
|
|
|
|
The values of properties can change at any time. |
|
state: the set of an object’s properties and
associated values at any given time. |
|
|
|
|
Commands instruct the object to perform some
action which often results in the object changing state. |
|
At any given time, a particular value is
associated with each property of an object. |
|
|
|
|
|
|
|
|
What are the objects? |
|
What features should these objects have? |
|
|
|
|
|
What must an object know? |
|
The properties of the entity the object is
modeling, and |
|
About other objects with which it needs to
cooperate. |
|
|
|
|
|
What must an object do? |
|
Compute particular values. |
|
Perform actions that modify state. |
|
Create and initialize other objects. |
|
Control and coordinate the activities of other
objects. |
|
|
|
|
Asking what an object knows: object queries. |
|
Asking what an object does: object commands and queries. |
|
|
|
|
|
|
|
Queries: |
|
How many tickets have we sold? |
|
How many tickets are left? |
|
Properties: |
|
Next ticket number |
|
Tickets left |
|
|
|
|
|
|
Queries: |
|
Where is a certain piece? |
|
What color is a player’s pieces? |
|
Is a player in check? |
|
Properties: |
|
Player’s color |
|
Piece’s position |
|
|
|
|
|
|
Commands: |
|
Move a piece? |
|
Change whose turn it is? |
|
|
|
|
|
|
An object is an instance of a class. |
|
A class specifies the features of a group of
similar objects. |
|
Two objects from the same class will have the
same set of queries and commands, but usually contain different values. |
|
|
|
|
A relation associates two or more objects in a
specific, well defined way. |
|
Relations define how objects interact to solve a
problem. |
|
An object’s property can be a reference to
another object. |
|
|
|
|
|
A value that denotes an object |
|
null reference: refers to no object. |
|
|
|
|
|
Introduction of fundamental notions of values
and objects. |
|
Java provides: |
|
Integer types (byte, short, int, long) |
|
Real or floating type (float, double) |
|
Character type ( char) |
|
Boolean type (boolean--true/false) |
|
|
|