DEV Community

Avinash Tiwari
Avinash Tiwari

Posted on

A cleaner way of writing code

I always have those Ahaa! moments, whenever I start making sense of something, I learn theoretically.

I am lucky to be in such an environment to experiment with my day-to-day work, so I can add that extra delta to my learning each day.

One such moment was to start using a class-based approach!

I mean we have been taught about Object-oriented programming since we started gaining consciousness in IT!

We mug things up for the interview...
"Encapsulation is object's attributes and methods under a single roof...blah blah blah"

But, to use it thoroughly, in our day-to-day life is missed by many of us engineers.

I asses a lot of engineers when I get a chance to take interviews, and I feel that not many are using the class-based approach, which in my opinion might make the thinking around the project much richer and code quality much "sexier".

And of course, a lot less work!

A few things I feel have improved in my code quality after writing in classes are:

  1. I can think beforehand about the business logic thoroughly before writing code
  2. Helps in structuring and refactoring the codebase
  3. I can save myself from writing lots and lots of code, as I can just extend classes
  4. Can follow DRY(don't repeat yourself) and hence, saves a lot of time

For Java people, it is quite mandatory to go with that approach. But, I urge all the other, Python, and Node developers to start writing in a class-based manner.

I promise you! You'll come and thank me!

Top comments (0)