Friday 05 April 2013 8:20:12 am

Thank you, Joe.

It looks like cyclomatic complexity should definitely have been a part of my article. I'll read more about this. happy.gif Emoticon

Thursday 04 April 2013 5:25:35 pm

Great points. Another good measure of function complexity is cyclomatic complexity. In other words, how many paths are there through this function, including returns, thrown exceptions, etc.? If you're trying to get proper test coverage, high cyclomatic complexity makes it difficult (8 paths through the code mean 8 tests are needed to hit everything), so it's better to write small functions that focus on more atomic tasks.

PHPMD is a nice complement to PHP_CodeSniffer, and can help identify some of the things discussed here. It's supported by PHPStorm for use on the desktop, and can be easy added to a build process as well.

Wednesday 03 April 2013 1:58:26 pm

Thanks, Gaetano.

Yes, I also keep writing too long functions in particular. But I'm working on fixing that. happy.gif Emoticon

I would say that an architecture should become more understandable with shorter functions, depending on how you implement them ofcourse. But I agree we should never follow such a list blindly, they are only ment as lose guidelines/warning signs. And keep in mind what I mentioned at the beginning of the post about different best practices conflicting with each other.

You must be logged in to post messages in this topic!