Session 4 Scavenger Hunt, Modeling OOP, Assessment Expectations

Goals

By the end of this session, you will be able to:
  • Define Object Oriented Programming
  • Understand how to utilize error messages from git
  • model real-world objects and apps by breaking down their attributes and behaviors
  • understand assessment expecations

Agenda

Materials

  • Notebook
  • Writing instrument
  • Laptop
  • Headphones & mic

Housekeeping and Goals

Wins

  • Good survey scores regarding git and github.

Follow-Ups

  • Leaving feedback directly on homework gists. Make sure you’re checking them. We’ll reach out in slack if we have major concerns.
  • Remember to be aware of where you are in your directory structure of the terminal before you clone anything down or start running git commands. Always run ls after cloning
  • New FE capstone. If you’ve already started on yours, please delete your fork and restart.

Other Notes

  • Good commit message format:
Add list of mod 0 resources
Remove reference to old blog post
Change data type of age field
Fix spelling mistake
  • Not good commit message format:
Rachel is adding her list of mod 0 resources
old blog post
changed data type for age field
Oops, I need to fix my spelling mistake

Intros, Review, and Icebreaker

Intros, Review, and Icebreaker

Person with the shortest first name goes first.

1. Introduce yourself: name, pronouns

2. What music are you listening to currently, and is there any music that you've found to be helpful when you're studying/programming?

3. Accountability review: what tangible progress have you made toward the focus skills you identified at the beginning of Mod 0?

Have extra time? Share what extra things you're doing to get ready to start school at Turing.

Scavenger Hunt

This portion of class was added because mod 1 instructors have noticed some behaviors in struggling students:

  • Missing or not understanding directions
    • What strategies can you use to avoid this?
  • Not reading error messages/using them to progress on a problem
    • What strategies can you use to avoid this?

In programming, we often need to follow tutorials in order to learn new things. If you miss even one step, you’ll get a different end result. Your challenge here is to follow each step very diligently. There are going to be things that you’ve already done, and things that you will need help from your old pal google to figure out on your own (I mean, tutorials can’t tell you how to do everything right?).

The end goal here is to create a pull request. Something you just did as homework for session 3. Can’t be that bad right?? Good luck!

We won’t be available for help during this scavenger hunt, however write down the questions and issues you run into. We’ll debrief as a group and answer any questions afterwards.

Note: The one exception to that rule is if you’re asking for clarification on a given step. If you’re unsure about what the directions are asking, please reach out in the slack thread.

Try It: Don't fork it up!

At this point, we'll split into breakout rooms. Everyone should do a fist to five to show their comfort with git. Whoever is the least comfortable with git will share their screen. Whoever is sharing their screen will be called the driver. Every other person in the room will be a navigator.

If you are already comfortable with git, your challenge during the breakout is somewhat more difficult: your goal is to focus on your explanations, communication, and ability to gauge whether or not another person understands you.

  1. Clone down this repo: https://github.com/damwhit/best-foods (do not fork it first)
  2. Create a new file within the repo called dumplings.txt
  3. Add pot stickers in snake case to the first line of the file
  4. Add and commit your changes (what should your message be?)
  5. List the origin for your repo from the command line
  6. Do you have access rights to push? why or why not?
  7. Create a new repo in GitHub called very-best-foods
  8. Change the origin of your local clone of best-foods to match the new very-best-foods repo you just created in GitHub
  9. How can you confirm that you changed the origin successfully?
  10. Push your changes from your local repo to your very-best-foods repo
  11. Is your local repo in sync with the very-best-foods repo in GitHub? How can you tell?
  12. In GitHub, change the first line of the readme to say very best foods in PascalCase (save and commit in GitHub)
  13. In your local clone, add a file called noodles.txt
  14. In that file, add fettucine alfredo in camel case to the first line
  15. Save, commit, and push your changes to your very-best-foods remote repo
  16. Can't push? Why not? ... follow the error message
  17. Once you've pushed, create another file locally called best.txt
  18. Add ramen to the 5th line of the file
  19. Save, commit, and push your changes
  20. Create a pull request to this directory: https://github.com/damwhit/very-best-foods
  21. If you followed all of the directions above correctly, you should see no difference between the two repos in the pull request

