Need For Reusable Program Components Activity 2
Need For Reusable Program Components Activity 2
1. Reusable program components are smaller pieces of code, usually functions which perform common, often used tasks.
Example 1: a user-defined function to clamp a value between a minimum and maximum:
Function clamp(value As Decimal, min As Decimal, max As Decimal)
If value < min Then Return min
If value > max Then Return max
Return value
End Function
Example 2: a function from a math library to return a random number:
xpos = math.random(0,1200)
Functions are often stored in libraries. What are the advantages of using libraries?
It provides reusable code, save development time, improve code reliability, and promote standardization by offering
tested and optimized functions or modules.