Vigtige ting Flashcards

1
Q

Make a unit test like in the lecture (calculator)

A
public class CalculatorTest{

  @BeforeEach
	
  public void setup(){
	
    Calculator c = new Calculator();
		
  }
	
  @Test
  
	public void mulTest(){
  
	  private int result = c.mul(2, 2);
		assertEquals(4, result);
  
	}

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

Write the skeleton for an if-statement:

A
boolean condition = true

if (condition) {

// something happens

} else {

// something ELSE happens

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

Write the skeleton for a while-statement:

A
while (condition) {
//something happens
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Write the skeleton for a for loop-statement:

A
for (int i = 0; i < 0; i++) {
//do something 10 times
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Write the skeleton for a for each-statement:

A
String[] mylist = {"Red", "Green", "Blue"}

for (String content : mylist) {
// do something
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Can you use “==” on Strings?

A

No, you instead use
message.equals("Hello, World");

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

Create an instance of a class:

A

Super class is Car, subclass is ElectricCar:
Car myCar = new ElectricCar();

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

how to write main?

A
public class Main{
  public static void main(String[] args) {
    System.out.println("Execute program");
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the benefits of OOP?

A

Abstraction, encapsulation, inheritance and polymorphism (maybe modularity?)

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

What is polymorphism?

A

When there are one or more classes or objects related to each other by inheritance. They behave the same. One of the benefits of polymorphism.

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

How do you use super?

A

Attributes: super(name, age);

Methods: super.animalSound();

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

Write a getter and a setter:

A
public int getPrice(){
  return price;
}

public setPrice(int price){
  this.price = price;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How to make enumeration in code?

A
enum level {
LOW,
MEDIUM, 
HIGH
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Make an abstract class with an abstract method in it:

A
public abstract class Animal{
  private int age;
  public abstract move();
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Make a constructor:

A
public class Animal{
  private int age;
	private String name;
	
  public Animal(int age, String name){
    this.age = age;
    this.name = name;
  }
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is static type and dynamic type?

A

Static type is known during DEVELOPMENT
Pet somePet = new Pet();
PET IS STATIC

Dynamic type is known during EXECUTION
Pet somePet = new Dog();
DOG IS DYNAMIC

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

What does instanceof do?

A

Checks whether object is an instance of the specified type

if (Pet instanceof Dog) {
  //does something
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is method overriding and method overloading?

A

Method overriding: Changes the method implementation of the super class. Keeps the same method signature (name and parameters).

Method overloading: Provides additional implementation, and changes the method signature, by having different parameters

(drive(Direction direction) and drive(Location location), the latter is the new implementation)

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

What are arrays and lists?

A

Arrays are for fixed numbers, allows speed of access.

Lists are dynamic and allows for ease of access

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

What does abstraction mean?

A

Focusing on details (necessities), leaving out unnecessary details.

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

What is encapsulation?

A

Regulates access to members from the outside. Put them in a capsule to protect them. Use visbility modifiers for this.

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

What does inheritance mean?

A

Reusing code (rather tha duplicate) and inherits from the super class (kind of polymorphism, because behaviours and traits are shared)

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

What is an interface?

A

Specifies some methods that all classes that implements the interface, should implement. All interfaces methods are abstract and public, attributes are public, static and final.

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

How to write an interface and implement it in a class?

A
interface Animal {
  public void makesound();
  public void eat();
}

public class Pig implements Animal interface {
  // implement methods now
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is software development?
ITERATIVE AND INCREMENTAL
26
Give an example of a list:
`List allRecords = new Arraylist<>();` OR `List content;`
27
Benefits of IDEs
Highlighting, debugging, code completion, execution
28
What terms are used when defining a Version Control Syste (VCS)?
Version, development line, branch, merge, tag, merge conflict
29
What is SVN (Subversion)?
Client-server VCS, local working copy and remote repository. ``` svn import svn checkout svn commit svn update ``` **import**: from working copy to remote repository **checkout**: from remote repository to working copy **commit**: from working copy to remote repository **update**: from remote repository to working copy
30
Characteristics of SVN:
Checks out only PARTS of the project Renames counts as a totally new file Not that great for non-linear workflow
31
What is Git?
Distributed VCS, working copy, local repository and remote repository ``` git init git clone (git add) git commit git push git pull ``` **init**: initialises from the working copy to the local repository **clone**: clones from the remote repository to local repository and then working copy **commit**: commits from working copy to local repository **push**: pushes changes from local repository to remote repository **pull**: pulls from remote repository to local repository and then working copy
32
How many releases are there?
**Long term support**: old versions, too costly to implement new version for whole firm **Stable**: the current version, most people use this **Pre-release**: beta, alpha, contains newest features (not tested properly)
33
What is Hadoop and Spark?
Both are tools used in parallel data processing. - Hadoop uses HDFS (Hadoop distributed file system), HiveQL - Spark uses RAM (therefore more expensive) SparkSQL
34
Name the data storage tools
Apache HBase Apache Phoenix Druid Cassandra
35
Name the data calculation tools
Apache Pig Apache Kafka Apache Samza
36
Name the data query tools
Apache Hive Apache Drill
37
Name the coordination tools
Apache Zookeeper
38
Name the machine learning tools
Apache Mahout ML4J dl4j WEKA
39
Why is software engineering difficult?
- Complexity - Conformity - Changeability - Invisibility
40
Outline software engineering
- Modeling activity - Problem solving activity - Knowledge acquisition activity - Rationale management actvitity
41
Describe the process of problem solving activity in software engineering
- Formulate the problem - Analyse the problem - Search for solutions - Decide on appropriate solution - Specify the solution
42
Stages in Object Oriented Software Development (OOSD)
1. Requirment elicitation 2. Analysis 3. System design 4. Object design 5. Implementation 6. Testing
43
What does rationale management activity entail?
That the problem domain eventually stabilises That the solution domain will constantly change How can we reason a decision taken in the past
44
What activities are common to all software processes (LIFECYCLE)?
- Software specification - Software development - Software validation - Software evolution
45
What is the spiral model?
An iterative and incremental model. It wants to reduce risk. Steps: 1. Determine objectives, 2. Identify risks 3. Development and test 4. Plan next iteration
46
What is the Waterfall model (not Barry's version)?
Strict sequence phase model. When a milestone is complete you can move onto the phase. Possibility for feedback, but only through neighbouring phases. Drawback: Difficult to accommodate changes
47
What is the agile method process?
Combination of iterative and incremental methods. Smaller iterations (sprints), delivers work in increments
48
When do you use change avoidance and change tolerance?
In the context of reducing the cost of rework
49
Benefits and drawbacks of agile processes?
Benefits: - Incremental and iterative process Drawbacks: - keeping the customers interested - Team members may not be suited for the agile methods
50
What is the V-model?
It's a model good for management and tight controlling Benefits: Integrates quality assurance Drawbacks: Rigid, bad for requirement changing. Not suitable for software engineers
51
Name 3 good practices of Extreme Programming (XP).
- Pair programming - Simple design - Test-first development - Refactoring
52
Mention 3 principles of Agile software development
- Collaboration - Motivation - Communication
53
Characteristics of Scrum
Scrum team: - Product owner - Developers - Scrum master Product backlog, sprint, sprint planning, sprint backlog, daily scrum, increment, sprint review, sprint retrospective
54
Drawbacks of Scrum and XP?
Scrum: Pretend to do scrum, but does the waterfall model. Bad for large systems XP: Programmers take shortcuts when testing, test-first development is a rigorous process
55
What is verification and validation?
Verification: Are we building the product right? Validation: Are we building the right product?
56
How do we deal with faults?
Fault avoidance Fault detection Faul tolerance
57
What is fault, erroneous state and failure?
Fault: bug Erroneous state: Further processing leads to failure Failure: Deviation of observed behaviour from specified behaviour
58
What is black box testing and white box testing?
**Black box**: Tests software without knowing the source code (internal structure). Focuses on I/O behaviour. The goal is to reduce the number of tests using equivalence classes **White box**: Tests the software WHILE knowing the source code (internal strcuture) Focuses on software working correctly. The goal is to ensure everything is tested
59
What does all the coverages do?
**Statement coverage (C_0)**: Executes every statement at least once **Branch coverage (C_1)**: Executes every branch at least once **Path coverage (C_2)**: Executes every path at least once WHITE BOX TESTING
60
How to deal with faults, erroneous states and failures?
- Patching - Declaring the bug as a feature - Modular redundancy - Testing (shows only presence of bugs, not absence)
61
Mention the integration tests
- Big bang - bottom up (no stubs, needs drivers) - top down (no drivers, needs stubs)
62
What are functional and non-functional requirements?
**Functional requirements**: How the system should behave on smaller features **Non-functional requirements**: Constraints and properties. Applies to the system as a whole rather than individual features (reliability, size, speed, ease of use, robustness, security, response time, portability)
63
What are the 3 non-functional requirements in the tree?
Product requirement, organisational requirement, external requirement
64
What are the requirement validations?
- Complete - Consistent - Clear - Correct
65
What is the requirement process?
Requirement elicitation (understood by user) and analysis (understood by developer)
66
FURPS+ model
FURPS: - Functionalit - Usability - Reliability - Performance - Supportability +: - Implementation
67
What are some requirement elicitation techniques?
- Document analysis - prototyping - questionnaire - interview - focus group - oberservation
68
How do we manage requirement specifications?
- Negotiating the requirements with clients - Maintaining tracebility - Document the requirments
69
What are the 3 C's of user stories?
- Card - Conversation - Confirmation
70
What is the product backlog?
Prioritise items. Pull of items, other items move up. Theme: collection of RELATED user stories Epic/saga: a larger user story (long rectangle)
71
What are the relevant steps of modeling in software development
- Analysis - System design - Detailed design - Implementation - Quality assurance - Maintenance
72
Name everything in UML class diagram
- Association - Aggregation - Composition - Association class - Association name - Role - Attribute - Class - Method - Multiplicity - Comment - Interface - Enumeration - Implements - Generalisation - Class members
73
Name everything in UML object diagram
- Object (can be anonymous) - Attributes (if relevant) - Associations
74
Name everything in UML deployment diagram
- Node - Artifacts - Stereotype - Communication path - Nested nodes - Titles (object)
75
Difference between UML and Java (protected visbility, inheritance, association type, association classes)
**Protected visbility**: Visible only for class and subclasses **Inheritance**: Multiple **Association types**: Association, Aggregation, Composition **Association classes**: Directly supported Java: **Protected visbility**: Visible for class, subclasses and same package **Inheritance**: Single **Association type**: Reference **Association class**: Need to be emulated
76
Name everything in UML activity diagram
- Action - Transition - Initial node - Final node - Decision - Guards - Fork - Join - Swim lanes
77
Name everything in UML state machine diagram
- State - Initial node - Final node - Transition - Decision - Trigger - Guards - Action
78
Name everything in UML sequence diagram
- Lifeline (write as object) - Activation box - Nested activation box - Synchronous message - Asynchronous message - Return message - Termination
79
What can UML be used for?
- Sketch - Blueprint - Development language
80
What are the symptoms of bad software?
- Confusing - Rigid - Fragile - Immobility (no reuseability) (common problems in software is spaghetti code, coupling and dependencies)
81
Explain coupling and cohesion?
Coupling: Interdependency between components (low coupling is good) Cohesion: How related a class is (high cohesion is good)
82
Name the SOLID principles and a short description
**Single responsibility principle**: “a class should only have one, and only one, reason to change”. **Open/closed principle**: “software entities should be open for extensions but closed for modifications”. (Bertrand Meyer 1988) **Liskov substitution principle**: “derived classes should be usable through the base class interface, without the need for the user to know the difference”. (Barbara Liskov 1987) **Interface segregation principle**: “many client-specific interfaces are better than one general-purpose interface”. **Dependency inversion principle**: “depend upon abstractions, do not depend upon concretions”.
83
What to look for in code to see if a SOLID principle has been broken?
S = A class has too many responsibilities O = You can't extend a class L = A subclass is not able to behave the same as the super class I = There's not enough interfaces D = When in the code we can see it depends on concretions rather than abstractions
84
What are design patterns?
Best practices and good design. Capture experience so others can use it.
85
What does software architecture consist of?
Non-functional requirements
86
What is layered architecture and name the 4 layers
Models interface of sub-systems. Organise into a set of layers. A changed layer will only affect the adjacent layers. - User interface - User interface management - Business logic - System support
87
Architectural design is a creative process, some other connected concepts are:
**Architectural styles**: high-level abstractions, guiding the overall organisation of a system (client/server, pipes and filters) **Architectural patterns**: detailed solutions to recurring architectural problems within a specific style. (model-view-controller) **Design patterns**: specific solutions to recurring design problems at a lower level than architectural patterns (adapter, compososite)
88
What are pipes and filters?
A way to process/produce data. Workflow matches the structure of business processes. Not suitable for interactive systems Filters: Processing component Pipes: Transitions, pipeline
89
What is Model-View-Controller (MVC)?
Supports presentation of data in different ways. Can be complex. Structured into 3 main components that: - Models the data - Views the data - Controls the data
90
Mention 4 design patterns and describe them shortly
**Adapter** (structural): Adapts a class that doesn't fit the expected interface, to then fit in (object adapter and object adapter) **Composite** (structural): Treats simple and complex objects as the same (recursive tree structure) **Strategy** (behavioural): Groups family of algorithms together, separate classes, interchangeable **Observer** (behavioural): Set of objects "observerving" the state of an object. Notifies the objects of changes and updates them
91
How to find out what the design pattern is in UML
**Adapter**: Look for class that acts as a bridge for another class to fit into the expected interface (superclass) (adapter has the aggregation, points towards the different interface) **Composite**: Recursion!!!! Looks like a normal subclass (generalisation), but with an aggregation on the composite to the super class **Strategy**: When there's grouped classes that points to an interface (generalisation), which points to the super class (aggregation on the superclass points towards the interface) **Observer**: Observer looks like strategy, but we will assume it says observer in the class name to see the difference (look for notify as well)
92
How to make an aggregation/composition in code?
Wherever the diamond is, is where we will declare a class. The direction it's pointing, is the name of the list, and the content is whatever is on the association line. ``` public class ResourceElement { private List content; //... } ```
93
How to write methods from UML into code: ``` + getPrice() : double + getPrice(d : double) ```
``` public double getPrice(); public getPrice(double d); ```