1 - 159.225 System Analysis and Modelling

1.1 - Intro to Systems Analysis and Modelling

What is System

There are two jobs mainly for system

  • achieve goals
  • MOST IMPORTANTLY add value to existing system

A system generally contain 2 character, user and developer. Developer can get value from user and user needs will accomplished from system

For programmer build a system using code. before writing they need a plan.

What is Systems Analysis and Modelling?

Programmers need to know what to write.

They can not just write as ‘I THINK’

image.png

a large assignment need cooperation and need required that everybody understand clear and no confusion. Most IMPROTANT, we need find a way providing value to ognization by meeting requirement from user.

To accompish that , programmer need follow rules

  • identifying the problem that needs to be solved
  • analysing the current situation (resources or evidence needed to find a solution)
  • identifying requirements for the new system(requirement from user)
  • modelling those requirements in a systematic way
  • creating a clear specification all above

Let’s leave a question here ==Q: What is modelling?==

as you may asking, is it all about design a system?

Well…..yes, but there are different definitions of design

analysis is problem focused, while design is solution focused. However, one morphs into another through the process. when model existing problem and model our new design of process.

a good analysis is important, so when to start? just before coding?

analysis start Right at the beginning ! When the project idea is first formed, some systems analysis activities are appropriate.

after first version formed, developer can continue throughout, depending on SDLC methodology, which will talk later

as mentioned before , developers should meet user’s need, somtimes they can not realised what they really want. To get fully understyand user’s idea developers Need to spend time with the users and observeand understand the current situation, systems and environment.

Modelling

OK, let’s explain former question, What is modelling. model is a way to define a analysised situation, which contain all data needed.

There are three layer of modelling,

image.png

Conceptual Analysis and Modelling is in high level

image.png

conceptual modelling sketches out broad concepts.

Logical analysis and modelling is more detailed and physical is much more based //todo

From requirement to analysis and modelling, we need a workflow to develop project. Let’s introduce Systems Development Life Cycle (SDLC)

SDLC

This is the MAIN concept of modelling requirement and analysis, which is the key part of hole lesson. we will talk deeply in later chapter

image.png

image.png

the workflow called Systems Development Life Cycle (SDLC), it’s a process of gradual refinement Each phase consists of a series of steps and Each phase is documented (deliverables) Phases are executed sequentially, incrementally, iteratively or in some other pattern

we don’t need to understand pattrns here, we foucs on 4 phase

Required Gathering

The most critical step for SDLC. when trying develop a system. Good method of requirement gathering can prepared

Lab & Exercise 1

Documenting Lab1

Overview: A wealthy entrepreneur and art lover has decided to create an online system called ArtSpace, to assist in the display and sale of works of art. She has employed you to create a design for the system. The system is intended to bring together a range of different user groups who are interested in art sales and purchases: artists; art dealers; serious art buyers and collectors; and casual members of the public who may consider buying art works on occasion.

1.1.1 - Requirements Gathering

The systems development process transforms the existing (as is) system into the proposed (to be) system

The systems development process transforms the existing (as is) system into the proposed (to be) system.

due to problems with requirements

Small batches of requirements can be identified and implemented incrementally like itrative

avoid risk convert high level business requirements (from the system request) into detailed requirements that can be used as inputs for creating model

high to low require

what’s require

detail

fuctional user and do non - system persisty like AES encrypt, can be test

non Look and feel requirements (fun, motivating, etc.) no subjective language standers or guidlines pagelayout, color patterns, follow those and reach some effact, can be tested

May be prioritize, sometimes may overwhemled

Defines the scope of the system – useful to avoid scope creep

functional

image.png

noun - verb sb is doing sth

managment

do lab before the lab time

bring lab1 and lab2

relay on our system

is fuction requure don not have numbers?

non-functional method can be tested

everyone need to kown nuon-name, need to be it’s full name

Important Concepts of OOAD UseCases

image.png

we dont care what happen in black box, we put input and get output

encapsulation called information hiding, have to use a method 头 change data.

