What is software design?
Software design means planning a program before you write code. You decide the parts (modules), what each part does, and how the parts talk to each other.
Every program has these components:
- Input: data comes in (keyboard, file, sensor).
- Processing: calculations and decisions.
- Output: results go out (screen, file, sound).
- Storage: variables, lists and files keep data.
Tools for design: a structure chart (boxes for modules), a flowchart, and pseudocode (plain-language steps).
Program templates (skeletons)
A template or skeleton is a program with the parts in place but empty. A common order:
- Header comment: title, author, date, purpose.
- Imports and constants (values that never change, like TAX_RATE = 0.1).
- Function definitions.
- Main part: input → process → output.
Starting from a template saves time and keeps every program in the same shape. Use the right vocabulary: variable, constant, function, parameter, return value, loop, condition. Use clear names (total_price, not x) and one naming style everywhere.
Modularity and reusable code
Modularity means building a program from small, separate pieces. Each function does one job and has a clear name.
- Parameters carry data in; the return value carries the answer out.
- A function should not depend on hidden global variables. Then it can be reused in other programs.
- Benefits: shorter code, easier testing (test each piece alone), bugs fixed in one place, team members work on different modules.
Libraries (like a maths library) are collections of reusable functions written by others.
User-friendly software interfaces
The user interface (UI) is the part people see and touch. Good UI rules:
- Clear prompts: "Enter your age (years):" not "Input?".
- Big buttons with clear labels; one main action per screen.
- Helpful error messages that say how to fix the problem.
- Check input (validation) so wrong data does not crash the program.
- Good colour contrast and readable text; works with screen readers (accessibility).
- Consistent layout: the same button is always in the same place.
Try it
On paper, design a canteen bill calculator. Write 4 module names (for example get_items(), add_prices(), add_tax(), print_bill()). For each, write what goes in and what comes out. Then use the free-play step to build it from blocks.
Key formulas and definitions
- Program = Input → Process → Output (+ Storage)
- Module / function: one job, clear name, parameters in, return value out
- Template order: header comment → constants → functions → main
- Good UI: clear, consistent, forgiving (validation), accessible
Worked examples
1. Split a 'student report card' program into modules.
1) get_marks() reads marks. 2) average(marks) returns the mean. 3) grade(avg) returns A/B/C. 4) print_report() shows the result. main() calls them in this order.
2. Two programs both calculate the area of a circle. How would you design this?
Write one function circle_area(r) that returns 3.14159 × r × r. Put it in a shared module and call it from both programs. If you improve it, both programs get the fix.
3. Improve this prompt: "Enter:"
"Enter the price in rupees (for example 250):". It says what, which unit and gives an example. Also check that the input is a positive number and, if not, say "Please type a number like 250."
Common mistakes
- Writing all code in one long block. Split it into functions with one job each.
- Copying the same code in many places. Write a function once and call it.
- Using names like a, b, x1. Use names that say what the value is.
- Showing error messages like "Error 42". Tell the user what went wrong and how to fix it.