If you see this banner, your environment is correctly configured.
3.0
Section 3: HTTP Fundamentals
How the web communicates
3.1
3.1 What is HTTP?
HTTP stands for HyperText Transfer Protocol. Originally developed (1989-1991) by Tim Berners-Lee for transmitting web pages, it has evolved into a general-purpose protocol for communicating on the web.
Key properties of HTTP:
Asymmetric: distinguishes between client and server. The client initiates a request and the server sends a response.
Application-level: HTTP sits on top of TCP/IP (other transport layers are possible).
Text-based: messages are human-readable character strings.
Figure 3.1: The client-server request-response model of HTTP.
3.2
3.2 HTTP Messages — Requests & Responses
A URI (Uniform Resource Identifier) specifies a resource, e.g.:
GET: GET /?name=John (in URL)
POST: POST / with name=John in body
3.4
3.4 A Simple Java Web Server
Java can create a basic web server using the built-in HttpServer class:
// Create server listening on port 8080
HttpServer server = HttpServer.create(new InetSocketAddress(8080));
// Handle requests to "/" using the handleRequest method
server.createContext("/", handleRequest);
server.start();
// Handler: respond with HTML
private static void handleRequest(HttpExchange exchange) {
String response = "<h1>Hello</h1>";
exchange.getResponseHeaders().put("Content-Type",
List.of("text/html"));
exchange.sendResponseHeaders(200, response.length());
exchange.getResponseBody().write(response.getBytes());
exchange.close();
}
The Content-Type header tells the browser what kind of content is in the response body (e.g. text/html).
3.Q
Knowledge Check — HTTP
Q1: In HTTP, who initiates the communication?
HTTP is asymmetric: the client always initiates the request, and the server replies with a response.
Q2: What HTTP method does a hyperlink (<a href="/">) generate?
HTML links always generate GET requests. Only forms can use POST.
4.0
Section 4: Java Review
OOP, Interfaces, SOLID, Generics, Records
4.1
4.1 Inheritance: Extend Carefully, Don't Modify
class Animal {
public void animalSound() {
System.out.println("Animal makes noise.");
}
public void sleep() {
System.out.println("Zzz");
}
}
class Dog extends Animal {
public void animalSound() { // Override
System.out.println("woof woof");
}
}
SOLID Principles at play:
O (Open/Closed):Animal should be open for extension but closed for modification. Don't change sleep() — it would break Dog.
L (Liskov Substitution): Overridden methods in Dog must be consistent with the superclass contract.
4.2
4.2 Interfaces Promote Maintainability
Think of interfaces as behaviour contracts — they define what an object can do, not how:
interface Animal {
void animalSound();
void sleep();
}
class Dog implements Animal {
public void animalSound() {
System.out.println("woof");
}
public void sleep() {
System.out.println("Zzz");
}
}
Why interfaces?
Loose coupling: code depends on the interface, not a concrete class
Replaceability: swap Dog for Cat without changing calling code
// Can easily replace Dog() with Cat()
Animal myAnimal = new Dog();
myAnimal.animalSound();
In this unit, Spring Boot uses interfaces extensively to make components replaceable. This is a key enterprise principle.
A class should have only one job. E.g. User shouldn't have both saveToDatabase() and sendEmail().
O
Open/Closed
Open for extension (subclass), closed for modification.
L
Liskov Substitution
Subclass behaviour must be consistent with superclass.
I
Interface Segregation
Use small, focused interfaces rather than one large one.
D
Dependency Inversion
Depend on abstractions (interfaces), not concrete classes.
4.4
4.4 Generics & Objects.equals()
Generics (type-safe collections)
ArrayList<String> cars = new ArrayList<>();
cars.add("Volvo");
System.out.println(cars.get(0));
// Output: Volvo
<String> tells the compiler this list only holds Strings. Avoids runtime errors.
Objects.equals() for safe comparison
Integer j = 30000000;
Integer k = 30000000;
// WRONG - fails for large Integers
j == k // false!
// WRONG - NullPointerException if null
i.equals(j) // crash if i is null
// CORRECT - null-safe
Objects.equals(j, k) // true
Always use Objects.equals(a, b) for comparing objects. It handles null safely.
4.5
4.5 Java Records — Concise Data Classes
Records (Java 14+) are immutable classes for data, eliminating boilerplate:
With Records (1 line)
record Person(String name,
String address) {}
Person joe = new Person("joe",
"1 Way Drive");
System.out.println(joe.name());
// Output: joe
What the compiler generates
class Person {
private final String name;
private final String address;
// Constructor
public Person(String name,
String address) {...}
// Getters
public String name() {...}
public String address() {...}
// equals(), hashCode(), toString()
}
Records are used heavily in enterprise code for data transfer objects — objects that carry data between layers.
4.Q
Knowledge Check — Java Review
Q1: Why should you use interfaces rather than inheritance for loose coupling?
Interfaces define a contract (what to do), not implementation (how). This lets you replace Dog with Cat without changing the rest of the code.
Q2: What does the "S" in SOLID stand for?
S = Single Responsibility: a class should have only one reason to change — only one job.
5.0
Section 5: UML & Database Review
Use Case Diagrams, Class Diagrams, ERDs
5.1
5.1 Use Case Diagrams (UCDs)
UCDs visualise who does what at an eagle's-eye perspective:
Figure 5.1: A simple Use Case Diagram.
Best practices:
Group small use cases with the same objective
Merge CRUD (Create, Read, Update, Delete) into a single "Manage X" use case
Use cases often map to menus in your application
Tools like PlantUML.com can render diagrams from text
5.2
5.2 Class Diagrams
Class diagrams capture data requirements — entities, attributes, and relationships:
Figure 5.2: EACH Customer has one or more Accounts.
Read cardinalities as: "EACH Customer has one or more Accounts" — not "Customers can have many Accounts."
5.3
5.3 ERD Relationships (COIT11237 Review)
Relationships have degree (how many entities) and cardinality (how many instances):
The three types of binary relationships (determined by maximum cardinalities):
Type
Example
Implementation
1:1
Employee ↔ Locker
FK in either table (choose wisely)
1:N
Department ↔ Employees
FK in the "many" side table
N:M
Students ↔ Classes
Intersection (junction) table
5.4
5.4 Foreign Keys & Intersection Tables
1:N — "Rob from 1, give to many"
Copy the PK of the "1" side as a FK into the "many" side table.
N:M — Use an Intersection Table
Neither PK can be a FK, so create a new table with a composite primary key:
Figure 5.4: N:M resolved via an intersection table (Enrolment).
5.Q
Knowledge Check — UML & Databases
Q1: In a 1:N relationship, where does the Foreign Key go?
"Rob from 1, give to many" — copy the PK of the "1" side as a FK into the "many" side.
Q2: How do you implement an N:M relationship physically?
Neither entity's PK can act as a FK, so you create a new intersection table whose PK is composed of both entities' PKs.
6.0
Section 6: JDBC & the Repository Pattern
Connecting Java to databases
6.1
6.1 Java Database Connectivity (JDBC)
From COIT11237 (SQL) and COIT12200 (JDBC), you know how to:
// SQL examples
CREATE TABLE test_table (id INT PRIMARY KEY, name VARCHAR(255))
INSERT INTO test_table VALUES (1, 'Alice')
SELECT * FROM test_table
In Java, JDBC connects to databases. H2 can be used as an in-memory database for development and testing:
Connection c = DriverManager.getConnection("jdbc:h2:mem:testdb", "sa", "");
Statement stmt = c.createStatement();
stmt.execute("CREATE TABLE test_table (id INT PRIMARY KEY, name VARCHAR(255))");
stmt.execute("INSERT INTO test_table VALUES (1, 'Alice')");
ResultSet rs = stmt.executeQuery("SELECT * FROM test_table");
while (rs.next()) {
System.out.println(rs.getString("name")); // Alice
}
6.2
6.2 The Repository Pattern
A Repository abstracts data access — it acts like a collection of domain objects, hiding the underlying SQL or database details.
record Employee(int id, String name,
int age) {}
class EmployeeRepository {
void save(Employee e) {
String query =
"INSERT INTO Employee " +
"(id, name, age) VALUES ...";
// Execute SQL
}
Employee findById(int id) {
String query =
"SELECT * FROM Employee " +
"WHERE id = ?";
// Execute & return
}
}
7.0
Section 7: Enterprise Software
Architecture, NFRs & the 3-Tier Pattern
7.1
7.1 What is Enterprise Software?
Enterprise = large organisation (e.g. government, hospital, bank). Different enterprises have different complex requirements.
Components of an Information System:
Domain examples:
Healthcare — medical records (JSON, HL7/FHIR)
Retail, Banking, Government — different priorities (security vs speed)
A key choice: build or buy (SaaS)?
7.2
7.2 The 3-Tiered Architecture
Figure 7.2: The 3-tiered enterprise architecture with cross-cutting concerns (Fernando 2022, Ch 2).
This unit will teach you each tier: Persistence (Weeks 2-4), REST (Weeks 5-6), MVC (Week 7), Security (Week 8), and Microservices (Weeks 9-11).
7.3
7.3 Non-Functional Requirements (NFRs)
Enterprise systems have competing quality attributes. You can't maximise all of them:
Example trade-off:
A banking system prioritises security over latency — it's OK to be slightly slower if transactions are safe. A streaming service (Netflix) prioritises latency and scalability.
7.4
7.4 Enterprise Considerations
Distributed teams — collaboration tools required (Git, CI/CD)
System integration — components communicate via N-tier or web services
Error handling — systems may be unreachable or change versions. Dependency Injection (DI) allows testing using mocks.
Separation of duties — developers may have partial view/control:
Cannot update the DBMS directly
Can only use logs to diagnose issues in production
Architecture choices: N-Tiered (this unit first) vs. Microservices (Weeks 9-11)
Reading: Chapter 1 of Fernando, C 2022, Solution Architecture Patterns for Enterprise, Apress.
7.Q
Knowledge Check — Enterprise Software
Q1: What are the three tiers in a 3-tiered enterprise architecture?
The three tiers are: Presentation (UI/View), Business Logic (Controllers/Services), and Data Persistence (Database/ORM).
Q2: Why do NFRs "compete" in enterprise systems?
NFRs are trade-offs. For example, adding encryption (security) adds processing time (latency). Architects choose which NFRs to prioritise based on the domain.
8.0
Section 8: Design Patterns Preview
Singleton & MVC
8.1
8.1 Singleton Pattern
Singleton ensures a class has only one instance and provides a global access point to it.
class DatabaseConnection {
private static DatabaseConnection instance;
private DatabaseConnection() {
// Private constructor prevents external instantiation
}
public static DatabaseConnection getInstance() {
if (instance == null) {
instance = new DatabaseConnection();
}
return instance;
}
}
// Usage: always get the SAME instance
DatabaseConnection db1 = DatabaseConnection.getInstance();
DatabaseConnection db2 = DatabaseConnection.getInstance();
// db1 == db2 is TRUE
Use Singleton when exactly one object is needed (e.g. database connections, configuration, loggers).
8.2
8.2 Model-View-Controller (MVC) Pattern
MVC separates an application into three components: Model (data & business logic), View (UI), and Controller (input handling & coordination).
Figure 8.2: The MVC pattern — Controller is the glue between Model and View.
We will build MVC applications with Spring Boot and Thymeleaf in Week 7.
8.Q
Knowledge Check — Design Patterns
Q1: What does the Singleton pattern guarantee?
Singleton uses a private constructor + static getInstance() method to ensure only one instance ever exists.
Q2: In MVC, which component handles user input?
The Controller receives user input, coordinates between Model (data) and View (display), and acts as the "glue".
9.0
Week 1 Summary
What to do next
9.1
9.1 Week 1 Recap & Next Steps
This week you covered:
Development environment setup (OpenJDK 26, VS Code, Spring Boot extensions)
HTTP fundamentals (client-server, requests & responses, HTML forms)