News Feed
Sections




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

Mathias Verraes:
Final Classes
May 13, 2014 @ 09:48:43

Mathias Verraes has posted some of his thoughts about using "final" in classes and what kind of impression it gives about your code.

I make all my classes final by default. I even configured the templates in my IDE prefix new classes with 'final'. I've often explained my reasoning to people. A blog post is in order! A guiding principle here is Clarity of Intent. [...] The reason we need clean code, is not for the compiler. It's to help our fellow developers, third parties, and even ourselves in six months time, understand the purpose and the design of our system.

He relates this concept of clean code and clarity back to the SOLID development principles, specifically the "Open/Closed Principle". This principle states that software should be open for extension but not for modification. It suggests that providing a stable, known API is a responsibility of the developer and using things like callbacks and listeners is a better way to extend. He gets into a bit more PHP-specific issues around using "final", including the difficulties that it can cause during testing.

0 comments voice your opinion now!
final class inheritance extension solid openclosed principle

Link: http://verraes.net/2014/05/final-classes-in-php/

blog comments powered by Disqus

Similar Posts

Eirik Hoem's Blog: Setting xsi:type for objects sent over SOAP (inheritance)

Nick Silvestro's Blog: Verification is a Wonderful Thing

Brandon Savage's Blog: Keeping Superglobals Out Of Classes

Paul Jones' Blog: Solar 0.27.0 and 0.27.1 Released

IBM developerWorks: What's new in PHP V5.2, Part 4: Using the new ZIP extension


Community Events





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


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

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