Week 2 Resit Flashcards

1
Q

Relative costs of development vs maintenance?

A

Maintaining and managing software and its evolution represents more than 90% of the total cost of software

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a monoloithic program?

A

Software architecture where all components of an application are tightly integrated into a single codebase, making it a unified and indivsible unit.Tightly linked to the imperative core of Java, consisting of types, values, variables, expressions, assignment, selection, repetition, and allows the expression of every computation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a quantified expression? What are quantifiers?

A

an expression that involves quantifiers
logical constructs that indicate the extent of the variables in a logical statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Describe all quantifiers and how they are denoted:

A

\forall\exists\sum\product\max\min\num_of

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a procedure in java?

A

a method or a function ways of wrapping up solutions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Methods vs Functions

A

Methods have return type void and are used as statements, whilst functions have return type non-void and are used as expressions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are parameters? What are arguments?

A

Parameters are variables in a function or method definition that represent the input values the function expects.

Arguments are the actual values or expressions passed to a function or method when it is called, filling in the parameters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is aliasing?

A

the situation where two or more variables refer to the same object or memory location, allowing changes through one variable to be reflected in the other

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Local vs global variables?

A

Local variables are declared within a specific block and have limited scope, while global variables, in the context of Java, typically refer to class-level variables accessible throughout the class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Steps in Divide,Conquer and Rule

A
  1. Split the problem into subproblems that are each to be solved by a given method (Divide)
  2. Solve subproblems independently (Conquer).
  3. Combine subproblem solutions into a total solution (Rule).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Format of a Method Contract:

A

@param param_name description_of_param@return what_function_returns@pre {@code … precondition}@modifies name_of_modified_var@post {@code … postcondition}@throws some_exception if condition

\old(v) refers to the value of var v at the start of function
\return or \result refers to the value returned by the function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Purposes of a contract

A
  • clearly delineate modules- acts as an interface between user and provider of solution- specifies which problem is solved by pre and post condition- relates invocation and implementation to contract, but not each other directly, as this leads to complexity and errors
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Are the preconditions and postconditions concerns or benefits for the users and providers of the solution?

A

Preconditions are a concern for the users, whilst they are a benefit for the provider.Moreover, postconditions are a benefit for the user, and a concern for the provider.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Test-driven development (TDD)

A

software development approach where tests are written before the actual code, guiding the development process by ensuring that the code meets the specified requirements and functions correctly

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Steps in TDD

A
  1. Gather and analyse the requirements to realise.
  2. Decide which requirement to develop next and what class and method it concerns.
  3. Specify the module informally in source code, using natural language.
  4. Specify the module formally, by providing its interface and contract.
  5. Design and implement a test case; document their motivation in the source code.
  6. Design and implement module features intended to make the test case pass.
  7. Test the new module implementation and fix any defects found.
  8. Where relevant, improve the structure of the code, preserving correcntess by running all test cases again.
  9. Repeat from step 5, until the entire module has been implemented and tested.
  10. If, after delivery, a defect is reported for the module in vivo, then first add a test case to defect that defect in vitro and only then repair the defect.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Manual vs automated testing

A

Manual testing is tedious, time-consuming, and error prone.

Automated tests are more convenenient, faster, and more reliable. Separate code, offer ability to rerun tests and report on results.

17
Q

Abstraction

A

simplifying complex systems by focusing on essential properties and hiding unnecessary details, allowing developers to work with high-level concepts and models

18
Q

How to abstract a monolithic solution:

A

separate 1 method into multiple parametrising methodusing auxiliary functions

19
Q

Dependence diagrams

A

Arrow from box A to box B means A depends on BThus, when code of B changes, code of A may also have to changeCode of A can change without affecting the code of BWhen reusing code of A, also code of/like B is neededWhen reusing code of B, code of A is not neededEach method and variable(s) gets a block in the diagram

20
Q

Decomposition

A

process of breaking down a complex system or software application into smaller, more manageable parts or components

21
Q

Modularisation

A

structuring a software system into distinct, independent modules or components, each responsible for a specific set of functionalities

22
Q

Advantages of Divide and Conquer, Decomposition, and Modularisation

A

Enable solutions of more complex problems
Organise communication about solution domain
Facilitate parallel construction by a team
Improve ability to plan work and track progress
Improve verifiability (allow early review of design, unit testing of separate components, stepwise integration)
Improve maintainability as changes affect fewer componentsImprove possibilities for reuse

23
Q

Disadvantages of Divide and Conquer, Decomposition, and Modularisation:

A

Top-level divisions are hard to make, can have big consequences, and need experience and experimenting

Separation often brings overhead and depends on implementation facilities

The result looks bigger but it has explicit structure

Functions cannot be specified/designed/implemented in isolation, but need to be considered in related groups (e.g., classes)

24
Q

Functional decomposition aims to maximise cohesion. What is cohesion?

A

the degree to which the elements within a module or component work together to achieve a common purposeHigh cohesion suggests that the elements (functions, classes, etc.) within a module are closely related and focused on a single task, promoting better maintainability and understanding of code, while low cohesion indicates that the elements may not be strongly related, potentially leading to a less maintainable and modular design.

25
Q

Functional decomposition also aims to minimise coupling. What is coupling?

A

the degree of dependence or connection between different modules or components in a software systemLow Coupling: Modules are independent, and changes in one module are less likely to affect others. This promotes a more flexible and maintainable systemHigh Coupling: Modules are strongly interconnected, and changes in one module may have a significant impact on others. This can lead to a less flexible and more challenging-to-maintain system

26
Q

What is the Single Responsibility Principle

A

Each function should solve a single well-defined problem

27
Q

Don’t repeat yourself Principle

A

Each problem should be solved only in one place

28
Q

Further guidelines for functional decomposition

A

If specification is difficult to provide, then something is wrong.Specify the right level of data abstraction.Limit the size of the interface, i.e., the number of parameters.Do not pass unnecessary data.Possibly combine parameters.Avoid code duplication.Copy-Paste-Edit is a bad way to reuse code.Use parameters to unify similar code.Functions should have a small/simple/clear implementation:No more than a few dozen linesNested control structures should invite further subdivisionCyclomatic complexity is a good metricCheckstyle measures this and warns when too highRefactoring if it is above 8