Zen of PHP better than the Right Way

The  majority of well known PHP programmers and  open source projects seek to make their PHP scripts become the only tool needed to create web applications. They group together a  following  for tools like Composer and  push usages of rules like PSR . They call it "PHP the Right Way". Honestly it would be hard to come up with a more misleading name.


In  promoting  "PHP the Right Way" a system which obviously forwards their own agendas. Most of these clustered communities forget about beginners and the reasons that PHP is the most popular web programming language. They lead beginners through a labyrinth of tools over a cliff  to a sea of unneccesary complications.  Beginners and experts alike need a simple set of principles to abide. Principles that make it easier for them not more complicated and harder to follow through.


As an alternative I offer a list  from Tim Peters a succinct set of  guiding principles for Python's design into 20 aphorisms, only 19 of which have been written down. They are some of the best general guidelines I have seen to date.

I have  modified them to suit PHP as something programmers of all levels should seek to acheive as they work to build their own web cms, applications and frameworks. 

The Zen of PHP

  • Beautiful is better than ugly. 
  • Ugly is better than nothing because nothing is horrific
  • Explicit is better than implicit.
  • Simple is better than complex.
  • Complex is better than complicated.
  • Flat is better than nested.
  • Sparse is better than dense.
  • Readability counts.
  • Special cases aren't special enough to break the rules.
  • Although practicality beats purity.
  •  Errors should never pass silently. 
  • Unless explicitly silenced.
  •  In the face of ambiguity, refuse the temptation to guess.
  •  There is one --obvious way to do it. 
  • There are always alternatives to the obvious because it's PHP. 
  • Now is better than never. 
  • Although never is often better than RIGHT now. 
  • If the implementation is hard to explain, it's a bad idea. 
  • If the implementation is easy to explain, it may be a good idea. 
  • MVC is one of the better ideas -- let's do it more often!

Use the Principles of "the Zen of PHP" for better coding before trying  it "the right way". I  suggest that you always keep them  in mind as you  add items from the right ways list on your way to learning.

Comments

  1. I'm agree with you.
    The bad news is that usually only after you directly experienced the "bad way" you can appreciate the "right way".
    I still see that, a lot of people loves the labyrinths.

    ReplyDelete
    Replies
    1. Yes, I'll talk about that later in a "love at first sight" and "stockholms syndrome" post.

      Delete

Post a Comment