Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Nikola Posa:
Better naming convention
Jan 07, 2019 @ 09:17:19

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.

tagged: naiming convention opinion structure code

Link: https://blog.nikolaposa.in.rs/2019/01/06/better-naming-convention/


Trending Topics: