Must read for all front-end people

Peter Svensson at Script Uncle has written a very good article on what to expect and how to define a front-end developer.  I have myself worked as interface developer, front-end developer, gui developer, front-end architect, web developer etc etc and I am willing to agree with Peters view on the topic. Today working as a front-end X could be anything, it all depends on what the people hiring you have in mind for today. I really appreciate Peters view on what the expectations are on front-end people when you look in the ads:

Looking at the skill set that the front-end developer should have we find that he or she must be a veteran of all major US armed conflicts since WWII, be able to design, build and fly a commercial airliner, have discovered at least three different cures for cancer (of which at least should have received the nobel price in either of Medicine, Physics or Chemistry) and also be the founder of two or more major schools of painting, including cubism.

It is important the the front-end gets its focus in large projects, and that we do not generalize to much thinking that person A can carry the role of the designer, coder, developer, architect and usability specialist and still do a good job. But on the other hand, front-end stuff is for people who do not understand the complexity of things happening in the back-end of a system. We only do this because we hope that one day we also may write generic server side solutions with xml configuration for creating value objects independent of data source.

CSS Frameworks and the Anatomy of Web Design

In this article I will try to dissect how we use CSS in order to design our webs and try to find a model that will make it easier for us to use and create CSS Frameworks that fits all the different problem domains we are facing when designing our websites. The Anatomy of Web Design is essential knowledge in order to create CSS Frameworks that are actually solving the problems we do not want to repeatedly solve over and over again when building websites.

Today no one would even think of writing their own JavaScript library from scratch and use on a site where the audience is diversed, making QA difficult. Libraries such as jQuery and Prototype solves most of the problems that occur on a public website, you only have to write snippets of code for smaller parts that are business specific, if you are writing large chunks of code for your business specific needs you are either solving problems at the wrong level or not thinking in terms of components/plugins. But when it comes to web design and CSS the wheel gets reinvented on each and every site you visit. I bet there are two main reasons for this:

- Design is difficult to quantify and generalize
- Designers do not think as programmers, who always quantify and generalize because they are lazy by nature.

But there are some projects, who have identified the css reinventing the wheel problem, both of them focus on giving designers and developers a generic set of CSS that solves problems that occur, independent from website. The two biggest, and most promising projects are:

They have a lot in common, both focus on first adding a reset CSS to the document and then use a grid for creating all types of design grids you could ever dream up. Blueprint has a module for forms, print and typography, while YUI has modules for fonts and a base css that tries to make a cross-browser-stylesheet from the reset document. YUI offers themes for different widgets/components. No project I have found focus on solving the biggest problem: Specific CSS for specific needs.

As you can see, we have a lot of different keywords (in bold) already, and we could start to quantify and generalize how we look at CSS.

Generalize Design

Generalising design is what CSS is all about. CSS is about finding property values that can be altered and combined in order to achieve the desired result in design. We may say that CSS in it self is the first level of abstraction when it comes to design. For a couple of years we have been focused on creating intriguing designs with our bare hands with CSS as our only (mental) tool.

Pretty soon people working with CSS found out that we had to take the abstraction one level higher, separating types of design into different parts of the design, making the stylesheets easier to edit, more modular and easier to redesign. A typical step is to split the applied styles into different parts, such as grid, typography and design. On top of that we possibly added specific styles for specific parts of the website. By making this separation, we made it easier to change and maintain the design of our websites. If we look at the biggest websites today (with a designed frontend) a lot of them uses this separation of design to different degree.

Still we are solving design problems over and over again in these styles. And the next problem is to identify generic components and grids without forcing a specific look and feel onto the user of the framework. YUI and Blueprint takes a couple of steps in this direction. What I would like to see from both YUI and Blueprint is components that are “wireframed” in their look and feel, this in combination with a well defined documentation on how to add look and feel to these components with specific themes/templates would solve a lot of the design problems some people are facing today. After all, when we dissect a page in interface components, we will realize that 75-90% of our look and feel is well defined patterns or components used elsewhere and if we have wireframed solutions for this, we will see better websites with less rendering errors because designers can focus on what they think is fun, designing, and web developers can focus on learning JavaScript, not play Russian CSS-roulette.

I am in the middle of a big redesign, re-gridding of one of the websites I am responsible for the frontend on, and I believe that we have to start using solutions like this for three main reasons:

