DEV Community


Understand the concept: What is CLASS in programming?

Ayobami Ogundiran
I am a software developer that loves going to any extent to make great things happen. I write history with PHP(Laravel), JavaScript(React). I'm a contributor @firefoxDevTools and tutor @udemy.
・2 min read

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?

  1. Me 😄.
  2. Jeff Bezos
  3. Bill Gates
  4. Mark Zuckerberg And other billionaires.

In short, class is used to group/categorise things or people that have things in common.


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
Enter fullscreen mode Exit fullscreen mode


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.

Discussion (0)