secure and easy to dubug

polymorphism, give one message, have different correspond result

UML

Use-case v-n no confusion sys boundry/ sys name.

1.2 - Scenarios and Use Cases

General software followed model of SDLC (Systems Development Life Cycle (SDLC)) which we have introduced. We need find a formalized approach to implementing the SDLC.

The approach or ‘find a way’ called methodology A methodology is a formalized approach to implementing the SDLC (i.e., it is a list of steps and deliverables).

Some methodologies are formal standards used by government agencies, whereas others have been developed by consulting fi rms to sell to clients. Many organizations have internal methodologies that have been honed over the years, and they explain exactly how each phase of the SDLC is to be performed in that company.

There are many ways to categorize methodologies, We will introduce two way

image.png

A process-centered methodology emphasizes process models as the core of the system concept. this methodology focus first on defining the processes (e.g., assemble sandwich ingredients).

image.png

Data-centered methodologies emphasize data models as the core of the system concept.

In Figure 1-1, data-centered methodologies would focus first on defining the contents of the storage areas (e.g., refrigerator) and how the contents were organized.

While object-oriented methodologies will balance the focus between process and data by incorporating both into one model.

this meth will focus first on defining major element in system, and look at the processes and data involved with each element.

we mainly talk(object-oriented Analysis and design) OOAD in this course

Another is the sequencing and effort of each phases. which will talk in 159.341

image.png

Object-oriented systems Analysis & design(OOSAD)

Object-oriented systems focus on capturing the structure and behavior of information systems in little modules that encompass both data and process.

OK, that hard to understand.

The primary difference between a traditional approach like structured design and an object-oriented approach is how a problem is decomposed. and processes and data are so closely related that it is difficult to pick one or the other as the primary focus.

let break a problem into small pieces

one single part or device will handle one problem, and the device or we called Modules contain both data and process. You can call it Objects if you want

with Object connected, a problem can be solved. any modern object-oriented approach to developing information systems must be use-case driven, architecture-centric, and iterative and incremental.

OOSAD IS USE-CASE DRIVEN

Requirement gathering is focus on users which means that use cases are the primary modeling tools defining the behavior of the system. Through use-cases, programmers can idntify problems and communicate require in system

A use case describes how the user interacts with the system to perform some activity, such as placing an order, making a reservation, or searching for information.

a non-use-case driven such as traditional structured methodology require the systems analyst and user to develop models of the entire system. They finished entire system through decomposed into small subsystem

This goes on until no further process decomposition makes sense, and it oft n requires dozens of pages of interlocking diagrams.

In contrast a use case focuses on only one business process at a time, so developing models is much simpler.

OOSAD has 3 view

the systems analysts develop their understanding of a user’s problem by building up the three architectural views little by little

image.png

analyst work with users to create functional requirement.

Next, the analyst attempts to build a structural representation of the evolving system. Using the structural representation of the system,

image.png

Lab2

Tutorial 2: Gathering Requirements for your chosen Case Study (no formal submission needed)

This week you can do the requirements gathering for one of the design briefs (mentioned in Assignment 1 – where you have to choose the design brief based on your family name). List these requirements appropriately (e.g. create requirements definition report).

image.png

first try:

lab2.drawio.png

Some Questions

  1. how to deal with third-part service or external service?
  2. list all possible task/information? or simplify that ?
  3. users or charities ? using use-case driven which entity are we talking about

2 - 159.261 Gaming Programming

159.261 Gaming Programming

In this course, we will explore a range of essential topics for implementing computer games including fundamental computer graphics, games software architecture and game physics systems. The course contains a significant practical computer lab component where students are guided through the games development process.

3D is NOT included

image.png

2.1 - Overview Java

Overview Java

Quiz:

One of the components of a computer is its CPU. What is a CPU and what role does it play in a computer?

Central process Unit, a component of computer, the job of CPU is to excute programs

Explain what is meant by an “asynchronous event.” Give some examples.

