Giter Site home page Giter Site logo

encapsulation's Introduction

Encapsulation

"Encapsulation is one of the fundamentals of OOP (object-oriented programming). It refers to the bundling of data with the methods that operate on that data. "

Encapsulation is the idea of grouping together your data with the functions that use it. That's it! (for now :) There are many ways to achieve this, but the end result is code that is easier to understand and nicer work with.

Heads up! In this module you'll be encountering some of the most important (and most challenging!) aspects of the JavaScript language this, inheritance & classes. These are all features of JS that allow you to encapsulate functions & data for readable, reusable code.

Along the way you will get your first introduction to one of the main programming paradigms in JS: object oriented. At their simplest level, programming paradigms are just different answers to the same question "How will I group my data and my functions?".

Contents


Learning Objectives

Vocabulary

  • Encapsulation
  • Object Oriented Programming
  • Inheritance
  • Code Reuse (DRY)
Soft Skills
  • Data-first development
    • Understanding applications as Data + User Interactions
    • Developing from the "inside" out: Writing the core object before the user interface
  • Organizing your projects into modules
  • Object Oriented TDD
    • Using tests to define and verify OOP programs
Hard Skills
  • Use the keyword this
    • Be able to refactor functions into methods
    • Be able to refactor methods into functions
    • Plan and implement objects based on User Stories
  • Use getters and setters
    • Be able to refactor between properties, methods and getters/setters
  • Using import & export to organize your codebase
  • Understand prototypical inheritance
  • Use ES6 Classes to organize your code
    • Be able to refactor between constructor functions & classes
    • Use classes to create simple programs
  • binding handlers to this
  • function () {} vs. () => {}
    • How does each one treat this differently?
  • Closure 101:
    • Using () => {} handlers to avoid binding

TOP


About the Projects

Projects in this module will have all the same concerns as projects in the last module, they'll just be organized a little differently. In the last module every function was a free-floating function written in a separate file and required separately into your .html files.

In this module you'll learn how to:

  • Encapsulate your application's data with the functions that operate on it using object oriented programming.
  • Organize your code base using ES Modules (import and export). Yo
  • Reuse your methods with inheritance and ES6 classes

TOP


Suggested Study

Helpful Links

Binding

Exercises

Code to Study

OOP TDD

TOP

Week 1

Learn to use function () {} functions and this to encapsulate your data and logic.

Prep Work

before class

Lesson Plan

during class

  • Functions to Methods
  • Getters & Setters
  • Refactor Code-Along

Project

after class

this is an individual project

Your project this week is to build something inspired by the Practical JavaScript Tutorial (best tutorial ever).

To help you get off the ground here is a starter repository. There is already some code to

You don't find a todo app so interesting? not a problem! Your group is free to invent a new project idea, just be careful about scoping!

Checklist

- [ ] [repo](https://github.com/_/_) (with a complete README)
- [ ] [live demo](https://_.github.io/_)
- Project Planning
  - [ ] [Backlog](https://github.com/_/_/tree/master/project-planning/backlog.md)
  - [ ] [Development Strategy](https://github.com/_/_/tree/master/project-planning/development-strategy.md)
  - [ ] [Project board](https://github.com/_/_/projects/_)
- Implementation
  - [ ] Tests for core app object
  - [ ] Tests for views (optional)
  - [ ] Initial state in `src/data.js`
  - [ ] Logs of each user interaction

TOP


Week 2

Learn to:

  • inspect prototype chains in the debugger
  • tell the difference between static and instance methods
  • use Object.create for code reuse

Prep Work

before class

Lesson Plan

during class

Before Break

  • Isolate: 7. Prototype Delegation

After Break

  • Isolate: 8. Object.create
  • Integrate: 3. Object.create

Project

after class

List Manager! Following up on the tutorial from last week, your group will be building a web page that allows users to create as many lists as they want. You will need to refactor the todo list from WatchAndCode into a prototype object that can be used to create so list instances. A suggestion: users can input a title and create a new list with that title.

Along with prototypes, your group will be exploring import and export. This week's starter repository has the basics already in place for you. Enjoy!

Checklist

- [ ] [repo](https://github.com/_/_) (with a complete README)
- [ ] [live demo](https://_.github.io/_)
- Project Planning
  - [ ] [Backlog](https://github.com/_/_/tree/master/project-planning/backlog.md)
  - [ ] [Communication](https://github.com/_/_/tree/master/project-planning/backlog.md)
  - [ ] [Development Strategy](https://github.com/_/_/tree/master/project-planning/development-strategy.md)
  - [ ] [Project board](https://github.com/_/_/projects/_)
- Implementation
  - [ ] ES Modules (`import`/`export`)
  - [ ] Logs of each user interaction

TOP


Week 3

Learn to use Classes for a reusable code base.

Prep Work

before class

Lesson Plan

during class

Before Break

After Break

Project

after class

Impress yourselves! Using this starter repository, plan and scope a project of your choosing. This can be a totally new idea or a reworking of a previous project, maybe even a continuation of last week's project!

Checklist

- [ ] [repo](https://github.com/_/_) (with a complete README)
- [ ] [live demo](https://_.github.io/_)
- Project Planning
  - [ ] [Backlog](https://github.com/_/_/tree/master/project-planning/backlog.md)
  - [ ] [Communication](https://github.com/_/_/tree/master/project-planning/backlog.md)
  - [ ] [Development Strategy](https://github.com/_/_/tree/master/project-planning/development-strategy.md)
  - [ ] [Project board](https://github.com/_/_/projects/_)
- Implementation
  - [ ] ES Modules (`import`/`export`)
  - [ ] at least one `class`
  - [ ] Logs of each user interaction

TOP


Class Recordings

Coaches, when sending your PR's with links please ...

  • Indicate which class you were teaching
  • Which week it was
  • Give your name
  • and a helpful description

Class 7 & 8

Anthony, Bram

  1. week 1:
  2. week 2:

Class 9 & 10

Anthony, Unmesh, Evan

  1. Week 1:
  2. Week 2:

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.