Firefox v1.0.1 released


Security update for Firefox to prevent phishing attacks.

Advertisements

Google AutoLink

The Google toolbar v3 (beta) includes a new feature called AutoLink. This essentially means that if it recognises an address, ISBN number, VIN number it can create a link in the HTML you see linking to a map, amazon, or VIN tracking site respectively.

A lot of bloggers are getting upset at this because it changes the webpage.

1. It doesn’t change the webpage, it changes the way that the user with Google Toolbar v3 BETA installed sees the webpage.

2. Surely the issue of changing your webpage is as intrusive as an advert which overlays your webpage and obscures the original content.

3. It’s your choice, if you don’t like the feature switch it off. If you don’t like the Google Toolbar, uninstall it (or use a different browser). Microsoft Word comes with a spell checker switched on by default underlining incorrectly spelt words, however based on the number of badly spelt documents around it seems people switch that feature off without griping!

4. It’s a BETA product. This means that Google are inviting people to download, play and comment on their product before they decide on a final implementation.

5. If the page author had added the links on the page already then Google wouldn’t need to add them! The number of times you visit a page to get an address and then have to go and get a map just because the author didn’t have the foresight…

6. Google is a commercial company, why shouldn’t they make money out of a free piece of software? There are many other toolbars out there from the other big players, get one of those instead.

Quick guide to nHibernate

nHibernate is a .NET port of the Java Hibernate system. The Hibernate system has been around for years in the open-source community. For this blog the terms are interchangeable.

Hibernate is a system that lets you persist your business entity objects into a persistent storage medium (database normally). So you write your business entity object, give it state and behaviour and then define an Xml file which instructs Hibernate on how to persist the class. (You could persist the class by serialising it, either to Xml or binary, but that only maps well to an object database, and even then it’s not ideal.)

With Hibernate you can define a table Employee, and a class Employee. The fields in the class persist into the columns in the table. All with a simple mapping file and a few method invocations.

You can also model relationships between your tables and classes. For example, an employee may work in a department so you define your Department table, model the FK/PK relationship in the DB, set the relationship in your Xml mapping file and voila, you have a collection class of Department objects available as a property of your Employee object.

Onto an example…

Department 0..* Employee
Employee *..* Computer

In the database, the tables are:

Employee: EmployeeId, Name, DepartmentId
EmployeeComputer: EmployeeId, ComputerId
Computer: ComputerId, Model
Department: DepartmentId, Name

In the code, the classes (public fields for ease of explanation):

[csharp]
class Employee {
public int Id;
public string Name;
public Department Department;
public Iesi.Collections.ISet Computers;
}

class Department {
public int Id;
public string Name;
public Iesi.Collections.ISet Employees;
}

class Computer {
public int Id;
public string Model
public Iesi.Collections.ISet Employees;
}
[/csharp]

Our user code can use syntax such as

[csharp]
Employee james = EmployeeFactory.GetStudent(1);
Console.WriteLn(“James is a member of the {0} department”, james.Department.Name);
Console.WriteLn(“James has {0} computers”, james.Computers.Count);
Computer newPC = new Computer();
newPC.Model = “P5”;
james.Computers.Add(newPC);
EmployeeFactory.SaveStudent(james);
[/csharp]

Our factory here has encapsulated the functionality of talking to the nHibernate classes. Let’s investigate that now.

[csharp]
class EmployeeFactory
{
private Configuration _cfg = null;
private ISessionFactory _factory = null;

public EmployeeFactory()
{
_cfg = new Configuration();
_cfg.AddAssembly(“Hibernate”);
_factory = _cfg.BuildSessionFactory();
}

public void GetEmployee(int id)
{
using (ISession session = _factory.OpenSession())
{
return (Employe)session.Load(typeof(Employee), id);
}
}

public void SaveEmployee(Employee employee)
{
using (ISession session = _factory.OpenSession())
{
Transaction tx = session.BeginTransaction();
session.Update(employee);
tx.Commit();
}
}
}
[/csharp]

So the only thing left is the Xml mapping files which instruct nHibernate how to map the C# classes onto the database tables. For each C# class we need an Xml file:

Employee.hbm.xml

[xml]

[/xml]

Department.hbm.xml

[xml]

[/xml]

Computer.hbm.xml

[xml]

[/xml]

Related articles:
http://www.theserverside.net/articles/content/NHibernate/NHibernate.html
http://www.theserverside.net/articles/content/NHibernateP2/NHibernateP2.html
http://www.xylax.net/hibernate/index.html
http://www.tobinharris.com/nhibernatefaq.aspx

Recommended travel sites

A couple of the travel sites I use…

http://www.skyscanner.net/ – good for seeing flight prices across different providers without irritating advertisers getting in the way. They also have a view showing prices for a destination across a month so you can go when it’s cheapest. (Europe only)

http://www.seat61.com/ – train travel across the UK and Europe. How to get from the UK to most European destinations by train, approximate times and prices, and how to book.

http://www.traveline.org.uk/ – public transport in the UK. Good to find out a public transport website in an area you are visiting.

DARPA Grand Challenge 2005

In July 2002 DARPA (Defence Advanced Research Projects Agency) in the USA announced a competition to push the development of autonomous vehicles. The aim was to build a vehicle capable of travelling 150 miles without human intervention across the Mojave desert in Arizona.

This happened in March 2004 and there’s a hilarious summary of what happened here.

Make a note in your diary because the 2005 Challenge is just kicking off. Let’s hope that my favourite entrant, the Ghostrider Robot (a motorbike!) has more luck this time.