1. Maintainability. If we use well defined components with a good documentation, it will be easier for people working with maintenance of the website, to create components, pages, flows that we know for sure will fit the graphic profile and will work in all browsers.
2. Quality. By minimizing the number of rows of new code on all levels we will create a better product. By using already tested and verified code, we will of course create the foundation for a better product.
3. Focus. Designers can focus on design, developers on development and people who have written CSS in the past, can start build UI Components in [INSERT_YOUR_PREFERRED_LANGUAGE_HERE] and make sure developers are distanced from the look and feel by creating a good API for creating these design components. But that is another article.

6 Should Read JavaScript Articles

Below I have listed a couple of JavaScript articles you should read to prepare for the awakening of JavaScript as the main web development tool. It doesnt matter if you consider yourself a .NET or Java-developer, if you do not learn JavaScript you will probably have a hard time finding a job within a couple of years if you would like to work with web development. And by the way: JavaScript-solutions today is not the same solutions you where scared with when you grew up.

Writing jQuery Plugins by jQuery Team

One of the strengths with the jQuery javascript library is the plugin framework that lets you easily create your own plugins. This article/HOWTO guides you in the art of writing jQuery Plugins

JavaScript Inheritance by John Resig

John Resig, creator of jQuery JavaScript Library has a nice article on how to simulate inheritance in JavaScript. This article is a good read for people who, by nature and religious reason, avoids JavaScript because the lack of inheritance and other must have OO-principles.

Event Driven JavaScript by Christian Heilmann

Christian Heilmann, Lead Developer at Yahoo!, has written a piece on JavaScript that dives into event driven javascript, custom events and planning your frontend application.

Simple Class Instantiation by John Resig

Another interesting article from John, focusing on Class Instantiation in JavaScript. Do not stop reading after the article, in the comments you find some interesting comments from a lot of people who are well known in the JavaScript-sphere, among them Brendan Eich, the creator of JavaScript.

JavaScript Closures by Richard Cornford

“A closure is formed by returning a function object that was created within an execution context of a function call from that function call and assigning a reference to that inner function to a property of another object.”

Closures are as cool as they are hard to get.

From Most Misunderstood to Worlds Most Popular Programming Language by Douglas Crockford

Douglas Crockford, architect at Yahoo! and introducer of JSON (JavaScript Object Notation) as data interchange format between applications has a mixed emotion relationship to JavaScript, that makes his articles more interesting to read.

Conclusion

I believe that more than 50% of all web development will be made in JavaScript within 10 years. JavaScript is the language for Mashups and AJAX-solutions and we are not going to see fewer solutions based on that. Combine that with open API:s from data providers such as Google, Yahoo and Blogs.

JavaScript is here to stay, make sure you read these good and advanced articles from people who will build the foundation you will develop on tomorrow.

10 Must have jquery plugins and extensions

Below you find 10 jquery plugins and jquery extensions you cannot do without if you are a serious front-end developer

  1. Easy DOM Creation with jQuery

  2. Form plugin

    If you are doing AJAX-stuff, you must have this plugin.

  3. Dimensions

    This plugin should be a part of the jQuery Core.

  4. Interface

    This library solves 90% of your user interface issues. Excellent work Stefan!

  5. Thickbox 3

    Note I have written version 3, I hope this version will be more extendable than the second version.

  6. Tablesorter

    Solves a generic problem on medium-sized datasets, I want to see an ajax-extension on this fetching data on the fly when paging the resultset.

  7. jQuery Form Validation

    Need I say more, this is the mother of all User Interaction Design Patterns, and it is important that someone has taken this beast on.

  8. jQuery Cookie

    Nothing fancy, but a really good plugin. Instead of writing it yourself again, again, again ….

  9. JSON

    JSON is what XML should be, jQuery should support it better in the core.

  10. Simple Star Rating Plugin

    Nice implemented Eye-candy.

Choosing the correct plugins to gain functionality from is an important detail in your front end architecture and should be taken seriously in order to create a future-proof and well built front end architecture.

10 reasons to choose jquery

I have been thinking a lot lately about why some open source projects gain momentum and some, though the quality is very good, do not.

jQuery is a typical example of a open source project that has gained enormous momentum the last year. It started out as a good idea, merged from other good ideas in other similar projects. Now, hundreds of developers, architects, designers and other web professionals helps the project, making it bigger, better and faster.

I tried to understand why jQuery achieved this kind of momentum the last year. I put down a list for myself trying to pinpoint the things that forms a good open source project.

