DEV Community

Discussion on: What is your advice on writing "clean code" ?

Collapse
 
jeremyf profile image
Jeremy Friesen

When I create a class in Ruby, if I'm at my best, I always try to start with the following comment before I write any code:

The purpose of this class is...

I have a high degree of confidence that that intention will persist regardless of the implementation details.

This then follows with methods, but by the time I've written out the class purpose, the methods are (in the moment) somewhat self-evident. (I still go back and document the methods)