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

Anthony Ferrara:
Beyond Clean Code
November 26, 2013 @ 13:12:41

Anthony Ferrara has posted the latest in his "Beyond" series today with this new post - "Beyond Clean Code". In it he looks at the idea of "clean code" and proposed a different way to think about its creation.

This is the fourth post in my "Beyond" series. The previous three posts focused on re-imagining OOP and questioning some of the core beliefs that we have come to take for granted. This one is going to be slightly different, in that I want to talk about another angle of writing code: the process itself. We always talk about how code should be clean, but how do you write clean code?

He starts with an overview of what it means for code to be "clean" with some of the common criteria including clear code flow, short routines and using libraries for complex tasks. He proposes that a change in perspective is needed away from "pretty code" and more towards code that contributes to the business value of the product. Following through on this pattern of thought, he proposes a more effective method than focusing on just clean code - DIRTI (Develop, Isolate, Refactor, Test and Integrate).

The real beauty of this approach is that it assumes that you don't know your abstractions before you start. This will help you understand the problem (and the solution) as you write it. [...] Initially, when you don't fully understand the solution, you will develop, isolate and refactor over and over until you fully understand the solution that you're building. Once that understanding solidifies, you're going to tend to spend more time in the later parts (Refactor Test and Integrate).
0 comments voice your opinion now!
clean code dirti structure dependencies perspective

Link: http://blog.ircmaxell.com/2013/11/beyond-clean-code.html

Bob Majdak:
Extending an Iterator to use an Iterator to make your code a little cleaner
March 12, 2013 @ 09:25:04

In this new post to his site Bob Majdak talks about extending iterators to help make it easier to customize it for your needs.

One of the nice things about iterators is the ability to shove them into other iterators, allowing you to wrap their functionality in other functionality to return a more precise result set. Take for example the idea that we want to read a directory to list only the images inside of it. There are two main ways to do this, via readdir functions and via FilesystemIterator objects. Going the FilesystemIterator route, one common way seems to be extend another class called FilterIterator which allows you to customize a filter based on you overwriting a method called accept().

He shows not only overriding the "accept" method, but also the constructor to make using this new iterator a much simpler (and cleaner) call. You can find out more about the FilesystemIterator (and others) over in the Iterators section of the PHP manual.

0 comments voice your opinion now!
extend iterator clean code accept constructor filesystemiterator


Adam Culp:
Clean Development Series Part 4, Rewrite dilemma
November 12, 2012 @ 10:28:30

Adam Culp has published the fourth part of his "Clean Code" series to his site today (see more about parts 1-3 here) with a look at the "Rewrite Dilema" - whether it's more productive to just rewrite or to try to refactor.

Unfortunately the first reaction to a poorly written application is usually a resounding "rewrite". Developers feel like a weight is lifted from their shoulders, as the manager hears a distant "cha-ching" sounds of money slipping away. [...] In the managers mind a rewrite means it must all be duplicated, and that's not far from the truth when we consider the salaries of an entire development team for the time it will take to rewrite the entire application.

Adam talks about some of his experience in the past with challenging applications and a typical scenario where one group in the company splits off and creates the new version while another maintains the old. He suggests, however, that refactoring may be a more viable option. While it might not seem easier to handle overall, the end results could lead to a more stable system and could take less time than starting from scratch.

0 comments voice your opinion now!
clean code tutorial series rewrite dilema refactor


Oscar Merida:
Smelly PHP code
November 09, 2012 @ 09:21:57

Oscar Merida has written up a sort of continuation to this series from Adam Culp about clean code, one that shares more tips on knowing when to refctor.

Adam Culp posted the 3rd article in his Clean Development Series this week, Dirty Code (how to spot/smell it). When you read it, you should keep in mind that he is pointing out practices which correlate with poorly written code not prescribing a list of things to avoid. It's a good list of things to look for and engendered quite a discussion in our internal Musketeers IRC.

His suggestions include things like "Comments are valuable", "Using switch statements" and a few other smaller ones involving error suppression, globals and prepared statements in database usage.

0 comments voice your opinion now!
smell code refactor tips clean development


Adam Culp:
Clean Development Series (Parts 1, 2 & 3)
November 06, 2012 @ 11:26:26

Adam Culp has posted a three part series to his blog with some guidance about how to create "clean code" in your application development:

Whether we're experienced developers or newcomers, we've all seen code that could/should have been done better. Many times it's even code we ourselves wrote and revisited later for one reason or another. I, for one, have seen my share of code written by a "past me" and wondered what on earth I was thinking when I wrote that. Of course there has also been times when I was hired to fix another developers code, and it can be scary also.

There's three posts in the series:

