Basleal.liabrary
Basleal.liabrary
Project Description
Libraries let you build functions that you and others can use to help build more powerful apps in lots of situations. As
the designer of a library you not only need to know how to program, you also need to think about the many different
kinds of programs other people might build.
For this project you will design and build a library of functions around any topic you want. You will have an opportunity
to exchange feedback with another group about how you might use their library to design an app. Finally you will
answer a few questions about the library you designed.
Library Requirements
● Your library must contain two or more functions
● At least one function must include
○ A loop
○ An if-statement
○ One or more parameters
○ Return
Step 1 - Brainstorm
Your library can be about any topic. If you need some ideas try the list below
● Strings
○ Capitalize: Capitalize first letter of each word in a sentence (long string)
○ Trim: Remove spaces from beginning and end of a string
○ Remove Letter: removes a given letter from a string
○ Anything else you'd want to do with a string
● Lists
○ Maximum: Find the maximum value in a list
○ Minimum: Find the minimum value in a list
○ Average: Find the average value in a list
○ Count: Count how many times a given value appears in a list
○ Combine: Join two lists together in one longer, larger list
○ Filter Numbers: Keep numbers in a list greater than or less than a provided value
○ Filter Letters: Keep strings in a list that begin with a given letter
○ Numbered List: Turn a list into a string with each item numbered and appearing on a different line
○ Top 3: Return the three biggest numbers in a list, in sorted order (This can be a little tricky)
○ Unique: Return a list of each unique item that appears in (This can be a little tricky)
○ Sort: Return the list in sorted order (This can be a little tricky)
○ Anything else you'd want to do with a list
● Dataset
○ Choose a dataset and build a function that will help a user access or summarize specific information
within that dataset
● Something else
○ As long as your library does something interesting and valuable
maximum(list) // Takes a list and returns the largest value Yes this function should include all of
that appears in the list these features.
// list {list} - the list of items
// return {number} - the largest number in
the list
Step 3 - Build
Program your library. Make sure you do the following.
● Start by building the function that will include all four required features (param, return, if-statement, loop)
● Debug your code as you write it
● Start testing your code early with sample inputs
Step 4 - Test
Write test cases for each of the functions in your library to make sure they return the expected values. Remember that
you should include.
● Inputs (arguments) that will result in your functions behaving differently or returning different values
● Inputs (arguments) just before, at, and after cut offs if your conditionals. For example if your code includes the
statement (value < 2) then try inputs where value is 1, 2, and 3 to see if the algorithm always behaves as you
expect.
Note: Once you are done testing your functions, make sure to comment out any tests you have written into your code
to test your library functions before sending your library to a classmate in Step 5.
Yes Kind Of No
I like: Give feedback on at least one thing you like in the library
What if: Give one idea for how to improve the library
Step 6 - Improve
Based on the feedback above make final improvements to your library.
Procedure: Capture and paste two program code segments you developed during this project that contain a
student-developed function that implements an algorithm used in your program and a call to that function.
I. Copy and paste a function definition from your library that:
a. Defines the procedure’s name and return type (if necessary)
b. Contains and uses one or more parameters that have an effect on the functionality of the procedure
c. Implements an algorithm that includes sequencing, selection, and iteration
II. Copy and paste an example call to the function definition above.
1. Refer to a code segment from your project that performs a specific task.
(a) Write documentation that describes the purpose of this code segment. Your documentation should explain
what the code does, its inputs, and its expected outputs.
(b) Explain how this code segment would contribute to the overall functionality of a program.
Write your response here
// Example usage:
var numbers = [10, 20, 30, 40, 50];
getAverage(numbers); // This will calculate and log the average of the numbers
Responses Point
(Question 1) Explains the purpose of the code segment, including what it does and its inputs and outputs. /1
(Question 1) Explains how the code segment contributes to the overall functionality of the program. /1
(Question 2a) Writes a new algorithm to perform the same task, or explains why writing a new algorithm is /1
not possible.
(Question 2a) Compares whether or not the two algorithms produce the same result. /1
(Question 2b) Describes two sets of inputs that can be used to test the algorithm /1
(Question 2b) Describes the output of each input and explains how this helps verify the algorithm works /1
correctly.
(Question 2c) Explains how the function manages complexity in the program /1
(Question 2c) Explains how the function improves organization and makes the program easier to maintain or /1
modify
Program Code
All functions include comments that explain the purpose of the function and the parameters /2
All functions include tests that demonstrate the code working as expected /2
Project Guide
Student provided clear and actionable feedback to a classmate on their project guide /1
Total /14