loading...

Understand the concept: What is CLASS in programming?

codingnninja profile image Ayobami Ogundiran ・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.

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.

Posted on by:

codingnninja profile

Ayobami Ogundiran

@codingnninja

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.

Discussion

markdown guide