event happen at unpredictable time. when CPU needs data in disk, CPU will send signal to disk ask for preparing, disk has releative low speed compare to CPU, so data preparing as an unpredictable event can be seen as asynchronous event.

What is the difference between a “compiler” and an “interpreter”?

compiler trans high-level lang to machine code, compiler will trans program all at once java’s machine code is run for an machine that not exists. JVM interpreter act like cpu, it trans instruction-by-instrction, as necessay, interpreter decide what is necessary and carry out that instruction java has both compiler and interpreter, interpreter is relativly small and simple. so it’s easy to wirte for an new type of computer. what’s more interpreter is user-friendly, user don’t have to understood complex java language, just handle class file to interpreter and the program can run on JVM

Explain the difference between high-level languages and machine language.

ML is simple and can be execute by mechine, however programming is difficut.

Java is an object-oriented programming language. What is an object? The central concept of object-oriented programming is the object, which is a kind of module containing data and subroutines.

review of Java, will introduce in Java topic

image.png

  • In Java, inheritance is an is-a relationship (Car is a Vehicle, Apple is a Fruit, Dog is an animal)

  • aggregation, is an has-a relationship

@Override is a non-functional aggression, we can delete that

what’s method body?

why we need polmophism? it does not make sense. we can not have a non-perdictive program.

Interface basicly a set of standers. Interface attributes are by default public, static and final. Interface methods are by default abstract and public.

Collection Framework

Variables, or data is valuable and complexty. But we can not just store them in an entire place randomly. That will cost a lot time in serching and getting

we need different strucher in different situation.

The Collection interface includes various methods that can be used to perform different operations on objects, They provided almost all atom scence in developing.

Collections work only with Reference types(objects) and not with primitive data types.

==OK, but why?==

image.png

order collection like an array allow to add or remove member

set like set in math, can not have duplicate elements

Queue FIFO manner

Map store value in key-value elements

image.png

arrayList

linkedlist is also arrayList.

we need to declare the size of an array before we can use it. What if we need resize it? like we need store more element, or reduce capicy for saving space

To handle this issue, we can use the ArrayList class. ArrayList implement all methods form list, upon that, It allows us to create resizable arrays.

Unlike arrays, Arraylists can automatically adjust its capacity when we add or remove elements from it. Hence, Arraylists are also known as dynamic arrays.

===clone and deep clone===

Exception Handling

vital to robustness

Sometimes, we hate unpredicet action from normal process, to indicate the problem as well as make an declearation to users, we introduce EH

Exceptioon Handling is an design pattern in program, it contain 2 basic aspects

  • Error that occurs during runtime
  • Cause normal program flow to be disrupted

Exception Handlling is methology with try-catch block and finally part

Lamda expression

noname subroutain

used in interfaces only have one abstract method.

Anonymous Inner Class

which means you can directly instance an Object without giving the name. Like instant interface, though it’s impossibale.

Thread

2 way to define multi Thread

extend Thread. and you have to implement Run(). call thread.start() will auto call start()

==but why we have to override run method in Thread?==

Or we can use Runnable interface, as well as override run().

3 - Computer Internet

计算机因特网-电子工业版

URL, URI

We have to deal with URLs every day. URL is an acronym that stands for Uniform Resource Locator.

you can simply call it address. It’s used as a string that denotes the location of a given resource on the Internet: a web page, an image, a mailbox, etc.

image.png

What Is a URI?

The URI acronym stands for Uniform Resource Identifier. It’s follow rules same as URL

So, are URLs and URIs the same thing? not really.

a URL is a URI. Beyond the fact that it uses the same URI syntax, it also identifies a resource through an address. URI doesn’t allow you to access any resource on the Web. URI work like an identifier. This identifier is nothing but a URI: a logical identifier for your API.

4 - 操作系统

Low level reference docs for your project.

4.1 - CPU Cache 高速缓存

CPU 缓存是为了解决 CPU 处理速度和内存处理速度不对等的问题。

CPU 缓存是为了解决 CPU 处理速度和内存处理速度不对等的问题。

image.png