Done? Switch drivers and try the process again!

Q and A time


BREAK

Turn off your mics and videos and walk away from the computer. Stand up, stretch, drink water. Do a few sit-ups, squats, push-ups, jumping jacks, arm circles, stress ball squeezes, or whatever else moves your body.


Object Oriented Programming

Object oriented programming, or OOP for short, is an approach to programming (or a programmming paradigm) where programs are organized as a series of objects.

OOP is very similar to how the world actually works. Objects are created from templates that we call classes.

A class defines attributes (or properties) and methods (or actions). An object is a very specific instance of a class. For example, if the class were Car, two objects might be David’s 2007 Blue Nissan Versa and Grandma’s 2014 Silver Nissan Juke. There is only one of each of them

Attributes contain data about a specific object. The information format should be one of the basic data types from Session 1 (string, integer, float, boolean, array, hash).

The names of attributes are generally nouns.

A good question to ask when you’re determining what should be classified as an attribute is:

  • “Is there any other data that underlies this piece of data?” (you want the answer to be no)

CAUTION: Sometimes, methods will feel like they should be attributes. For example: percent_full or volume.

Try It Together: Bottle Class Attributes

Follow along as we walk through defining a bottle class with three different bottle objects.

NOTE: For consistency in this lesson, we're going to stick to the naming convention of camelCase. This will look very Javascript-esque. However, in Ruby land, you'll see snake_case.
Class: Bottle

Attributes:
color (string)
lidType (string)
totalCapacity (integer)
stickers (array)
currentCapacity (integer)
recyclable (boolean)
insulated (boolean)

Methods define the behavior of an object, actions that can be performed on that object, or calculations that use the object’s attributes. Methods are generally verbs (action words or short action phrases).

Methods generally answer the question “What can this thing do?” or “What can be done to this thing?”

A return value is the result of a method that performs a calculation. For instance, a calculatePercentFull method could divide the value of a currentCapacity attribute from the value of totalCapacity attribute. The result of that calculation would be the return value for calculatePercentFull method.

Key Points

  • A method performs some kind of work and will almost always use or modify an attribute
  • Anything that does work (calculations) should be a method, not an attribute
    • the result of that work is called the return value
  • Attributes are generally nouns (99.9% of time)
  • Methods are generally verbs (90% of time – can also be questions OR nouns that are the result of calculations)
    • ie. percent_full or volume since they require calculation

Try It Together: Bottle Class Methods

Follow along as we walk through defining some methods for our Bottle class.

What kind of methods can we add? What would their return value be?

Class: Bottle

Attributes:
color (string)
lidType (string)
totalCapacity (integer)
stickers (array)
currentCapacity (integer)
recyclable (boolean)

Methods:
calculatePercentFull (divides currentCapacity by totalCapacity)
refill (subtracts currentCapacity from totalCapacity and then refills that amount)
addSticker (append a sticker item into the stickers array)
changeColor (changes the color attribute)

Try It Together: Defining Bottle Class Instances

Follow along as we walk through defining a couple instances

Make sure that your syntax is correct for each data type: if it's a string, the value below should be wrapped in quotes. If it's an array, each item in the collection should be valid data as well, etc.

Object: Nalgene

Attributes:
color: "Pink"
lidType: "Twist top"
...


Methods:
calculatePercentFull: 800 / 1000 = .8
changeColor: color = "Blue"
...

Try It (Big Breakout Rooms) (~15 minutes)

Person whose first name starts closest to Q will share their screen and choose one of the following classes:

  • Vehicle
  • Book
  • Playlist
  • GroceryStore

Everyone should create a .txt file to work off of following the conventions we used above for defining classes and instances

