DEV Community

Cover image for ๐Ž๐›๐ฃ๐ž๐œ๐ญ-๐Ž๐ซ๐ข๐ž๐ง๐ญ๐ž๐ ๐๐ซ๐จ๐ ๐ซ๐š๐ฆ๐ฆ๐ข๐ง๐  ๐–๐ข๐ญ๐ก ๐“๐ฒ๐ฉ๐ž๐ฌ๐œ๐ซ๐ข๐ฉ๐ญ : ๐š๐ค๐š โ€œ๐๐จ ๐ฆ๐จ๐ซ๐ž ๐ฆ๐ž๐ฌ๐ฌ๐ฒ ๐œ๐จ๐๐ž, ๐จ๐ง๐ฅ๐ฒ ๐œ๐ฅ๐š๐ฌ๐ฌ๐ฒ ๐ฏ๐ข๐›๐ž๐ฌโ€
SHAHNAWAZ SAZID
SHAHNAWAZ SAZID

Posted on

๐Ž๐›๐ฃ๐ž๐œ๐ญ-๐Ž๐ซ๐ข๐ž๐ง๐ญ๐ž๐ ๐๐ซ๐จ๐ ๐ซ๐š๐ฆ๐ฆ๐ข๐ง๐  ๐–๐ข๐ญ๐ก ๐“๐ฒ๐ฉ๐ž๐ฌ๐œ๐ซ๐ข๐ฉ๐ญ : ๐š๐ค๐š โ€œ๐๐จ ๐ฆ๐จ๐ซ๐ž ๐ฆ๐ž๐ฌ๐ฌ๐ฒ ๐œ๐จ๐๐ž, ๐จ๐ง๐ฅ๐ฒ ๐œ๐ฅ๐š๐ฌ๐ฌ๐ฒ ๐ฏ๐ข๐›๐ž๐ฌโ€

I finally sat down and decided it was time to face my fears and tackle Object-Oriented Programming (OOP) in TypeScript. And guess what? Itโ€™s not just buzzwords and confusing diagrams it actually makes sense

Checkout All Detailed OOP With Ts Concepts and Code In My GitHub Readme : https://lnkd.in/gG_9UEH9

Hereโ€™s a breakdown of what Iโ€™ve been learning with a sprinkle of chaos, caffeine, and curiosity:

๐‘ช๐’๐’‚๐’”๐’” & ๐‘ถ๐’ƒ๐’‹๐’†๐’„๐’•

Think of a class like your momโ€™s biryani recipe and the object is the biryani you make from it. The recipe doesn't change, but you can make as many plates as you want .

๐‘ฐ๐’๐’‰๐’†๐’“๐’Š๐’•๐’‚๐’๐’„๐’†

Why write the same code twice when you can inherit your dadโ€™s methods and your momโ€™s properties? OOP lets one class borrow anotherโ€™s stuff. Just like real life but with less drama.

๐‘ป๐’š๐’‘๐’† ๐‘ฎ๐’–๐’‚๐’“๐’…๐’” (๐’•๐’š๐’‘๐’†๐’๐’‡ & ๐’Š๐’)

These are the bouncers of TypeScript. They check IDs at the door before letting values in. โ€œSorry buddy, only strings allowed here.โ€

๐˜ช๐˜ฏ๐˜ด๐˜ต๐˜ข๐˜ฏ๐˜ค๐˜ฆ๐˜ฐ๐˜ง :
This one checks if an object is from a certain class. Great for those moments when youโ€™re like, โ€œWait... what even are you?โ€

๐‘จ๐’„๐’„๐’†๐’”๐’” ๐‘ด๐’๐’…๐’Š๐’‡๐’Š๐’†๐’“๐’”

public, private, and protected the introvert/extrovert settings for your class properties. Finally, I can keep my variables from oversharing.

๐‘ฎ๐’†๐’•๐’•๐’†๐’“๐’” & ๐‘บ๐’†๐’•๐’•๐’†๐’“๐’”

Why give direct access to your private stuff when you can negotiate with a getter? These let you control how your properties are viewed and changed like a velvet rope to your data.

๐‘บ๐’•๐’‚๐’•๐’Š๐’„ ๐‘ด๐’†๐’•๐’‰๐’๐’…๐’” & ๐‘ท๐’“๐’๐’‘๐’†๐’“๐’•๐’Š๐’†๐’”

These belong to the class, not any specific object. It's like that one cousin who thinks they speak for the whole family.

๐‘ท๐’๐’๐’š๐’Ž๐’๐’“๐’‘๐’‰๐’Š๐’”๐’Ž

Different objects acting the same way. Like how every intern, no matter the department, somehow ends up making coffee.

๐‘จ๐’ƒ๐’”๐’•๐’“๐’‚๐’„๐’•๐’Š๐’๐’

Hide the messy details and just show the clean interface. Itโ€™s like every cooking show ever: โ€œAnd wooooh! I already made this off-camera!โ€

๐‘ฌ๐’๐’„๐’‚๐’‘๐’”๐’–๐’๐’‚๐’•๐’Š๐’๐’
Keep your internal logic locked up like itโ€™s your browser history. Only show whatโ€™s necessary. Boundaries matter even in code.

TypeScript #OOP #ObjectOrientedProgramming

Top comments (0)