CPU Cache 的工作方式: 先复制一份数据到 CPU Cache 中,当 CPU 需要用到的时候就可以直接从 CPU Cache 中读取数据,当运算完成后,再将运算得到的数据写回 Main Memory 中。但是,这样存在 内存缓存不一致性的问题 !比如我执行一个 i++ 操作的话,如果两个线程同时执行的话,假设两个线程从 CPU Cache 中读取的 i=1,两个线程做了 i++ 运算完之后再写回 Main Memory 之后 i=2,而正确结果应该是 i=3。

操作系统屏蔽了底层硬件的操作细节,将各种硬件资源虚拟化。于是,操作系统也就同样需要解决内存缓存不一致性问题。

操作系统通过 内存模型(Memory Model) 定义一系列规范来解决这个问题。无论是 Windows 系统,还是 Linux 系统,它们都有特定的内存模型。

4.2 - 存储器的层次结构

在计算机执行时,几乎每一条指令都涉及对存储器的访问,存储器的速度必须非常快,能与处理机的速度相匹配,否则会明显地影响到处理机的运行。

在计算机执行时,几乎每一条指令都涉及对存储器的访问,存储器的速度必须非常快,能与处理机的速度相匹配,否则会明显地影响到处理机的运行。

image.png

存储层次至少应具有三级:

最高层为CPU寄存器,中间为主存,最底层是辅存。

其中寄存器和主存也被称为 可执行存储器

可执行存储器

是通过访问方式区分的

可执行存储器 使用一条load或store指令对可执行存储器进行访问。

对辅存的访问则需要通过I/O设备实现。

主存储器

主存储器 主存储器简称内存或主存,

是计算机系统中的主要部件,

用于保存进程运行时的程序和数据,也称可执行存储器

寄存器

寄存器具有与处理机相同的速度,

故对寄存器的访问速度最快,完全能与CPU协调工作,

但价格却十分昂贵,因此容量不可能做得很大。

[高速缓存](CPU Cache 高速缓存)

高速缓存是介于寄存器和存储器之间的存储器,

主要用于备份主存中较常用的数据,

以减少处理机对主存储器的访问次数,

这样可大幅度地提高程序执行速度。

磁盘缓存

目前磁盘的I/O速度远低于对主存的访问速度,

为了缓和两者之间在速度上的不匹配,而设置了磁盘缓存,主要用于暂时存放频繁使用的一部分磁盘数据和信息, 以减少访问磁盘的次数。

4.3 - 操作系统基本特性

操作系统有四大基本特性

并发

OS能够提高系统资源利用率的原因

并发是指多个任务在同一时间段内被处理,但并不意味着它们必须是同时发生的。实际上,处理器可能会在同一时刻只能处理一个任务,但操作系统通过切换任务的方式让多个任务在短时间间隔内“交替”执行。

  • 并发的关键特点是:在同一时间段内,多个任务会被交替执行,这种交替执行给人感觉是同时进行的。操作系统调度器负责任务切换。

共享

在操作系统中,共享资源需要控制不同进程或线程的访问,常见的控制方式有 互斥同时

  • 共享资源是指多个进程或线程可以访问同一块内存或设备资源。例如,多个进程同时访问打印机、磁带机等共享设备。
  • 操作系统中的共享通常是通过 锁机制(如互斥锁、读写锁等)来避免资源竞争问题,确保资源访问的有序性。
1. 互斥

互斥是指在某一时间,只能允许一个进程或线程访问共享资源,防止并发执行时的资源冲突。

  • 例如,打印机是共享资源,但同一时刻只能由一个进程打印,其他进程需等待。
  • 操作系统通过 互斥锁(Mutex) 来保证同一时间内只有一个进程(或线程)能访问资源。
2. 同时

同时是指多个进程或线程在时间上交替执行共享资源的访问请求,而非在同一时刻访问。 例如,某个设备在微观上并不是完全同时被多个进程访问,而是交替执行。

虚拟

