Random Notes: LAMP/Web development |Tools & Best practices
I was planning to write a post similar to this for very long time. My intension is to help beginners to know the jargons and best practices. Please add your comments and I will update.
- HTML should be validated.
- Should test your web page/application with IE/Firefox/Webkit(Safari/Chrome)
- CSS - Organize your CSS files and there is a great tutorial (video 1) from Sitepoint.
- Optimize your front-end: YSlow has set of rules to optimize front end (Caching PHP scripts are so old tricks)
- Use JS frameworks and I suggest jQuery. JS frameworks helps you not to worry about browser identification and common AJAX calls and more. And there are plug-ins available.
- There are many tools to validate the html and I found HTML Validator for Firefox is the great tool and it validates offline.
- Browser Labs by Adobe is another tool to test all major browsers.
- Portable Firefox version are available to major versions.
- IE Tester is a great tool to test multiple version of Internet Explorer.
- Web Developer – The best tool before the rise of Firebug, but it still has the unique features.
- YSlow – A great extension from Yahoo UI (YUI)
It is a simple language to learn, it was tailored to do so. The same advantage is its curse many do not follow standards. We no longer write simple write and forget scripts, we develop websites and application that are continuously updated/upgraded. You cannot always remember the reason why you wrote the logic that way. So always document the files, use PHPDoc (tutorial).
Thanks to Rails (Ruby on Rails) it changed the way we use to code. Web developers were porting the features by developing PHP Frameworks and there were many frameworks available now. I prefer/suggest CodeIgniter and Zend Framework for many reasons (I’ll try to explain the reasons in another post). Use CodeIgniter (manual | Tutorial) for every (Small/Medium) project/site you will reap only benefits and use Zend Framework for Enterprise/Large projects.
I have seen people who copy a script from live servers and rename it with date stamp before editing it. There are better alternatives available called version control a great tool developed by the developers for the developers (Wow! Close to the definition of democracy). It helps us to revert back to a particular version in a second. You can analyze the log, archive a version by tagging it. It can help multiple developers to work on the same file. Whatever I have listed are very few benefits you get by using version control. I use SVN for almost all my project and I suggest you to try the same.
Testing is important to any project though I do not share good relationship with my testers :) (who accepts their faults). Programmers always test only positive/happy flow by default and testers are there to help us on developing the usable project for real time users.
And as a web developer we have more HTML forms to validate user inputs. Rule of thumb, do not trust input from users always validate.
We programmers do test the form we just add validation; however we don’t retest the same sequence of inputs that we have tested before adding an extra validation to the form. There are tools that capture our actions/inputs from the browser and replay the same N times. Tools like iMacros for Firefox are providing many options which can be overridden. This helps you to unit test your frontend. There is a unit testing framework called PHPUnit which helps you to unit test your backend/business logic so future update will not mess the site/application.
I am not aware of tools like iMacros for other browsers. I have used iMacros for testing validations of form and I have not found an occasion where the same fails in other browsers. Other than unit testing you should also test for the following
If you validate your users’ inputs then you are almost made 80% XSS and SQL injections are byproduct of malicious inputs.