Wednesday, June 23, 2010

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.

Front-end (HTML/CSS/JS)

  • 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.
  • Write unobtrusive JavaScript. Separate your design and logic; html should be free of DOM event attributes. Link 1 | Link 2
  • 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.

Tools

  • 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.
  • Firebug – Javascript/AJAX debugging tool (Tutorial)
  • 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)

PHP

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).

Coding Standards

Frameworks

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.

Optimization: There are many things you can do before thinking about optimizing your script before jumping into caching/profiling it. Follow the simple tips like Link 1, Link 2

Version Control

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

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.

--
Dr.P

Wednesday, June 16, 2010

WWDC 2010 - iPhone 4

  • iPad didn't replace common tasks. Steve was referring his notepad on stage:). Old habits die hard.
  • Steve can still memorize 24 countries and repeat them in the same order. Bravo! Good job Steve.
  • Yes, he appreciated Microsoft for their HTML5 demos.
  • Now the revenue will be shared  60-40%. 40% of iAd revenue to Apple.
  • Will FaceTime work if there are quite a few devices on the Wi-Fi network?
  • If FaceTime is Open, then H.264 and AAC too?
  • If the same front side glass was used in the back of iPhone 4, can we replace the backside glass for the front in case of damages to the front?
  • 29$ for bumb ( a band covers the antennas'). Come on Steve, let the poor guys live with the iPhone/iPad cover business.
  • FaceTime is open since it use many OpenSource tools & standards.

are the points I notice with Keynote video.

--
Dr.P

Download Apple WWDC Keynote videos

I was always disappointed with Apple Keynote pages. It allows you to stream and watch the videos with QuickTime which is not great for streaming and videos are not HTML5 yet. Another restriction with QuickTime is, you need to have QuickTime Pro to save the video.

Yesterday I found how to download their Keynote videos with iTunes. In fact Apple podcast all their keynotes (many of them) with an iTunes Channel and videos can be downloaded for Free*

But there is one issue, I was not able to find the low/Medium only Hi-Def available WWDC 2010, Jun 7 – 1.27Gb

--
Dr.P

Tuesday, June 15, 2010

iPad - My Experience

Warning: My observations are biased as I'm not an Apple Fanboy, at least right now (was one in the past, I both respect and hate Apple & Microsoft)

  • It is heavy.
  • It is fast.
  • Touch response is great and the best one available. But I doubt the same after the release iPhone 4G :-P
  • It is great for web browsing. Pity myself! I am waiting for my Nook ebook reader. But I'm going to have the Android.
  • I love the remake of Notes and Contacts app.
  • iBooks is simple with bundles of feature which are must for any ebook apps/devices from now on. (Yet to try Kindle/Nook/Kobo so I may be wrong will update after my Nook.)
  • Speaker is good, compared to my 1st gen MiPhone :(


It is not iPhone on steroids, it is iPod Touch on steroids :) I suggest you not to buy until they give you a better product on next revision, a camera + a basic phone features + dignity (other technologies).

It is not a product you must require unless you have a budget in every quarter for Apple.

I wonder, is there a device available for all platform with touch inputs + the area of iPad or 3/4th of it?

--
Dr.P

Wednesday, June 9, 2010

Solving Read-Only Notes.app issue

Notes.app of miPhone was not allowing me to save any new notes. This was after restoring the manual backup of notes.db. I have taken the backup of my Address book, notes and images data with iPhone Explorer.

With the help Terminal app from Cydia I was able to CD to my private dir to check the permission of the files. And I was right, the owner of the file was root instead of mobile. I executed sudo chown mobile:mobile notes.db from the directory to solve the issues.

Before

after, sudo chown mobile:mobile notes.db 

After

--
Dr.P