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.
Top comments (0)