10 reasons why jQuery will be the de-facto JavaScript library late 2007

  1. John Resig

    I believe that in order for an open source project to succeed it is crucial to have a front figure that is focused, talented and driven. John is all that. John is a big factor in jQuerys success.

  2. Marketing

    For an open source project to gain momentum, it has to draw attention to the product. This is crucial since attention makes interest bigger and bigger interest makes more intelligent people wanting to share their knowledge, thoughts and help in the future roadmap of the project. jQuery has really been good the last 4-6 months within this area.

  3. Community

    From the beginning it has been easy to get answers from other users of jQuery. jQuery do not have a forum, and thats a good thing in my opinion. Forum tends to create an elite and that makes user with less cred or knowledge more likely to not join the discussion. jQuerys main discussion is done on the discussion e-mail list together with the wiki. And the jQuery-community is a friendly community, no question is left unanswered. There is also a development list for project discussions.

  4. Architecture

    jQuerys architecture has evolved. It is easy for developers to get into the architecture and start developing plugins and add-ons to jquery. The architecture has evolved since its early releases. Add-ons and plugins must use the correct (according to coding-standards) namespace (jQuery), in order to attach to the architecture. I believe that the current architecture will benefit the evolution of the jQuery library.

  5. Library

    jQuery is a library, not a framework. Framework decides everything for you, libraries exposes solutions to you, but doesnt say anything about your potential implementation of the problem. Libraries gets more users in the developer community.

  6. Documentation

    jQuery has a great set of documentation. You have the wiki, the jquery e-mail list and the jquery developer e-mail list. Above that, you have a community that is focused on showing the rest of the world the power and potential of the library, it doesnt get any better than that.

  7. Configuration Management

    The releases of jQuery is very well communicated in the blog, community and e-mail-lists. Minor version updates is minor version updates and major updates is major updates. As a site-owner you do not have to worry that jquery 1.8 is totally different to 1.9. John takes good care of the users he has.

  8. Team

    The users developing jQuery are a group of people enjoying what they are doing, and they are good at what they are doing. I know a couple of guys in the team, and I have 100% confidence in them doing the right thing.

  9. Joint Ventures

    The jQuery inner circle (John, Rey ++) connects to the correct people, maing the library even stronger. Drupal, Jack Slocum and other software developers big in the open source community.

  10. Focus

    John Resig has not lost focus. I think it is important to see where the open source project you are promoting is aiming. John has had a great focus for jquery, it is a JavaScript library focusing at making it easier for developers and designers creating DOM-scripts that creates a greater and richer experience to the end-user.

Choosing the correct JavaScript Library is one of the important thing that has to be taken into account when building your front end architecture. Choosing jQuery is from our point of view, the future friendly way to go.

JavaScript Form Validation

Top 10 tips for JavaScript Form Validation

JavaScript Form ValidationThis article is an introduction on how to approach and create efficient form validation with javascript. I will briefly describe the interaction pattern of client side validation with javascript. Later I will focus on 10 actions/tips/mindsets that will make your form validation perfect.

Table of Contents

The Design Pattern of Client Side Form Validation

Whenever a user needs to submit data to your application, there is a need in validating the users input.

Use a form validation framework or a form validation library

I strongly recommend using some kind of JavaScript-library or framework when implementing your client side validation. On top of that it is important to use/implement a validation framework, this is because you will have bugs and issues with your client side validation, and a framework makes it easier addressing these bugs and issues. When we changed client side validation on a redesign of a larger site lately, we built the validation framework on top of the jquery javascript library. That architecture has made it easier addressing issues and bugs that do arise during development and maintenance of your forms.

Focus on solving the big validation problems

As soon as you start developing and implementing your validation, it is easy trying to address all potential validation that is needed for all types of input. My advice is to try to catch 75-85% of the potential user input errors in the front-end validation. Trying to catch all will lead to the following:

  • Bloated code, your framework will grow too large
  • More or less impossible to test client side validation as there are too many combinations of validation that can go wrong
  • Business rules will move to the front-end.(More on how to avoid this by using Ajax later)

To avoid this I think that creating a small validation framework that can do most of the validation is the way to go, and leave the specific things for the server (or create a plugin to your framework later) to validate.

Do Form Validation before form is submitted

The traditional JavaScript form validation pattern used since the 1995+ is to validate the form when the user hits the submit button, and whenever the script encounter a form item with some error in it, focus on that form item and prompt the user with an JavaScript-alert saying that something went wrong.Today, there is no need doing it that way.In your pursuit of creating the perfect front-end validation framework, you must add the possibility to validate controls on other events than just submitting. I see these potential events:

  • Whenever a controls value is changed
  • When a control is blurred
  • Periodically check if controls has changed
  • When a control that is connected to another control changes value
  • When a form is submitted
  • When a form is reset (if you for some reason finds it intelligent to have a reset-button on your form)

Use Ajax Form Validation for business data input

In order to validate business data you have three alternatives

  • Let the server take care of it
  • Add business logic to your front-end code
  • Let the front-end talk to the back-end through an Ajax-API

