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

Andrew Podner:
Intro to PHP Comments and Docblocks
January 28, 2013 @ 09:21:58

If you've ever looked at your code an wondered about its commenting, if there was a kind of "best practice" to follow when it comes to its structure, you should read this article from Andrew Podner about docblocks.

The subject is how to properly document code with PHP comments and docblocks. This one took a while for me to really just accept as a part of the development process. To me now, the comments are now just as much a part of the application as the code is. I believe it is that important. With IDE's today, there really is no reason not to have good documentation in your source code.

He talks some about his own reluctance at first to use comments and how it helped him remember what his thought process was behind parts of this code. He includes an example of a typical docblock structure, showing the general description, parameters and a "return" value. He also includes something interesting in the topic of documentation - good variable names. There's links included to two tools that can take these standardized comments from your code and build HTML documentation from it - phpDocumentor and ApiGen.

You can find out more about the PHP docblock standards from this site.

0 comments voice your opinion now!
comments docblocks introduction phpdocumentor


Vinícius Krolow:
Some tips to improve your codes readability
January 25, 2013 @ 09:53:55

In this new post to his site Vinícius Krolow shares some tips he thinks will help to make your PHP code more readable in the long run.

What about code readability, from my point of view is one of the most important thing in the code. Who writes code that is easy to read, writes good code. Probably reading code is where you spent most part of your time, and not only your code, probably code of your team mates, or maybe code from the open source community, so write code that is simple and is easy to understand it's really important.

His tips (seven of them) are:

  • Comment before write your code (DocBlock)
  • Return frequently, Return early
  • Break, Continue
  • Code Standard / Name conventions
  • Throw Exception
  • Comment often, but not write stupid comments
  • Methods can be always smaller than they are

It's a little difficult to read as the English isn't the speaker's native tongue, but it gets the point across. He also recommends reading this if you'd like more information about writing better OOP code that's easier to read.

0 comments voice your opinion now!
code readability recommendations structure comments conventions


Jake Bell:
PHP Annotations Are a Horrible Idea
October 18, 2012 @ 09:45:56

