GithubHelp home page GithubHelp logo

mosh-oop's Introduction

Overview

This is a code-along with Mosh's Object-Oriented Programming and Git courses. Below are some notes taken along the way.

Objects

  • Constructor property: Every object has a constructor property, and that references the function that was used to create that object.
// constructor
new String() // same as string literals: '', "", ``
new Boolean() // same as boolean literals: true, false
  • Functions are objects: When we create a new operator, the operator will internally create an empty object, and pass that as the first argument in the call method. This object will determine the context for this. If you don't use the new operator, this keyword will refer to the global object.
// the following...
const anotherCircle = new Circle(2)
// ...is the same as:
Circle.call({}, 2)
  • Value vs. Reference Types: What will the following console log?
let num = 10
function increase(num) {
  num++
  // the number passed in here is copied by VALUE, 
  // i.e. it's INDEPENDENT from the variable above
  // the parameter is LOCAL in this function
  // the increased number (11) will go out of scope when we exit this function
}
increase(num)
console.log(num) // -> 10

What and Why of OOP

  • Define: OOP is a programming model that is based on objects rather than functions and logic
  • Detail: A program is divided into collections of code called objects that contain both data and methods. These methods give objects the ability to interact with each other and access/manipulate data.
  • Reasons:
    • Modularity
    • Efficient problem-solving
    • Code reuse
  • Resource:

Git

  • Branching
    • What is a branch?
      • Just a pointer to a commit
    • To switch branches: git switch {branch-name} (more modern than git checkout)
    • HEAD vs. master (via stackOverflow):
      • HEAD is a pointer/label to the most recent commit of the branch you are currently on
      • master is the default branch created when you initialized a git repository (e.g. git init)
      • You can delete the master branch (e.g. git branch -D master). You cannot delete the HEAD pointer.
    • Stashing: storing code changes in a temporary safe place
    • Merging:
      • Fast-forward merges (if branches have not diverged)
      • 3-way merges (if branches have diverged)
      • Resolving merge conflicts
      • To abort the merge: git merge --abort
      • To revert to the previous commit (one commit before the last/most recent one): git reset --hard HEAD~1
    • Resetting:
      • soft: revert only the last snapshot
      • mixed: revert the staging area and last snapshot
      • hard: revert the working directory, staging area and last snapshot
    • Rebasing:
      • It rewrites history
      • Only use when re-branching or when your commits are local in your repository
    • Cherry-picking:
  • Collaborating:
    • Fetching (git fetch):
      • Shortcut for git fetch origin
      • Only downloads new data from a remote repository - but it doesn't integrate any of this new data into your working files
    • Pulling (git pull):
      • Fetch + Merge
      • Not only downloads new data, it also directly integrates it into your current working copy files
  • Resource:

mosh-oop's People

Contributors

liaowow avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.