Practices yegor256.com

Builders and manipulators  ↦

Yego Bugayenko:

Here is a simple principle for naming methods in OOP, which I’m trying to follow in my code: it’s a verb if it manipulates, it’s a noun if it builds. That’s it. Nothing in between. Methods like saveFile() or getTitle() don’t fit and must be renamed and refactored. Moreover, methods that “manipulate” must always return void, for example print() or save(). Let me explain.

Naming objects well has been a career-long struggle for me. I just might give this a try…


Discussion

Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00