In his latest post Jake Bell talks about why he thinks annotations in PHP are a bad idea (not the concept of them, but how developers are currently using them. He's in favor of officil support though).

Both the Symfony 2 and Doctrine 2 libraries and components make liberal use of what have come to be called annotations - special code comments, usually prefixed with an @ that are actually interpreted by the application and affect its functionality. [...] This trend needs to die.

He points out that the use of code comments like this isn't a good practice and applications should never have to rely on them for functionality. He mentions issues with syntax/language functionality (can't use "php -l" on them, can't var_dump an annotation) and that it makes it more difficult to read and interpret the code. He includes an example from Ruby of an alternative and a possible solution in PHP involving a static "mapping" variable.

0 comments voice your opinion now!
annotations code comments opinion doctrine symfony


Matt Frost:
Using Comments
October 16, 2012 @ 09:27:43

Matt Frost has posted a few of this thoughts about effective code commenting and how it can help make your application easier to follow and maintain in the long run.

Code comments are strange things; they can be invaluable or they can make the code they're describing more confusing. They can be necessary, unnecessary, explanatory or muddled and some times they're neither; they just are. [...] Code comments have their place, don't get me wrong; but I don't usually come across good comments.

He talks some about the two cases for comments - when to use them (and do it effectively) and when not to use them (yes, there's a time for this too). He notes that, sometimes, if you feel like you need to comment excessively on your code, you might be doing it wrong - that there's a simpler, more understandable way.

The goal should always be to add value to a codebase, whether than be in the form of code, comments or documentation. Bad comments are just as bad as poorly written code and good comments can take poorly written code and make it more easily understandable.
0 comments voice your opinion now!
code comments opinion recommendation


Reddit.com:
Can We Revive php.net User Notes Or Kill It?
September 13, 2012 @ 12:56:44

In this discussion on Reddit, there's talk about the user comments feature on the PHP.net site and the value they provide to the language and community.

The question, however, has always been "how useful is this feature really and does it bring more harm than good?". It's not that easy to answer since there are so many notes submitted by a wide range of users and some will likely go unnoticed while others seem to get undue attention due to their positioning near the top of the user-notes section of a particularly trafficked page.

The poster proposes a few things that could help make them a bit more effective (and useful overall) including voting on the note contents, flagging potential issues and sorting the notes based on popularity/age. He's put together a proof of concept as seen here with some of the new features.

0 comments voice your opinion now!
phpnet website user comments notes features feedback


Programmers Community Blog:
20 controversial programming opinions
September 04, 2012 @ 10:14:44

On the Programmers Community Blog there's a post (with quite a bit of feedback) that lists twenty controversial opinions about programming and programmers in general that have been proposed over the years.

One of the very first ideas we had for this blog was to convert some of the wonderful gems of the early era of our site, the undisciplined period, to blog posts. Questions that were once enthusiastically received by the community, but no longer fit Programmer's scope.

The post has the top twenty answers to the "What's your most controversial programming opinion?" question as proposed on StackOverflow and includes things like:

  • Programmers who don't code in their spare time for fun will never become as good as those that do.
  • The only "best practice" you should be using all the time is "Use Your Brain".
  • Not all programmers are created equal.
  • If you only know one language, no matter how well you know it, you're not a great programmer.
  • Your job is to put yourself out of work.
  • Readability is the most important aspect of your code.

Check out the full post for the complete list...and for the 100+ comments that have been added to it by programmers with both agreeable and disagreeable opinions.

0 comments voice your opinion now!
controversial programming opinion list top20 comments


Antonin Januska:
How To Write Code Comments Well
August 20, 2012 @ 10:17:42

In this new post Antonin Januska shares some reminders about what good code comments should look like - what needs to go in and what needs to stay out (you comment all your code, right?)

Code organization is a huge thing, especially for developers (because they deal with code), and often times it's a philosophical debate as to how code should be documented, if spaces should be used instead of tabs, what kind of documentation should be used and so on. Yet, what no one brings up is the dire issue of COMMENTING. We can all agree that comments are essential (and sometimes used to build half-ass documentation on big systems) but what no one really mentions is the fact that people are crappy commenters.

There's two topics he touches on that (surprisingly) it's easy for developers to forget when writing their code - "be informative" and "use consistent formatting". A lot of the issues could be helped if developers made more use of DocBlock formatting which many IDEs already have support for.

0 comments voice your opinion now!
code comments opinion docblock formatting informative


Jeff Atwood's Blog:
The PHP Singularity
July 02, 2012 @ 11:22:46

In case you missed it (there's been a good bit of buzz about it in the PHP community lately) there's a recent post from Jeff Atwood about the PHP language and some of his thoughts on its usefulness, it's structure and some of this thoughts on the usual "PHP sucks" kinds of articles.

Remember the immediate visceral reaction you had to the double-clawed hammer? That's exactly the reaction most sane programmers have to their first encounter with the web programming language PHP. This has been going on for years.

He talks about the the anti-PHP rants that have been happening (over and over) for years, his thoughts on it being the "worst designed mainstream 'language'" out there...and how the discussion doesn't need to be around these points anymore. It needs to be about how to get programmers to use better tooling (whether or not PHP is the right tool for the job).

Of course, there's no shortage of comments on a post like this, so be sure to go through them and see the various reactions to Jeff's thoughts.

0 comments voice your opinion now!
opinion language quality tooling comments


Francois Zaninotto's Blog:
Introducing Code Usability
May 05, 2009 @ 13:48:19

Francois Zaninotto has a recent post looking at something every developer should consider when creating their applications - especially the libraries that might be used by other developers: code usability.

Usability guidelines can sometimes be of use in awkward places. I try to apply them to source code. [...] Of course, coding guidelines are there to make the code easy to read by everyone. But code usability goes somehow beyond. Let's see some of the differences.

He compares good versus bad code in a few different areas:

  • Bad Code Comments
  • Split Up Code
  • Cleanliness
  • New Conventions
  • Listen To User Feedback

Each item is described, some including code examples to help make them more clear. Be sure to check out the comments for more good suggestions.

0 comments voice your opinion now!
usability comments split clean convention user feedback


NETTUTS.com:
Asynchronous Comments with PHP, jQuery, and JSON
February 23, 2009 @ 12:52:35

The NETTUS.com site has a new tutorial posted today looking at the combination of PHP, jQuery and the JSON format for messages to create a "more web 2.0" version of the traditional comment form.

In this article, we're going to look at how we create a simple but effective means of capturing and displaying visitor comments using a blend of jQuery, PHP and JSON. In the public forum that is the blogosphere, the ability to capture and display visitor comments on your blogs can give you instant feedback and opinions from the people that matter most '" those that read your blog.

Their script (check out the demo here) acts as an interface between a MySQL database and the HTML front end. Both the display and submission of the comments are handled by Javascript with the submission being handled by the ajax method in jQuery.

You can also download the source here.

3 comments voice your opinion now!
tutorial jquery mysql asynchronous comments json database



Community Events





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


unittest opinion series list refactor community threedevsandamaybe language install code laravel release podcast testing interview experience introduction framework wordpress developer

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