As a team, brainstorm at least five attributes (and data types) and five methods (and descriptions) for your chosen class. Each person should be keeping their own copy up to date to use as a reference.

Person whose first name starts closest to the letter A will suggest an object that is an instance of the class. This is Object #1.

Brainstorm the values for each attribute of that object.

Brainstorm the results of each method called on that object.

Person whose first name starts closest to the letter E will suggest a second object that is an instance of the class. This is Object #2.

Repeat the brainstorm process for attributes and methods for object #2.

Can You Spot the Problem?

What would be wrong with…

  • a class called Turing
  • an attribute called current_time
  • having attributes for a Review class called one_star, two_stars, three_stars, etc.
  • a Senator class having an array attribute called senator_names
  • a class called California
  • having attributes on a ShoppingCart class called item_one, item_two, item_three, etc.
  • a method on GroceryStore called clean_aisle_seven
  • a Bottle class having an attribute called water
  • a Chair class having an attribute called number_of_chairs
  • a MenuItem class with a method called CustomerSurvey

Mod 0 Technical Assessment

This is our final Mod 0 technical session. Your assignment between now and Session 5 is to find 80 minutes to complete the Mod 0 Technical Assessment.

SAMPLE INSTRUCTIONS

The work portion of the assessment should take you approximately 70 minutes, but we recommend taking an additional 10 minutes to throughly read over the expectations outlined in this document. The timed nature is meant to get you used to working under pressure.

First, fork the assessment checklist. You will use this checklist to ensure that you have met the Mod 0 Technical Assessment expectations.

Part I: Creating Directories and Files; Initializing Git and Pushing to GitHub (10 min)

  1. Use your terminal to create a directory called ...
  2. Inside of that directory, make an empty text file called ...
  3. Initialize your directory as a git repository.
  4. Add your file and commit using the message "Initial commit"
  5. Create a public repo on Github with the same name.
  6. Add the remote and push your local repository to Github.

Part II: Classes, Objects, Attributes, and Methods (35 min)

  1. Inside of ..., create a new directory called ...
  2. Inside of ..., create four files: ..., ..., ..., and ...(If you're comfortable trying markdown at this point, feel free to use .md instead of .txt).
  3. Open up ... in your text editor.
  4. Brainstorm one class that might exist in a ... and put this at the top of the file.
  5. List at least four attributes for that class. In parentheses, list the data type for that attribute (string, boolean, integer, float, hash/object, datetime).
  6. List at least four methods for that class. In parentheses, explain what the method does, including the names of the attributes that it uses or modifies.
  7. Save your file.
  8. Add and commit your changes for this class.
  9. Open up ... in your text editor.
  10. At the top, type the name of an object that is an instance of your class.
  11. List the values for each attribute.
  12. List the results of the method being called for this specific object.
  13. Save your file.
  14. Add and commit your changes for this class.
  15. Repeat steps 3-8 with ...
  16. Repeat steps 9-14 with ...
  17. Push your changes to GitHub.

Part III: Program Specific Challenge (25 min)

  1. Open up your ... file in your text editor.
  2. You'll be given directions for some exercises that are program specific. Looking for something to study? Check out session 1 on data types and variable assignment. The capstone is also a good resource.
  3. If you are really solid with data types and variable assignment, it shouldn't be too bad
  4. Save your file.
  5. Add and commit your changes.
  6. Push your changes to Github.

Done?

There is a link to a google form where you'll submit your mod 0 assessment repo at the end of your checklist

Other faq’s:

  • Can I update my work after I’ve committed a file?
    • Yes, please do. Update and commit away!
  • I messed up my commit message. Should I fix it?
    • No, mistakes happen. We don’t want you wasting time on that. Just be more diligent on the next commit

Be sure to fill out the survey from your project board!

Also, capstone is due in a couple of weeks. Frontenders, remember to delete your forks, and restart it. As it has changed a lot :)