"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. "
- Module Summary
- Learning Objectives
- Example Projects
- In-Class Exercises
- Week 1
- Week 2
- Week 3
- Class Recordings
- Study Links (external)
- Homework Submission (external)
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?".
- Object Oriented Programming
- Refactor projects from last module into OOP projects
- Data-first development
- Understanding applications as Data + User Interactions
- Developing from the "inside" out: Writing the core object before the user interface
- Explain what a schema is and why it's useful (PS. it's like tests, but for data!)
- Use the JSON schema specification to document your program's data
- Use a schema validation library to grantee the integrity of your project's data
- Debugging:
- Bugs are when you don't understand what your code is doing, not when your code doesn't understand what you want it to do! The computer is always right :)
- Stepping through your programs with the Browser and Node.js debuggers
- Using the
debugger
,console.assert
,assert
(in Node) and breakpoints for native debugging - Refactoring & testing segments of code you don't understand / are not working
- Understand Behavior vs. Implementation
- Behavior: The test cases that a function does and doesn't pass. What the function does.
- Implementation: The actual lines of code written. How memory is manipulated so that the behavior happens.
- Testing
- Learn to predict what will happen instead of describing what did happen
- Testing each step of your project before moving on
- Using the native Node.js module
assert
- Writing & using popular testing libraries (jasmine & mocha)
- Understand
this
- Be able to refactor functions into methods
- Be able to refactor methods into functions
- Plan and implement objects based on User Stories
- Understand
getters
andsetters
- Understand the
class
keyword- Be able to refactor between constructor functions & classes
- Use classes to create simple programs
- Understanding your projects as being first an object, and second a user interface
- Object: what data is stored in your application, and how can users interact with it? (Data & Logic)
- User Interface: what does a user see on the screen? (styles & DOM)
- User Interactions: how does the user interface connect with the core object? (listeners & handlers)
- DOM Components
- Create functions and methods that return DOM elements
- Reuse the same components in different places on your site