Saturday, 23 April 2011

Debuggers (the other half of your trade!)

Most browsers come with addons that you can switch on to help you see what's happening in the page when there are errors, etc. The industry standard for this is Firebug for firefox and frankly in the past I would recommend no other - it is AMAZING!

But Chrome, Opera and Safari all have their own built in developers tools, and they are catching up, if not on a par! For a guide to each follow the links:


OK. So then there's this other family of browsers that I'm really in love with Microsoft Internet Explorer - and would you believe it, the developers tools for this family of retarded browsers are...shit. You'll have to learn to use these unfortunately; don't expect anything great from them - I solve more IE problems through intuition and safe styling/scripting than I do using these tools. You can try and put Firebug Lite into them, but in my experience it rarely works well - still, no harm in trying. :)

Tuesday, 19 April 2011

IDE's - half the tools of your trade!

When it comes to writing code you can literally write it in notepad/preview/VIM, etc. As long as it's saved with the right file extension and in the right character code (ie UTF-8, etc - don't worry about this too much just now) it'll work. I'd recommend that ocassionally you test your skills and write simple pieces of code by hand; when I interviewed at LBi one of the first tests was to write html, css & js by hand ON PAPER!! (no computer in sight...). In web development we plan for the lowest form of technology; you should do the same for your skillset!

Trouble is, though, that when you type it our by hand it's:

  1. Long and laborious
  2. You're prone to make tiny typos that will break your code
Fortunately there's an easy way around all this: IDEs (Integrated Development Environments).

IDE's often come with some great features that'll really help you and speed up production, such as:

  1. Code highlighting (This colours your code so you can instantly see what things are and if there's a fault)
  2. Code Hinting (This indicates errors to you with red underlines or exclamation marks, etc)
  3. AutoComplete (As you type it gives you options which you can navigate and accept, so if you type '<i' it will show you '<input', so 3 keystrokes instead of 6)
  4. Validation: NOT a substitute for real validation, but helpful nonetheless...
  5. Code commenting/uncommenting
  6. Find & replace - VERY USEFUL/VERY POWERFUL/VERY DANGEROUS.
  7. FTP (File Transfer Protocol) functionality. This allows you to put files up to a server and get them down.
  8. SVN functionalities - in a word "don't". Use tortoise SVN instead.
  9. Code tidying. (there are prolly better online versions but these are ok.)
List of some popular IDE's:

  1. Komodo: Free and pay versions (pay has things like FTP, etc). I'm just starting to use this IDE - TBH, I think you should too, even though I don't think it's as amazing as people make out (but for a free product it's hard to beat!).
  2. notepad++ Free and light. Works ok, in windows.
  3. Textmate. Not free and I've never used, so...
  4. WebStorm. Apparently very good for JS. (Has a sibling phpstorm, which is recommended)
  5. Dreamweaver (part of the creative suite). Costs a lot. Hated by developers because designers used to use the design mode to create web pages that could be technically described as 'boll*cks'. There are even companies that will not interview you if you state that you can use this software on your CV!! Having said that; If you CAN code, I found it ok and indeed have spent most of my junior development life using it - stands by for incoming fire...
For now, I'd recommend you use Komodo (with zencode and jslint addons [works like firefox for addons])...

PS. If anybody has any more info, suggestions, etc please feel free to comment. :) 

Saturday, 9 April 2011

Tip for today...

Throughout the blog I'm going to include some random tips that'll help out when you're going about your general business...

Today's tip is about case sensitivity in URLs. In Windows case sensitivity is overlooked; in linux it isn't.

On your .htaccess file you'll need to include a line like this.

NB, not all servers are set up with mod_speling

Sunday, 3 April 2011

On your local machine...

As a developer there are many ways which you can develop. The most convenient is to download (or create) the files on your local machine. You'll then need to install a web-server on your machine to run them as web pages. There are many different web servers available to you, but the two most common are:

  1. Microsoft IIS (Internet Information Services). Currently at version 7. IIS comes built into the windows operating system and is available for anybody with a 'professional' or higher version of the Windows OS. It naturally runs asp.net and has support for PHP too. Install guide here.
  2. Apache. There are various different versions of Apache. The OSX operating system for macs comes with a basic version of this already installed, you just turn on the internet sharing option. For windows, XAMPP is great (as it has the mercury mail server and various other things built in). Installation is simple and Google is your friend if not so. Be aware that Skype may very well interfere with apache and also, make sure your firewall isn't crocking you too. If you press start and it stops immediately, it's probably windows firewall - you just need to go into the firewall and edit the permissions. Other reasons may include your log files getting too big (in xampp/apache/logs/) and the permissions on them being wrong. Also, a crash of an apache run may leave httpd.pid which will need removing.

