Advantages of Reusable Components
| Advantage of reuse | Practical effect |
|---|---|
| Time/cost efficiency | Faster development with less duplicated work |
| Reliability | Reused components are often already tested |
| Consistency | Same behaviour across multiple modules/projects |
| Maintainability | One fix can improve all places where component is used |
Challenges
| Reuse challenge | Practical impact |
|---|---|
| Compatibility issues | Integration can fail across different environments/frameworks |
| Modification costs | Adapting third-party code may be expensive/complex |
| Learning curve | Team needs time and documentation to use components correctly |
// 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)
• 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