Subscribe to PHP Freaks RSS

Nikola Posa: Better naming convention

syndicated from www.phpdeveloper.org on January 7, 2019

In a new post to his site Nikola Posa takes a look at naming conventions in code and makes some recommendations based on his own work.

In the last couple of months, I spent a lot of time studying Proophessor Do demo project that showcases features of Prooph components, all with the aim of mastering CQRS/Event Sourcing concepts. Along the way, something else turned my attention away from the main topic - unconventional, but clean and concise naming convention for class and method names.

This was a true eye-opener for me, I immediately liked the idea and after adapting it a bit I started practicing it at work. Excited and full of enthusiasm, I shared my findings and opinions with the rest of the world.

He tweeted about his excitement but found that there was more to say and a blog post was the place to put it. So in this post he covers several "anti-patterns" to avoid in code naming conventions:

  • Anti-pattern 1: Prefixes/suffixes convention for Interfaces
  • Anti-pattern 2: Archetype suffix convention for domain classes
  • Anti-pattern 3: "get" prefix convention for property accessors

He finishes the post with some final thoughts and a "TL;DR" image showing a "right" and "wrong" way to structure your code.