0% found this document useful (0 votes)
123 views2 pages

CSP U7L6 '21-'22 Activity Guide

This document provides guidance for investigating how to use and create libraries in Code Studio. It outlines steps to run programs that use pre-built library functions, view the code behind these libraries, test the functions, and reflect on the benefits of libraries. Creating a library involves building reusable functions with documentation and sharing the code. Using a library requires accessing the functions by calling the library name, function name, and any arguments. Testing is important to ensure the library functions work as expected.

Uploaded by

Allen Marks
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
123 views2 pages

CSP U7L6 '21-'22 Activity Guide

This document provides guidance for investigating how to use and create libraries in Code Studio. It outlines steps to run programs that use pre-built library functions, view the code behind these libraries, test the functions, and reflect on the benefits of libraries. Creating a library involves building reusable functions with documentation and sharing the code. Using a library requires accessing the functions by calling the library name, function name, and any arguments. Testing is important to ensure the library functions work as expected.

Uploaded by

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

CSP U7L6 Libraries Investigate Activity Guide

Directions: Go to Code Studio Unit 7 Lesson 6. Follow the instructions listed below at each
level.

Level 1
Run this program and read the code carefully. Try several different inputs.
● Describe what happens when the button is clicked:

Open the functions drawer and look at each of the StateLibrary functions. Mouseover them for
documentation.
● Make a prediction on how these functions work (code used in order to do what the
documentation says):

Click "Manage Libraries" in the gear menu, then hover over “State Library” and click "view
code".
● Read the code.
● How do the library functions work?

● Were your predictions correct?

Level 1 Reflection
● What are the benefits of hiding all of the code for filtering the dataset in a library?

● What information does the user need to know in order to use the library functions?

Level 2
Run this program and read the code carefully. Try several different inputs.

Open the functions drawer and look at each of the StringsLibrary functions. Mouseover for the
documentation.
● How do these functions work?

Test the functions:


Re-read the documentation for each library function.
Do This: Add a console.log() statement to the end of the program and call a function.
● Put in a reasonable argument in the space for the parameter.
● For example: console.log(StringsLibrary.firstLetter("pizza"));
Do This: Hit run to see the output.
Do This: Now add console.log() statements to test the rest of the functions.
Do This: Try several different inputs.
● Is the output what you would expect?

Level 2 Reflection
● Why should we test the functions in the library?

● What does this help us to know?


Level 1 - Part 2
Navigate back to the States App
Do This: Add console.log statements for each of the functions and test them out.
● Is the output what you expected?

Level 1 Reflection Part 2


● What makes a good library function?

● How can you make sure that the end users of your library have what they need in order
to use your functions?

Final Reflection
Up to this point, you have either created your own algorithms from scratch, or modified existing
ones (usually in Investigate Lessons). Now you have another tool to use combining existing
algorithms to make new algorithms. Today, this was accomplished with a library.
● What are the benefits of using existing algorithms instead of brand new algorithms?

Takeaways:
Highlight any takeaways below that you still have questions about or need help with. After
highlighting a takeaway that you still have questions about, go ahead and add your questions
next to or below the takeaway you need help with.
● Creating a library:
○ Build functions
○ Add documentation
○ Share as a Library
● Using a library:
○ Click "Manage Libraries"
○ Either choose a classmate's library, or paste in a library code
○ Call the functions by writing the library name, a dot, the name of the function, and
including any arguments for the parameters
● Testing a library:
○ Use console.log as the end user to test functions in a library
○ Check that the output is what you would expect
○ Read the library code if something does not work correctly, and contact the
library owner if something needs to be changed.

You might also like