PHP in Action

Category: PHP

How code comments deteriorate

There was a lot of disagreement on the value of code comments after my earlier post Comments considered harmful . Perhaps the most important objection that was raised was the idea that it's OK to improve the code, but it's even better to keep the comments in addition to the improved code....

How harmful is "harmful"?

Conflict is not a bad thing. That is, if it leads eventually towards clarity and understanding rather than confusion and misunderstanding. And it's almost always better to have a conflict openly than to sweep it under the rug. Fear of conflict is the second of the five ...

Comments considered harmful

There is too much old advice in PHP. A recent case comes from the PHP Advent calendar. Eli White is a strong believer in commenting code, including inline comments inside functions. Unfortunately, he's at least 10 years too late. This used to be good...

The one-line web framework

The core of your average web framework is a Front Controller. Front Controllers are commonly considered complex and esoteric. That's a myth. I sometimes brag that I can construct a Front Controller in 15 minutes. Actually, it's doesn't take quite that long. In PHP, a Front Controller can...

How to test everything

They say there's no free lunch, but at least there's free breakfast. Last week I attended a "breakfast seminar" with Robert C. Martin (Uncle Bob). There really was free food. Anyway, Uncle Bob held an extremely entertaining and useful introduction to the FitNesse testing tool. He...

Zend_Test

I admit I don't follow Zend Framework very closely, since I haven't been using it for any serious work. But I did write a piece about testing a Zend Framework action controller with View Helpers . This might need updating, since the testing capabilities of the Zend Framework have...

More beautiful code

I got some interesting comments to my previous post on "beautiful code" . Some were pretty strong disagreements. So am I wrong? Did I get carried away? Did my critical faculty go on vacation somewhere nice and sunny? I admit that sometimes I deliberately look at the positive and...

Beautiful code

Max Horwath has published his slides on Making Selenium Test Writing easier using a DSL online from IPC 2008 . Let me quote the whole short description: Implementing automated tests by using Seleniums API methods has several drawbacks. Selenium is great for what...

Refactoring is design

Refactoring is by definition a design actitivity, since the definition of refactoring is "improving the design of existing code". But is this generally and fully recognized? After attending my friendly local agile conference ( Smidig2008 —sorry, it's in Norwegian), I'm getting more of...

Get links with XPath

There's a tutorial that appeared recently called Get Links With DOM . Planet PHP lists the author as Kevin Waterson, although his name is not mentioned on the page itself. Anyway, he claims: Perhaps the biggest mistake people make when trying to get URLs or link text from a web page...

Many test methods versus custom assertions

This is something I posted to the Sitepoint PHP Application Design Forum with a little bit of added background. The background is the idea that unit test methods, for the sake of readability, should test only one single behavior. This may mean several tests for one method under test,...

Type hints are more useful for scalars than objects

Max Horvath has implemented a library for type hinting scalars. That interests me, since I find that type hinting for objects has limited usefulness. I tried using type hints extensively from an early beta version of PHP 5. I mostly gave up on them for...

Performance optimism

I like weird ideas. There should be more of them. And the idea that we need to make programs efficient to save energy is weird enough to interest me. David Peterson tells his version of Rasmus Lerdorfs views on it : He continues on by stating that PHP developers really need...

Testing a Zend Framework action controller with View Helpers

I came across a Zend Framework (ZF) example I wanted to refactor. You really have to have unit test coverage to refactor effectively, and since there were no tests, I started trying to find out how to test it. There didn't seem to be a wealth of information available on the web, so I've ...

Flash messages

Redirects are useful in web programming, especially when implementing the Post-Redrect-Get pattern . But there is a problem with redirects: there is no simple way to send a message to the user across the redirect. When processing a GET request, you can display whatever messages you want. The...
1 2  Next»
 
Accessible and Valid XHTML 1.0 Strict and CSS
Powered by LifeType - Design by BalearWeb