News Feed
Sections




News Archive
feed this:

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

Mathias Verraes:
Verbs in Class Names
October 07, 2013 @ 11:40:07

Mathias Verraes has an interesting post to his site suggesting that using verbs in class names can make for easier to understand and easier to read code - more "natural language."

When you first learned Object Oriented Programming, somebody probably told you that objects map to things. And that still holds true most of the time. And maybe somebody explained it using the simple heuristic to "look for the nouns", which can indeed be a great discovery technique. But then somebody probably phrased that as "class names should not have verbs in them". To me, that rule is severely limiting the possibilities for your models. So here are some cases where I prefer to use verbs.

He suggests that class names, in some cases, could be used as "messages" to the developers using them in the OOP. He includes some suggestions (based on the suggestion of nouns from another post) that use verb-names to convey what they're doing. He also talks about three specific cases - specifications, exceptions and interfaces - and includes samples of each using this idea of verb-based class names.

0 comments voice your opinion now!
verb class naming noun alternative example

Link: http://verraes.net/2013/10/verbs-in-class-names/

Keith Casey's Blog:
Useful Naming Conventions
December 09, 2008 @ 15:31:15

In a new post to his blog Keith Casey shares a few tips on naming conventions that can help increase readability in your code and make maintenance simpler in the future.

In my regular web wanderings recently, I found a great post entitled "The 7 Worst Verbs Programmers Use In Function Calls" and couldn't help but be reminded of a system that I worked on a few years ago. The core function of the system was named - no kidding - "doStuff". Everything in the application led towards that, used it, and then did other things as a result.

He suggests a structure he uses - "verbAjectiveNounStructure". Starting with an action, moving to a description of the action, to the target of the action and finally an optional structure - how the returned data is formatted.

0 comments voice your opinion now!
useful naming convention verb adjective noun structure



Community Events





Don't see your event here?
Let us know!


community list voicesoftheelephpant interview introduction install api package bugfix symfony laravel language library tips opinion framework deployment series release podcast

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework