Vigtige ting Flashcards
Make a unit test like in the lecture (calculator)
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); } }
Write the skeleton for an if-statement:
boolean condition = true if (condition) { // something happens } else { // something ELSE happens }
Write the skeleton for a while-statement:
while (condition) { //something happens }
Write the skeleton for a for loop-statement:
for (int i = 0; i < 0; i++) { //do something 10 times }
Write the skeleton for a for each-statement:
String[] mylist = {"Red", "Green", "Blue"} for (String content : mylist) { // do something }
Can you use “==” on Strings?
No, you instead usemessage.equals("Hello, World");
Create an instance of a class:
Super class is Car, subclass is ElectricCar:Car myCar = new ElectricCar();
how to write main?
public class Main{ public static void main(String[] args) { System.out.println("Execute program"); }
What are the benefits of OOP?
Abstraction, encapsulation, inheritance and polymorphism (maybe modularity?)
What is polymorphism?
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 do you use super
?
Attributes: super(name, age);
Methods: super.animalSound();
Write a getter and a setter:
public int getPrice(){ return price; } public setPrice(int price){ this.price = price; }
How to make enumeration in code?
enum level { LOW, MEDIUM, HIGH }
Make an abstract class with an abstract method in it:
public abstract class Animal{ private int age; public abstract move(); }
Make a constructor:
public class Animal{ private int age; private String name; public Animal(int age, String name){ this.age = age; this.name = name; } }
What is static type and dynamic type?
Static type is known during DEVELOPMENTPet somePet = new Pet();
PET IS STATIC
Dynamic type is known during EXECUTIONPet somePet = new Dog();
DOG IS DYNAMIC
What does instanceof
do?
Checks whether object is an instance of the specified type
if (Pet instanceof Dog) { //does something }
What is method overriding and method overloading?
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)
What are arrays and lists?
Arrays are for fixed numbers, allows speed of access.
Lists are dynamic and allows for ease of access
What does abstraction mean?
Focusing on details (necessities), leaving out unnecessary details.
What is encapsulation?
Regulates access to members from the outside. Put them in a capsule to protect them. Use visbility modifiers for this.
What does inheritance mean?
Reusing code (rather tha duplicate) and inherits from the super class (kind of polymorphism, because behaviours and traits are shared)
What is an interface?
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 to write an interface and implement it in a class?
interface Animal { public void makesound(); public void eat(); } public class Pig implements Animal interface { // implement methods now }
What is software development?
ITERATIVE AND INCREMENTAL
Give an example of a list:
List allRecords = new Arraylist<>();
OR
List<Elements> content;
Benefits of IDEs
Highlighting, debugging, code completion, execution
What terms are used when defining a Version Control Syste (VCS)?
Version, development line, branch, merge, tag, merge conflict
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
Characteristics of SVN:
Checks out only PARTS of the project
Renames counts as a totally new file
Not that great for non-linear workflow
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
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)
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
Name the data storage tools
Apache HBase
Apache Phoenix
Druid
Cassandra
Name the data calculation tools
Apache Pig
Apache Kafka
Apache Samza
Name the data query tools
Apache Hive
Apache Drill
Name the coordination tools
Apache Zookeeper
Name the machine learning tools
Apache Mahout
ML4J
dl4j
WEKA
Why is software engineering difficult?
- Complexity
- Conformity
- Changeability
- Invisibility
Outline software engineering
- Modeling activity
- Problem solving activity
- Knowledge acquisition activity
- Rationale management actvitity
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
Stages in Object Oriented Software Development (OOSD)
- Requirment elicitation
- Analysis
- System design
- Object design
- Implementation
- Testing
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
What activities are common to all software processes (LIFECYCLE)?
- Software specification
- Software development
- Software validation
- Software evolution
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
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
What is the agile method process?
Combination of iterative and incremental methods. Smaller iterations (sprints), delivers work in increments
When do you use change avoidance and change tolerance?
In the context of reducing the cost of rework
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
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
Name 3 good practices of Extreme Programming (XP).
- Pair programming
- Simple design
- Test-first development
- Refactoring
Mention 3 principles of Agile software development
- Collaboration
- Motivation
- Communication
Characteristics of Scrum
Scrum team:
- Product owner
- Developers
- Scrum master
Product backlog, sprint, sprint planning, sprint backlog, daily scrum, increment, sprint review, sprint retrospective
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
What is verification and validation?
Verification: Are we building the product right?
Validation: Are we building the right product?
How do we deal with faults?
Fault avoidance
Fault detection
Faul tolerance
What is fault, erroneous state and failure?
Fault: bug
Erroneous state: Further processing leads to failure
Failure: Deviation of observed behaviour from specified behaviour
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
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
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)
Mention the integration tests
- Big bang
- bottom up (no stubs, needs drivers)
- top down (no drivers, needs stubs)
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)
What are the 3 non-functional requirements in the tree?
Product requirement, organisational requirement, external requirement
What are the requirement validations?
- Complete
- Consistent
- Clear
- Correct
What is the requirement process?
Requirement elicitation (understood by user) and analysis (understood by developer)
FURPS+ model
FURPS:
- Functionalit
- Usability
- Reliability
- Performance
- Supportability
+:
- Implementation
What are some requirement elicitation techniques?
- Document analysis
- prototyping
- questionnaire
- interview
- focus group
- oberservation
How do we manage requirement specifications?
- Negotiating the requirements with clients
- Maintaining tracebility
- Document the requirments
What are the 3 C’s of user stories?
- Card
- Conversation
- Confirmation
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)
What are the relevant steps of modeling in software development
- Analysis
- System design
- Detailed design
- Implementation
- Quality assurance
- Maintenance
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
Name everything in UML object diagram
- Object (can be anonymous)
- Attributes (if relevant)
- Associations
Name everything in UML deployment diagram
- Node
- Artifacts
- Stereotype
- Communication path
- Nested nodes
- Titles (object)
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
Name everything in UML activity diagram
- Action
- Transition
- Initial node
- Final node
- Decision
- Guards
- Fork
- Join
- Swim lanes
Name everything in UML state machine diagram
- State
- Initial node
- Final node
- Transition
- Decision
- Trigger
- Guards
- Action
Name everything in UML sequence diagram
- Lifeline (write as object)
- Activation box
- Nested activation box
- Synchronous message
- Asynchronous message
- Return message
- Termination
What can UML be used for?
- Sketch
- Blueprint
- Development language
What are the symptoms of bad software?
- Confusing
- Rigid
- Fragile
- Immobility (no reuseability)
(common problems in software is spaghetti code, coupling and dependencies)
Explain coupling and cohesion?
Coupling: Interdependency between components (low coupling is good)
Cohesion: How related a class is (high cohesion is good)
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”.
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
What are design patterns?
Best practices and good design. Capture experience so others can use it.
What does software architecture consist of?
Non-functional requirements
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
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)
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
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
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
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)
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<Element> content;
//...
}
~~~</Element>
How to write methods from UML into code:
~~~
+ getPrice() : double
+ getPrice(d : double)
~~~
public double getPrice(); public getPrice(double d);