0%

Week4_note

XP is an Iterative Process

  • Iteration = two week cycle (1 - 3 weeks)
  • Plan each iteration in an iteration meeting that is held at the start of the iteration
  • Iteration is going to implement set of user stories
  • Divide work into tasks small enough to finish in a day
  • Each day, programmers work in pairs to finish task

What are user stories

  • A user story represents
    • A feature customers want in the software
  • A user story is the smallest amount of information (a step) necessary to allow the customer to define (and steer) a path through the system
  • Written by customers(through communication with developers), and not by developers
  • Typically written on index cards

Writing user stories

  • Material
    • A stack of blank index cards
    • Pens or pencils
    • Rubber bands
  • Start with a goal of the system
    • e.g. "Applicant submits a loan application"
    • Think about the step that the user takes as he/she does the activity
    • Write no more than one step on each card

Format of a user story

  • Title: 2-3 words
  • Acceptance test(unique identifier)
  • Priority 1-2-3(1 most important)
  • Story points(can mean #days of ideal development, i.e., no distractions or working on other things)

Concepts

  • Story point: unit of measure for expressing the overall size of a user story, feature, or other piece of work. The raw value of a story point is unimportant. What matters are the relative values.
    • Related to how hard it is and how much of it there is
    • Not related to amount of time or the number of people
    • Unitless, but numerically-meaningful
  • Ideal time: the amount of time "something" takes when stripped of all peripheral activities
  • Elapsed time: the amount of time that passes on the clock to do "something"
  • Velocity: measure of a team's rate of progress

Priority

  • High
  • Medium
  • Low

Estimating story points

  • Choose a medium-size story and assign it a "5"
  • Estimate other stories relative to that
    • Twice as big
    • Half as big
    • Almost but not quite as big
    • A little bit bigger
  • Only values:
    • 0,1,2,3,5,8,13,20,40,100

Estimating ideal days

  • Ideal days vs. elapsed time in software development
    • Supporting current release
    • sick time
    • meetings
    • demonstrations
    • personal issue
    • Phone call
  • When estimating ideal days, assume:
    • The story being estimated is the only thing you'll work on
    • Everything you need will be on hand when you start
    • There will be no interruptions

Ideal Days vs. Story Points

  • Favoring story points:
    • Help drive cross-functional behavior
    • Do not decay(change based on experience)
    • Are a pure measure of size(focus on feature, not person)
    • Estimation is typically faster in the long run
    • My ideal days are not your ideal days(focus on person and their speed)
  • Favoring ideal days;
    • Easier to explain outside of team
    • Estimation is typically faster at first

Deriving an estimate for a user story

  • Expert opinion
    • Rely on gut feel based on (extensive) experience
    • disadvantage for agile: need to consider all aspects of developing the user story, so one expert will likely not be enough
  • Analogy
    • Relative to (several) other user stories
    • Triangulation: little bigger than that "3" and a little smaller than that"8"
  • Disaggregation
    • Break up into smaller, easier-to-estimate pieces/tasks.
    • Need to make sure you don't miss any tasks
    • Sanity check: does the sum of all the parts make sense?
    • Planning poker
      • Combines expert opinion, analogy, disaggregation

Velocity

  • Velocity is a measure of a team's rate of progress
  • Velocity is calculated by summing the number of story points assigned to each user story that the tea completed during the operation
  • We assume that the team will produce in future iterations at the rate of their past average velocity
    • "Yesterdays weather"

Prioritization

  • Driven by customer, in conjunction with developer
  • Choose features to fill up velocity of iteration, based on:
    • Desirability of feature to a broad base of customers/users
    • Desirability f feature to a small number of important customers/users
    • The cohesiveness of the story in relation to other stories
      • Example:
        • "Zoom in" a high priority feature
        • "Zoom out" not a high priority feature
          • But it becomes one relative to "Zoom in"

Planning game

  • Customer writes user stories
  • Programmers estimate time to do each story
  • If story is too big, customer splits it
  • Customer chooses stories to match project velocity
  • Project velocity is amount of work done in the previous iteration(s)

Planning

  • Programmers only worry about one iteration at a time
  • Customer can plan as many iterations as desired, but can change future iterations

Simplicity

  • Add one feature(user story) at a time
  • Don't worry about future stories
  • Make program as simple as possible
  • The simplest thing that could possibly work

Need Educated customer

XP works best when

  • Educated customer on site
  • Small team
  • People who like to talk
  • All in one room(including customer)
    • These days the room can also be virtual
  • Changing requirements

Unit tests and refactoring

  • Because code is as simple as it can be, adding a enw feature tends to make it less simple
  • To recover simplicity, you must refactor the code
  • To refactor safely, yous should have a rigorous set of unit test

Working software

  • All software has automated(unit) test
  • All test pass, all the time
    • Never check in broken code
  • How to work on a task
    • Get latest version of the code. All tests pass
    • Write test first. If fails
    • Write code to make test pass. Now all tests pass
    • Refactor(clean up)
    • Check in your code

One key practice

  • Write tests first, then write code
  • various name
    • Test-first programming
    • Test-driven development
  • Is it testing or designing?
  • Degree to which yous tick to if for MP?

Why test?

  • Improve quality - find bugs
  • Measure quality
    • Prove there are no bugs?
    • Determine if software is ready to be released
    • Determine what to work on
    • See if you made a mistake
  • Learn the software
  • Grade MPs

What is a Test?

  • Run program with known input(test inputs/data), check results (with test oracles)
    • Test pass (green) or fail(red)
  • Tests can document faults
  • Tests can document code
  • Important terminology to remember:
    • Mistake, fault(or defect, or bug), failure, error
    • Oracle

Terminology: Mistake, Fault/Bug, Failure, Error

  • Programmer makes a mistake
  • Fault(defect, bug) appears in the program
  • Program failure occurs during execution(program behaves unexpectedly)
  • Error: difference between computed, observed, or measured value or condition and true, specified, or theoretically correct value or condition.

Test input vs. test oracle

Advanced topics in junit

  • Assertion patterns
  • Parameterized JUnit tests
  • Junit theories

Test Driven Development(TDD)

  • One of the practices in XP

Kent Beck's rules

  • Becks concept of test-driven development centers on two basic rules:
    • Never write a single line of code unless you have a failing automated test
    • Eliminate duplication.

Informal Requirements

If the maintenance contract number provided by the customer is not valid, the item follows the procedure for items not covered by warranty.

Steps in Test Driven Development(TDD)

The iterative process

  • Quickly add a test
  • Run all tests and see the new one fail.
  • Make a little change to code.
  • Run all tests and see them all succeed.
  • Refactor to remove duplication.

Test First Scenario

  • Write test for the newly
    • These test cases will serve as a specification for your implementation
    • These test cases should fail now because the corresponding methods are not implement
    • Write minimal code to make the test pas
    • Add more tests

week3_Note

前苏格拉底时代

Anaximander

  • 万物的本原是“无定”
  • 万物的多样性,水的“湿性”不能解释一切
  • 万物的本原应是没有任何确定规定性 - 混沌
  • 不定形且与水有关的东西 为 无定

Anaximenes 546 a.d. - 545 a.d

  • 世界的本原是气(综合了水和“无定”的特征)
  • 与东方本体论相似

Heraclitus 赫拉克利特 504 a.d. - 501 a.d

  • 性格高傲,出身望族, 把王位让给兄弟
  • “世界是客观的”
  • “世界的本原是火” - “世界秩序不是任何人或任何人锁创造的,它过去,现在,未来永远是永恒的活火,在一定分寸上燃烧,在一定分寸上熄灭”
    • 唯物主义 - 客观存在
    • 万事万物是变化的
  • “万物皆变,无物常驻”
    • “一切都是通过斗争和必然性而产生的”
    • “太阳每天都是新的”
    • “人不能同时走进同一条河流”
    • “我们存在又不存在”
  • 简单,直观,朴素的表达

本原内在不变的统一原则是“逻各斯”

原意为话语,指说出的道理,是火在燃烧中遵循的理性规则和原则。即“一定分寸”

我们看见特殊,我们只能说出普遍

  • 我们使用名词描述 - 名词 在 逻辑学上 为 概念

毕达哥拉斯学派

毕达哥拉斯 建立了一个有伦理,宗教和政治目的的社团:大家庭式的集体生活。

基本观点:数是万物的本原

  • 第一,数先于事物存在,是构成万物的基础
    • " 万物的本原是一,从一产生二,而是从属于一的补丁的质料,一则是原因。.....”
  • 第二,一切事物的性质都可以被归结为数的规定性
    • 比例关系:(决定事物结构的和谐)
    • 对立关系:(有限和无限,奇数和偶数)
    • 类比关系:(4代表正义,8代表爱情.......)

埃利亚学派

创始人:Xenophanes

  • 世界的本原是绝对不动的“神”

Process

  • A Process is an execution instance of a program
    • More than one process can execute the same program code

Process vs. program

  • A process has states concerning the execution.
    • Which line of codes it is running
    • How much time left before returning the CPU to others
  • Linux commands about processes
    • ps: "process status", it can report a vast amount of information about every process in the system.
    • top: allows users to monitor processes and system resource usage on Linux

What is a Shell?

  • A shell is a program, open a "terminal", actually launches a "shell" process
    • Bash in linux
  • Written in C
    • use getchar() to get your command "ps"
    • syntax checking
    • invoke a function fork() (a system call) to create a new process
      • i.e., becoming a child process of the shell
    • Ask the child process to exec() the program "ps"

Process hierarchy

  • Process relationship
    • A parent process will have its child processes
    • Also, a child process will have its child processes
    • This forms a tree hierarchy

System call

  • a function call
  • exposed by the kernel
  • abstract away most low-level details
  • Categorizing system calls
    • Process, File system, Memory, Security, Device
  • How can we know if a "function' is a system under linux
    • Read the man page "syscalls" under linux

System calls VS Library function call

  • Library functions are usually compiled and packed inside an object called the library file
    • In Windows: .DLL - dynamically linked library
    • In Linux: .So - shared objects

What will we learn about Process

  • System calls
    • Hoa to program a simple, bare-bone shell?
  • Lifecycle and Scheduling
    • How to create processes?
    • How to handle the death of the processes
    • Which process shall get the core next?
  • Signals
    • How to suspend a process
  • Synchronization

The Memory of a Process

Memory

  • Virtual memory
    • Your process virtually owns all your machine's RAM
  • Memory-related functions
    • E.g., how to write "malloc()"

File System

  • Each disk can have multiple FSs
  • An OS may understand different FSs

OS_L02_fundamental

Four Components of a Computer System

  • computer hardware
  • operating system
  • system and application programs
  • user(human being or program)

What is an operating system?

  • It is not an "operation" system
    • It is operating system
  • Abstraction of hardware
  • Software that supports applications
    • Managing resources
    • resolving conflicts
    • handling faults
    • preventing attacks, etc.

Welcome to CS302

  • We will study Operating System
    • Concepts & practice
    • Overview, Process, Memory, Storage

What is an OS

  • Special layer of software that provides application software access to hardware resources
    • Convenient abstraction of complex hardware device
    • Protected access to shared sources
    • Security and authentication
    • Communication amongst logical entities

An OS

  • Includes a program
    • called "kernel", which manages all the physical devices(e.g., CPU, RAM, and hard disk)
    • exposes some functions as system calls for others to configure the kernel or building things (e.g., C library) on top
  • Includes some more programs
    • called "drivers", which handles the interaction between the kernel and the external devices(e.g., keyboard)
    • called a "shell", which renders a siple command-line user interface with a full set of commands
  • Includes some "optional" programs
    • GUI, Browser, Paintbrush paint

What does an OS do?

  • Provide abstractions to apps
    • File systems(not a real things)
    • Processes, threads
    • Virtual memory
  • Manage resources:
    • Memory, CPU, Storage,
    • ...
  • Achieves the above by implementing specific algorithms and techniques
    • Scheduling
    • Concurrency