Object Oriented Programming 2 Flashcards
Rich API support
Doing / learning networking, parallelism, graphics, GUI, algorithms
Why is java platform independent
It runs in a virtual machine: JVM
Why learn Java?
Active development, many jobs, platform indep, tools (networking, …)
Java and Distributed Systems
Socket communication, thread management, object serialization, remote method invocations, servlets, applets
Java compilation
Programm compiled into bytecode, which the JVM executes at runtime
Object
Combines methods (behaviour) and data (state),
hide complexity, modularization, modelling of domain
How are objects defined
throught the keyword “class”
“volatile”
ensures visiblity accross threads, safe to use across threads
Interface
Defines a group of methods, classes implement them to provide functionailty, implementation enforced at compilation
static nested classes
no access to outer members, to hide access
Named constants
entirely in uppercase with underscore
Creation of Arrays:
anArray = new int[10];
float[] anArrayOfFloats;
int[] anArray = {
100, 200, 300,
400, 500, 600,
};
Casting
Cast allows access to specific object
methods
Defensive copies
gainst outside failures, ill-behaved clients, or attacks
also for getters
varargs
represent zero or
more arguments of a specified type
Parallelism (concurrency)
one computer that does multitasking, real (processors) or pseudo (threads)
Distributed system
Networked components, coordinated by messages
Server threads
within server process; handle concurrent user requests
Server processes
handle different types of access
(e.g., web, mail, file, …)
Remote Invocation
Client invocation and server result
RPC (remote procedure call) or RMI (remote method invocation)
Requires defined messaging protocoL
Server State:
Stateful (client tables)
Soft state (for given time)
Session state (for session)
Stateless
Thread-based Connection Abstraction
incoming request -> accepted by dispatcher thread
Threaded Server Design Patterns
Fix or dynamic number of threads
Re-usage of threads: thread pool (created at start), non active threads kept in pool
Thread per Request
dispatcher reveives request, for each a thread is created or assigned from pool
Worker thread: Read request
Process request
Answer request
End