Using a debugger; Big Oh review; enums; exception handling; stack explorations

Note: All due dates are listed on the main page for this course.  They are NOT listed here.

Individual Post-Class Exercises

EVERYONE must complete these exercises!

(This is the last week the above reminder will be posted.  Thanks!)

  1. Lesson Setup
    This is stuff you'll need to download and/or browse before starting this lesson

    1. Start-of-lecture Slides (Required)
      Online students will need to read these on their own. 
      Hybrid students will seem them at the start of class.

    2. 'Starter' project for the lesson 02 PCEs (DOWNLOAD THIS!!) (Project updated on 1/12)
      Download and extract this file.  You will (generally) use it to do all the programming exercises for the rest of this lesson.
      (Note: You may not use all the provided classes in the starter project)
       
      1. The above link provides a starter project that works with VS 2019 and .Net Core (.Net 5, really).
        In case that doesn't work I'm going to leave a link to the previous version of the starter project here.
        ONLY DOWNLOAD THIS IF YOU HAVE PROBLEMS WITH THE ABOVE PROJECT

        Please note that for Lessons 01 and 02 the exercises are the same for both versions are the same but the file structure is very different.
        The new version (above) has everything in one file while this older, backup version has several different files (and projects) instead.
    3. Watch the online videos for this lesson and demonstrate your knowledge (Hand-In)
      You have two choices to demonstrate that you've watched (and understood) the videos: either create an outline or fill out the viewing comprehension quiz (described below).  Either way make sure that you include the appropriate file in the .ZIP file you hand in for this lesson (in either Word .DOC/.DOCX format or .PDF format).
      NOTE:
      You can download a .ZIP of all the videos for this lesson from Microsoft's OneDrive website by opening the folder (click this link to open the folder), then clicking on the "Folder Actions" menu, then clicking on the "Download Folder" menu item.

  2. Review: How To Use The Debugger

    1. Lesson 02 was a lot of work for a bunch of people.  Let's move 'Debugger' to Lesson 03 or 04?
      Covering NUnit first, then the debugger briefly, seemed to be a good way to go.  It gives the students several examples, and a clear use-case for the debugger
    2. VIDEO:
      OneDrive: Debugging, Part 1
      DropBox: Debugging, Part 1

      (Remember that these are two separate links to two separate copies of the exact same file.  You can watch either one, and you only have to watch one)
    3. VIDEO:
      OneDrive: Debugging, Part 2
      DropBox: Debugging, Part 2
    4. Exercise: How to use a debugger: Intro
  3. Enumerations (enums) by using git and GitHub

    1. VIDEO:
      OneDrive: Enums
      DropBox: Enums
    2. Exercise: Figure out what an enum is  
      (Demo Video   VS Project Used in the Video)

    3. Exercise: Define and use the ErrorCode Enum (Hand-In)

      Link to access the project for this assignment in GitHub

    4. Exercise: Adding a file to git, using VS on your computer (Hand-In)

  4. Review: Big Oh Notation (Running Time Analysis)

    1. VIDEO: (18:02)
      OneDrive: Big Oh Review
      DropBox: Big Oh Review
    2.  Exercise: Review: Big "Oh" Notation  (Hand-In)

      1. (Handy reference: A Beginner's Guide To Big O Notation)

  5. Exception Handling

    1. VS Project Used in the following videos

      NOTE: all of the 'exception handling' videos are in a subfolder named 'ExceptionHandling'
    2. Video: (5:49 - this video is 5 minutes and 49 seconds long)
      OneDrive: Exception Handling: Overview
      DropBox: Exception Handling: Overview
    3. Video: (7:10 = minutes:seconds)
      OneDrive: Exception Handling: File I/O Overview
      DropBox: Exception Handling: File I/O Overview
    4. Video: (5:52)
      OneDrive: Exception Handling: Try Catch in the same method that throws the exception
      DropBox: Exception Handling: Try Catch in the same method that throws the exception
    5. Video: (4:22)
      OneDrive: Exception Handling: Try Catch in Main
      DropBox: Exception Handling: Try Catch in Main
    6. Video: (3:19)
      OneDrive: Exception Handling: Throwing your own exceptions; using exception handling in a constructor
      DropBox: Exception Handling: Throwing your own exceptions; using exception handling in a constructor
    7. Exercise: Use the exception handling to reimplement the SmartArray (Hand-In)

  6. Preview: Investigate The "Stack" Abstract Data Type

    1. Exercise: Figure out what a stack is  (Hand-In)
    2. Exercise: Preview: Using the .Net FCL Stack (Hand-In)
    3. This link provides some really interesting, really well-done visualizations of data structures.  It's well worth checking out:
      http://www.cs.usfca.edu/~galles/visualization/Algorithms.html
  7. Extra Credit (ADDED ON 4/5/2019 at 11am)
    I'm thinking about switching from NUnit to MSTest. 
    They're so close that they're almost identical, but MSTest is made by Microsoft and I'm wondering if it'll "just work" without the troubleshooting that NUnit seems to need.
    In order to get 5 points of extra credit you need do the following:

    1. download this project
      NOTE: this is separate from the starter project listed above. 
      If you take a screenshot of the wrong project you will NOT get the extra credit points

    2. extract it

    3. open it

    4. open up the Test Explorer window (just like you did with NUnit) and click 'Run All'

    5. wait about 5 seconds for Visual Studio to find the tests and run them
      NOTE: most of the tests will fail and that's fine.
      NOTE: If VS does _not_ find the tests that's also fine - I just want to see if this works better than NUnit or not.

    6. The goal is to see a list of tests that are colored red (and/or green), which shows that the tests were not only found but that they were also actually run.

    7. grab a screenshot that includes the Test Explorer window

    8. Put that screenshot into a Word .DOCX file -OR- a .PDF.  Make sure the file is named MS_TEST_RESULTS.docx (or .pdf).
      (Note - I don't really care what the file is named I just want to be able to find it quickly and easily.  As long as it's clear which file contains it then I'm fine)

    9. Make sure to include that file in the .ZIP that you upload for this lesson

  8. Unit Testing With the NUnit Framework: Getting the tests to pass
    1. The goal for this section is to show you how to run NUnit-based unit tests, how to diagnose problems when a test fails, and to get you some practice getting tests to pass before next week (when all your work will be verified using NUnit tests)
      1. WARNING: Because of the open-ended nature of figuring out "why is this test failing?" you may need to dedicate a goodly amount of time to getting these tests to pass.
      2. Warning: Lessons 03 and onwards use NUnit to generate part of your PCE grade.
    2. Download a copy of the feedback form and read through it.  You must hand in a copy of this form with whatever feedback you can provide.
      1. In general, I want to check that this activity can be done and that the course materials clearly explains what you need to do. 
        All feedback is appreciated, but I particularly want to check that the activity is doable and the materials clear.
      2. A smaller amount of Insightful feedback is better than a huge volume of space-filling feedback
    3. NOTE: You will continue using the same 'NUnit' material that you used in the prior lesson.
      (I've included these links here for your convenience but they link to the same files that they did last time.)

      1. Starter project (using VS 2019, NUnit 3, and .Net Core / .Net 5) for the below videos and exercises (yes, this is separate from the above starter project.  You do NOT need to hand this one in)
      2. This same slide stack is used by all the NUnit videos:
        Slides (used in the following NUnit videos)
        1. One really good way to use these slides is to skim/read through thrm to get an idea of what's in each video.  For example, if you wanted to remind yourself how to get the tests working (which was covered in the prior lesson) you might flip through those slides again.  If you need more detail you can then watch the video, or not.
      3. You should start this work by downloading the NUnit starter project, extracting it, and making sure that you can see all the tests listed in the 'Test Explorer' panel on Windows or in the 'Unit Tests' panel on Mac
    4. You may have trouble getting the tests to show up and/or getting them to run.
      If so, please refer back to the advice in Lesson 01.  In particular, the video for How To Get NUnit3 To Work In Visual Studio (and the corresponding slides in the  NUnit slide deck) can be very helpful.

      NOTE: This may (or may not) happen every Lesson (every time you download a new project)
    5. VIDEO:  (4:08)
      OneDrive: How To Run The Tests
      DropBox: How To Run The Tests
      • NOTE: Yes, there are a bunch of videos to watch.  I've tried to keep each one pretty short.  This is one is (4:08) - only 4 minutes and 8 seconds long!
    6. VIDEO:  (1:36)
      OneDrive: How To Debug A Test
      DropBox: How To Debug A Test
    7. VIDEO:  (1:27)
      OneDrive: Explanation Of Files
      DropBox: Explanation Of Files
    8. VIDEO:  (9:56)
      OneDrive: NUnit Details
      DropBox: NUnit Details
    9.  VIDEO:  (5:50)
      OneDrive: Finding Things Quickly In Visual Studio
      DropBox: Finding Things Quickly In Visual Studio
    10. Exercise: Make failing tests pass (Hand-In)
    11. Exercise: Making a basic unit test pass (Hand-In)
    12. VIDEO:  (6:25)
      OneDrive: Attributes: 'Values' and 'TestCase'
      DropBox: Attributes: 'Values' and 'TestCase'
      1. There are no exercises specifically for these two attributes
      2. TODO:  there's a section in the video about combos - it looks like I claim that 2 params X 4 values is 256, when it's actually 16 (4^2)
    13.  VIDEO:   (11:21)
      OneDrive:  Example #1 for getting tests to pass
      DropBox: Example #1 for getting tests to pass
      1. This is the 'Exercise description' document used in the above video:  example #1
    14.  VIDEO: Example #2 for getting tests to pass (using the debugger)  ()
      1. This is the 'Exercise description' document used in the above video:  example #2
    15. VIDEO:  (5:11)
      OneDrive: I/O Redirection
      DropBox: I/O Redirection
    16. Exercise: Fixing broken output (Hand-In)
    17. Exercise: Fahrenheit to Celsius (Hand-In)
    18. In order to hand in your work for this section, please create a folder named something like "NUnit", and put the following two files into it.  Put the NUnit folder inside the .ZIP file that you hand in
      1. Student_Answers.cs
      2. The feedback form
  9. Last Steps

    1. Hand in your work:
      Because some of your work was done via GitHub and some wasn't you'll need to hand in both parts, in two separate steps
       
      1. Please follow the instructions listed here to hand in the starter project for the overall Lesson.
        (These instructions are for BIT 142 specifically, but they should make sense for this class, too)

        MAKE SURE THAT YOU INCLUDE THE 'PLACEHOLDER' FILE FOR INSTRUCTOR FEEDBACK, and that you upload this file directly to Canvas.
      2. in order to hand in exercise 3-C ("Define and use the ErrorCode Enum")you’ll need to commit your work into your local git repo and then push those changes back to your copy of the repo that’s stored in GitHub.

        If you need a refresher on how to do that please review the material from the previous Lesson and/or make use of office hours, the tutoring hours in the Bock Learning Center, and/or Google/Bing/etc.
    2. Hand in your work:
      Go to the StudentTracker  web app, and create an account for yourself, and then "enroll" in the course.
      (There's a link to StudentTracker on the main page for this course)
      Please submit a .ZIP (and ONLY a .ZIP - not a .RAR, .7z, etc).  It's fine for it to contain files that I"m not grading, but please make sure that contains the Program.cs files, the video outline/viewing quiz .DOCX (or .PDF), the NUnit folder with the Student_Answers.cs file and the NUnit feedback form, along with any other files you wish to include.

      1. For these PCEs please keep the Program.cs files in the folders you found them in so it's clear which Program.cs is which.
        For example, please keep the PCE_Starter folder, please leave in that folder the Program.cs that was there, please keep the SmartArray_EH_Test folder with it's Program.cs, etc.
        That said - as long as I can find the Program.cs file that I'm looking for reasonably quickly and easily I'll be happy :)

      2. VIDEO: Using StudentTracker

      3. VIDEO: How to .ZIP your homework into a single file

      4. Remember that you can use an extension to hand in your work slightly late (see the lecture 1 slides for details).
        Once you get the feedback (the grade) from the instructor you have a limited time to email your missing work to the instructor (make sure to tell the instructor that you're using an extension). 
        You can use an extension if you forgot to hand in the entire .ZIP file, and you can  use the extension if you forgot to include an entire, specific file.  You CANNOT use an extension to revise work that you submitted and got a grade on.

        This is true as long as you have extensions left; next week will be the last time that this notice is posted

    3. Make sure that you're working on the next homework assignment.
      Details are listed on the
      homework assignment page.
      The due date is listed on the main page.
    4. Practice what you've learned
      Remember that in order to really learn this stuff you're going to need to practice it.  Go back and redo the exercises from this lesson until you've really got it down.  Go back to the prior lesson(s) and review and redo that.  Make sure that you've really got this stuff in your head (and remember that it gets easier each time you redo the work)!
  10. Modern collections classes: generic classes and interfaces
    If you find something confusing you should seek help earlier than normal - post a question to the class discussion board, email your instructor, talk to other students, etc.
    The Visual Studio project that is used in the videos below can be found here.


    1. VIDEO: What is a modern collection class? (including "What is a 'generic' class?")
      Part 1: Collections
      Part 2: Generics
      Note that there are no quiz questions for these videos, so you will need to do a video outline, instead.
      Slides from the video
    2. Exercise: Using the GENERIC .Net FCL Stack as an example of a Collection class (Hand-In)
    3. VIDEO: Creating your own generic class
      Note that there are no quiz questions for this video, so you will need to do a video outline, instead.
    4. Exercise: Create a basic, generic class (Hand-In)
    5. VIDEO: What is an interface?
      Note that there are no quiz questions for this video, so you will need to do a video outline, instead.
      Slides from the video
    6. Exercise: Implement the generic 'IComparer' interface (Hand-In)
    7. New Material Feedback (Hand-In)
      Your feedback is critical to improving this new material. 
      Please fill out PCE_Feedback.docx and include it in the .ZIP file for this week.
 
 
In-Class Materials:

These materials are used by students in the hybrid class during leture time.  Online students can safely ignore everything in this 'In Class Materials' box.

In-Class Materials:

Instructor's Materials:

  • Notes
    • These notes are for the instructor’s use, and not meant for public consumption.
      They're posted here on the off chance that you find them useful - If they help you, that’s great.  If not, please just ignore them :)

Videos recorded during class (of the In-Class Exercises):