DEV Community

Discussion on: How I finally understood what a class is

Collapse
 
echoes2099 profile image
echoes2099

Not to troll or sound douchy but it would be more helpful if you shared more context and what you thought about classes before and after. The reason is because a "classification" (i.e., the concept of a class) is such a fundamental concept to being human, that this post is super surprising. For example, my toddler learned that fido and rover are both types of dogs, that is, he knows about the class of dogs. Later in school, he will learn that people and dogs are both mammals, another class.

Not surprisingly when I first learned Java many years ago, i took to classes like a fish to water. I realized that it made programming more relate-able i.e., easier to understand. As for my context, I had previous experience with procedural programming, which made OOP a refreshing, more natural alternative. Maybe that's what made classes so hard for you?

Where I did struggle is with overengineering---that is, not everything should be a class (rushing to abstractions to early). Later I also learned from experience that using classes for code sharing can be bad in large projects---you get too much coupling. That means shallow hierarchies are preferable, and object composition for code sharing is even better.