Encapsulation and "static" - Classes and Object Oriented Programming (OOP) - Javascript In Depth

Published: 30 December 2022
on channel: Tech with Nader
2,623
148

We learn about Encapsulation which is one of the four pillars of Object Oriented Programming, using Javascript. This concept allows us to think of classes as "capsules" or "black-boxes" that we can interact with using a narrowed down set of functions so it's easier for us as developers to use them. We also look at some real-world analogies so the concept becomes clearer.

We then take a look at private fields and methods within classes which is a relatively new addition to the language. This allows us to "hide" information and functionality in our classes that's internal to the class and not necessary to be exposed to the user-facing side. We also see how this interacts with sub-classes.

We wrap up the video by looking at the "static" keyword and how it can be used to add functionality and data directly to the class Object itself. There are ample examples of this within the Javascript language itself as well as from 3rd party libraries which we'll see as we build more projects out.

Note that this is an advanced topic and will take a lot of practice and trying different things over time to really cement. We'll go through some practice exercises together on Encapsulation as well as private fields/methods and the "static" keyword in the next video in the series.

This is part of a series where we go over Javascript in depth to learn programming concepts as well as web development:    • Javascript In Depth  

Chapters:
00:00 Introduction
01:10 4 Main OOP Concepts Recap
02:17 Encapsulation Main Concept
04:05 Encapsulation Analogies
10:10 Encapsulation Class Visual
11:43 Why We Need Information Hiding
18:05 Information Hiding Code Issues
23:47 "Private" Data and Methods
26:21 Private Data/Methods Code Example
35:26 Private with Sub-Classing
38:10 Private Sub-Class Code Example
42:21 "Static" Keyword Intro
47:04 "Static" Keyword Code Example
53:45 Next Steps

📦 Github Repository with the notes and exercise code+solutions: https://github.com/Nooder/javascript-...
💬 Come join us on Discord to chat with a like-minded community about tech and learning:   / discord  
🏅Support the channel and content through Super Thanks, Channel Memberships, or on Patreon:   / techwithnader  


On this page of the site you can watch the video online Encapsulation and "static" - Classes and Object Oriented Programming (OOP) - Javascript In Depth with a duration of hours minute second in good quality, which was uploaded by the user Tech with Nader 30 December 2022, share the link with friends and acquaintances, this video has already been watched 2,623 times on youtube and it was liked by 148 viewers. Enjoy your viewing!