University of London / MSc Computer Science: Software design and programming(後半)

University of London / MSc Computer Science: Software design and programming(後半)

July 2, 2024

ロンドン大学で MSc Computer Science: Software design and programming モジュールを履修中。

講義内容に関して記録した個人的なスタディノートです。

全 12 週のうち 6〜12 週目の内容を記録します。(6 週目開始:2024 年 5 月 13 日 / 12 週目終了:2024 年 7 月 1 日)

Week 6: Design patterns I #

レクチャーのキーコンセプト

  • design Patterns
  • reducing boilerplate code.

レクチャーリスト

  • Overview of design patterns
    • Lecture 1: Design patterns – An introduction
  • Design patterns
    • Lecture 2: An introduction to creational design patterns
    • Lecture 3: An introduction to structural design patterns
    • Lecture 4: An introduction to behavioural design patterns

Lecture 1: Design patterns – An introduction #

A pattern describes a problem which occurs over and over again in our environment and then describes the core of the solution to that problem so that you can use this solution a million times over without ever doing it the same way twice.

Christopher Alexander

According to the Gang of Four (GoF), there three categories of the design patterns.

  • creational design patterns
  • structural design patterns
  • behavioural design patterns

Lecture 2: An introduction to creational design patterns #

  • Creation of complex objects
  • They hide how complex objects are created and put together

Lecture 3: An introduction to structural design patterns #

  • Composing objects to form larger structures
  • Realise new functionality from old functionality
  • Provide flexibility and extensibility

Lecture 4: An introduction to behavioural design patterns #

  • Algorithms and assignment of responsibilities to objects
  • Avoid tight coupling to a particular solution

Further material #

Week 7: Design patterns II #

レクチャーのキーコンセプト

  • Design patterns in Java

レクチャーリスト

  • Design patterns in Java
    • Lecture 1: Design patterns in Java
    • Lecture 2: (screencast): Creational Design patterns worked examples in Java
    • Lecture 3: (screencast) Structural Design patterns worked examples in Java
    • Lecture 4: (screencast): Behavioural Design patterns worked examples in Java
  • Case Study
    • Lecture 5: (screencast) Worked example
  • Labs
    • Practical: Design patterns – Creational
    • Practical: Design patterns – Structural
    • Practical: Design patterns – Behavioural

Lecture 1: Design patterns in Java #

(内容省略)

Lecture 2: (screencast): Creational Design patterns worked examples in Java #

(内容省略)

Lecture 3: (screencast) Structural Design patterns worked examples in Java #

(内容省略)

Lecture 4: (screencast): Behavioural Design patterns worked examples in Java #

(内容省略)

Lecture 5: (screencast) Worked example #

(内容省略)

Further material #

Week 8: Graphical user interfaces #

レクチャーのキーコンセプト

  • graphical user interfaces
  • cross-platform interfaces
  • event handling,
  • callbacks
  • asynchronous and synchronous behaviour.

レクチャーリスト

  • GUI concepts
    • Lecture 1: Graphical User Interfaces: Model-view controller
    • Lecture 2: Event handling
    • Lecture 3: (screencast) Components and layout
    • Lecture 4: Cross-platform issues
  • Java provisions - AWT, Swing, and JavaFX
    • Lecture 5: AWT
    • Lecture 6: Swing
    • Lecture 7: JavaFX
  • Cross-platform frameworks
    • Lecture 8: (screencast) JavaFX Example
    • Lecture 9: (screencast) Introduction to Flutter
  • Labs
    • Practical: JavaFX

Lecture 1: Graphical User Interfaces: Model-view controller #

  • MVC stands for model-view-controller.
    • The model is the actual internal representation.
    • The view is a way of looking at or displaying the model.
    • The controller provides for user input and modification.
  • A model does “business logic”:
    • It should be I/O free.
    • Communication with the model is via methods.
    • This approach gives maximum flexibility in how the model is used.
  • The controller organises the program and provides input (control) o the model.
  • The view displays what is going on in the model:
    • It should never display what should be going on in the model.
    • For example, if you ask to save a file, the view shouldn’t itself tell you that the file has been saved - it should tell you what the model reports.

Lecture 2: Event handling #

  • Event: an object representing an external happening that can be observed by the program.
  • Event-driven programming: a style of programming where the main thing the program does is respond to Events.
  • Event loop: a loop that waits for an Event to occur, then dispatches it to the appropriate code.
  • GUI: a graphical user interface (user interacts with the program via things on the screen).

Lecture 3: (screencast) Components and layout #

(内容省略)

Lecture 4: Cross-platform issues #

(内容省略)

Lecture 5: AWT #

Abstract window toolkit (AWT)

import java.awt.*;
import java.awt.event.*;

Swing

import javax.swing.*;

Swing versus AWT

  • Swing is bigger, slower, and more complicated (but much faster than it used to be).
  • Swing is more flexible and better looking.
  • Swing and AWT are incompatible. You an use either, but you cannot mix them (actually, you can, but it is tricky and not worth doing).
  • Learning the AWT is a good start for learning Swing.

