Software Engineering
Software Engineering
21F3001823
Software Engineering December 2, 2024
1
• Software Development: Write code based on the requirements and the design. Usually distributed, and
the developers write documentation and precise interface definitions.
• Testing is done to ensure that the software behaves according to the requirements, many bugs might still
exist in the system. A failure to address bugs can even cause severe catastrophes.
• Testing is done at different granularities, examples include unit testing, integration testing, acceptance
testing.
• Alpha testing done by internal employees and Beta testing done by actual users.
• Maintenance: After the feature is rolled out, monitor how users are using the feature. Purpose of
doing this is to monitor what users are doing, and how they are using the software, change the code for
upgrades/updates, or add features.
• Overall Process: Requirements → Design → Development → Testing → Maintenance
2
2 Requirements Gathering and Analysis
2.1 Case Study: Amazon Seller Portal
• Our vision of what the software should look like and behave is quite different from what the user has in
mind.
• We want to make sure that developers understand what customers want, customers come to an agreement
about their requirements. If this does not happen we could end up with increased cost and iterations.
• Amazon wants to develop a portal for sellers. Products which sellers list on the portal will be available for
people to buy on the Seller portal.
• Primary Users: Frequent users of the system. Example include Independent sellers, Sales team of
consumer companies, Independent authors and publishers.
• Secondary Users: Do not directly use the system, use the system through an intermediary. Examples
include Sales team managers.
• Tertiary Users: Do not use the software at all, affected by the introduction of the software, and Influence
the purchase of the software. Examples include logistics, shipping companies, banks, people buying on
Amazon.
• Requirements can be vague or unclear. Requirements can be inconsistent or contradicting. Requirements
can be incomplete.
• Documentation: Procedures and rules for a task, steps involved in an activity, regulations governing a
task.
• Basic Guidelines: Focus on identifying stakeholders needs, involve all stakeholder groups, use combination
of data gathering techniques. Run a pilot session if possible to ensure your data-gathering session is likely
to go as planned.
• Data gathering is expensive, time-consuming - have to be pragmatic, make compromises.
• Functional Requirements: Captures a functionality required by the users from the system.
• Non-Functional Requirements: Essentially specifies how the system should behave. Examples include
Reliability, Robustness, Performance, Portability, Security, etc.
• Reliability: Te extent to which a program behaves the same way over time in the same operating
environment.
• Robustness: The extent to which a program can recover from errors or unexpected input.
3
2.3 Software Requirement Specification
• Requirement gathering and analysis: Done by system analyst, along with other members of the
software team. Organize these requirements in Software Requirements Specification(SRS) document.
1. Introduction
1.1 Purpose
1.2 Scope
1.3 Definitions, acronyms, and abbreviations
1.4 References
1.5 Overview
2. Overall Description Broad outline and description of the software system
2.1 Product Perspective
2.2 Product Functions
2.3 User Characteristics
2.4 Constrains
2.5 Assumptions and Dependencies
3. Specific Requirements
3.1 External Interface Requirements
3.1.1 User Interfaces
3.1.2 Hardware Interfaces
3.1.3 Software Interface
3.1.4 Communication Interfaces
3.2 System Features
3.2.1 System Feature I
3.2.1.1 Introduction/Purpose of Feature
3.2.1.2 Stimulus/Response Sequence
3.2.1.3 Associated Function Requirements Functional and Non-Functional Requirements
3.2.1.3.1 Functional Requirement I
...
3.2.1.3.n Functional Requirement n
3.2.2 System Feature 2
...
3.2.m System Feature 2
3.3 Performance Requirements
3.4 Design Constraints
3.5 Software System Attributes
3.6 Other Requirements
• table ○
1 is a guideline of how an SRS document should look like and is not very rigid.
• SRS helps form an agreement between customers and developers. It helps to reduce future reworks. Provides
a basis for estimating costs and schedules.
• Behaviour Drive Design: Asks questions about the behaviour of an application before and during
development. Requirements are continuously refined to meet user expectations.
• User Stories: Short, Informal, plain language description of what a user wants to do within a software
product which is of value of them. Smallest unit of work which can be done in 1 sprint, which is about 1–2
weeks.
4
Figure 1: User Story Examples
• User Stories are lightweight and help plan and prioritize development. Concentrate on behaviour rather
than implementation of the application. Conversation between users and the development team.
• SMART: Specific(know exactly what to implement), Measurable(known expected results for some inputs),
Achievable(Implement the user story in 1-2 weeks), Relevant(Business value to one or more stakeholders),
Timeboxed(Stop implementing a feature once time budget expected).
• May be difficult to have continuous contact with users. Not able to scale to very large projects, safety
critical applications.
• Brief overview of the difference between requirements and user stories.
5
3. Satisfaction: What motivates people to use the system? What does it enable people to accomplish?
What need does the system fill?
• Digital Mock-ups: Using stuff like photoshop, PowerPoint, transform a paper prototype into a digital
mockup.
6
• Experts evaluate the prototype, i.e., do multiple passes and provide a list of issues that violate design
heuristics.
• Importance of typography.
7
4.2 Project Scheduling
• Helps monitor timely completion of a task, and take corrective action if it falls behind.
• Activity Network: Different activities making up a project, estimated durations, interdependencies. Leaf
nodes of the WBS become the nodes of the activity network.
• Technical Risks: Due to development team’s insufficient knowledge about the product.
• Developing the wrong functions and user interfaces, can be mitigated by communicating with clients and
build prototypes.
• Shortcomings in external components, can be mitigated by benchmarking and regular inspections.
• Project Risks: Project risks occur due to problems in budget, schedule, personnel, resources, and customer
related problems.
• Most common type is schedule slippage, the project falls behind schedule, can be mitigated by creating
detailed milestones, constant iterations, communicate frequently with clients.
• Insufficient domain knowledge/technical knowledge, can be mitigated by hiring developers with relevant
experience, or we could outsource to third party vendors.
• Personnel shortfalls, can be mitigated by cross-training, train multiple people with skills required to work
on the project.
8
• Business Risks: Risks which can harm the business aspects of the software product.
• Product is no longer competitive in the market, can be mitigated by exploring the market for similar
products.
• Gold plating, developing unnecessary features, can be mitigated by communicating with clients and do
cost-benefit analysis.
• Risk Assessment: Project manager asks everyone in the team for worst case scenario and the PM then
creates a ”risk table”.
• Then a probability(P) is assigned to each risk, each risk is also assigned Impact(I), which can negligible,
marginal, critical, catastrophic(1-4).
• The risk is then calculated as Risk = P × I, which then is sorted in descending order and decide which risk
need to mitigated first.
• Product Backlog: Prioritized list of work for the development team that is derived from user stories and
requirements. Prioritizing will be done in sprint planning meetings.
• Standup/Daily Scrum Meeting: Daily meeting which involves everybody. Each member answers three
questions, What did I work on yesterday?, What am I working on today?, and What issues are blocking me?
• Sprint Review: After the sprint the team demonstrates what they have completed. Move things from
To-Do, In Progress to Done.
• Sprint Retrospective: Evaluate the last sprint, Discuss user stories/tasks that went well/didn’t go well,
and finally create and implement a plan.
• Project Scheduling: Key indicator of progress is how many user stories are implemented. Project
estimation can be simply counting the number of user stories completed per iteration/sprint.
• Not all user stories require the same effort, and hence this can lead to mis-prediction. This is mitigated by
assigning points to user stories, and calculate velocity which is the number of points per iteration/sprint.
• One good software to do this is Pivotal Tracker, Link for which can be found here.
5 Software Design
5.1 Outcomes of the Design Process
• We will design an high level view of software architecture
1. Components: Collection of functions and data, should accomplish some well-defined tasks.
2. Interfaces: How components communicate with each other.
3. Data Structures: Suitable data structures for storing and managing data.
4. Algorithms required to implement individual components.
• Characterizing a Good Software Design
9
1. Correctness: Correctly implement all the functionalities of the system.
2. Efficiency: Ensure that resources, time, space, cost, are managed well.
3. Maintainability: Easy to Change
4. Understandable by everyone in the development team.
• Modular: Problem has been decomposed into a set of modules that have only limited interactions with
each other.
• High cohesion: Functions of the module cooperate with each other for performing a single objective.
• Two modules are data coupled if their communication is using a primitive data type.
• Control Coupling: Data is passed that influence the internal logic of a module.
• Common Coupling: If two modules share global data items.
• Content Coupling: If one module refers to the internals of the other module.
• Functional Cohesion: Different functions of the module cooperate to complete a single task.
• Sequential Cohesion: Different functions of the module execute in a sequence. Output from one function
is input to next in the sequence.
• Communicational Cohesion: If all functions of the module refer to or update the same data structure.
• Procedural Cohesion: Activities in the module are related by sequence. Set of functions in the module
are expected one after the other, work towards entirely different purposes.
• Coincidental Cohesion: Module has functions with meaningless relationships with one another.
• Class are template for object creation. All objects possessing similar attributes and methods constitute a
class.
• Association: Take each other’s help to perform some functions.
• Composition: Represents whole/part relationships.
10
• Dynamic Behavioral View: Describes behavior of the system over time. Further classified into
1. State Machine View: Models different states of an object of a class.
2. Activity View: Models flow of control among computational activities.
3. Interaction View: Sequence of message exchanges among parts of a system.
• Purposes of Modelling
1. Serves as a vehicle for communication and idea generation.
2. Guide Development of software
3. Close correspondence with the implementation. Generate code from models.
• VeriSIM: Verifying designs by Simulating Scenarios. Develop an integrated understanding of class and
sequence diagrams. A VeriSIM learning platform can be found here.
• Design Tracing Strategy: Construct a state diagram which models the scenario.
• Check chapter 3 of the reference manual for an overview, it can be found here.
11
6 Software Development
6.1 Rest APIs
• Use editor.swagger.io, can be found here.
• Use Insomnia software for testing downloaded YAML file and code. Download link can be found here.
• Centralized VCS: maintained on the server, that everybody shares. Entirely based on client server model.
Checkout whole or part of the repository, make changes and push back the changes to the server. Highly
dependent on the server.
Anything goes wrong, the development halts till the server is up again.
May even lose entire history or repository if no backups configure.
• Distributed VCS: Entire repository is mirrored locally that includes the full change history. Centralized
repository hosting possible but complete dependency is not on it. Basically everyone owns their own local
copies of the repository.
• Git: Free and open source VCS. Focus is on speed, data integrity and working on multiple tasks.
• git status view the status of your local files in the working directory and staging area.
• git diff show changes between commits, commit and working tree
• git reset HEAD filename unstage the file
• git checkout filename undo the changes that are committed but not yet pushed to remote.
• git log check commit logs/history.
• Branching: Branches are independent versions of repository. Mechanism to diverge work from the main
project line.
git branch feature1 create a new branch named feature1 from the base branch you are working on.
git branch list all local branches
git checkout command to switch branch, git checkout feature1
12
• Merging: A way to combine changes made through one or more branches to a single branch.
git merge feature1 merge the branch ”feature1” to the current working branch.
• Rebase: Incorporate changes from one branch to another. Incorporate latest changes from master branch
to feature1 branch. git rebase.
• For more details refer git-scm book, can be found here.
• An issue is reported by developer or tester or user when encountered, this needs to be saved and tracked till
it is fixed. We need a system to do this.
• Can create a branch or pull request to map to an issue. Can map more than one issues to a branch.
• Code Reviewing: Quality assurance in which multiple people examine the changes done by a developer.
• Improves code Quality, Focus not just on correctness but also on aspects like efficiency, complexity and
security.
• Minimize Technical debt, Well documented code with consistent design and implementation reduces
maintenance costs and efforts.
• Risk reduction, Testing cannot guarantee software to be completely bug free.
6.3 Debugging
• Error: discrepancy between actual behaviour and intended behaviour
• Failure: Observable error, Incorrect output value, exception etc.
13
6.4 Software Metrics
• Quantitative way to measure the quality of your code
• Cyclomatic Complexity: Number of decisions a block of code contains +1, use Radon(python package).
• Refactoring: Changing the code by improving its structure, without changing its behaviour.
7 Software Architecture
7.1 Introduction
• Way of organizing your code
• Define software elements/modules, relations among them, and properties of both elements and relations.
14
• Model-view-controller: Architectural style where views of the data are separated from the manipulations
of data
1. Model: the component which models the data required for the service
2. View: the GUI objects, presentation layer, visual representation of the Model
3. Controller: coordinates multiple Views on the screen, and helps users manipulate the model
• Peer to Peer Architecture: Distributed application - different systems form nodes, and share resources
with each other.
• Connectors: Code that transmit information between components. Responsible for regulating interactions
between components
• Protocols: Set of pre-defined rules which describe how components should interact with each other
• Design Patterns: Descriptions of communicating objects and classes that are customized to solve a
general design problem in a particular context
• Design Smells: warning signs that your code may be heading towards an antipattern
• SOLID Guidelines: Avoid design smells
• Refactoring: moving code between classes, creating new classes or modules, removing classes that aren’t
required
15
• Structural: Composition of classes or objects
1. Facade Design Pattern: Reusing code, will have to know details about different objects, functions
Solutions: Provides a simple interface to a library, or a complex set of classes
Pros: Isolate code from other libraries/classes’ complexity
Cons: Tightly coupled to other objects, maintenance becomes more difficult
2. Adapter Design Pattern: Some products have cost in dollars/euros. Conversion to rupees is needed
Pros: separate data conversion code from primary business logic, New types of adapters
Cons: Overall code complexity increases
• Behavioral: Characterize the ways in which classes or objects interact and distribute responsibility
1. Iterator Design Pattern: Different types of collections, How to access and iterate through elements?
Solution: Separate the behaviour of how elements are accessed into a separate object called an iterator
Pros: Separate access of elements from other functionalities, new types of iterators, collections
Cons: Can be an overkill for simple collections
2. Observer Design Pattern: Notify a particular set of buyers when a new product is launched
Solution: Subject object maintains a list of observers, Notifies them of automatically of any changes
3. Strategy Design Pattern: Process orders based on different strategies
Solution: Extract different strategies (algorithms) into separate classes, Original class (context)
delegates the work to strategy object
Pros: Isolate implementation details of algorithm, new strategies without changing existing classes
Cons: Not required if there are only a few algorithms which will be used
8 Testing
8.1 Motivation
• Errors in software programs, even simple errors can cause entire systems to crash.
• Testing for a large collection of randomly selected test cases do not guarantee that all errors will be
uncovered.
• Domain of all input values in a software system is sufficiently large.
• Necessary to design a minimal test suite where each test case helps detect different types of errors.
16
8.3 Black box and White box testing
• Black box testing: Examining input/output values only, No knowledge of design or code required
• Equivalence Class Partitioning: Domain of input values partitioned into a set of equivalence classes.
Program behaves similarly for every input data in a particular equivalence class.
• Boundary Value Analysis: Examine the values at boundaries of the equivalence classes.
• White box testing: Analyze the structure of the program using some heuristics
• Branch coverage: Every branch in the program needs to be taken at least once
• Multiple branch coverage: Each component condition takes true and false values
• Path coverage: access all linearly independent path at least once.
9 Software Deployment
9.1 Development Environment and Strategies
• Development Environment: Local environment of a software developer, Contains IDE and other tools
• After Development or during we have a testing environment.
• Staging Environment: Exactly resembles the production environment, Run on a remote machine
17
• Blue/Green Deployment: Staged Deployment, Create a new separate production environment for the
new version, without affecting the current one, Regular cycling between real and previous versions
Advantage: rollback is easy
• Canary Deployment: Phased Rollout/Incremental Rollout, Slowly roll out the change to a small subset
of users
Drawback: manage multiple instances at once
• Versioned Deployment: Allow users to choose version, Keep all versions alive, If user updates, route
them to the new version
Drawback: have to maintain multiple versions
18
9.4 Performance and Monitoring
• Caching: Store results of common operations in memory, Fetch from memory instead from database,
examples include Memcached, Redis
• Different levels of caching are Web browser, Web server(page cache), Database query cache, results of recent
queries which haven’t changed
• Asynchronous work queue: executed outside the HTTP request-response cycle
• Consists of Queue of jobs to be performed, parameters and Pool of workers take multiple jobs from queue
• Quick loading of pages is important, minifying code helps, and compressing static pages.
• Issues can still arise in the live environment
• Generate reports: Analyze page resources, find optimization suggestions, check SEO and accessibility
metrics and calculate your performance score. One example of this is Lighthouse.
• Clickstreams: which sequences of pages do your users visit the most
• Think time/dwell time: how long does a typical user stay on a given page
10 Other Aspects
10.1 Software Organizations
• Marketing Team: Look for opportunities in the market, to provide value, Conduct market research,
identify audiences
• Business: Works closely with marketing teams and sales, Understand business goals, how the product will
maximize return on investment
• Tech: Should know the technology stack, Understand the level of effort involved, Take important technical
decisions.
• UX: Passionate about the user, What does the user want
• A good product manager must be experienced in at least one, passionate about all three, and conversant
with practitioners in all.
19
• Designers: User Experience (UX) roles, Transform requirements to solutions, Talk to users, create
prototypes
• Software Engineers: Write code with others in the team to implement requirements, Software engineers
don’t get to decide what product is made, or what problems the product solves
• Engineering Managers: In large organizations, transmitting information between higher and lower parts,
Also known as project manager.
• PMs are responsible for Organizing and prioritizing work, Coordinating between different teams, Resolving
interpersonal conflict between engineers
• Sales Team: Sell the product it to users that marketing team has identified. Provide feedback to marketing,
product, and design teams regarding the product, which engineers then address.
• Support Team: Resolve problems that clients have, Provide feedback to product, design, and engineering
about the product and it’s defects/shortcomings
• Data Scientists: Analyze data generated from different teams, users, Help organization make better
decisions
• Ethics and Policy Specialists: People with background in law, social science, policy, Shape the terms
of service of the software product, software licenses, privacy policy etc. Important for any company that
works with data
• Stack Overflow: Helps to resolve issues that you are facing, Provides links to additional learning resources
• Knowledge of one project might be needed in another project. Useful if it is documented and archived
properly
• When people leave the organization, specialized knowledge goes along with them
20