I am sure class is class in the real world and programming world.
It is a set or category of things having some property or attribute in common and differentiated from others by kind, type, or quality.
I will explain CLASS from 6 angles so that you can understand the concept of class:
π 1. Real World Class.
π 2. HTML & CSS Class.
π 3. "Programming" class.
π 4. The relationships among classes.
π 5. The relationships among members & class.
π 6. And how they are similar.
When I was in class SSS3 in high school, my class mates and I had a lot in common in terms of age, purpose, duties, activities and many others.
We sat for the same subjects, the same exams and we could call one another easily because we were close and bound together in a CLASS.
So, in the real world, who will be in the class of billionaires?
- Me π.
- Jeff Bezos
- Bill Gates
- Mark Zuckerberg And other billionaires.
In short, class is used to group/categorise things or people that have things in common.
In HTML & CSS.
Class of billionaires
Class of billionaires
These divs belong to two classes - billionaire and entrepreneur just like I can belong to one or many classes - African & Nigerian.
.billionaire {
business: true;
influencial: true;
}
. entrepreneur {
smart: true;
bad: possible;
good: possible;
stupid: impossible;
}
What is baffling is how beginners don't see the similarities between HTML & CSS class and the Programming CLASS.
Let me show you how class looks like in JavaScript.
class Entrepreneur {
// constructor () {}
isBad () {
//Write the logic
}
isGood () {
//Write the logic
}
isSmart () {
//Write the logic
//It is inbuilt in css
}
}
From this one can deduce that the major difference between HTML & CSS and Programming CLASS is abstraction.
You have to create most things in programming languages but in html and css, you just use inbuilt "APIs", sorry, markups, attributes, values and properties.
Follow me here or on twitter: Shakespeare of Code
For continuation.
Comment your views below.
Top comments (0)