News Feed
Sections




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

Typical Programmer Blog:
Doing it wrong getters and setters
June 16, 2008 @ 11:19:17

According to this new post on the Typical Programmer blog, using getters and setters in your scripts only adds in a bit of unnecessary coupling and complexity to your scripts that you just don't need.

Today most of the popular programming languages support objects, limiting scope, modularity, passing by value, and sophisticated built-in types. There should be no reason to deliberately expose an object's data to the rest of the code because the language can enforce encapsulation and data hiding.

While not specific to PHP, the post does recommend against them because of one simple reason common to all languages that make them possible - they "break the encapsulation OOP offers". For them, they're like a cheat to get around bad coding practices and are not needed to make a successful application work.

0 comments voice your opinion now!
getter setter break object oriented encapsulation scope bad


blog comments powered by Disqus

Similar Posts

PHPBuilder.com: Preventing spam when using PHP\'s mail function

Kevin Schroeder's Blog: ZF2 Dependency Injection - Multiple Object Instances

Richard Lord's Blog: PHP 5.2 - Nesting level too deep - recursive dependency?

Stefan Mischook's Blog: OOP in PHP: New PHP Article in Web Designer Magazine (Nov 2006)

Stubbles Blog: My wishlist for PHP 6, pt1: The 'object' type hint


Community Events





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


series community interview unittest testing introduction refactor developer framework install release language podcast list symfony2 threedevsandamaybe code api opinion laravel

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