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:
Foundations Of OO Design
October 30, 2014 @ 09:36:24

In his newest post Anthony Ferrara looks at some of the things he calls the foundations of object-oriented design, as set of three things (and principles) to keep in mind when working on OOP applications.

It's quite easy to mix up terminology and talk about making "easy" systems and "simple" ones. But in reality, they are completely different measures, and how we design and architect systems will depend strongly on our goals. By differentiating Simple from Easy, Complex from Hard, we can start to talk about the tradeoffs that designs can give us. And we can then start making better designs.

He starts with the "simple vs easy" concept and how sometimes making the two meet can be difficult. He includes an example of interdependent interfaces and how they add complexity (and, in turn, make them less easy to use). He also talks about accidental versus essential complexity and how, sometimes, "accidental" isn't always a bad thing. Finally, he wraps it up with a few principles to remember in your development including recommendations to reduce (accidental) complexity and keeping the target developers in mind, making it easiest for them to use.

0 comments voice your opinion now!
foundation oop objectoriented design complex simple developer opinion

Link: http://blog.ircmaxell.com/2014/10/foundations-of-oo-design.html

NetTuts.com:
Refactoring Legacy Code Part 6 - Attacking Complex Methods
June 27, 2014 @ 13:17:37

The NetTuts.com site has posted the sixth part in their "Refactoring Legacy Code" series, this time with a focus on the more complex methods. They look at simplifying their contents and testing their various parts (better code coverage). The post is based completely on the contents of the previous five in the series, so if you haven't read up on those do that before starting.

In our previous five lessons we invested quite a lot of time in understanding our legacy system, in writing tests for whatever testable piece of code we could find. We reached a point to where we have quite a few tested methods but we still avoided the complex, hard to understand logic. It's now time for some serious coding.

The start with one of the more complex methods (roll) and work through it line-by-line to figure out what it's being given, how it's handling the data and what kinds of things it might return or modify inside. The break it down into to "parts" and figure out the right tests to write for each. With the method fully tested, they then start in on the refactor, teasing out various parts of the method into other methods and property changes. There's also a section at the end talking about pair programming and how it relates to good testing practices.

0 comments voice your opinion now!
refactor series tutorial part6 complex method unittest phpunit

Link: http://code.tutsplus.com/tutorials/refactoring-legacy-code-part-6-attacking-complex-methods--cms-21522

NetTuts.com:
Refactoring Legacy Code Part 3 - Complex Conditionals
May 05, 2014 @ 10:43:20

The NetTuts.com site has posted the third part of their series sharing some tips for refactoring the code in a legacy application. In part one they looked at the "Golden Master" and in part two about moving away from magic strings and constants.

Old code. Ugly code. Complicated code. Spaghetti code. Gibberish nonsense. In two words, Legacy Code. This is a series that will help you work and deal with it. I like to think about code just as I think about prose. Long, nested, composed sentences with exotic words are hard to understand. From time to time you need one, but most of the time, you can just use plain simple words in short sentences. This is very true for source code also.

Continuing on with this "prose" theme, he gives an example of simplification and reducing the amount of validation needed before completing the task. He compares this to complex conditionals and shares something called the "extract method" to help simplify them. He also looks at directory and file structure and suggests cleanup there as well. The tutorial finishes with a few other suggestions, things like cleaning up "runner functions" reworking negative conditionals.

0 comments voice your opinion now!
refactor legacy code series part3 conditionals complex

Link: http://code.tutsplus.com/tutorials/refactoring-legacy-code-part-3-complex-conditionals-long-methods--cms-20944

Rob Allen's' Blog:
A Zend Framwork compound form element for dates
March 21, 2011 @ 12:23:08

In a new post to his blog today Rob Allen shows you how to create compound form element handling in a Zend Framework application thanks to some custom work with Zend_Form and Zend_View extensions.

A little bit of googling found this site http://codecaine.co.za/posts/compound-elements-with-zend-form which has not unfortunately disappeared, so the code in this article owes a lot of the author of that article. It turns out to be remarkably simple to create a single Zend Form element that is rendered as multiple form elements. We create an element object and a view helper object and we're done.

He shows how to create a custom form date helper that extends the base XHTML to create the isValid/getValue methods for handling the complex date input. There's also the code for the view that creates the custom date input and repopulates the content if there's a need.

0 comments voice your opinion now!
zendframework complex date select zendform zendview


Paul Jones' Blog:
How Complex Systems Fail
May 13, 2010 @ 14:27:53

Paul Jones points out a paper from Richard Cook, How Complex Systems Fail [pdf], and mentions how a lot of the points can directly correlate with programming in general.

