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

DevShed:
PHP and the Law of Demeter
August 16, 2011 @ 10:20:26

On DevShed today there's a new tutorial looking at how to use dependency injection to help prevent you from breaking the "Law of Demeter" in your application's structure.

When [responsibilities aren't well defined for classes], it's a clear symptom of a common issue known as the "Law of Demeter" breakage. In case the name doesn't ring any bells, the "Law of Demeter" (http://en.wikipedia.org/wiki/Law_of_Demeter) - or the Principle of Least Knowledge - is a paradigm that allows to create loosely-coupled classes, based on a simple concept: each class should be designed to work properly using only the dependencies that it really needs.

He talks about how violation of this law (whether you knew you were or not) can lead to some bad coupling practices. He includes a few classes under a SampleApp that handles the interface between a database and the domain model. The violation of the law comes in when the database and service layers are introduced - a fetch the code does to get an adapter from the service locator rather than directly from the database functionality as it should.

There's code for everything included in the post

0 comments voice your opinion now!
lawofdemeter dependency injection tutorial


Pim Elshoff's Blog:
SOLID design
August 11, 2011 @ 12:15:01

In your development time, you might have heard of the SOLID development design principles that aim to keep you and your application well structured and on track. If you haven't had the time to learn much about them, you should consider this new post from Pim Elshoff that briefly covers each principle (with some code examples along the way).

Oh how we love acronyms. We've discussed a lot about writing a class, but we haven't talked about writing classes yet. How do you know if your solution is right? It is not enough to have a working program. SOLID is a set of principles that define severable measurable properties your architecture should have at least, in order to be dubbed right.

He goes through each of the principles (single responsibility principle, Liskov substitution principle, etc) and gives a summary statement, a definition and code illustrating it in use. The examples aren't all based on the same code as implementing all of these principles at once as been found to be difficult. He also includes another principle to keep in mind - the "Law of Demeter" dealing with calling scope of properties and methods.

0 comments voice your opinion now!
solid software development overview lawofdemeter introduction



Community Events





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


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

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