E19: Experience Functional Programming (Part 2)

In this experience, you will continue to gain familiarity with functional programming.

As before, we’ll use a Hawaii Open Dataset providing University of Hawaii Student Degrees Awarded. Here’s a screen image of this dataset:

As a reminder, here’s what the uhdata variable’s value looks like and you can use this as your testdata if desired:

type UhData = {
fiscalYear: number;
campus: string;
cip: number;
cipDesc: string;
group1: string;
group2: string;
group3: string;
group4: string;
group5: string;
outcome: string;
hawaiianLegacy: string;
awards: number;
};

const testData: UhData[] =  [
  {fiscalYear: 2023, campus: "UH Hilo", cip: 90101, cipDesc: "Speech Communicatn & Rhetoric", group1: "College of Arts & Sciences", group2: "Arts & Humanities", group3: "Communication", group4: "Communication", group5: "", outcome: "Bachelor's Degrees", hawaiianLegacy: "HAWAIIAN", awards: 16},
  {fiscalYear: 2023, campus: "UH Manoa", cip: 130301, cipDesc: "Curriculum & Instruction", group1: "College of Education", group2: "Education", group3: "Curriculum Studies", group4: "Curriculum Studies", group5: "", outcome: "Master's Degrees",
    hawaiianLegacy: "HAWAIIAN", awards: 20},
  {fiscalYear: 2023, campus: "UH Manoa", cip: 140801, cipDesc: "Civil Engineering", group1: "College of Engineering", group2: "Engineering", group3: "Civil Engineering", group4: "", group5: "", outcome: "Master's Degrees", hawaiianLegacy: "", awards: 16},
];

Open TypeScript Playground. Open your solution from the previous experience, or start a new one. Then copy the https://ics-software-engineering.github.io/uhdata/uhdataf24.ts code into your TypeScript Playground to see the data structure.

The WOD

Let’s continue the fun!

  1. Read through the problem statement and understand the requirements. Then come up with an estimate for the time it will take to complete the task. Record your estimate in your Estimation Log.

If you plan to use any AI assistance (LLMs, Copilot, code generation), briefly note the tool and plan for verification in your Estimation Log. Record prompt/verification time separately so your estimates reflect where effort is spent.

  1. Start your timer.

  2. Open your solution from the previous experience.

  3. Implement the following functions using the Array functional methods. Note that your solutions cannot include a for or while loop!

  4. listCampuses(data). This function can be passed uhdata and returns an array containing all the campuses referenced in the dataset. The array returned should be ["UH Hilo", "UH Manoa", "Kauai CC”, “Windward CC”, “Kapiolani CC", "Maui College", "Hawaii CC”, “Honolulu CC”, “Leeward CC”, “UH West Oahu"] TiP: You may find the .from() and .map() methods useful here.

  5. totalDegreesByCampus(data, campus). This function can be passed uhdata and a campus and returns the total number of degrees awarded for the campus. The correct answer for uhdata is 3042. Tip: You you can first .filter() then .reduce()

  6. Press the “Share” button to save your playground.

  7. Stop your timer and record your time for this attempt in your Estimation Log. Compare your estimate with the actual time taken. Did you underestimate or overestimate? Why do you think that is? What can you do to improve your estimation skills in the future? Add your reflections to your Estimation Log.

Be sure to record it, because you will need your WOD time data when you write your technical essay.

Rx: < 9 min Av: 9 - 12 min Sd: 12 - 15 min DNF: 15+ min             

Demonstration

Once you’ve finished trying the WOD for the first time, watch me do it. (Note: the screencast below has not been updated to use Typescript but the functional programming is the similar and you do not need underscore.js).

Standard WOD Caveats

You’ll learn significantly less from watching me solve the if you haven’t attempted the WOD yourself first.

While it’s an achievement to finish the WOD no matter how long it takes, you might experience “diminishing returns” if you work longer than the DNF time. Thus, it is usually strategic to stop working at the DNF time and watch my solution.

After watching my solution, I recommend that you repeat the WOD if you have not achieved at least Av performance. If so, be sure to:

Feel free to keep trying until you make Rx if that’s of interest to you.

Submission Instructions

By the time and date indicated on the Schedule page, submit this assignment via Lamaku.

Your submission should contain:

You will receive full credit for this practice WOD as long as you have attempted it at least once and submitted your work on Lamaku with all required data before the due date. Your code does not have to run perfectly for you to receive full credit.