As programs grow, putting all the code in one long sequence becomes hard to read, test and change. Decomposition is the practice of breaking a problem into smaller, well-defined sub-problems and giving each one its own function. Instead of one 200-line script, you might have read_scores(), average(), grade_for() and print_report(), and a short main section that calls them in order. Reading the main section then tells you the whole story of the program in a few lines, and each detail lives in one clearly named place.
Keep reading for free
Create a free StudyToCert account to read the rest of this lesson: 7 more sections, 6 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.