DEV Community

Discussion on: Please don't write a class

Collapse
 
notriddle profile image
Michael "notriddle" Howell

You're missing the point: that example is completely useless without some idea of what the business requirements are.

If I were designing something like Microsoft Bob, then I wouldn't have a Dog class at all. There might be a class for the visual character in general, but behind that the different avatars (the dog, the dude, I don't remember what the other ones were) can just be data files with no code at all. If I were designing a video game, the dog might be built up of a rendering model plus a number of Components that handle different behaviors that get linked up with the dog (some of them might only ever be used with the dog, but some wouldn't). And if I were tracking pets in a database, the only distinction between a dog or some other animal would be a single column; again, no dedicated dog-specific code here.

Collapse
 
pancy profile image
Pan Chasinga

Thanks for the comment.

I invite you not to get bogged down by my examples. I was just suggesting an alternative.

My point being when something is simple enough to maybe solve with functions, maybe there's no need to jump to writing classes from the get-go.

No one is suggesting classes are bad here.