Black Profile picture
Jun 12 13 tweets 4 min read Twitter logo Read on Twitter
Give me 5 minutes and I'll teach you everything about object-oriented programming:

Documented by: @ChrisStaud Image
1. Object-oriented programming (OOP) is a programming paradigm in which programs are designed using classes and objects.

This design allows related functions and data to be grouped together in self-contained and reusable units.
2. A class is a template or blueprint from which objects are made from.

Classes define the properties and methods that an object can have, and objects are unique instances of a class.
3. For example, let's say you want to create a life simulation game where players can adopt and raise pets.

You would have a "Pet" class that defines the properties of each pet (like "name" and "age"), as well as behaviours they can do (like "speak" and "eat").
4. You could then create objects, or instances, of this class for each specific pet.

Each object could have its own values for each property.

For example, you could have a 2 year old pet named "Winston", & a 1 year old pet named "Wesley"; both initialised from the "Pet" class.
5. Object-oriented programming has 4 main principles: encapsulation, inheritance, abstraction and polymorphism.
6. Encapsulation hides internal details but exposes data & methods via a public interface, preventing unintentional changes.

E.g. — a player can view a pet's age but can't accidentally change it. But they can run methods avail on the public interface, like change a pet's name.
7. Inheritance allows for classes to inherit properties and methods from other classes, making code reusable and organized.

E.g. — A "SuperPet" class that extends from "Pet "and would inherit "age", "name", "eat", and "speak"; while defining new behaviours like "fly"
8. Polymorphism is a principle that enables objects to change their form by extending or overriding existing methods.

E.g. A "Dog" & "Cat" class that extended from the "Pet", shouldn't share the same "speak" method. You'd override it to have their own logic like "woof" or "meow"
9. Abstraction and encapsulation both intend to hide information, but abstraction does so to reduce complexity.

E.g. A "Player" class doesn't need to know how the "eat" method works in the "Pet" class, it just needs to know how to interact with it — i.e. its input and output.
Recap:

OOP provides a way to design your program that makes it reusable, secure, stable, and easy to understand.

But it isn't without disadvantages.

A couple of arguments against it is that it can lead to over-engineering and complexity on a large scale.
Thanks for viewing 🫶

If you found this tweet helpful, don't forget to:

Follow us @_blackdevdes for more.
Retweet the first tweet.
Enable notification to be the first to get our posts 🔔

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Black

Black Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @_blackdevdes

Apr 17
Learn AWS with 10+ Cheatsheets free of cost 🫶

Thread 🧵👇

Documented by:@ghumare64
AWS S3 : bit.ly/3JMYe2A
AWS Lambda : bit.ly/3Jq2QtI
AWS EC2 : bit.ly/3JpyuYz
AWS CloudFormation : bit.ly/3JHE3D1
AWS IAM : bit.ly/3mYW6f5
AWS API Gateway : bit.ly/3LvmW8K
AWS Route 53 : lnkd.in/gJWK9KqR
AWS EKS : lnkd.in/gUZYvdvB
AWS ECS : lnkd.in/geu_Hmu3
AWS RDS : lnkd.in/g-i6kMWB
AWS Redshift : lnkd.in/gH_fEdU8
AWS DynamoDB : lnkd.in/ghvfM889
AWS Infographics: awsfundamentals.com
Read 4 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(