Courses / Computer Science I
Programming I

Simple Modelling with Code

Computer Science I 174 words Free to read

From Problem to Program

The hardest part of programming is modelling: deciding how to represent a real-world problem for a computer. A model is a deliberate simplification that captures what matters and ignores the rest.

Modelling follows three core steps. First, identify the data: what quantities and entities are involved, and what type is each?

EntityData RepresentationExample
Shopping CartListItems with prices
Phone BookDictionaryNames to numbers

The right structure makes the algorithm easy; the wrong one makes it painful.

Two problems, two shapes -- and one of them tried on the wrong shape

Algorithms and Constraints

Second, define the algorithm: the step-by-step procedure transforming input into output. Write this in plain, structured pseudocode before real code to get the logic right without fighting syntax.

Third, state the assumptions and constraints (prices are non-negative, lists may be empty) so the program handles them properly.

Common pitfall: Diving straight into code before modelling. Always name your data types, sketch pseudocode steps, and then translate.

Practise this lesson

The explanation above is free to read. The graded practice for this lesson lives in the Tryals app.

11practice questions
2interactive scenes

Programming I