操作系统通过软件技术为应用程序和用户提供的一种抽象和隔离机制,使得多个程序可以在相同的硬件资源上独立运行,并且每个程序认为它独占系统资源,实际上是操作系统通过合理调度和资源分配来共享这些资源。

时分复用(Time Division Multiplexing, TDM)

时分复用是指通过时间片轮转的方式将处理器时间分配给多个用户或任务。每个用户在指定的时间段内占用资源,其他用户则需等待空闲时间。

  • 例子:操作系统通过时间片轮转的方式将 CPU 时间分配给各个进程,保证每个进程都有机会执行。
空分复用(Frequency Division Multiplexing, FDM)

空分复用通过将频带划分成多个较小的频带来为不同的通信用户提供服务,每个用户在一个独立的频带内通信。

  • 例子:在无线通信中,多个通信设备通过不同的频率带宽进行通讯。每个设备占用一个特定频段。

异步

在多道程序并发的环境下,每个程序何时执行、何时暂停 都是未知的,即他们以不可预知的速度向前推进,

操作系统 应当保证程序执行结果的可再现性。

执行顺序

同步

同步是指任务的执行是按顺序进行的,一个任务完成后,另一个任务才能开始执行。

  • 例子:多个进程依次在 CPU 上执行,前一个任务完成后,后一个任务才能开始。
异步

异步是指任务的执行不必按顺序进行,多个任务可以并行执行,任务之间的执行顺序不受限制。每个任务执行时不会阻塞其他任务的执行。

  • 例子:在事件驱动的程序中,任务的执行顺序可能不固定,可以由事件触发机制来决定。

4.4 - 进程同步

无论是硬件临界资源还是软件临界资源多个进程必须互斥的对它进行访问在每个进程中访问临界资源的代码称之为临界区

临界资源

一次只允许一个进程使用,多个进程同时使用就会造成系统混乱的资源

诸进程间应采取互斥方式,实现对这种资源的共享。

源如打印机、 磁带机、共享变量等

临界区

无论是硬件临界资源

还是软件临界资源

多个进程必须互斥的对它进行访问

在每个进程中访问临界资源的这段代码称之为临界区

image-20250109233136840

临界区的作用

  1. 保护共享资源

通过互斥访问机制,任意时刻只有一个线程修改和访问共享数据

从而保护资源一致性,完整性

  1. 防止竞态条件

多个线程同时访问共享资源时

由于执行顺序的不确定导致结果不可预测

临界区通过确保同一时间只有一个线程运行,避免竞态发生

  1. 提高程序稳定性

如果不能采取有效的措施,对多个进程的运行进行妥善的管理,

必然会因为这些进程对系统资源的无序争夺给系统造成混乱。

致使每次处理的结果存在着不确定性,即显现出其不可再现性。

有多个进程需要同时修改某一数据,系统必须控制, 一次仅允许一个进程完成读数据,并修改数据两件事以后,才允许别的进程对同一数据的读和修改操作。

4.5 - 进程的状态与转换

多个进程在并发执行时共享系统资源,致使它们在 运行过程中呈现间断性的运行规律,所以进程在其生命周期内可能具有多种状态。

进程的状态与转换

多个进程在并发执行时共享系统资源,

致使它们在 运行过程中呈现间断性的运行规律,

所以进程在其生命周期内可能具有多种状态。

基本状态

就绪(Ready)状态

执行(Running)状态

阻塞(Block)状态

image.png

创建与终止状态

创建状态

进程正在被创建

创建工作尚未完成,进程不能被调度运行

终止状态

进程从系统消失

两个步骤:

首先,是等待操作系统 进行善后处理,

最后将其PCB清零,并将PCB空间返还系统。

image-20250109201649501

这里注意。就绪到运行获得处理机前需要获得其他所有资源

Exam.

进程描述中正确的

A. 进程获得CPU是通过调度得到的

B. 进程申请CPU未获满足时,其状态变为阻塞

B 进程申请CPU未获满足仍为就绪,只有申请IO或资源失败才是阻塞

{CB7FEC31-EF3E-43F6-BE77-B17715A69A8F}