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

SitePoint Web Blog:
Code Manifesto Words to Live By
July 28, 2014 @ 12:45:29

The SitePoint Web blog has posted an interesting article sharing something called The Code Manifesto. The "code" referenced here isn't so much related to the actual code developers write as it is the conduct they follow in their relationships with others (on a professional level).

The tech industry has a rather bad reputation. Stories of discrimination, disrespect, sexism and outright mistreatment aren't exactly hard to come by. [...] In an industry ostensibly aimed at helping everyone to reach their potential, it's clear that when it comes to issues of equality and respect, the tech world has a long way to go. Kayla Daniels is one person working to try to change this situation. A North Carolina PHP developer, Kayla is behind The Code Manifesto, a list of values she hopes can be a small step in the right direction.

Among the points made in the manifesto are things like:

  • Discrimination limits us.
  • We are our biggest assets. None of us were born masters of our trade.
  • Respect defines us. Treat others as you wish to be treated.
  • Reactions require grace.

The Manifesto was born out of the frustration felt by Kayla in her work in technology. The six points are designed to help with two main things: respect and equality and contributing to the community...all as equals.

0 comments voice your opinion now!
code manifesto values advice conduct technology

Link: http://www.sitepoint.com/code-manifesto/

Larry Garfield:
On empty return values
March 29, 2013 @ 09:15:59

Larry Garfield has posted some of his thoughts on return values and reminds you about consistent return types, regardless of the result.

Earlier today, I posted a brief tweet (isn't that redundant?) about return values in PHP (or really, any language). Originally it was about return values from functions (such an exciting topic, I know), but it ended up generating a fair bit of lively conversation, as well as a patch against Drupal 8. So lively, in fact, that I think it deserves more than 140 characters.

He proposes a new rule of thumb: "If your function returns a collection, its null value return must also be a collection." A more broad version of this might be: "make your return types consistent." It's all about predictability and the contracts you have between different parts of your code. If a user calls your method expecting to be able to loop over the results, they'll be disappointed with a "false". He talks some about using and throwing exceptions more effectively for error handling and answers several "but wait..." arguments for his return strategy.

0 comments voice your opinion now!
empty return values opinion contract exception expected


Giulio Pons' Blog:
PHP to get enum/set values from mysql field
January 21, 2010 @ 11:14:26

Giulio Pons has a quick post with a code snippet showing how to grab the possible values for an ENUM or SET field on a MySQL database.

This function returns an array with the elements allowed in a ENUM or SET mysql field. This can be usefull if you're making some automation and need to retrieve those values without writing them in your code.

The function uses the database's metadata to get the column information for a table and filter out the "enum" information from that. The column information includes the set of values possible and a few simple string handling functions make it easy to grab them. They could also be replaced by a regular expression or two to grab the same information more concisely.

1 comment voice your opinion now!
enum mysql allowed values


Jonathan Snook's Blog:
CakePHP Setting Default Values
June 28, 2006 @ 05:42:33

Jonathan Snook is back today with more information gleaned from his voyages into the world of the CakePHP framework, this time focusing on setting up default values in your script.

If you've got a user seeing a form for the first time, normally the fields are blank. But there are times where you want to prefill fields with data or preselect a certain option. Setting a default value turned out to be really straightforward.

He includes the code to make this "really straightforward" functionality happen. It's a simple seven line affair to make the value for the Project's name set to "Default Project Name". It uses the special "data" variable to push the value into, which, as he mentions later, is best set with a "$this->data" format as is in his example.

0 comments voice your opinion now!
cakephp framework set default values data controller cakephp framework set default values data controller



Community Events





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


threedevsandamaybe podcast code bugfix library interview list language wordpress api unittest laravel developer release application community introduction series configure install

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