My suggestion is to go with the first or the last option, if you go with the last option there are a couple of things to keep in mind

  • Make sure your code is secure. Sometimes “smart” solutions like these, exposes business data to people with a little technical knowledge
  • Create a server-side API that has a defined set of methods with a defined set of parameters to be sent to it.
  • Create a client-side wrapper, wrapping the functionality exposed in the server-side API.
  • Only allow communication between the server-API and the client-side API-wrapper
  • Make your API-responseType configurable, sometimes you want to show the result as HTML, sometimes you want to manipulate the answer within your JavaScript code and sometimes you will use the response for more queries. I think that the API at least must be able to response with these types:
    • json
    • html
    • xml
    • script
    • text

Typical business data in my mind, are unique usernames and emails, age-validation rules, address verification etc etc

Do extensive testing of your javascript form validation

There is one thing worse than no validation: Validation that do not let correct data through.In order to avoid this, my finding is that coding is a smaller part then the actual testing of the validation framework. My tips is to create unit-tests for all your validation rules as a part of the validation framework, this way it is easy for you/your team to verify functionality whenever a change is needed to your framework

Rewrite input data to valid formats

Some input will come in different formats, dates for example. JavaScript Form Validation should address this problem by rewriting from known invalid formats to the valid format. An example can be:20070325 -> validation rewrite format -> 2007-03-25Because the user has not made an error, he/she has given the system a correct date, it is not his/her problem if the system doesnt use his/her format. The system should then be able to rewrite the known wrong format (20070325) to the system correct format (2007-03-25). Typical areas where reformatting can be used

  • Dates
  • Time
  • Phone numbers
  • Social Security numbers / Personal Numbers
  • Trim spaces
  • Remove/exchange invalid characters

Attach javascript form validation late in the design process

Semantic webs must be able to present forms that do validate and function without the attachment of behavior, which is the case when adding JavaScript Form Validation. Therefore I think it is important to make sure your use-cases is valid with or without the adding of client side validation. If you make sure this is valid, there will be small problems making sure the web is ready for mobile users and search engines.

Make the script i18n- and l10n-compatible

If your web is successful for an international public, the non-english-speaking audience is next. In order to achieve this it is important that even user generated error messages is localised and translated. Make sure your client side validation framework is prepared for translation and other localised parameters such as currencies, dates and time-formatting.

Add callback functions to validator framework

90 % of the time you want to use your validation framework as it was intended to be used, 10 % of the time you will be wishing that your framework would be more generic to achieve some specific interesting effect you have identified while working with your site and validation framework. In order to achieve this I think it is important to add the possibiltity to attach callback functions for your forms, letting the developer use your library in a way you couldnt dream of. The definition of a good library is when people using it creates stuff you as a creator of the library didnt think was possible.

Make your framework/library extensible

If you add working hours to a framework or a library, it is important that the architecture of the library/framework is open, and is extendable.

Resources

jQuery Plugin Development Process

I have been thinking about the plugin development process for jquery. As it is today we have a wide variety of plugins and some of them are officially supported. The problem as I see it today are the following:

- Version management, some plugins that are official do not change in the same speed as the jquery core, leaving end-users to either not upgrade the core or make their own changes to offical plugins. This is not optimal. I believe that in order to become an official plugin, the author(s) of the plugin has to verify what plugin versions works with what core versions. If this is not possible, we must create a way to identify how to work with plugins and version without forcing the end-user to manually hack the core of jquery or the plugins. Maybe we should look at PEAR or other libraries and see how they handle version management for plugins.

- Offical plugins becomes official by word-of-mouth today, that is the only way as it is now. Maybe offical plugins also should be able to become official by adding requirement specifications for future plugins to the jquery plugin library and letting development-teams take on these requirements. This way we could maximise the quality of the official plugins by letting people good at implementing implement
them and letting people interesting in focusing on how to make jquery a more powerful and usable platform focus on that work. Of course a lot of people do both, but I think there are a lot of really good jquery-developers just waiting to implement a really good requirement for an official plugin (John mentioned a charting plugin in a earlier
posting).

- Coding conventions. I believe that in order to make a plugin
official it has to follow strict coding conventions, otherwise it is difficult for people to take on development whenever the orginal author feels he/she do not have the time or focus for keeping the work up.

This is just my thoughts and I am sure that John and the rest of the core team has big ideas in this area, I just hope to create a bigger discussion about how to work with official plugins and how to handle requests for plugins, which I think is an important step in order to make jquery more stable, user-friendly and the de-facto choice for javascript-libraries.