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:
DRY is about Knowledge
August 04, 2014 @ 10:51:50

In this new post to his site Mathias Verraes approaches the concept of the DRY principle (Don't Repeat Yourself) as being more about knowledge. He includes two "real world" examples where the business rules can change around you.

"Don't Repeat Yourself" was never about code. It's about knowledge. It's about cohesion. If two pieces of code represent the exact same knowledge, they will always change together. Having to change them both is risky: you might forget one of them. On the other hand, if two identical pieces of code represent different knowledge, they will change independently. De-duplicating them introduces risk, because changing the knowledge for one object, might accidentally change it for the other object.

In his examples, he shows how hard-coded rules (like "a product container can only contain 3 products") could just be around certain needs, not the entire range of requests. He covers some of the principles of Domain-Driven Design and how they apply here, pointing out that changing rules in one part of the application can have an effect on other parts depending on it.

0 comments voice your opinion now!
dry dontrepeatyourself principle knowledge domaindriven design business goal

Link: http://verraes.net/2014/08/dry-is-about-knowledge/

Jonas Hovgaard's Blog:
How I stopped writing awesome code
June 14, 2012 @ 11:55:21

In this recent post to his blog Jonas Hovgaard talks about how he "stopped writing awesome code" by dropping a few things from his usual development practices - like unit tests and interfaces.

If writing awesome code is using all the best practices I can find, writing interfaces, unit tests and using top notch IoC containers to control my repositories and services all over my application's different layers - Then I'm not writing awesome code at all! I've been that guy, the one writing the awesome code, but I stopped. I'm not awesome any more. Instead, I'm productive, I'm so damn productive!

He talks about how not writing unit tests (which "customers don't care about") gave him extra time to work on other code and how not using things like interfaces, ORMs and how he follows DRY, but only so far.

My personal result of doing all of this is productivity and better products. I can't tell if I did it all wrong, and that's why I'm writing better code now, but I truly believe that I'm not alone. In fact I think that most of us regular web developers, tend to do the same "mistakes" as I did.

The post has turned into flame bait and has pulled in lots of comments discussing his decisions and other sympathetic souls that feel the same way he does about some of the complexity of the "best practices" promoted in development today.

0 comments voice your opinion now!
opinion development practices bestpractice unittest interface orm dry


Phil Sturgeon's Blog:
CodeIgniter Base Classes Keeping it DRY
February 11, 2010 @ 09:46:51

In a new post to his blog Phil Sturgeon looks at creating sharable code for your controllers in a CodeIgniter application (DRY: Don't Repeat Yourself).

The idea is that most of your controllers share something in common with each other. For example: All admin controllers need to make sure a logged in user is present and that they are an administrator. A public controller may want to load a theme for your application and load default user data, navigation links or anything else frontend related.

The problem is solved by creating a base controller - in his example its one called MY_Controller that follows the CodeIgniter naming convention and allows you to easily make other controllers that extend it. You'll also need to make a small addition to your config.php file to get the base controllers working correctly and make them able to be found.

0 comments voice your opinion now!
codeigniter base class controller dry



Community Events





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


introduction version laravel symfony framework tool security library community series composer interview release voicesoftheelephpant artisanfiles conference list opinion podcast language

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