xcrypt
xcrypt

Reputation: 3376

Should a class name reflect the class itself or instances of the class?

I have a class named 'Material'

The class itself represents an effect, but instances of that class represent a material.

Should I call the class 'Effect' or 'Material' ?

Upvotes: 0

Views: 67

Answers (2)

Amy B
Amy B

Reputation: 110071

Apply the Single Responsibility Principle (SRP) and make two classes for two represented concerns.

Upvotes: 1

AshBrad
AshBrad

Reputation: 492

What environment are you working in?

I'd keep both class and instances of classes representative of the material and employ a subclass for effect - particularly if the effect is coupled tightly with the material as is often the case. This will allow for better management as your effect arrays become more sophisticated.

Upvotes: 1

Related Questions