Web Development Good Practices

>> Thursday, May 3, 2012

In this post I'll try to add some good practices which are nice to have in mind while developing for the web.
Developing for the web includes varios different technologies, this is what I like about web developing, it includes HTML, CSS and Javascript for the client, then a programming language like PHP or C# for the server, let's not even get into the server technology, like Linux + Apache, or Windows + IIS, and data storage like MySQL, Postgree, MSSQL, or even NoSQL databases like MonoDB and Cassandra.

I'll talk about the most common technologies and the ones I know, of course.


It's very important to follow standards, in every technology, but in web is really important, as your app is released to the masses and HTML is one of the things everyone can see. If you output bad HTML the browser might render it just fine, but it might break in some browsers, also, it's not good for a professional site to have malformed HTML, or deprecated HTML.

If you are starting a project from scratch you should consider using HTML 5, it's already supported, modernizr helps quite a bit for unsupported browsers, it's the new standard and it will look good on your portfolio.

HTML 5 isn't really hard to learn, it's simpler and nicely evolved from the old HTML, so you should really give it a try.


CSS hasn't changed much, and support for CSS 3 isn't quite implemented correctly yet, so using CSS 2/2.1 is what you should do by now, but that doesn't mean you can't extend it!
LESS is there just for that, it takes CSS and adds a bit of logic inside, like variables, nested rules and more.

You can compile it to standard CSS or just write LESS CSS and use Javascript to interpret it, up to you, Javascript is really supported right now, so it's safe enough to use it.

Do not use flash!

There are very few things you can do with flash that you can't with HTML 5 + Javascript, and to be honest, I can't think of one right now, with HTML 5 + Javascript you can do a Video Player (like youtube does), Image Manipulation, you even have sockets now! There's really no need to use a privative plug in with security issues, you can just use the browser, and the user won't need to install anything nor compromise his security.


When using Javascript you might want to use JSHint (or the more strict and mean, JSLint) to check your code, writing code that follows JSHint ensures it follows basic good practices.
Also you should use a library like jQuery, it ensures cross-browser compatibility, making the biggest pains of Javascript go away!
Also! It's important that you understand how Javascript really works, Object Orientation with Javascript can be a bit tricky.
Once you understand this little language it's easy to love it.

Client Side Frameworks

There are several frameworks for this, basically what these frameworks do is give you a nice solid base so you can write cross-browser and even cross-platform (PC, Tablet, Mobile) applications with less effort.
These frameworks give you a base style and/or script for you to be as productive as possible.
My favourite right now is Bootstrap, a lightweight open source framework by Twitter. It gives you a nice CSS reset, fonts adjustments, and a grid system.
It also defines a nice set of components you can use on your site, some with CSS, and others with Javascript (which depend on jQuery).
Using a framework like Bootstrap is highly recommended.

Server Side Technologies

This is sometimes personal taste, and sometimes more technical. The most common technology for web applications today is probably LAMP (Linux, Apache, MySQL and PHP), but there are other technologies which are getting quite popular too, like RoR, Django and ASP.NET MVC.
All of them are free to use, ASP.NET of course requires IIS 7 and a windows environment, but hiring a windows hosting isn't much more expensive than a linux one, nevertheless, if you plan on hosting your own app or are afraid it will scale a lot, licences might be a problem, Azure might be a workaround for this, as you don't pay licences at all, just the resources your site uses, but learning a whole new technology just you host your application there it's not really a big advantage.
Most of the time though, you can just choose whatever you feel like using, and its more fun to use for you, PHP, Django, RoR and ASP.NET MVC all handle themselves pretty nicely, performance won't be a real issue, you should worry about the speed of development and your own fun while developing.

Comparing PHP to RoR is quite unfair though, as RoR is a framework and PHP is a language, if anything, we could compare PHP to Ruby, but you won't ever want to use plain ruby for a web application, what you want is a framework, you can either make one yourself or use a well-tested one.
So for PHP I recommend using a MVC Framework, like CodeIgniter, CakePHP, Symfony or Yii.
What PHP really lacks is some kind of advanced functionality, of course, PHP does have that, but for example, if you want advanced caching, you might need to install APC, or XCache, or memcache, on ASP.NET MVC you just use the standard cache you are given with the framework, this makes PHP a bit harder to use, but more versatile.
Note: StackOverflow uses redis for it's cache.

It's important to note though, most of the time you won't really need to worry much about the server-side technology, that beeing what database engine you use, how you cache, what language or framework you use, what you do have to have in mind is the client side, that's why using something like Bootstrap is awesome.

If you do care about the server, then you can start worrying about using MySQL, Oracle, Postgree or MSSQL, or mixing standard SQL with a NoSQL database like MongoDB, Cassandra or Redis, or mixing different languages, like making your own modules for PHP in C, or use Facebook's HipHop PHP to compile your PHP code to C++, but that's far beyond the scope of this entry.

What I want to emphasize is, use whatever you find fun, and pay special attention to the user interface, follow the standards and you will be fine, they are there for a reason.

Post a Comment

  © Blogger template Simple n' Sweet by Ourblogtemplates.com 2009

Back to TOP