Software Engineering 2 Cheatsheet
Software Engineering 2 Cheatsheet
Intro
Engineer = capable of designing a system; Programmer = hired to produce code; Developer = design and architect software + documents; Software
engineer = thinks of the end product, bridges the gap between customers and programmers
Requirements Engineering
Domain Analysis; Problem Definition; Requirements Gathering; Requirements Analysis; Requirements Specification
Design = User Interface Design, Define Subsystems; Modeling = Use Cases, Structural (Formal) Modelling, Dynamic Behavioural Modelling
Quality Assurance
Review and Inspection; Testing; Deployment; Configuration Management; Process Management = Cost Estimation, Planning
Incremental vs Iterative
Incremental Iterative
1. The requirements are divided into different builds 1. Does not start with a full specification
2. Needs a clear and complete definition of the whole system from the start 2. Building and improving the product step by step
3. Customers can respond to each build (but a build may not represent the whole 3. We can get reliable user feedback
system)
4. Incremental fundamentally means add onto and helps you to improve your 4. Good for big projects
process
5. Only major reqs. can be defined, details may evolve over time
Story Cards
Story Maps
Prototyping
Types of Prototypes:
Throwaway = Example is a paper one. Will be used only for evaluation;Incremental = created a separate components; Evolutionary = refined to
become actual product
Prototype Fidelity:
Low = Omit details (Rough, no code, easy to trash) - Paper, Storyboard, Wizard of OZ (evaluation) High = Looks like a polished product (looks of product,
comment on aesthetics, GUI powerpoint etc are used)
Prototyping can help answer:
Prototyping (cont)
- Crowded UI, Knobs versu slider for controlling volume, Navigation = Transparent or solid menu?
White = AKA glass box, structural; Tester know the source code and can debug at runtime = Developer's perspective
Unit Testing = Do discrete parts of my system work as expected?
- Does an individual method work as expected?
- Necessary calls to other methods should be mocked out where possible
-Always white box
Black = Tester gives inputs and observe outputs (No code, only focus on reqs., interacts with UI only) = User's perspective
Acceptance Testing = Is the system working from the customer's perspective? (AKA. System testing)
- Interacts with system through GUI
- Focused in feature
Usually black box
Agile vs TDD
TDD = focused on how code gets written (for work cycles of individuals or small groups of developers exclusively)
Agile = Overall development process (focuses on project management and groups of developers, as opposed to specifically how a given developer writes
code)
Polymorphism
A property of OO software by which an abstract operation may be performed in different ways, typically in different classes.
Inheritance
Implicit possession by a subclass of features defined in a subclass. Features include variables and methods
- A class that has one or more abstract more abstract methods must be declared abstract.
- Any class, except a leaf class, can be declared abstract
- Label with <abstract>
Sturctural Modelling
Dependency: Used for extremely weak relationships between classes. Ex. A class makes use of a library
Aggregation: Represents "part-whole" relationships. The whole side is called the aggregate. Aggregations are read as "is part of"
Composition: Are strong forms of aggregation. If the aggregate is destroyed, then the parts are also destroyed.
Aggregation = An association is an aggregation if: the parts 'are part of' the aggregate. The aggregate 'is composed of' the parts. When something owns
or controls the aggregate, then they also own and control the parts
Evolvability
"The ability to be evolved" - to adapt in response to change in its environment, requirement and technologies that may have impact on software structural
and/or functional enhancements, while taking architectural integrity into consideration
Ways of dividing: distributed systems = clients and servers; systems = subsystems; subsystem = one or more packages; package = classes; class =
methods
Occurs when there are interdependencies between one module and another
When interdependencies exist, changes in one place will require changes somewhere else
Network of interdependencies makes it hard to see at a glance how some components work
Coupling implies that if you want to reuse one module, you have import the coupled ones too
Types (high coupling to low): - Content: one module to another - Common: two modules share global data, - External : two modules share data format,
protocol, - Control - one module controls the flow of another through the argument it passes, - Stamp: Modules share a data structure but each only use a
part of it, - Data: modules share data (through parameter passing), - Message: communication between modules via message passing
Adapter
Context = Building an inheritance hierarchy and want to incorporate it into an existing class; the reused class is also often already part of its own
inheritance heirarchy
Motivation = how to obtain the power of polymorphism when reusing a class whose methods have the same function but not the same signature as the
other methods in the hierarchy?
Pros = allows you to reuse code that doesn't quite match the method signature you were expecting and you can't modify, decouples clients from internal
structure
Cons = changes the interfaces to the functionality you want to use, overuse allows for many redundant classes
Singleton
Intent = ensure a class only has one instance and provides a global point of access to it
Motivation = It's important for some classes to have exactly one instance. We want to use a single log object to keep track of when multiple threads are
taking certain actions and it's important that the timing is shown correctly
Cons = Better ways of doing this, usually used wrong and is dangerous (security)
Observer
Context = When an association is created between two classes, the code for the class becomes inseparable, reuse of one class means reuse of the other
Motivation = how do you reduce the interconnection between classes, especially between classes that belong to different modules or subsystems?
Antipatterns = Connect an observer directly to an observable so that both have reference to each other, - Make the observes subclasses of the observable
Pros = Limits the amount of information accessed by different classes, ensures that events are handled
Cons = Many modern programming languages have a better, built in event system
Software Architecture
- Dividing software into subsystems - Deciding how these will interact - Determining their interfaces: the architecture is the core of the design so all software
engineers must understand it. Architecture will often constrain the overall efficiency, reusability and maintainability of the system
Importance: To enable everyone to better understand the system, To allow people to work on individual pieces of the system in isolation, prepare for
extension of the system, facilitate reuse and reusability
- Logical breakdown into subsystems, - Interfaces among the subsystems, - Dynamics of the interaction among components at run time, - Data will be
shared among subsystems, - Components will exist at run time and the machines or devices on which they will be located, -
- Stable = means new features can be easily added with only small changes to the architecture
Intent = an architectural pattern used to help separate the user interface layer from other parts of the system
Motivation = I have a program which interacts with advanced user (through command line) and novice users (through a GUI)
Model = Manages behaviour data, responds to requests about its state (view), responds to state change commands (controller)
Refactoring
The process of changing a software system while not altering the external behaviour of the code
Code Smell = surface indication that corresponds to a deeper problem in the system (Duplicated code, Feature Envy, Middle Man, Temporary Fields)
Refactoring Techniques = Extract method, Move method, Pull Up method, Remove middle man, Extract Class, Inline = put body in caller's method and
remove the self method
Duplicated code (same expression in two methods of same class or subclasses/similar code/does same thing, different algorithm) = Extract method, Pull
up method/field
Feature Envy (likes other classes than it's own) = Move method, Extract method
Requirements Activities
Eliciting Requirements; Modeling and Analyzing Requirements; Communicating Requirements; Agreeing Requirements; Evolving Requirements
Elicitation = Surveys, analysing existing documents, brainstorming, model driven techniques, observation or card sorting
Modelling = Data, Enterprise, Behavioural, Domain or non-functional reqs.
Communicating = Effective communication among different stakeholders
Agreeing = Verification and validation, requirement conflicts, requirement risks, stakeholder conflicts
Evolving = Managing change, adding reqs, reqs. scrubbing, fixing errors, managing documentation
Overriding
2. SubClassA implements method M' such that the signatures of M and M' are indistiguishable
Dependencies only involve using other classes Associations involve maintaining references to other classes
Aggregation vs Composition
Aggregate parts continue to exist if the aggregation is destoryed and can be Composite parts are specific to their composition and will be destroyed
used in multiple aggregations with the composition
Sequence = good for explicit ordering of interactions (Interaction model Communication = Adding details to class diagrams (validates a class
for use case = use case make time ordering explicit) diagram and derives an interaction from a class diagram)
Maintainability = actual effort required to locate and fix a fault in the program within its operating environment Evolvability = potential to respond
Evolvability Charcteristics
Integrity Capability of the software system to maintain architectural coherence while accommodating changes
Portability Capability of the software system to be transferred from one environment to another
Extensibil Capability of the software system to enable the implementation of extensions to expand or enhance the system (new capabilities and features)
ity with minimal impact to the existing systems
Design Patterns
Motivation = short scenario illustrating the context in which the pattern can be used
Concurrent Engineering
Refactoring: Incrementally improving the code Sustainable Pace: No overtime, people work when rested
Agile Spiral
Not good for low rates of requirements change (cost of collaboration) Suitable for large scale development (due to risk analysis)
Is good for low-risk and less critical systems More emphasis on documentation and process
Name = What is this use case about? Needs to be descriptive so people can use it. The most important part
Actors = Who is going to use this use case? Focus on types of people
Postconditions = What is the result of this interaction Focus on what has been accomplished
Integration Testing
TDD
Specification and not validation (one view), Is a programming technique (another view), Is a way of managing fear during programming, Enables you to take
small steps when writing software
Writing the test beforehand makes developers think from a user's perspective when coding leading to a usable API
Objective = Finding errors in early Objective = Checks the functional Check that the software product meets Whether the system is well-
stages of the development cycle behaviour of the system the customer's actual needs engineered? Error free?
Are we building the product right? Are we building the right product? Dynamic Static
Activities = Reviews, Walkthroughs, Inspection Testing - The product meets the user's needs = the product fulfills its intended use
Checking whether the software is of high quality will not ensure that the system is useful. SoTrust but verify, verify but also validate.
Testing Practices
Exploratory Testing Simultaneously learning about the software under test while designing and executing tests
Equivalence Classes Divide possible inputs into equivalence classes based on how the system should react to them
Testers require knowledge: how system works (internally and in detail), how to create input to trigger all code paths
Race Conditions
A race occurs when two threads are using the same resources and the order of operations is important
Critical races can be prevented by locking data so they cannot be accessed by other threads
Testing Strategies
- Hard to test critical races
- Use mocking to control the order
OO systems make use of abstraction in order to help make software less complex
OO systems combine procedural and data abstractions = organizing procedural abstractions in the context of data abstractions
OO paradigm is an approach which all computations (abstractions) are performed in the context of objects.
OO analysis = which objects are more important for the users (no programming consideration)
Procedural = The entire system in organized into a set of procedures. One main procedure calls the others. (Performs calculations with simple data)
Data = Idea to group together the pieces of data that describe some entity, so that programmers can manipulate the data as a unit
Instance Variables
Association Represents the relationship between instances of one class and instances of another
Operation Used to discuss and specify a type of behaviour, independently of any code the implements that behaviour (higher level abstraction)
Interface
UML Diagrams
Interaction Diagrams: A set of diagrams to model the dynamic aspects of the system. To visualize how the system runs. Often built from a use case and
class diagram to illustrate how a set of objects accomplish the required interactions with an actor.
Sequence Diagrams: An interaction diagram that focuses on the sequence of messages exchanged by a set of objects performing a certain task
State Diagrams At any given point in time, the system is in precisely one state and will remain in the state until an event occurs to change state. Is a
directed graph, nodes are states, edges are transitions. Have timeouts to automatically change states
Interaction Diagrams Show (Interaction) = the steps of the use case, the steps of a piece of functionality. Composed of instances of classes, actors and
messages.
Sequence Diagrams: Can represent conditional logic and loops and show explicit destruction of objects.
Communication Diagram: Annotations of object diagrams. Shows link between objects that communicate
UML Modelling
UML (Unified Modelling Language) = graphical language for modelling OO software. 1980s - 1990s = first OO development processes
Types of UML diagrams = Class, objects, interaction, use case, state, activity, component and deployment
Component + Deployment = how the various components of the system are arranged logically and physically
Main symbols = Classes, Associations, Attributes, Operations, Generalizations (groups classes into inheritance hierarchies)
- Associations can be labelled to make explicit associations (are bi-directional by default, can add an arrow) = many to one, many to many, one to one/one
to itself (one to one can sometimes be unnecessary, look carefully!)
Subsystem or module has high cohesion when related things are kept together and everything else out
Measures the organization of the system, makes it easier to understand and change
Functional = code that computes a particular results is kept together (easy read, replaceable and reused)
Procedural = keeps procedures together (does not necessarily provide input to the next)
Functional = updating a database, creating a new file or interaction with a user is not functionally cohesive
Procedural = Each individual should have high cohesion in addition to organizing code in objects
Facade
Motivation = I have several parts of a subsystem that is getting quite complicated and I would like to simplify the process for using the subsystem.
Cons = if your subsystem changes, your facade will need to be updated as well
Requirements
Requiremen All of the things that a system needs to do!; Things you system should (or should not) do; Features your system must provide; Things your
t users will expect
Functional Inputs the system should accept; Outputs the system should produce; Data the system should store that other systems might use;
Requiremen Computations the system should perform (Not algorithms); Timing and sync. of the above (Not response time but the ordering of events)
ts
Functional Requirements: Could relate to interactions with a person or with another system
Functional What is the system doing? For example: Should be able to make two slides
Non Functional How is the system doing a thing? For Ex. A created slide should be displayed in 1 second
Non - Functional
Response Time, Throughput, Resource Usage, Reliability, Availability, Failure Recovery, Maintainability, Modularity, Security, Testability, Learnability,
Usability, Price, Extensibility, Reusability
Non functional requirements may be more critical than functional requirements, if these are not met, the system is useless! Usually cannot be implemented
in a single module of a program.
Planning
Planning = Process of deciding: What activities will be performed, when activities should be started/completed.
Project Planning = Scope of system as a whole, what order features will be done
Iteration Planning: Which features will be included in the next deliverable?
Parts of Planning
Which features are most valuable or risky?
Which features will make it into the project or iteration?
How much effort will each feature take?
Does a given feature depend on other features?
Based on all this: in which order will features be implemented?
Generally the high priority tasks should be picked first for an iteration
Tracking
TDD Techniques
Triangulation (Playing Difficult): Referring to how we're using multiple bearings to pinpoint the implementation towards the proper implementation
Using a test double As alternative and suitable implementations of an interface or class that we don't want to use in a test
This is because it's too slow, or not available or depends something not available or is just too difficult to instantiate
Objects
Represents anything with which you can associate properties and behaviour
Behaviour = the way an object acts and reacts to the possible changing of its state
Classes
Class = a software module that represents and defines a set of similar objects.
Class contains all of the code that relates to its objects. This includes data for implementing properties and procedures (AKA methods) for implementing
behaviour
Classes (cont)
Instance Variables = Each class declares a list of variables corresponding to data that will be present in each instance
Naming Classes
Noun or noun phrase
Singular
Capitalization Style: Pascal Case
No Space: PartTimeEmployee
Do not use underscore (_)
Neither too general nor too specific (city should be municipality)
Avoid reflecting the internals of the system ("Record, Table, Data, Structure, or Information")
Interface vs Abstract
- In Java, a class only derive from one other class = no multiple inheritance in Java (inherit only one abstract class)
- But a class can implement multiple interfaces.
- Abstract classes = meant for inheritance to form a strong relationship between two classes. Can have some implementation code.
- Interface = no method definition/only method headings
When to use?
Abstract = Inheritance (Gives a base class), having non-public members, to add new methods later on
Interface = The API will not change for a while, similar to multiple inheritance, has all public members
1. The classes of the two objects have an association between them (same direction = unidirectional)
2. The receiving object is stored in a local variable of the sending method. Object created in the sending method or some computation returns an object
(<<local>> or [L])
3. A reference to the receiving object has been received as a parameter of the sending method. (<<parameter>> or [P])
4. The receiving object is global. When reference to an object is obtained using a static method. (<<global>> or [G])
API
An API is provided by a piece of software - abstracts away the implementation of the software
An API is used by other pieces of software. Two pieces interact via API (API acts a contract between them)
They use knowledge of the reqs., the design created so far, the tech. available, software design principles and 'best practices' and past experiences.