 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Patrick Allaert's Blog: Readable PHP code #2 - Make your API handle more!
by Chris Cornutt May 28, 2010 @ 08:41:22
In a new post today Patrick Allaert has continued his "Readable Code" series with some tips on how you can make your API handle more.
His suggestions include:
- Changing the handling to look for multiples by default
- Avoiding inner looping (repeated looping) and try for code reuse
- Transforming a scalar value into an array to make it easier to handle this way (by casting)
- and how to handle objects in the same array-handling kind of code
He also tosses in a little mention of performance, noting that a call with range in the argument to his array-handling method is faster than looping over the same range and calling the method each time.
voice your opinion now!
readable api handle array object scalar tip
NETTUTS.com: Top 15+ Best Practices for Writing Super Readable Code
by Chris Cornutt December 09, 2009 @ 07:50:51
On NETTUTS.com today Burak Guzel has written up some good tips on how to make your code much more readable (and easier to maintain in the future. Not all of them are directly PHP related, but they are general enough to be applied in other places in your development.
Code readability is a universal subject in the world of computer programming. It's one of the first things we learn as developers. Readable and maintainable code is something to be proud of in a finished product. We can share it with others, contribute to other projects, and reuse code from applications we wrote months or even years ago.
Tips included in the list cover topics like:
- comments & documentation
- code grouping
- avoiding deep nesting
- using consistent temporary names
- using object-oriented code versus procedural
- effective refactoring
voice your opinion now!
bestpractices readable code tutorial
Shawn Straton's Blog: Code Readability Part 2, Code Structure
by Chris Cornutt January 19, 2009 @ 12:59:41
Shawn Straton has posted the second part of his look at code readability today. This time the focus is on the structure of the code - file structure, code layout, etc.
I've had the pleasure of
maintaining a legacy application developed by people who were past
deadline the second they had their assignment handed to them in the
past and it can get really interesting rather quickly when you see
how sloppy you can get when you are in such a hurry. Here are some
guidelines I've given myself to ensure that the structure is correct
at the end of the day.
Some of his suggestions include:
- Breaking larger files apart into smaller, easier to maintain pieces
- Correctly naming functions/variables/etc
- Tabbing/spacing in to indent code blocks
- Input validation and error checking should always be included
voice your opinion now!
readable maintain structure naming convention
SocialGeek.be: Clean urls through readable slugs in PHP
by Chris Cornutt January 06, 2009 @ 14:28:16
On the SocialGeek blog there's a recent post that looks at making stubs for your URLs, making them easier to read and remember.
This is where the fun begins of course. How many times have you been confronted with someone sending you an indecipherable, thus untrustworthy link? Right, so we agree that for a user, it is important to have a clean URL that is readable and includes the title of the page or (at least) some description related to the content. Slug time!
They explain what slugs are (and how they're useful for users) as well as how to convert a title into a "slugged" string by replacing anything that's not an A-Z or 0-9 character to remove the less URL friendly characters.
voice your opinion now!
clean url readable slug tutorial regular expression
PHP in Action: More beautiful code
by Chris Cornutt November 10, 2008 @ 10:25:34
Continuing on from a previous post, the PHP in Action blog takes another look at their suggestions on "beautiful code" with some responses to the previous post.
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? [...] My main point is that it's close to plain English. Not everyone agrees that that's a good thing, but I argue that we're built (genetically wired, in fact) to understand natural languages, not program code.
He reasons that code should be easier to understand than just a bunch of random functions and parameters jumbled together. He thinks that it should read more like a human could understand rather than just the machine. With function names like "assertThat" and "hasSelect", it does make it easier to follow.
voice your opinion now!
beautiful assertthat hasselect withname hasvalues readable
Patrick Allaert's Blog: Readable PHP code #1 - Return ASAP
by Chris Cornutt October 14, 2008 @ 11:14:42
Patrick Allaert has made this recent post to his blog looking at something that a large group of PHP developers seem to forget about - readable PHP code. Specifically, he mentions the "return as soon as possible" mentality.
This is the first article of a series I will dedicate to tips to write PHP code that is easier to maintain, review, refactor,... These tips may be applied for other languages but are mainly focused on PHP. The first one could be entitled as "return as soon as possible.
He compares a code example - simplifying multiple if/elses, replacing the need for multiple nested evaluations that make the code harder to read. Check out the before and after to see how it helps the flow.
voice your opinion now!
readable return asap refactor ifelse nested
David Otton's Blog: Neat PHP tricks Casting Arrays to Objects
by Chris Cornutt August 14, 2008 @ 13:38:10
David Otton has a handy little tip if you're looking for a cleaner way to deal with array data - casting it to an object.
Array notation is fine, but it can look a bit clunky when you're working with complex structures. [...] Casting the array to an object allows us to use object notation (->) and makes the code more readable.
He includes examples of the casting, showing the difference between the array and object notations including a method for creating an object based on a simple array that has basic properties built in. This sort of transformation can be useful if you want consistency through out the application - just passing objects with their properties rather than arrays.
voice your opinion now!
array object casting trick notation readable
Nick Halstead's Blog: Three New Programming Tips
by Chris Cornutt December 05, 2007 @ 07:53:00
Nick Halstead has posted a few more of his programming tips in the series he's running - three more to be exact dealing with readable code, aggregation, and code structure tips.
- Programming Tips #3 "Divide, Indent, Comment and Name": "We all started programming at some point in our life, some of us on our own, some under guidance of teachers, parents, but even now there are few tips, that should be known by everyone."
- Programming Tips #4 "Aggregation over Inheritance": "My favourite rule is to favour aggregation over inheritance."
- Programming Tips #5 "Readable Code": "It's easier to debug, and later to maintain. Make it readable by using descriptive identifiers, properly tabbing the code, and breaking down the application into functional and reusable pieces."
You can check out the full list of his programming tips in this list.
voice your opinion now!
progamming tips readable aggregation inheritance comment divide progamming tips readable aggregation inheritance comment divide
|
Community Events
Don't see your event here? Let us know!
|