why you're a bad php programmer
DESCRIPTION
TRANSCRIPT
Why You’re a Bad PHP Programmer
Presented by: Aubrey
You Don’t Plan Before You Start Coding
“Before you write a single line of code, you should have a solid plan of attack.”
➔ Write an outline in comments first
➔ Plan out an entire application using
this..
➔ If there comes a feature that requires
a functionality tweak, just change the
comment
You Don’t Comment Anything
“Five seconds at a time will add up in a
big way.”
➔ The single worst problem with most
code is that it’s poorly commented or
not commented at all
Code without comment
Code with comment
You Sacrifice Clarity for Brevity
“Good examples of sacrificing clarity for brevity include unclear variable names and dropping the curly braces.”
➔ Example of sacrificing clarity for
brevity include short, unclear variable
names (such as $a) and dropping the
curly braces
You Sacrifice Clarity for Brevity
➔ Adding curly braces adds a few lines,
but it clarifies the statement
immensely
You Don’t Follow a Coding Standard
“Choose a standard and stick to it.”
➔ Choose a standard (e.g. PSR - 1, PSR - 2) and stick to it
➔ When it comes to programming, think of it like a spoken language. Grammar and
punctuation exist for a reason: so we can clearly understand each other when we
write things down
➔ Following a standard means people understand what you’re trying to say
You Duplicate Code
“You're doing it wrong.”
➔ Look at every single piece of your app as something that will need to change at
some point
➔ If you have to update more than one file, it’s time to re evaluate how you write code
Don’t Repeat Yourself (DRY) -- "Every piece of knowledge must have a single, unambiguous,
authoritative representation within a system."
You Don’t Follow a Development Pattern
“You should always have a structure when you code.”
➔ You should know how to classify components and where they should go
➔ By following a logical development pattern, many decisions become automatic, and
someone coming to your code doesn’t have to guess much when looking for a
certain functionality in your codebase
You are Too Clever for Your Own Good
“The simplest solution is usually the most appropriate”
➔ Resist the urge to force a complex solution into a space where a simple one is
sufficient
➔ Avoid overcomplicating things
➔ Don’t think your way is better just because it’s your way
You’re a Wang
“Avoid actively making your code hard to understand at all costs.”
You’re a Wang
“Avoid actively making your code hard to understand at all costs.”
Dude, What are you Talking About?
“If you stop learning, then the projects you work on are stuck in whatever time period you decided to settle.”
➔ You lack continued learning and forward progress
Technology isn’t changing because the community at a large is bored and we decide
to redecorate; most new technologies emerge to more efficiently and easily solve
existing problems.
You’re Trying to Do it All Yourself “Find out which of these programmers have a similar approach and let them fill you in
on the big news.”
➔ Take time to find out a programmer that has a similar approach and style
You’re Not Out of Your Comfort Zone
“I simply mean to suggest that you'll feel more fulfilled as a programmer and see your talents progress more and more if you choose to always be looking to the next level of programming.”
➔ Find new challenges within projects
➔ Try not to settle in and convince yourself you’ve learned everything you’re going to
learn
➔ Try out a new concept that you’re not quite comfortable with
You’re Not Sharing
“Always discuss your code with your fellow programmers.”
➔ Write a tutorial or release an open-source project
➔ Hangout on a community forum and offer help to the newcomers
e.g. StackOverflow.com
Usually, if you post a solution that could be optimized, other experienced
programmers are going to hop in and offer tweaks.
You Don’t Have Any Side Projects
➔ Start a new project that uses the technique you’ve learned
Questions?
Source
➔ http://code.tutsplus.com/tutorials/why-youre-a-bad-php-programmer--net-18384