Lecture 6: Swing #

(内容省略)

Lecture 7: JavaFX #

JavaFX is the platform for creating desktop and we application developed by Oracle Corporation.

  • Rich set of UI controls
  • Easy integration with Java
  • Styling and customisation options
  • Hardware acceleration for smooth graphics
  • Cross-platform compatibility

Lecture 8: (screencast) JavaFX Example #

(内容省略)

Lecture 9: (screencast) Introduction to Flutter #

(内容省略)

Further material #

Week 9: Modules and versioning #

レクチャーのキーコンセプト

  • modules versioning
  • JPMS
  • OSGi
  • build tools
  • CI/CD.

レクチャーリスト

  • Modules and versioning
    • Lecture 1: Overview
    • Lecture 2: JPMS – the Java platform module system
    • Lecture 3: OSGi – an alternative approach
  • Packaging and managing the build process
    • Lecture 4: (screencast) Packaging - jar files
  • Labs
    • Practical: Modules, versioning, packaging and the build process
    • Practical: OSGi modularity and services
    • Practical: Build a CI/CD pipeline with GitHub actions

Lecture 1: Overview #

(内容省略)

Lecture 2: JPMS – the Java platform module system #

The JPMS allows the division of large codebases into smaller, self-contained modules.

Lecture 3: OSGi – an alternative approach #

OSGi is an alternative module system.

  • It allows for the creation of independently deployable bundles.
  • It enables runtime installation, update nad removal of modules without system restarts.
  • It promotes loose coupling through a service-oriented programming model.

Lecture 4: (screencast) Packaging - jar files #

(内容省略)

Further material #

Week 10: Concurrency and parallelism #

レクチャーのキーコンセプト

  • concurrency
  • parallel processing
  • virtual environments.

レクチャーリスト

  • Concurrency and parallelism
    • Lecture 1: An introduction
    • Lecture 2: (screencast) Concurrency through examples
    • Lecture 3: (screencast) Parallelism through examples
    • Lecture 4: (screencast) Virtual environments through examples
  • Concurrency and parallelism through Java
    • Lecture 5: (screencast) Synchronization in Java, Part 1 - Race conditions, locks, and conditions
    • Lecture 6: (screencast) Synchronization in Java, Part 2 - The synchronized keyword
    • Lecture 7: (screencast) Synchronization in Java, Part 3 - Atomic operations and deadlocks
  • Virtual environments
    • Lecture 8: Developing code in the Cloud
    • Lecture 9: (screencast) Docker by example
  • Labs
    • Practical: Concurrency and parallelism
    • Practical: Project Loom

Lecture 1: An introduction #

Difference between concurrency and parallelism

# Concurrent (Single Core)
T1 ----------------┐      ┌------->
    Context Switch |      |
T2                 └------┘        -------->


# Parallel (Multiple Core)
T1 -------------------------------------------->

T2 -------------------------------------------->

What is Concurrency?

Concurrency is the ability of a computer system to execute multiple tasks simultaneously, where each task progresses independently and makes progress over time.

  • Interleaved execution
  • Shared resources
  • Synchronisation

Challenges

  • Race conditions: when multiple task access and manipulate shared resources, unexpected and incorrect results may occur.
  • Deadlocks: situations where two or more tasks are unable to proceed because each is waiting for the other to release a resource.
  • Synchronisation overhead: coordinating access to shared resources introduces additional complexity and can impact performance.

What is Parallelism?

Parallelism involves dividing a large task into smaller subtasks that can be executed simultaneously by multiple processors or cores.

  • Task decomposition
  • Independent execution
  • Concurrent progress

Concurrency vs Parallelism

  • Concurrency focuses on managing multiple tasks, providing interleaved execution and synchronisation, regardless of the available resources.

  • Parallelism focuses on dividing tasks into subtasks that can be executed simultaneously, taking advantage of multiple processing units or cores.

  • Concurrency and parallelism can be combined to achieve optimal performance in certain scenarios.

  • Concurrent execution can be used within a parallel program to manage shared resources and synchronise operations.

Lecture 2: (screencast) Concurrency through examples #

(内容省略)

Lecture 3: (screencast) Parallelism through examples #

(内容省略)

Lecture 4: (screencast) Virtual environments through examples #

(内容省略)

Lecture 5: (screencast) Synchronization in Java, Part 1 - Race conditions, locks, and conditions #

Lecture 6: (screencast) Synchronization in Java, Part 2 - The synchronized keyword #

Lecture 7: (screencast) Synchronization in Java, Part 3 - Atomic operations and deadlocks #

Lecture 8: Developing code in the Cloud #

(内容省略)

Lecture 9: (screencast) Docker by example #

(内容省略)

Further material #

Week 11, 12 #

最終課題の期間。CLI 上で実行するようなゲームアプリを Java の Spring Boot で開発する。具体的には、以下の Domination の模倣品のようなものを作成する。(以下は GUI で実行するアプリだが、課題はこれを CLI で実行するものとして作成する。)