Get one of these two up and running (preferably Apache) and Bob is your uncle... :)

The Browsers.

There are many many browsers but at the time of writing this document there are 8 that commercially you need to know about:

  1. Mozilla Firefox. Now at version 4, Firefox runs the Gecko engine. This engine is strong but some may argue secondary to the WebKit engine which runs Google Chrome and Apple Safari. Firefox is fast; forgiving of errors, and; HAS THE BEST DEVELOPERS TOOLS. Firefox is the main browser I debug in...
  2. Google Chrome. Now at version 10. Google's VERY fast and lite browser (to be even faster look at chromium). (N.B. Google are set to launch an operating system of their own, so this already popular browser may be VERY important in the future.)
  3. Apple Safari. Now at version 5. Again a very fast browser AND THE BROWSER SHIPPED NATIVELY WITH OS/X, which means that a lot of people who use a mac will using this browser.
  4. Opera. Now at version 11. An under-rated and lesser known browser, you feel that opera was ahead of the game for a long time but didn't deliver exactly what its customers required. And not being open source meant that people didn't develop an involvement with it, or add-ons for it: In short, very good, but wrapped in its own reality.

The next browser I'm going to deal with is by far and away the biggest hunk of shit you'll ever have to deal with. Tragically for you as a web developer, it is shipped natively with windows and therefore has the majority of the market share. The company that make it are notoriously arrogant and the words 'cutting edge' need rarely be applied (although when they are #Ajax, #@font-face, they are REALLY impressive). It will be the bain of your life and you will spend approximately 33% of your time de-bugging for it. Ladies and gentlemen, I give you 'Microsoft Internet Exploder', er, I mean 'Explorer'...

  1. IE9. The demos were full of features which weren't real, to anyone with a tech background - such as the 'deep zoom' demo. Being fair now. IE9 should be OK. It's too early to tell its idiosyncrasies yet, but they should be less as Microsoft have been getting a severe ear-bashing for the state of their browsers for such a long time now. It scores 95% on the Acid 3 test (don't get hung up on Acid 3; I don't think it's that great a test).
  2. IE8. 8 was the first IE browser that I didn't have to scrutinize massively. Generally it copes, and that's about it.
  3. IE7. Well, at least it's not IE6. IE7 can be relied upon to throw a wobbly fairly regularly (about 10-20% of the time, when it comes to layout)
  4. IE6. This browser is the bain of your existence. Microsoft, Google and various others have now totally withdrawn support for it after a massive internet campaign to have it ended. (although you'll note that Microsoft still have a download page for it). Microsoft themselves have recently launched a campaign to get users to update their browser. Typically for Microsoft, you'll notice that 33.8% of the worlds users are Chinese - of course no Chinese language version of the site was provided! (NB. Just for comedy value. ) IE6 was a great browser 11 years ago, however times change and so does what is required of a browser. The main problem is that apart from being woefully behind in terms of technology (JS engine, etc.), it was also using THE WRONG 'box model'!! A list of IE6 bugs and fixes are provided here. Top tip, if you have 2 anchors next to each other in your code, make sure there's no white space between them...
IE browsers all use the Trident layout engine, just FYI. One issue that you will have is that in order to debug you will need to run multiple versions of the same machine. Here you'll have to get yourself a series of 'Virtual Machines' and load them up with the appropriate 'virtual hard disks'. If you're using a mac you'll need a VM to see IE at all...

A comparison of web browsers will help to fill you in a bit more on the current state of play, but for now I'll see you next time.


Saturday, 2 April 2011

How the internet works...

So how are web pages made and what technologies are involved in the process? Well...

Front End ('Client Side' - or, 'what you can see'). These 3 technologies make up the 3 layer model:
  1. HTML (Content) - what's actually there on the page.
  2. CSS (Presentational) - how it looks...
  3. Javascript (Behaviour) - what it does when you interact with it.

Back End ('Server Side'). These technologies arrange the package of the above technologies that you receive when you make an http request (when you put a web address into the browser and press return, or click on a link...). They most often comprise of two parts:
  1. A back-end language, such as PHP, ASP C#.net, etc.
  2. A database language, such as MySQL, MSSQL, PostgreSQL, etc
You'll often find that people in the business will try and tell you that something is front or back end in nature. Let me give you a guiding principle to help you:

The client side is there to present a ready made product - it's a self-contained document with no interaction with the realities of the outside world. As soon as any concerns outside the scope of the document (or the pre-formatted data sent with it) are brought up (such as 'who is this user?', 'what addresses are available?' and many other logical queries), the process is then handled server side.

I'd like to give you an analogy that'll help you understand the basic technologies that make up web development and how they interact with each other...

Imagine you're setting up a restaurant. You'll need a few things:
  1. A table and chairs
  2. Cutlery and crockery
  3. Menus
  4. A waiter (or server)
  5. A kitchen
  6. A chef
  7. Ingredients.

The front end of the restaurant, the dining area, is where the customer interacts with the restaurant. In the analogy this represents your user interacting with the technology of the internet by using their browser (Firefox, Chrome, Internet Explorer, etc).

HTML says: get your dining area and in it put a table, cutlery, crockery, etc.

<dining room>
  <table>

    <fork />
    <plate />
    <spoon />
    <knife />

  </table>
</dining room>

CSS says: Put the table in this position, put the chairs around it, facing inwards, in these positions. Put a plate in front of each chair and put a knife to the right of the plate facing way from the chair, a fork to the left and a spoon above facing right.

dining room {
 width: 10m;
 length: 6m;
}

table {
  margin: 1m; /* must be a 1 metre gap around the table to allow people to sit down. */
  position: relative; /* all further objects are positioned relative to the table */
}

chair {
  facing: table;
}

plate {
  position: in front of chair (on the table, because all further objects are positioned relative to the table);
  position: relative; /* all further objects are now positioned relative to the plate */
}

knife {
  facing: same way as chair;
  position: right (of plate);
}

etc, etc...

Javascript says: 

function eating (knife, fork, plate, food, mouthPosition){
  this.useFork (food){
    food.stab();
    food.holdStill();
  }
  
  this.useKnife (knife, plate, food){
      knife.placeKnifeOnFood();
      while (knife !== touching plate){
        knife.drawForwards();
        knife.drawBackwards();
      }
  }
  this.putFoodInMouth (mouthPosition){
    food.position = mouthPosition;
  }
 useFork (food);
 useKnife (knife, plate, food);
 putFoodInMouth (mouthPosition);
}

Not entirely accurate code-wise, but good enough to give you an idea of how the 'client-side' technologies work. Client side technologies are the technologies that your browser uses to display the web pages it is sent by the server; the 'back end'...

If we think of the interaction between the waiter (server) and the customer (client): The client makes an initial request to the server to come into the restaurant and be seated and see what's on the menu. That's like the http (hyper text transfer protocol) request when you first request a web page and it is amassed by the server and sent to you. You can then make further requests to your server, such as 'can I have the soup', etc. and, depending on who you are the server will give you what you have requested. For example, a small child may request a beer, but the server will recognise that the child is too young and deny the request. In the real world someone may request to post on a thread, but may not be allowed because they are not logged into the site, etc.

Server-side languages often communicate with databases (using a database language). Databases are effectively tables of information. The tables link data in meaning by putting them in rows:

Name                     Suitable for Children
Beer                        No
Orange juice          Yes.

In our restaurant example, the client will ask the server for something extra beyond the original setup, such as asking for the soup. The waiter then goes to the kitchen and asks the cook to prepare soup. Think of the cook as the database language - bringing resources together to give bring a product. The waiter then returns the result of the cooks efforts and gives it to the client.

In short, that's how the internet works. As you'd expect this is a simplistic view - for example, technologies like Ajax (Asynchronous Javascript and XML) allow the client-side to make request to the server-side from within the document (rather than request a whole new document), but essentially the above holds true in the majority of cases. In the next few chapters I'll go into each technology separately and show you how to use and how not to use.

Welcome...

Hi there,
I'm Jim Sherry, I'm a web developer for LBi, the UK's leading web development agency (ref. http://www.brandrepublic.com 's league tables).

About 6 years ago I came out of the military and came to London to start a new life. I tried many a career and in the end decided to set up my own adventurous activities company - guess what... that summer it rained and everyone went out of business. During the preps for starting the business I had built my own website and really got a buzz from it. Since then I've studied long and hard (no, really - like Neo-tastic!!) to finally get into the position I have. There's a lot of knowledge I've accumulated along the way which I'd really like to share with you to help you get where you want to go, so...

The aim of this blog is to show junior and beginner level web developers the techniques and resources they will need to progress into becoming professional web developers.

Hopefully, it'll be fun and useful, so lets get started...