Skip to content
Definition
Reusable program components are blocks of code (functions, classes, subroutines) designed to be used in multiple programs or different parts of the same program. They are key to efficient software development.

Advantages of Reusable Components

Key Point
Advantage of reusePractical effect
Time/cost efficiencyFaster development with less duplicated work
ReliabilityReused components are often already tested
ConsistencySame behaviour across multiple modules/projects
MaintainabilityOne fix can improve all places where component is used

Challenges

Key Point
Reuse challengePractical impact
Compatibility issuesIntegration can fail across different environments/frameworks
Modification costsAdapting third-party code may be expensive/complex
Learning curveTeam needs time and documentation to use components correctly
Worked Example
Worked Example: Reusable Sorting Component
pseudocode
// Reusable sorting function in a library
function quickSort(array, compareFunction):
    // Implementation of quicksort algorithm
    // Thoroughly tested and optimised
end function

// Used in Program A: Sorting student grades
grades = [85, 92, 78, 95, 88]
sortedGrades = quickSort(grades, descending)

// Used in Program B: Sorting customer names
customers = ["Smith", "Jones", "Brown", "Taylor"]
sortedCustomers = quickSort(customers, alphabetical)

// Used in Program C: Sorting products by price
products = [{name: "Book", price: 10}, {name: "Pen", price: 2}]
sortedProducts = quickSort(products, byPrice)
Benefit: The quickSort function is written once, tested thoroughly, and reused across multiple programs without rewriting or retesting.
Exam Tip
Exam Tips for Thinking Ahead:
• Be able to identify inputs and outputs for given scenarios
• Understand the purpose of preconditions and why they matter
• Explain benefits AND drawbacks of caching (don't just list benefits)
• Describe advantages and challenges of reusable components
• Give specific examples for each concept (ATM, stack, web browser, sorting)
• Consider data types appropriate for different inputs