re: Please don't write a class VIEW POST

VIEW PARENT COMMENT VIEW FULL DISCUSSION
 

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.

 

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.

 

Well said, sir! I think there's too much extremism in development these days (Java sucks, FP rules, JS is horrible, etc., etc.)

No one is saying Java sucks, or we shouldn't write classes. Classes are great when dealing with complex projects, but themselves introduce overheads. Just have to be wary of writing classes for everything.

(Java does make programmers write class for everything though. Just saying)

code of conduct - report abuse