Skip to content
AI Knowledge MapSearch / Text directory

Chapter 1 Traditional programming

The core stages of programming

Programming means expressing rules for processing information and performing actions in code, so that a computer can carry out a task. The task might be calculating statistics for a set of grades, processing images in batches, or making an interactive program. In this chapter, traditional programming means working primarily by organizing and writing the code yourself: a programmer analyzes the problem, designs the approach and code structure, uses tools to implement it, and then checks and revises the program based on what happens when it runs.

This process has five core stages: clarify the problem; gather information; design the approach and program structure; write and run the program step by step; and verify results, locate errors and improve the program. You will move between these stages repeatedly. Running the program may reveal missing information, checking it may uncover unclear rules, and making a change may require adjusting the code structure.

Along the way, you gradually learn techniques that support this work. Runtime environments and dependency management help make a program runnable. Functions and modules help organize code. Git saves versions and lets you compare them. Tests and logs help check behavior and find problems. Choose techniques to fit the task: when changing an existing project, you can start by reading its tests; when a program has a performance problem, measure and analyze it.

The table below groups these techniques by stage. Short introductions follow. Start by understanding what problem each technique solves and what role it plays in programming.

Core stageImportant techniques
Clarify the problem
Gather informationRead existing tests; runtime environments and language versions; package managers; dependency manifests and lockfiles; virtual environments; configuration files.
Design the approach and program structureConditions and loops; functions, parameters and return values; module boundaries and program interfaces; data cleaning; code comments and function documentation.
Write and run the program step by stepCode editors and IDEs; Git version control.
Verify results, locate errors and improve the programRegression testing; debug output and logs; refactoring; performance profiling.

Important techniques at a glance

1 Read existing tests

Read the checks already written for a project to understand what they check, what inputs they use and what results they expect. Running them helps you find out whether the program currently meets its existing requirements. Existing tests can also miss things.

2 Runtime environments and language versions

A program needs a suitable software environment and language version to run. Checking these requirements helps prevent problems caused by version differences or missing components.

3 Package managers

Tools that install, update and remove code libraries. They also handle dependencies between libraries, reducing the work of finding and installing related components by hand.

4 Dependency manifests and lockfiles

A dependency manifest declares the libraries a project needs and the version ranges it allows. A lockfile records the specific dependency versions resolved by the tool. Together, they help recreate the required dependencies at another time or on another device.

5 Virtual environments

A virtual environment isolates a project's dependencies. Different projects can use different versions of a library, reducing the chance that installing or updating something for one project will affect another.

6 Configuration files

Files that keep program settings in one place, such as file locations, processing options and operating modes. The program reads these settings as it works. Changing the configuration lets a user adjust the corresponding behavior.

7 Conditions and loops

Conditions let a program choose an action based on the situation, such as deciding whether a grade is a passing grade. Loops repeat a process, such as checking each grade in a set.

8 Functions, parameters and return values

A function organizes a piece of work into code that can be called. Parameters carry information into the function, and a return value is the result it sends back. These help break a task into smaller parts and reuse an implementation.

9 Module boundaries and program interfaces

Modules group related code together. Interfaces define how parts call one another, what they receive and what they produce. Clear responsibilities and connections make a program easier to understand and change.

10 Data cleaning

Check and handle missing, duplicate, inconsistently formatted or invalid data so that later processing can use data that meets the task's requirements. Whether to correct, fill in, flag or exclude something depends on the task's rules.

11 Code comments and function documentation

Explain the purpose of nearby code, any necessary reasoning and how to use it. Function documentation can also explain parameters, return values and limitations, helping you and others understand the code.

12 Code editors and IDEs

A code editor is used to write and change code. An IDE, or integrated development environment, usually also brings together tools for running programs, navigating code and managing projects, so you can perform several programming tasks in one place.

13 Git version control

Check file status and differences, select a set of changes, and save them as a commit with a description. Earlier versions, diffs and commit messages help explain how the code developed and which change introduced a problem. You can also compare versions, undo changes or restore saved content, giving you a way back as you continue working.

14 Regression testing

After changing a program, check its existing features and previously fixed problems again to make sure the change has not broken them. Keep important checks so you can repeat them after later changes.

15 Debug output and logs

Record which part of the program ran, what it processed and what intermediate results it produced. This makes the execution easier to observe and helps locate problems. Temporary output is useful for immediate inspection; logs support ongoing recording, filtering and later investigation.

16 Refactoring

Adjust the code structure while preserving its expected behavior, for example by splitting an overly long function or reducing duplicate implementations. Check the program after refactoring to make sure the restructuring has not broken existing features.

17 Performance profiling

Measure execution time, memory use and other resource consumption to find actual bottlenecks before deciding how to optimize. The task's performance requirements should determine whether optimization is needed and what it should achieve.