0 comments voice your opinion now!
clean development cause effect smell tutorial series


PHPMaster.com:
Laravel Is It Really Clean and Classy?
August 08, 2012 @ 12:34:18

PHPMaster.com has a new tutorial in their series about the Laravel framework posted today asking if the framework is really "clean and classy" as its documentation describes.

"Laravel is a clean and classy framework for PHP web development. Freeing you from spaghetti code, Laravel helps you create wonderful applications using simple, expressive syntax. Development should be a creative experience that you enjoy, not something that is painful. Enjoy the fresh air." That's the text which can be found on the Laravel homepage and, if we'd believe it, wouldn't it be wonderful? Let's test this claim by building a simple TODO application and see how much effort we have to put into it.

The article is pretty high-level and only touches on some of the key features like migrations (to create the database) and making the controller, model and view for the basic TODO app.

0 comments voice your opinion now!
laravel framework beginner clean tutorial


Ibuildings techPortal:
DPC Radio Clean PHP
March 22, 2012 @ 14:37:05

On the Ibuildings techPortal today they've published the latest in their DPC Radio podcast series, sessions as recorded at the 2011 edition of the Dutch PHP Conference. In this latest episode Sebastian Bergmann talks about "Clean PHP".

Even bad code can function. But if code isn't clean, it can bring a development organization to its knees. Every year, countless hours and significant resources are lost because of poorly written code. But it doesn't have to be that way. In this session you will learn how you can offset your technical debt with clean code that is readable and testable as well as reusable.

You can listen to this latest session either using the in-page player or by downloading the mp3 directly. The slides (for a similar version of the presentation) can be found on Slideshare.

0 comments voice your opinion now!
dpcradio clean code sebastianbergmann dpc11 session


Rafael Dohms' Blog:
Book Review The Art of Readable Code
February 29, 2012 @ 10:41:12

Rafael Dohms has posted a new review of a book that focuses on helping you create better, more readable code - "The Art of Readable Code" (Dustin Boswell, Trevor Foucher, O'Reilly). This is isn't about "pretty code" as much as it is manageable, easy to follow structures and logic flows.

"The Art of Readable Code" was written by Dustin Bowell and Trevor Foucher and basically focuses on concepts and suggestions to make you code not just readable, but comprehendible by other developers, or as the author's suggest, yourself in six months. Code readability is a topic that I truly believe the PHP community does not focus enough on and i really wanted a look at this book to see what kind of ideas it had and what I could do my best to bring to the attention of other developers.

The book is language-agnostic and provides ideas that developers should keep in mind when doing their development - clear variable names, making comments that make sense, refactoring tips and hints for implementing your ideas in code. He recommends the book to any developer (in any language) to help them make code that will stand the test of time and be easier to manage/understand in the future.

0 comments voice your opinion now!
code readable book review oreilly clean comment naming refactor testing


DZone.com:
Writing clean code in PHP 5.4
February 23, 2012 @ 12:08:18

With the first stable release of PHP 5.4 not too far off, it's important to understand the new features it offers and how to use them effectively. In this new post to DZone.com Giorgio Sironi shows how to "write clean code" with these new features, including a few snippets of code to illustrate.

After seven release candidates, it's clear PHP 5.4 is coming: as always the improvements from the previous minor version are many. [...] Let's look at the new features and score them on two metrics: usefulness, and potential for abuse. I'll try to avoid discussing non-language related matters.

He starts by pointing out some of the "gotchas" that can happen with traits (like errors thrown when more than one method is named the same and that they are a separate hierarchy), the short syntax and dereferencing support for arrays, closure binding, upload progress and more. For each of them he gives two measurements - the usefulness of the feature and the potential for abuse.

0 comments voice your opinion now!
clean code upcoming features usefulness abuse


Perforce Software:
Seven Pillars of Pretty Code
April 23, 2010 @ 12:08:43

As linked to by Paul Jones there's an interesting whitepaper that's been published by Perforce Software about what they see as the Seven Pillars of Pretty Code.

The essence of pretty code is that one can infer much about the code's structure from a glance, without completely reading it. I call this "visual parsing": discerning the flow and relative importance of code from its shape. Engineering such code requires a certain amount of artifice to transform otherwise working code into working, readable code, making the extra step to leave visual cues for the user, not the compiler.

The goal of these recommendations isn't to help you structure your code better or to optimize it for the best performance. The goal is to make code that is easy to follow and simpler to read for both the experienced developers and those just coming in.

Their suggestions include making the code blend in, keeping the code "untangled", including plenty of comments and reducing clutter overall.

1 comment voice your opinion now!
suggestion clean code opinion



Community Events





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


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

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