0% found this document useful (0 votes)
16 views1 page

Need For Reusable Program Components Activity 2

Uploaded by

handryoutlook
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views1 page

Need For Reusable Program Components Activity 2

Uploaded by

handryoutlook
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Thinking ahead

The need for reusable program components

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)

Example 3: a method to play a sound:


sound.play("#bounce")

Example 4: a method to sort a list:


list.sort()

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.

You might also like