Quiz

  1. Are modules and libraries similar?

    Yes! In fact, most programs using the C language (one of the oldest still in common use) start with:

        #include <stdlib.h>
    

    which "imports" the Standard Library.

    So, yeah, they're similar ideas: importing/including stuff into our programs.

  2. Still not too sure what modules are

    They are a feature of the programming language to better allow us to "divide and conquer". A module

    • might be part of the ecosystem, allowing our program to access the OS, file system, network, do math or graphics, etc. (so, written by others)
    • might be written by other members of our "team" or
    • might be written by ourselves, but we are trying to divide our code into conceptually and functionally distinct parts.
  3. can you talk about what you mean by execution contexts and why they're not technically namespaces?

    Sure. An execution context is the set of names that are available at a particular point in the code. For example:

    
        function addQuiz(studentList, quizResults) {
            // context A
            studentList.forEach( function (wendy) {    
                // context B
                let email = wendy.email;
                let result = quizResults.find( (quiz) => (quiz.email == email) )
                if( result ) {
                    wendy.quizzes.append(result.score);
                } else {
                    alert("Remind "+wendy.name+" to take the quiz ");
                    wendy.quizzes.append(0);
                }
            });
         }
    
    

    The set of names available at point A is a strict subset of those available at point B, and so forth.

    Some people (me) would call those different namespaces; others would call them different executation contexts. But that's a minor point of terminology. The important thing is understanding how they differ.

  4. Can we still call the module we imported outside the <script type="module"> tag?

    Well, we don't call modules (they are not functions), but if you mean use the names in them, then I think the answer is no. The spread of names is strictly controlled.

  5. Can we walk through the code for the App example? / I am still confused with the App example. Can you please re-explain in class?

    For sure!

  6. No questions for now, but I'm loving the class!

    I'm so glad to hear it!