No addresses in databases

I thought it would be a good idea to write this rule down in hopes that I never get bit by it again.

The rule: Never store addresses in databases.

If you do, the databases then can’t be moved to different folders, machines or operating systems, because addresses in Frontier contain hard-coded file names. This was a design mistake we made many years ago. It’s reality. Accept it.

Luckily there’s an easy way to get the functionality of addresses without storing them.

Convert the address to a string using string.popFileFromAddress.

Then when you want to use the address in code, coerce it to an address. It will then be converted to point to the location on your machine in the syntax of your operating system. Use these addresses in memory as much as you want, just never store them in a database that you might want to move some day. That is, never store them in a database.

I caught this one in the Scripting2 project before there was an installed base. I was storing addresses to the previous and next posts as real hard-coded addresses. Wrote a simple script to convert them. Back on track.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: