header
愚 館
THE HONKY TONK OF FOOLS
Scientia ipsa potentia est


[INF43] Lecture 14 Testing part 4

闲谈 Digressions

写于2020年5月26日

White box testing

  • Use source code to derive test cases
    • Build a graph model of the system
    • State test cases in terms of graph coverage
  • Choose test cases that guarantee different types of coverage
    1. Node/statement coverage
    2. Edge/branch coverage
    3. Loop coverage
    4. Condition coverage
    5. Path coverage

(更多…)


[INF43] Lecture 13 Testing part3

闲谈 Digressions

写于

Two overall testing approaches

  1. Black box testing
    1. Specification-based testing
      1. give input and use testing oracle to check whether output is success
  2. White box testing
    1. structural-based testing

(更多…)


[INF43] Lecture 12 Testing part2

闲谈 Digressions

写于2020年5月19日

Testing curve

Ways to choose test cases

  1. Intuition
  2. specification black
    1. know something what should they behaved then write the tests
  3. code (white-box testing)
    1. make sure the every line of code works
  4. Existing test cases (regression test)
    1. after making some changes, rerun the previous tests to make sure they can pass
  5. Faults
    1. based on experience, test the area that are likely to have bugs

(更多…)


[INF43] Lecture 8 How do we structure the software in detail

闲谈 Digressions

写于2020年4月29日

Design Phases

Software Design

  1. Design behaviors
  2. Desgin phase of softare engineering:
    1. after requirements
    2. ask questions of "How"
  3. Software Design Goals/ Activities SEE PPT
    • Making system-wide decisions
      • Architecture, languages, libraries, platforms
    • Making lower-level decisions in an iterative manner
      • Studying the problem
      • Identifying solutions
      • Creating abstractions
      • Evaluating
      • 重复循环上面的步骤
  4. 6 Approaches to Software Design
    1. Software architecture
    2. Functional decomposition
    3. Relational database design
    4. Object-oriented design and UML
    5. User interface design
    6. (Sketching) – Lecture 8

(更多…)


[INF43] Lecture5 How do we structure software

闲谈 Digressions

写于2020年4月28日

Software architecture

  1. So software architecture deals with how we go from requirements to code right there has to be something in between. And often, it seems like magic, pulling a rabbit out of your hat.
  2. So software architecture and design deals exactly
    1. what that how the software is to be structured
    2. what its components are what its pieces are
    3. and how those pieces are related to each other.
  3. And for large systems of particular. It usually makes sense to divine. This does that whole design activity into two parts architecture and
    1. architecture dealing more with a high level
    2. and design dealing more with the low level

(更多…)


[Inf43] Lecture 6 Software Architecture Styles

软件工程 SoftwareEngineering|闲谈 Digressions

写于2020年4月24日

Styles

  1. Object-oriented
    1. components are objects and each object contains all the data and behavior relevant to the object.
    2. connectors are just function calls or messages between the different objects.
    3. key benefits: understand ability
    4. example:
      Uber
      Passenger - Ride - Driver

(更多…)


[INF43] Lecture 1 Introduction to software engineering

闲谈 Digressions

写于2020年4月07日

Introduction to software engineering

1. software engineering

  1. “A broad field that touches upon all aspects of developing and supporting a software system.” [Tsui, Karam, Bernal]
  2. “A discipline that deals with the building of software systems which are so large that they are built by a team or teams of engineers.” [Ghezzi, Jazayeri, Mandrioli]
  3. Multi-person construction of multi-version software.” [Parnas]
  4. “A discipline whose aim is the production of fault-free software, delivered on-time and within budget, that satisfies the user’s needs. Furthermore, the software must be easy to modify when the user’s needs change.” [Schach]
  5. Managing the complexity of both a problem and its solution, to create a software product that successfully solves the problem.” [Navarro]
  6. Inf43 definition:
    1. Informatics 43 definition
      1. The process of constructing software
        1. Requirements
        2. Design
        3. Implementation
        4. Verification
        5. Maintenance
      2. Phases of development other than programming
        1. Documentation
        2. Diagrams
      3. Principles and qualities of enduring value
        1. correctness
        2. reliability
        3. Adaptability
        4. Modularity
        5. Usability
        6. Efficiency

[INF43] Lecture 2 What is software engineering

闲谈 Digressions

写于

What is software engineering?

1. Perspectives

1. Business perspective
    1. What matters most?
        1. Cost
        2. Time/market how fast make proft
        3. Profit
        Money
    2. How SE help?
        reduce cost and increase profits
2. Engineer perspective
    1. What matters most?
        1. software quality/design of software
    2. How does SE help?
        1. deal with high cohesion and modularity
3. User perspective
    1. What matters most
        1. external experience
    2. How SE
        1. give us technices for devloping usable softwares.
4. INF43 perspecitive
    1. the process of constructing software
    2. The p

2. Essential Ingredients

1. People + Processes + Tools
    1. People is more important

3. Principles of software engineering

4. Inf 43 Recurring, fundamental principles