The paper How Complex Systems Fail by Richard Cook should be required reading for anyone in programming or operations. Hell, it should be required reading for most everyone. You should read the whole paper (it's very short at under five pages).

He lists out some of the key points made in the paper including that complex systems can both be helped and harmed by the inclusion of humans in the mix and that, when things change, it opens the door for a whole new kind of failure.

0 comments voice your opinion now!
complex system fail opinion


Developer.com:
Creating Complex, Secure Web Forms with PHP and HTML_QuickForm2
May 11, 2010 @ 11:05:51

New on Developer.com today there's a tutorial looking at creating complex, secure forms with the HTML_QuicForm2 PEAR package. This package will give you more control over the form, the validation it performs and the overall security it automatically handles.

For PHP developers, HTML_QuickForm2 PEAR package provides a programmatic interface for rigorously defining form controls, value requirements, and user notifications. Using HTML_QuickForm2 helps these developers create usable and secure Web forms without sacrificing visual appeal. This solution takes much of the guesswork out of secure forms development, allowing you to create robust forms with minimal time investment. In this article, I show you how to take advantage of HTML_QuickForm2 to streamline the creation and validation of complex HTML forms.

They help you get the package installed (if all goes well, it's just a call with the "pear" command-line tool) and how to create a simple form for accepting a user's name and email address. They modify it a bit to create another example - one that takes in a preferred format for the email that would be sent over to the user. They also work in the concept of required fields and how to show the error messages that might result from those being empty.

0 comments voice your opinion now!
complex htmlquickform2 pear tutorial form


Jim Plush's Blog:
Rethinking the Zend Models
July 15, 2009 @ 12:35:16

Jim Plush has taken a look at his models in the Zend Framework and has rethought them a bit to work with a bit more complex process than the usual simple sort of Zend Framework application.

The current active record/table gateway patterns just aren't going to cut it for the complex business logic that's approaching. I'm starting to lean towards the domain model approach which would increase the initial complexity of the design but allow for the flexibility for future changes and features. The issue is with where to put your business logic?

He diagrams out his potential solution and includes two bits of code showing how it would work in practice. He's soliciting opinions as to the validity of this approach too, wondering if its the best way to go for more complex application structures requiring these sorts of business requirements.

0 comments voice your opinion now!
logic business complex model zendframework


Jani Hartikainen's Blog:
Using a builder to construct complex classes
April 02, 2009 @ 12:58:28

If your code is getting more and more complex all the time and you find yourself creating a similar group of objects over and over, you might check out Jani Hartikainen's latest advice and create a "builder" around them.

Sometimes if you have a complex class, which needs to be set up in a specific way: Perhaps it takes a lot of constructor arguments, or often requires calling some setters. [...] Sometimes if you have a complex class, which needs to be set up in a specific way: Perhaps it takes a lot of constructor arguments, or often requires calling some setters.

His example is a "message builder" wrapper that lets you specify the receiver, sender and message and inject them into a to() method call (with a fluent interface). He shows how to make sure that the object you need (the message object) is always complete.

0 comments voice your opinion now!
fluent interface builder class complex tutorial


PHPImpact Blog:
PHP Spaghetti alla Bolognese
January 09, 2009 @ 11:17:05

On the PHP::Impact blog Federico Cargnelutti has expressed his opinion about the inclusion of the "GOTO" statement into future builds of PHP:

The GOTO statement has been the target of much continued criticism and debate, with the primary negative claim being that use of GOTO results in unreadable and generally unmaintainable spaghetti code. [...] Well, great news. The GOTO statement has just been added to the PHP language and it's now in the hands of experienced programmers and inexperienced Web developers.

He references a quote from Jeff Moore stating his dissatisfaction with the inclusion of it too. Comments on the post, however, correct Federico on how the "GOTO" in PHP will work - not quite as global as he'd thought.

0 comments voice your opinion now!
spaghetti goto opinion complex


Jani Hartikainen's Blog:
Complex custom elements in Zend_Form
October 23, 2008 @ 12:09:55

In this new post Jani Hartikainen shows a quick and easy method for creating a custom form element in your Zend Framework application. His example is a custom time element.

The alternatives would be creating custom view helpers to output the custom form elements, and using the viewscript decorator. Creating a custom view helper would also require a custom form element class, and it would be a bit tricky. [...] I think the viewscript approach is the most flexible and simplest to implement, so I chose to go with that.

His example defines a time field made up of three drop down lists, one each for hours, minutes and seconds. Included is the code to make the element (including a regular expression for validation) and the view script to display it.

0 comments voice your opinion now!
zendform zendframework complex custom element time tutorial



Community Events





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


deployment introduction opinion api framework tips podcast bugfix release package interview language list series laravel voicesoftheelephpant symfony library install community

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