Skip to content

(feat) OOP Concept #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ I am an independent educator and open-source enthusiast who creates meaningful p

### Module 5 - Object Oriented Programming(OOP) in JavaScript

TBA
- **`Day 29: Object Oriented Programming (OOP) Explained with Real-Life Analogies 🤩`** - [Watch Video](https://www.youtube.com/watch?v=oRQOiyO-kHg) || [Source Code](https://github.com/tapascript/40-days-of-javascript/blob/main/day-29/README.md)
36 changes: 36 additions & 0 deletions day-29/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Day 29 - 40 Days of JavaScript - OOP Concepts

## **🎯 Goal of This Lesson**

- ✅ Welcome to Module 5
- ✅ Things to Learn Today
- ✅ Objects
- ✅ Classes
- ✅ Functions
- ✅ Object Oriented Programming(OOP)
- ✅ Real-world Examples of OOP
- ✅ Abstraction
- ✅ Encapsulation
- ✅ Inheritance
- ✅ Polymorphism
- ✅ Composition
- ✅ Quick Recap

## 🫶 Support

Your support means a lot.

- Please SUBSCRIBE to [tapaScript YouTube Channel](https://youtube.com/tapasadhikary) if not done already. A Big Thank You!
- Liked my work? It takes months of hard work to create quality content and present it to you. You can show your support to me with a STAR(⭐) to this repository.

> Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)

### 🤝 Sponsor My Work

I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. **You can support my work by [Sponsoring me on GitHub](https://github.com/sponsors/atapas) or [Buy Me a Cofee](https://buymeacoffee.com/tapasadhikary)**.

## Video

Here is the video for you to go through and learn:

[![day-27](./banner.png)](https://www.youtube.com/watch?v=oRQOiyO-kHg "Video")
Binary file added day-29/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions day-29/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OOP - The Concept</title>
<script defer src="./index.js"></script>
</head>
<body>
<h1>Welcome to 40 Days of JavaScript</h1>
<h2>We are Learning the OOP Concepts today!</h2>
</body>
</html>
78 changes: 78 additions & 0 deletions day-29/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

// 1. What are Objects?
// 2. What are Classes?
// 3. What are Functions?
// 3. How Can you practically think of Classes and Objects?
// 4. What is OOP?
// 5. Why OOP is Important in programming?
// 6. Real-World Use Cases of OOP
// 7. Five key OOP principles:
// a. Abstraction
// b. Encapsulation
// c. Inheritance
// d. Polymorphism
// e. Composition

/*
city
-> houses
-> roof
-> doors
-> windows
-> cars
-> model
-> brand
-> color
-> wheels
-> people
-> hospitals
-> roads

*/

// Game Development => Objects like Player, Enemy, Weapon help structure gameplay logic.

// E-commerce Website => User, Product, Cart, Order objects each have roles.

// Mobile Apps => Components like Screen, Button, Notification are objects.

// Banking Software => Customer, Account, Transaction manage real-world banking processes.

// Vehicle Management System => Vehicles are objects with types (Truck, Bike) that inherit from a base Vehicle

// Abstraction

// Abstraction is the process of hiding the internal complexities of how something works and only exposing what’s necessary for the user to interact with.

// Encapsulation

// Encapsulation is the bundling of data and methods that operate on that data into a single unit, usually a class — and restricting direct access to some of the object’s components.

// Inheritance

// Inheritance allows one class (child) to reuse the properties and methods of another class (parent), reducing duplication and promoting reusability.

// Polymorphism

// Polymorphism means “many forms” — it allows objects of different classes to be treated as if they are of the same type, but behave differently based on their class-specific implementations.

// Composition

// Composition is a design principle where one class contains or is composed of one or more objects of other classes to reuse their functionality, instead of inheriting from them.

// has-a


// Abstraction ── Hide complexity, expose interface
// Encapsulation ── Bundle + protect state
// Inheritance ── Share logic across classes
// Polymorphism ── Same method, different behaviors
// Composition. ── Build by combining units


{
"name": "tom",
"isCat": () => {
return true
}
}
55 changes: 55 additions & 0 deletions day-29/task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Tasks

Please complete the following tasks and post them on the tapaScript Discord under "40 Days of JavaScript".

> **DO NOT USE AI to FIND ANSWERS**. If you are stuck, let's discuss it on DISCORD and learn. Also, please note that none of the answers need you to create any UI. Just focus on the logic building and print the output on the browser console.

## 1. Identify Real-Life Objects with OOP Concepts

Pick any 3 real-life objects (e.g., smartphone, bicycle, school), and for each:

- List at least 3 properties (attributes).
- List at least 3 behaviors (methods).
- Write which OOP principle each property or behavior best represents and why.

## 2. Draw a Diagram of an OOP Modeled System

Create a diagram (hand-drawn or digital) of a system like:

- A library system (Books, Members, Staff, etc.)
- Or a fast-food restaurant system (Orders, Menus, Employee)
In the diagram Show classes/objects

- Arrows to represent relationships like inheritance or composition
- Indicate which class encapsulates what data and methods

## 3. Explain OOP Principles with Human Analogies

Write your own analogy (non-code) to explain each of the 5 OOP principles:

- Abstraction
- Encapsulation
- Inheritance
- Polymorphism
- Composition

It must be unique (not from the class), and explain how that analogy relates to programming.

## 4. Compare OOP vs Functional Thinking

Choose a simple system (e.g., a To-Do app or Alarm Clock) and:

- Describe how you’d design it using OOP (with objects)
- Describe how you’d design it using Functional Programming (with functions)

You don’t have to write code — just use words and bullets.

## 5. Object vs Class vs Function – Explain Like a Teacher

Imagine you’re teaching a 10-year-old:

- What is a Class?
- What is an Object?
- What is a Function?

Use simple language, drawings, or emojis if needed.