1. rigor and formality
2. separation of concerns
    1. modularity
    2. divide and conquer -> assign different parts to different people
    3. abstraction -> showing certain details and omit others
3. Anticipation of change
4. Generality -> building things in most general way as possible
5. Incrementality -> building things little by little

5. No silver bullet

1. Essential properties of software make SE hard
    1. Complexity
        1. "... a construct of interlocking concepts: data structures and classes, algorithms, function calls"
        2. "No two parts are alike"
        3. Consequence
            1. hard to communicate
            2. hard to modify without side effects
            3. make software unreliable
            4. security issues
            5. any error is fatal
    2. Conformity
        1. Software must conform to human institutions and systems
    3. Changeablity
        1. "All successful software gets changed"
        2. Why
            1. easy to change
            2. people want new changes
            3. environment changes -> hardware changes
    4. Invisibility
        1. "The reality of software is not inherently embedded in space"
        2. Consequence:
            1. diffcult to understand -> we have to find ways to make it visible
            2. hard to communicate
2. False silver bullets
    1. High-level language
    2. Time-sharing
    3. Unified programming environments
    4. OOP
    5. AI
    6. expert systems
    7. Graphical programming
3. Potential silver bullet
    1. Buy vs. Build
        1. open-source software deal with mulitple issues
            1. easy to reuse
    2. Requirements refinement and rapid prototyping
    3. Incremental development
    4. Great designers:
        1. investing people, train well, treat well
        2. people are most important.

[ICS_32A]Lecture2Week4

闲谈 Digressions

写于2019年10月25日

Namedtuple

  1. namedtuple('Name',["field1","field2",..,"fieldn"]) ->field名要是str
    • 大概率不会考:可以用任何一个collection来装这些名字,包括tuple和set,但是set会让顺序变乱
  2. 例子 Point
    //三个等价的构造
    Point(3,5,7)
    Point(x=3,y=5,z=7)
    Point(z=7,y=5,x=3) //如果明确field名的话,可以调换顺序
  3. 参数一定要传的刚刚好,构造新对象的时候不能缺少任何一个参数,也不能多一个函数
  4. p1= Point(3,5,7)
    p1[0]==p1.x==3
    可以用p1[0]调X
    可以用p1.x调x
  5. 和tuple一样,不可以对fields重新赋值
    p1.x=10 =>WRONG

    • 几种变相重新赋值的方法:
      1. 创建新的对象,并重新赋值
        p2=Point(x=p1.x-1,y=p1.y,z=p1.z)
      2. _replace 没讲
  6. print(p1)
    Point(x=3,y=5,z=7)

  7. field可以与其他一些东西重名,比如说可以创建p1.input或者p1.print之类的。不会与顶层方法产生冲突。

    Protocol

TIPS:

  1. 编程过程中不要一直编不测试,要模块化编程,然后逐个测试每一个function

[ICS_32A] Lecture1Week4

闲谈 Digressions

写于2019年10月23日

模块导入 Module Import

#powers.py
def square(n):
    return n*n
def cube(n):
    return n**3

#program.py
import powers
def ask_for_number():
    return int(input())
def run_user_interface():
    number=ask_for_number()
    squared=powers.square(number)
    cubed=powers.cube(number)
    print(f'The square of {number} is {squared}')
    print(f'The cube of {number} is {cubed}')

run_user_interface()
  1. Python的模块名不能重,不要把自己的模块命名成math.py之类的
  2. Executable module 对比 module that provide tools

    some_else.py

    def something():
        number=program.ask_for_number() =》出错
  3. import x 实质上是让Shell直接把x.py执行一遍,所以全局语句也会被执行
  4. 这也就是为什么要用
    if name == "main":
  5. 更改后的program.py

    program.py

    import powers
    def ask_for_number():
        return int(input())
    def run_user_interface():
        number=ask_for_number()
        squared=powers.square(number)
        cubed=powers.cube(number)
        print(f'The square of {number} is {squared}')
        print(f'The cube of {number} is {cubed}')
    if __name__ =="__main__":
        run_user_interface()

    Network

  6. Socket: one end of a network "conversation"
    "connecting" a socket means establishing a connection between sockets in two programs.
  7. A socket contains two streams:
    1. input stream
    2. output stream
  8. client and server:
    1. client is the one that initiates the conversation
    2. server is the one that accepts the request and responds to it
  9. IP = Internet Protocol
    choose你想要连接的machine
  10. IP要考
  11. IP : four numbers in the range 0-255, 中间由.分割
    256=2^8
  12. port端口:0-65535
    65536=2^16
  13. 一些特殊的IP:127.0.0.1 一般指本机
  14. DNS(Domain name service)
    maps "fully-qualified domain names"域名 into IP addresses
  15. import socket
  16. socket.socket是socket里的一种type
  17. example_socket=socket.socket()
  18. example.connect((IP adress,port)) -> 要是一个(IP,port)的tuple
  19. 如果连接一个不存在的地址,会出错 getaddrinfo failed之类的
  20. 要创建pseudo files来处理IO streams
    input_stream=example_socket.makefile('r')
    output_stream=example_socket,makefile('w')