Be symmetric while writing methods

When working with class or module sometimes you would need equal and opposite operations. The methods should be symmetric. Please make sure they are not added causally that would add non symmetric verbs.

Not symmetric

  • turnOn()/disable()
  • openConnection()/shutConnection()
  • increaseVolume()/turndownVolume()
  • push/remove

If you are adding symmetric methods, then make sure they feel symmetric one.

Symmetric

  • turnOn()/turnOff()
  • openConnection()/closeConnection()
  • readFile()/writeFile()
  • increaseVolume()/decreaseVolume()
  • activateAlarm()/deactivateAlarm()
  • push()/pop()


Leave a Reply

I’m Datta

Welcome to BeingCraftsman — where software architecture is treated as a long-term responsibility. I’m a Software Architect and Cloud Lead based in Pune, India, with over a decade of experience designing scalable systems, guiding teams, and making practical engineering decisions. This space is about clarity in architecture, reliability in systems, and leadership that helps teams build software that lasts.

Let’s connect

Linkedin

Discover more from Being Software Craftsman (DFTBA)

Subscribe now to keep reading and get access to the full archive.

Continue reading