Introduction to Software Engineering
Software Engineering: Principles, Processes, and Practices
What Software Engineering Is
Software engineering is a standardized, structured, and thorough approach to developing software. It treats software development as a complete process that begins before coding and continues through planning, implementation, testing, deployment, maintenance, and future improvements.
Programming focuses primarily on writing code. Software engineering includes programming but also addresses:
Understanding what customers and users actually need.
Planning how a large system will be built.
Organizing code into maintainable components.
Following common design and coding practices.
Verifying that the software is correct, efficient, secure, and reliable.
Collaborating with other developers.
Maintaining and improving the system over time.
A hobbyist programmer can often begin by writing code immediately and discovering the solution while working. A professional developer usually cannot rely on this exploratory approach, especially when building a large system for a customer or team. Professional software development requires a process that reduces wasted effort and increases confidence in the final product.
Software engineering distinguishes professional development from simply being able to write code.
Why Software Engineering Matters
Software engineering is valuable for three central reasons:
Building the correct product
The software must satisfy the customer’s actual needs.
A technically functional program is still unsuccessful if it solves the wrong problem.
Developing the wrong product wastes time, money, and development effort.
Following appropriate standards
Professional software may need to be maintained for months or years.
Multiple developers may need to understand and modify the same code.
Consistent coding styles, naming conventions, organization, and documentation improve collaboration and maintainability.
Achieving technical rigor
Software should be correct and produce the intended results.
It should be efficient enough for its intended environment.
It should be secure against misuse and attack.
Structured engineering practices provide evidence and confidence that these qualities have been addressed.
The Software Engineering Lifecycle
Software development can be viewed as a cycle containing four broad phases:
Requirements gathering and analysis
Planning
Development
Testing
These phases are useful for understanding the overall process, but they are not always completely separate. They may overlap or occur concurrently. For example:
Planning can begin while requirements are still being gathered.
Testing can occur during development rather than only after all coding is complete.
Feedback from a prototype may cause the requirements to be revised.
Testing may reveal design problems that require returning to the planning stage.
After the software is deployed, customers may request enhancements, fixes, or new capabilities. The lifecycle then begins again.
1. Requirements Gathering and Analysis
Software engineering begins before development. The first goal is to determine what the customer and users need the software to do.
Importance of Requirements
Requirements gathering is essential because customers do not always know precisely what they want. A customer may describe a general problem without understanding:
Which features are necessary.
How users will interact with the system.
Which constraints matter.
What should happen when errors occur.
How the system should respond in unusual situations.
Simply asking a customer for a list of features may therefore be insufficient. The list may be:
Very long.
Vague or incomplete.
Written in terms that are not useful to developers.
Focused on desired features without explaining the underlying problem.
Missing error conditions and exceptional cases.
The developer or development team often needs to actively investigate the customer’s work and translate user needs into clear, testable requirements.
Requirements-Gathering Techniques
Customer-Provided Lists
The simplest method is to ask the customer to provide a list of requirements. This can provide useful initial information, but it has limitations:
Customers may not understand the technical implications of their requests.
Important requirements may be omitted.
The list may describe solutions rather than actual goals.
Different requirements may conflict with one another.
The list may not explain how users will interact with the system.
A customer list is therefore often treated as a starting point rather than a complete specification.
Surveys
Surveys collect information from many users or stakeholders. They are useful when:
A large population needs to be consulted.
The development team wants to identify common needs or complaints.
Quantitative responses are valuable.
Users are geographically distributed.
Surveys may not provide enough detail about individual workflows, so they are often combined with interviews or observation.
Interviews
Interviews involve speaking directly with customers, users, or other stakeholders. They allow developers to:
Ask follow-up questions.
Clarify ambiguous statements.
Explore the reasons behind a request.
Investigate specific problems in detail.
Adapt questions based on the participant’s responses.
The interviewer should record and organize the information rather than simply allowing an unstructured conversation to determine the requirements.
Focus Groups
Focus groups bring several users or stakeholders together to discuss their needs and experiences. They can reveal:
Shared concerns.
Disagreements between users.
Different expectations about the same feature.
Common workflows and pain points.
Reactions to possible designs.
A focus group can produce broader feedback than an individual interview, although dominant participants may influence the discussion.
Observation
When an existing software system or workflow is available, developers can observe users as they perform their normal tasks. Observation helps identify:
How users actually work rather than how they describe their work.
Features users depend on.
Repetitive tasks.
Workarounds.
Sources of frustration or inefficiency.
Existing habits that a new system should preserve or improve.
Observation is especially useful because users may forget to mention routine actions or may be unaware of inefficiencies in their own workflow.
Use Case Analysis
Use case analysis describes how a user interacts with a system in a realistic situation. It focuses on the user’s perspective rather than the programmer’s internal implementation.
A use case should generally be:
Written in understandable language.
Free from unnecessary technical jargon.
Descriptive of what the user sees and does.
Organized as a sequence of actions and responses.
Focused on a particular user goal.
Main Success Scenario
The main success scenario describes the normal sequence of events when the user accomplishes the goal successfully.
For example, a sales system might use the following scenario to describe adding a sale:
The user initiates the process of adding a sale.
The system asks for the relevant information.
The user enters the product name and quantity.
The system stores the information.
The system completes the sale-entry process.
This scenario explains the interaction from beginning to end without describing the internal code or database design.
Alternative and Error Scenarios
A complete use case also considers situations in which the normal process does not occur.
For example:
The user enters a quantity less than 1.
The system displays an error message.
The system returns the user to the input step.
The user corrects the quantity.
Other alternatives may include:
The user cancels the operation.
The user closes the dialog box.
Required information is missing.
The system cannot connect to a database.
The user does not have permission to perform the action.
As more alternatives and error conditions are included, the use case becomes longer and more detailed.
Preconditions
A precondition is a condition that must be true before a use case can begin.
Examples include:
The user is logged in.
The user has permission to add a sale.
The database is available.
The required product already exists in the system.
Postconditions
A postcondition describes the state of the system after the use case ends.
Different outcomes may produce different postconditions. For example:
After a successful sale, a new sales record exists.
After cancellation, no new sale is stored.
After an error, the original data remains unchanged.
After the user closes the dialog, the operation is incomplete.
User Stories
A user story expresses a requirement from the user’s point of view. User stories are usually less detailed than use cases, but they emphasize the user’s goal and motivation.
A user story should identify three key elements:
Who wants something.
What that person wants to do.
Why the person wants to do it.
A common structure is:
As a particular type of user, the user wants to perform an action so that a specific benefit is achieved.
The “why” is especially important because it may not appear explicitly in a detailed use case. Understanding the reason behind a request helps developers determine which solution best satisfies the user’s actual need.
Functional and Non-Functional Requirements
After requirements have been gathered, they must be analyzed and organized. Two major categories are functional requirements and non-functional requirements.
Functional Requirements
A functional requirement specifies what the system must do. It describes a function, behavior, or service provided by the system.
Examples include:
The system must allow a user to add a sales record.
The system must calculate the total price.
The system must store customer information.
The system must allow an administrator to remove an account.
The system must display an error when invalid data is entered.
Functional requirements describe system actions and responses.
Non-Functional Requirements
A non-functional requirement describes a characteristic, constraint, or quality of the system rather than a specific function.
Examples include:
Performance requirements.
Security requirements.
Reliability requirements.
Usability requirements.
Maintainability requirements.
Scalability requirements.
Availability requirements.
For example, “the system must calculate a total” is functional. “The result must appear quickly” is non-functional because it describes a performance characteristic of the operation.
Functional requirements describe what the system does; non-functional requirements describe qualities or constraints concerning how the system operates.
Prototyping
Once the requirements have been organized, developers can create a prototype. A prototype is an early representation of the proposed system used to explore and communicate its design.
A prototype does not need to be fully functional. It may consist of:
Sketches.
Wireframes.
Screen layouts.
Clickable interface mockups.
Presentation slides.
A partially working interface.
Purposes of Prototyping
A prototype helps customers and developers examine:
What the system will look like.
How information will be arranged.
How users will move between screens.
How one feature connects to another.
Whether the proposed workflow makes sense.
Whether the design satisfies user needs.
Prototyping is normally an iterative process:
Developers create an initial design.
The customer or users review it.
Feedback is collected.
The prototype is modified.
The design is reviewed again.
Development begins once the requirements and interface are sufficiently clear.
The purpose is to identify misunderstandings early, before substantial development effort has been invested.
2. Planning
Planning often occurs alongside requirements gathering and analysis. Its purpose is to determine how the software will be developed during the coming weeks or months.
A large software system may contain tens of thousands of lines of code and many interacting components. Without a plan, developers may struggle to understand:
Which features should be developed first.
How components will interact.
How work will be divided among team members.
Which technical decisions must be made early.
How the system will be expanded later.
How the project will progress from requirements to deployment.
A development plan acts as a roadmap for the project.
Modularization
Modularization is the process of dividing a large program into smaller, organized parts called modules.
A module may contain:
Related data.
Functions that operate on that data.
A specific responsibility.
An interface through which it communicates with other modules.
For example, a game might be divided into modules for:
The game engine.
Players.
Enemies.
Input handling.
Graphics.
Sound.
Levels.
Inventory.
The objective is not merely to split code into multiple files. The division should reflect meaningful responsibilities and clear relationships between components.
Benefits of Modularization
Good modularization makes a system:
Easier to understand.
Easier to test.
Easier to modify.
Easier to expand.
Easier for multiple developers to work on.
Less likely to suffer from changes in unrelated parts of the program.
Two major goals of modularization are high cohesion and low coupling.
Cohesion
Cohesion measures how closely related the elements within a module are.
High Cohesion
A module has high cohesion when its functions and data strongly relate to one central responsibility.
For example, a records module may contain functions for:
Retrieving records.
Adding records.
Updating records.
Deleting records.
Searching records.
All these operations concern records, so they belong together logically.
High cohesion improves organization because a developer can go to one module to find the code responsible for a particular task.
Low Cohesion
A module has low cohesion when it contains unrelated tasks that have been grouped together without a strong reason.
A general “utilities” or “tools” module may become low-cohesion if it contains miscellaneous functions that do not share a common purpose. Such modules are often created because individual functions do not seem to belong anywhere else.
Low cohesion can make a system harder to understand because:
The module has no clear responsibility.
Unrelated code becomes mixed together.
Developers have difficulty locating functionality.
Changes to one area may make the module increasingly disorganized.
Coupling
Coupling measures the degree of dependence between modules.
High Coupling
Modules are highly coupled when they depend heavily on each other’s internal details or shared data.
A highly coupled design may require changes in many modules whenever one module is modified. This creates risk because:
A small change can produce widespread effects.
Developers must understand many components before making a modification.
Testing becomes more difficult.
Replacing one component becomes impractical.
Different team members may interfere with each other’s work.
A particularly problematic example is a design in which many modules directly share and modify a single global game-state object. Because every module depends on the same state, changing its structure or behavior can confuse the entire system.
Low Coupling
Modules have low coupling when they communicate through simple, well-defined interfaces and do not depend on each other’s internal implementation.
For example, a game engine can:
Ask the player module for the player’s position.
Ask the enemy module for the enemy’s position.
Compare the two positions.
Tell the player module to reduce the player’s health if a collision occurs.
The game engine does not need to know how the player stores its position or how the enemy calculates its location. It only needs to understand the messages or interfaces used to request and return information.
Low coupling makes it possible to:
Replace one module with another compatible module.
Add multiple players or enemies.
Support different enemy types.
Change internal implementations without affecting other components.
Test modules more independently.
High cohesion keeps related responsibilities together; low coupling keeps unnecessary dependencies between modules apart.
Separation of Concerns
When a system achieves high cohesion and low coupling, it demonstrates separation of concerns.
Separation of concerns means that each module handles its own responsibility without taking over the responsibilities of other modules.
This improves:
Readability: Developers can understand what each part of the system does.
Maintainability: A change can often be made in one location.
Reliability: Changes are less likely to cause unexpected effects elsewhere.
Teamwork: Different developers can work on separate components.
Extensibility: New features can be added without rewriting unrelated code.
If a developer needs to fix or upgrade a particular responsibility, a well-separated design makes it clear where the change belongs. The developer can modify that module without duplicating or conflicting with logic elsewhere.
3. Development
Development begins after the requirements, design, and planning work has provided a sufficiently clear direction. Professional development differs from hobbyist coding because it often relies on established patterns, standards, and practices.
Design Patterns
A design pattern is a standardized, reusable approach to a recurring software design problem.
The same types of problems appear repeatedly in software development. Rather than inventing a completely new solution each time, developers can apply an established pattern.
Advantages of Design Patterns
Design patterns can:
Make solutions easier for other developers to recognize.
Improve consistency across a codebase.
Make code easier to read.
Reduce the need to invent and evaluate a new design.
Increase confidence because the approach has been widely used.
Provide a shared vocabulary for discussing architecture.
A creative solution is not necessarily a good solution if it makes a common problem difficult for others to understand. A familiar pattern is often preferable when it fits the problem appropriately.
Model–View–Controller Pattern
Model–View–Controller (MVC) is a common design pattern for programs that contain data or application logic and a user interface.
MVC divides the system into three main parts:
Model
View
Controller
Model
The model contains the application’s data and core logic.
It may include:
Stored information.
Data structures.
Functions for retrieving data.
Functions for changing data.
Rules governing how the data behaves.
The model is an abstract, low-level representation. It is not designed to be directly understandable to the user.
For a sales system, the model might contain:
Sales records.
Product information.
Customer information.
Functions for adding, editing, searching, and retrieving sales.
View
The view presents model data to the user.
It determines how information is displayed, such as through:
A table.
A chart.
A form.
A dashboard.
A report.
The view translates the model’s abstract data into a form that a user can understand.
Controller
The controller handles user interaction and coordinates actions between the user interface and the model.
It may respond to:
Button presses.
Menu selections.
Form submissions.
Mouse or keyboard input.
Requests to add, edit, or delete data.
The controller receives user actions, interprets them, and causes the appropriate model or view operations to occur.
MVC Example
In a sales system:
Model: Stores the sales records.
View: Displays the sales records in a table.
Controller: Provides buttons and controls that allow the user to add, edit, or remove records.
This separation prevents the data, presentation, and interaction logic from becoming unnecessarily mixed together.
Substitutability in MVC
A major advantage of MVC is substitutability, meaning that one component can be replaced without changing the other components, provided the relevant interfaces remain compatible.
For example:
A table view can be replaced with a chart.
The model remains unchanged because the sales data is still the same.
The controller remains unchanged because the user actions may still be the same.
Similarly:
A basic controller can be replaced with an administrator controller.
The administrator controller can expose additional tools.
The model and view may remain unaffected.
This flexibility makes MVC useful for systems that must evolve over time or support different types of users.
Readable and Maintainable Code
Professional software often needs to be maintained for many years and by developers who did not write the original code. Readable code is code that developers can understand, modify, and extend without spending excessive time reconstructing the original author’s intentions.
Readable code is especially important when:
A project is large.
Many developers work together.
The software must be updated repeatedly.
Bugs need to be fixed quickly.
Features must be added without damaging existing functionality.
Avoiding Magic Numbers
A magic number is a numeric value placed directly in code without an explanation of what it represents.
For example, a program might receive a numeric code from an infrared remote control. If the code is written directly in a conditional statement, a future developer may not know which button the number represents.
Magic numbers can also include:
Screen dimensions.
Configuration limits.
Special status values.
Timing values.
Application-specific constants.
Problems Caused by Magic Numbers
Magic numbers reduce readability because:
Their meaning is unclear.
Developers may forget why they were chosen.
The same value may be repeated inconsistently.
Updating the value requires finding every occurrence.
A future maintainer may mistakenly change or reuse the value.
Better Approach
The number should be assigned to a meaningful constant, variable, or macro.
A descriptive name communicates intent, such as a name indicating that a value represents the previous button on a remote control. The code then explains itself more clearly than a series of unexplained numerical values.
Meaningful Variable and Function Names
Names should communicate purpose.
Function Names
Function names are generally clearer when they describe an action and use a verb.
A name such as
databasedoes not explain what the function does.A name such as
queryDatabasecommunicates that the function connects to a database and performs a query.
Good function names help developers understand behavior without opening the function’s implementation.
Boolean Variable Names
Boolean variables should clearly describe a condition or state.
A name such as isOn is more understandable than a vague name such as power. It also makes conditional statements read more like ordinary English:
if (isOn)clearly means “if it is on.”A vague condition may force the reader to inspect surrounding code to understand its meaning.
Meaningful names improve readability, reduce misunderstandings, and make maintenance easier.
Revision Control Systems
A revision control system records changes made to software over time.
Platforms such as GitHub commonly host code managed using revision control systems, but the important concept is the version-control process itself.
Main Functions
Revision control systems allow developers to:
Track changes to files.
View the history of a project.
Compare different versions.
Return to an earlier version.
Experiment without permanently damaging the main project.
Identify who made a change and when.
Collaborate with other developers.
Developers can commit their changes, after which the contributions can be combined or merged into the shared project. This supports teamwork by allowing multiple people to contribute to a common codebase in an organized way.
4. Testing
Testing is a structured process for comparing what a program actually does with what it is expected to do.
Informal testing might involve opening a program, clicking around, and deciding that it appears to work. This is insufficient for large or important systems because many defects may remain hidden.
Professional software development often uses automated testing, in which tools execute predefined test cases and compare the actual results with expected results.
Testing checks program behavior against expectations; it is not limited to randomly searching for bugs.
Testing as Verification of Expectations
Suppose a function is expected to perform a particular operation:
A test supplies an input.
The test specifies the expected output.
The function processes the input.
The actual output is returned.
The testing tool compares the actual and expected results.
The test passes if they match and fails if they do not.
A failing test provides useful information:
It identifies the affected operation.
It shows how the actual result differs from the expected result.
It can help locate the responsible module or function.
It may reveal the nature of the error.
For example, if a subtraction function produces the result expected from addition, the failed test provides a strong clue about the implementation problem.
Unit Testing
Unit testing tests individual modules, functions, or other small units of software in isolation.
A unit test typically checks one focused behavior. A collection of unit tests can verify:
Normal inputs.
Boundary values.
Invalid inputs.
Error conditions.
Different branches of a function.
Expected state changes.
Unit testing is particularly valuable because failures can be localized. If one test for one operation fails, developers can focus their investigation on the corresponding functionality.
Integration Testing
Integration testing tests multiple modules working together.
A module may work correctly by itself but fail when connected to other modules. Integration testing examines whether the connections and interactions between components behave properly.
For example, in a sales system:
The user edits a sales record through the controller.
The controller sends the change to the model.
The model updates the stored record.
The test verifies that the model contains the modified information.
This confirms not only that the controller and model work individually, but also that the communication between them works correctly.
Black-Box Testing
Black-box testing treats the system as an opaque component. The tester does not need to know how the system is implemented internally.
The tester:
Supplies selected inputs.
Observes the outputs.
Compares the outputs with the specifications or expectations.
Black-box testing focuses on externally visible behavior. It is useful for determining whether a component satisfies its requirements from the user’s or client’s perspective.
White-Box or Glass-Box Testing
White-box testing, also called glass-box testing, considers the internal implementation of the system.
The tester may:
Design inputs that exercise specific branches.
Ensure that internal paths are executed.
Test internal functions that are not directly visible through the public interface.
Examine how loops, conditions, and states behave.
Target implementation details that black-box testing would not reveal.
Black-box testing and white-box testing have different strengths. Black-box testing checks compliance with external behavior, while white-box testing examines whether important internal paths and structures have been exercised. A robust testing strategy may use both.
GUI Testing
GUI testing checks whether the graphical user interface behaves correctly from the user’s perspective.
It can verify:
Whether buttons perform the correct actions.
Whether screens display the correct information.
Whether navigation works.
Whether forms accept and reject appropriate input.
Whether visual responses match user actions.
Whether the interface remains usable during different workflows.
Automated GUI testing may use:
Screen-capture tools.
Screen-reading tools.
Automated keystrokes.
Simulated mouse actions.
Comparisons between expected and actual interface results.
The general testing process remains the same: perform an action, observe the result, and compare it with the expected behavior.
Security Testing
Security testing examines whether software remains safe and reliable when exposed to unexpected, invalid, or malicious input.
For example, a login system might be tested with:
Random values.
Unexpected characters.
Very long inputs.
Empty fields.
Repeated attempts.
Unusual combinations of valid and invalid data.
Randomized input can be valuable because ordinary tests use values that developers intentionally selected. Security problems often occur in situations that developers did not anticipate.
Security testing helps identify whether the system:
Crashes.
Reveals sensitive information.
Accepts invalid credentials.
Produces unexpected behavior.
Can be manipulated through unusual input.
Remains stable under repeated or hostile requests.
Code Coverage
Code coverage measures how much of a program’s code is exercised by tests.
A program may contain many:
Functions.
Conditional branches.
Loops.
Error-handling paths.
Possible states.
High code coverage generally improves confidence, but achieving complete coverage is difficult.
Challenges of Complete Coverage
Loops create many possible execution patterns. A thorough test strategy may need to consider:
A loop running zero times.
A loop running once.
A loop running twice.
A loop running many times.
The loop terminating normally.
The loop encountering an error.
Programs with internal state are also difficult to test because behavior may depend on the system’s current state. If a system has many possible states, every state and transition may be difficult to exercise.
Although complete coverage is often impractical, greater coverage generally provides stronger evidence that the program has been tested.
Test-Driven Development
Test-driven development (TDD) is a development methodology in which tests are written before the corresponding implementation code.
The process follows a repeating cycle:
Write a test describing the desired behavior.
Run the test and observe that it fails because the behavior has not been implemented.
Write the smallest amount of code needed to make the test pass.
Run the test again.
Improve or restructure the code if necessary while keeping the test passing.
Write the next test and repeat the process.
TDD emphasizes writing only enough code to satisfy the current test. This creates a growing set of automated tests while the program is being built.
Benefits can include:
Early clarification of expected behavior.
Frequent verification of correctness.
Strong automated test coverage.
Detection of regressions when later changes affect earlier behavior.
A design shaped around observable requirements.
The Iterative Nature of Software Development
The software engineering process is not necessarily a one-time sequence that ends when the product is first deployed.
After deployment, customers may request:
New features.
Improvements to existing features.
Bug fixes.
Performance enhancements.
Security updates.
Interface changes.
Support for new users or environments.
The development team must then:
Gather and analyze the new requirements.
Plan the changes.
Prototype or design the updated behavior.
Develop the changes.
Test the new and existing functionality.
Deploy the updated product.
This cycle may continue indefinitely, particularly for large systems that remain in use for many years.
Software engineering is a continuous, iterative process of understanding needs, designing solutions, building software, testing behavior, and improving the deployed system.
Key Principles
Software engineering is broader than programming: it includes requirements, planning, architecture, development, testing, deployment, and maintenance.
Requirements must be understood before development: customers may not know how to express their real needs clearly.
Use cases describe user interactions: they include success scenarios, errors, preconditions, and postconditions.
User stories identify the user, desired action, and motivation.
Functional requirements describe system behavior; non-functional requirements describe system qualities and constraints.
Prototypes expose misunderstandings early and allow customers to provide feedback before expensive implementation.
Modularization divides complex systems into manageable parts.
High cohesion keeps related responsibilities together.
Low coupling minimizes unnecessary dependence between modules.
Separation of concerns improves readability, maintainability, testing, and extensibility.
Design patterns provide familiar solutions to recurring design problems.
MVC separates data and logic, presentation, and user interaction.
Readable code avoids magic numbers and uses meaningful names.
Revision control preserves project history and supports collaboration.
Automated testing compares actual behavior with expected behavior.
Unit testing examines individual components; integration testing examines their interactions.
Black-box testing focuses on external behavior; white-box testing examines internal implementation.
GUI testing evaluates user-interface behavior, while security testing probes resistance to unexpected or hostile input.
Code coverage measures how much code tests exercise, although complete coverage is difficult.
TDD writes tests before implementation and uses repeated test-and-correct cycles.
The software lifecycle continues after deployment as customers request fixes, enhancements, and new capabilities.

Ask anything
We've read this whole study set, so questions about it get the best answers.