Seasons greetings to all! January 9, 2010
Posted by darynholmes in General.add a comment
After a long break from writing posts I have committed to starting up again. I will continue writing about anything and everything. The Rails posts have proved to be the most popular and therefore I will certainly continue to write posts on Rails. I have not decided what will be next, although I am leaning towards a tutorial on Rails forms.
Thank you to all of you who have made positive comments on this blog, these kind comments have inspired me to start up again.
My sincere apologies for my long absence. Please let me know if there is anything in particular you would like me to cover.
Have a great year!
Zuhlke – Corporate Networking Event October 22, 2008
Posted by darynholmes in General, Presentations.Tags: Corporate Networking, Presentations, Zuhlke
add a comment
Zuhlke Engineering is hosting a corporate networking event at Canada Square on the 20th November. There will be an informative one hour presentation, followed by lunch and a networking session.
Here is a short snippet from the leaflet:
Zuhlke will share thier experience in successfully helping CIO’s and Programme / Project Managers in Top Tier Banks and other Corporates to:
- Get the business on your side by capturing requirements in their language but with the precision you need
- Win the battle for budgets, ensuring the right level of project funding throughout
- Get compliance and audit without the pain
- Corner suppliers into delivering only high quality software
The speakers at the event are:
Prof. Dr. Wolfgang Emmerich (Chairman, Zuhlke UK)
Wolfgang is a Partner in the Zuhlke Technology Group of Switzerland. He was also co-founder of Zuhlke Engineering GmbH, Germany in 1998 and Zuhlke Engineering Ltd, London in 2001, where he is currently Chairman and part-time Principal Consultant, primarily to the investment banking sector.
Keith Braithwaite (Head of Zuhlke’s Centre for Agile Practice)
Keith is a Principal Consultant and Business Unit Leader with Zuhlke in the UK. He has trained, coached and managed development teams from New York to Sydney working on systems ranging from mobile telephone applications to enterprise scale financial systems. He is a regular presenter at conferences around the world.
This is a free event and seats are limited. If you would like to attend this event then please contact me.
Regards, Daryn
Ajax Fundamentals – Part 4 September 23, 2008
Posted by darynholmes in AJAX, Technologies.Tags: AJAX, JavaScript, Tools
5 comments
Index | Part 1 | Part 2 | Part 3 | Part 4 | Part 5
5. Development and Debugging Tools
5.1. Documenting JavaScript
JSDoc is an open source tool used to add inline documentation to JavaScript source files. JSDoc is based on the javadoc tool. Many of the javadoc characteristics have been included in JSDoc. An example of using JSDoc can be found here.
5.2. Firefox Tools & Extensions
DOM Inspector is included in the Mozilla Suite and Firefox browser. This tool provides a graphical user interface that enables a user to brows the document object model of any site. One can view, update and insert DOM attributes dynamically. In order to assist JavaScript developers, DOM Inspector can be switched to JavaScript Object mode. This shows all the properties and methods available to a JavaScript for a particular mode. DOM Inspector provides a JavaScript evaluation window that allows the user to execute JavaScript against selected nodes. There is the option to use CSS Style Rules and Computed Style information. This allows a user to examine the CSS attributes associated with different page elements.
Firefox JavaScript Console is a tool that logs JavaScript errors found on a page when the page is rendered. The Firefox JavaScript Console gives ‘compiler-type’ messages. It describes the error that occurred and the gives the line number.
Firebug integrates with Firefox and provides many development tools. Firebug has a version of a DOM inspector that enables a developer to find elements. CSS support allows settings to be altered and viewed. Firebug allows one to monitor the network activity in order to determine how long it takes for different sections of a page to download. A JavaScript Debugger allows one to debug and step through the JavaScript at runtime.
HTML Validator is a Mozilla extension that performs HTML validation within Firefox and Mozilla. HTML Validator validates the HTML locally and does not use a remote third party. The number of errors of a HTML page is seen on the form of an icon in the status bar when browsing. HTML Validator offers a set of tools to assist in validating and correcting HTML tags.
Checky is Firefox extension tool for validating HTML. In addition to HTML, Checky can validate XHTML, CSS, RDF, RSS, XML and many more formats. Checky sends the source to third-party cites to be validated. The third-party cites may be free or commercial services.
Pederick’s Firefox Web Developer extension offers a large set of tools for a website developer. Web Developer provides an extensive set of tools, from highlighting table cells to converting ‘GET’ requests to ‘POST’ requests. This toolbar contains more than 80 tools and is an essential commodity.
5.3. JavaScript Syntax Checking
JSLint is an online tool that evaluates JavaScript code. JSLint scans the JavaScript code and identifies syntax errors, structural problems and questionable coding-style conventions.
5.4. Compression and Obfuscation
MemTronic’s FREEWARE HTML/JavaScript Cruncher-Compressor is a freeware tool that can perform both compression and obfuscation. The MemTronic’s website provides the following information. The tool can Crunch, Compress and Obfuscate. Crunching removes all comments and whitespace. Crunching has a bandwidth saving between 20%-50%. Compressing will compress the script with a real compression-scheme, with auto decompression added to the file. This results in bandwidth savings between 40% – 90%. The obfuscator has not been released at this stage. Once complete this tool will encode the script into a format that humans can not easily read. When using Compress, the file will undergo a level of obfuscation.
Index | Part 1 | Part 2 | Part 3 | Part 4 | Part 5
Ajax Fundamentals – Part 3 July 12, 2008
Posted by darynholmes in AJAX, Tutorials.Tags: AJAX, JavaScript, Search Engine Indexing, Security
5 comments
Index | Part 1 | Part 2 | Part 3 | Part 4 | Part 5
3. Security Issues
The XMLHttpRequest object is restricted to run within the browser’s security sandbox. Any resources requested by the XMLHttpRequest object must reside within the same domain from which the calling script originated. Therefore the XMLHttpRequest object is constrained to requesting resources that reside within the same domain from which the script was originally served. The W3C states, that in the future The XMLHttpRequest Object specification will define a way of doing cross-site requests.
There is an overabundance of online documentation stating that Ajax introduces multiple security threats. These threats include fake requests, denial of service, cross-site scripting (XSS), reliance on client-side security, and more. Jeremiah Grossman’s article, Myth-Busting AJAX (In)security, maintains that these security issues existed before Ajax and the recommended security best practices remain unchanged. Part of internet security basics is to distrust the client. Ajax is a client side technology and requests need to be treaded with the same caution as all other calls.
4. Disadvantages
4.1. Usability Problems
Web users have become familiar with using classic web pages. Users have become accustomed to using browser features such as the back and next buttons. Ajax calls are not loaded onto the browsers navigation stack. Therefore the back button will not undo the last ‘Ajax operation’. Developers need to explicitly cater for undo operations.
Ajax enabled pages have a notion of state; this state is altered as the user navigates through the site. The browser is unaware of this state, and it is not reflected in the address bar. Therefore users are not always able to book mark a certain page state. Developers need to consider this when deciding on when to use Ajax.
The asynchronous nature may make page updates difficult for the user to notice. The developer needs a way of drawing the user’s attention to the modified section of the page. The ‘yellow-fade technique’ has become common practice. In this technique the changes are highlighted with a yellow background, and the yellow fades gradually. These and other techniques are becoming familiar to web users.
4.2. JavaScript Disabled
If a user has disabled JavaScript no JavaScript will be executed and certainly no Ajax requests will be sent. A site that relies too heavily on JavaScript will be crippled if the user disables JavaScript, Gucci is an example of this. This site used to show a blank white page if a user browsed to it after disabling JavaScript. Now it explains that you need to have JavaScript enabled to use the site.
A site that relies on JavaScript for core functionality restricts its users to those who have JavaScript enabled. Having said that we should look at how many users are allowing JavaScript to run in there browsers. The following statistics from The Counter show JavaScript statistics.
Thinking in Rails – Part 1 July 10, 2008
Posted by darynholmes in Ruby on Rails, Tutorials.Tags: Ruby on Rails, Tutorial
7 comments
In this part we look at the basic set of requirements for our text editor. I have no doubt that these requirements will change, but let’s have a quick look to get an idea of the direction we are heading in.
Text Editor Requirements
As mentioned in part 0, the text editor is going to be a very basic editor. It will maintain a version history that will allow users to roll back to a previous version of a document. This requirement is what will make this task interesting and worthwhile.
We would like to end up with screens similar to this:
The documents index page:
Thinking in Rails – Part 0 July 10, 2008
Posted by darynholmes in Ruby on Rails, Tutorials.Tags: Ruby on Rails, Tutorial
1 comment so far
This is ‘part 0’ as it is an explanation of the tutorial, no Rails code is covered in this part – I still need to write the code. This post explains what you can expect to see in future parts of this tutorial. If there is a topic you would like me to cover then please feel free to make a request…
What is the purpose of this tutorial?
Ruby is not just another OOP language. It has many idioms and constructs which seem foreign at first. Once a developer becomes familiar with these aspects the developer tends to program in a new way – the once foreign code starts to feel very natural.
Moving from Java or .Net to Ruby (and Ruby on Rails) is a challenge, but it is worth the effort. Once you start thinking in the Ruby and Rails way code starts falling into place. To cross the conceptual chasm you need to read many articles, books and as much code as you can. This tutorial aims to assist you as you crossover. Use it as a stepping stone on your path to the land of the ducks.
How did this tutorial come to be?
This tutorial is a spin-off from the ‘Routing in Rails’ tutorial. The ‘text editor’ application covered here was originally intended to be the practical section of part 6. I started developing the application and soon realised that the actual routing work was very small, and was being lost amongst the rest of the code. I felt that the application still covered many useful topics, therefore I decided to move it into its own tutorial – and here it is.
Short-listed!?! July 8, 2008
Posted by darynholmes in General.Tags: blog awards, computer weekly
add a comment
About a week ago I noticed some incoming links from Computer Weekly.com. I assumed that someone had commented on one of my posts, so I browsed there wondering if it was a positive or negative comment. Once the page loaded, I was completely surprised. It turns out that this blog has been short-listed for the Computer Weekly.com IT Blog Awards! This came as a complete surprise to me.
This blog had really humble beginnings. In fact it was not even my idea to start a blog, it was my work that encouraged me to start one. Initially I felt that I did not have that much to contribute to the world at large. In fact I still don’t feel that my blog is as innovative as some others, although judging by the response to my ‘Routing In Rails Tutorial‘ it appears as if I do have a nice way of explaining things. I guess this is one of the main reasons I have been voted onto the shortlist.
The competition ends on the 31st of July 2008. If you would like to vote please go to this on-line voting page. This blog can be found under the ‘Programming and technical blogs’ drop-down list. It is a surprisingly painless exercise, it takes less then a minute and no registration is required.
Thank you to all of you who have voted for this blog.
Daryn
Beginners Tutorial: Routing in Rails 2.0 (with REST) – Part 6 of n July 6, 2008
Posted by darynholmes in Ruby on Rails, Tutorials.Tags: Beginner, Routing, Ruby on Rails, Tutorial
30 comments
In part 5 we looked at RESTful routing. In this part we continue to explore RESTful routing, by examining nested resources.
I originally planned to cover nested routes and to cover two questions posted to me in previous comments and emails. One question was with regards to ‘one to many relationships’ e.g. an album has many songs. The second question was from Tom in part 3; this was about adding save as functionality.
In trying to answer these questions I created a new application – a text editor with a version history. This has turned out to be a fairly interesting piece of work. I then changed my mind and decided to include it in a follow up post. I am hoping to have that out later this week (before Friday the 11th of July). As the ‘follow up’ post will have a practical example of nested resources, this post will not have the usual practical section with the experiments.
Part 6
Introduction to Nested Resources
The Nested URI
Returning to the familiar Music Store application, imagine we added songs to the application. Like Albums, Songs are resources and we could expect to access a song with this URI:
/songs/124
We could then perform the required CRUD operations on that URI based on the REST API as discussed in part 5.
An album has many songs. We can express this within the URI e.g.
/albums/10/songs/124
Once again we could make use of the HTTP verbs to perform CRUD in a RESTful way.
In this particular implementation, this URI does not mean that this is the 124th song of album 10 - it is possible for it to be the fist song of album 10. The URI is pointing to the 124th song in the system.
If we wanted the URI to state the song\track number of the specified album then we could alter the above implementation. Then we could expect to see URIs of:
/albums/10/songs/5
and
/albums/11/songs/5
This would not result in a URI conflict.
Programming While Stupid June 21, 2008
Posted by darynholmes in General.Tags: lean software development
5 comments
Over engineering is a major problem within the software industry. This problem has led to the adoption of ‘lean software development’ – at least amongst the agile folk. Lean software development is writing code to support the current set of requirements and nothing more. This is not as easy to do as one might think.
As developers we naturally tend to make assumptions as to what the user, or system, will need. In truth, it is very difficult to accurately predict the future requirements of a system. Coding to meet our assumptions will inevitably lead to over engineering.
We should not let our intuition guide us into false requirements. As strange as it may sound, it takes a concious effort to stop ourselves from doing extra work. We need to adopt a ‘lean coding culture’. We need to constantly remind our selves to stick to lean software development. In agile teams it is common to hear developers reminding each other with certain acronyms and expressions e.g. ‘do the simplest thing that works’.
‘Do the simplest thing that works’ is in-line with lean software development, although it can be misleading. Some people interpret this as ‘do the first thing that comes to mind’ e.g. slap on another if statement – that is a simplistic solution and not a simple solution. If you take a quick and dirty simplistic approach you will end up with a big ball of mud. You need to do the simplest thing that works. The thing that works is something that can be tested, it is something that does not add unnecessary complexity. Therefore the simplest thing that works is not necessarily the quickest and easiest thing to do.
Beginners Tutorial: Routing in Rails 2.0 (with REST) – Part 5 of n May 26, 2008
Posted by darynholmes in Ruby on Rails, Tutorials.Tags: Beginner, Routing, Ruby on Rails, Tutorial
46 comments
In part 4 we explored named routes. In this session we move onto Rails’ REST.
Part 5
The Critics
Before we begin you should know that there are many critics of the Rails implementation of REST. There are many reasons for arguments against Rails’ REST e.g. Rails uses server side session state and client side cookies. Some people say that this is not REST compliant. Rails’ REST might not be 100% REST compliant, but you can still benefit from using REST in your Rails applications. In The Rails Way, Obie Fernandez explains that the benefits from using Rails’ REST fall into two categories:
- Convenience and automatic best practices for you
- A REST interface to your application for the rest of the world
Therefore it is worth learning and using Rails’ REST.
The Standard Introduction
Representational State Transfer (REST) is an architectural style. It was first introduced by Roy Fielding in his PhD thesis. Roy Fielding is one of the principal authors of HTTP.
The Mindset
When developing a Rails application in the RESTful way it helps to change your mindset. You should not think that you are developing a web site for users accessing the site via a browser. It is better to think of the application as being a service. The service performs actions for clients. These clients may be humans or other machines on the network.
This service will typically be placed on the internet. Therefore we could call it a web service. When I hear the term web service I immediately start thinking about SOAP and all the WS-* specifications. Let’s be clear, we are not talking about ‘those’ web services. We are talking about RESTful web services. These two technologies provide similar functionality, but RESTful web services are simple and sensible.
The Terminology
As previously stated, programming in REST requires a change in the way we think about the system. This naturally leads to a change in the way we talk about the system. The following provides a brief description of some of the key terms used in discussions about REST and HTTP.
A resource is one of the key concepts in REST. Many discussions on REST claim that a resource is anything and everything. This is neither true nor helpful. Let’s examine this concept with the aid of an example.
Let’s assume that the music store has started selling albums. The database may have the following schema:
The data in the database is the raw data. There is data which, given in isolation, is of no real value to a client. For instance it is unlikely that a client will want only one row from the LineItems table. This means that a LineItem (on its own) is not a resource within the context of the music store service.
A client would want all the information pertaining to an order. This would include data from one or more tables. Some data would not be included e.g. database keys. Some information may be added e.g. the total cost of the order might be calculated and included in the ‘order information’. This ‘order information’ is an example of a resource. Order resource is the type, there will be one order resource instance for each order made.
Each resource must be given a globally unique identifier. This is done using a URI. This could look like this:
http://www.example.com/orders/65
A client, in an admin role, may want a list of all the orders. This collection of orders would be another resource. Following the REST architecture, the orders resource would be assigned the following URL:
http://www.example.com/orders
It is important to note that these resources are not HTML documents. Roy Fielding describes a resource as a conceptual mapping. As a resource is a conceptual entity it can not be used by a client. The service provides the client with a representation of the resource.
When the client is a browser, the service typically provides an HTML representation of the resource. If the client is another machine then the service may provide an XML representation of the resource. Other representations could include a PDF file, an image, csv etc. A representation is only supported by the service if it is applicable and required.
Resources are often referred to as nouns. This is often done when talking about HTTP to assist learning. The term ‘noun’ is more abstract. For our purposes, resources and ‘nouns’ are synonymous.
HTTP also has the notion of verbs. These are the HTTP operations. We are all familiar with the POST and GET operations. In addition to these two operations, HTTP also supports: DELETE and PUT.
There are a few more terms to cover, but we can do that later. The core terms have been explained.

