Required attributes in Smalltalk

Viewed 305

I am writing classes in Pharo Smalltalk, but I assume the question is valid for other Smalltalk implementations.

I know a way to enforce instances with specific attributes is to provide a class method for instance creation, and then suggesting to use the class creation method. But any user know that new or basicNew can be used anytime.

I thought about invalidating new and basicNew raising an exception, but this seems to be too drastic measure, giving that sometimes I could require to create instances to debug for example.

Is there another library or mechanism to enforce those specific attributes to be completed?

2 Answers
Related