Continuous data protection for programmers

November 13th, 2009 Peter Molyneux 3 comments

We neglect it
Programmers today are familiar with Source control management, such as GIT, Subversion or Visual SourceSafe. We understand the importance of it and almost all of us use it.
CDP (Continuous Data Protection) on the other hand is most often neglected. This article aims to explain why Continuous Data Protection is so important and how it can help programmers in their daily work. I will also try to include real life examples from my own experience.

Use them all

CDP isn’t a replacement for Source control or regular backups. I recommend you to use it all. If you are a team of developers, I would suggest that each user has it’s own continuous backup or local file versioning for easy access to old files, then you need a Source Control Management system of some sort with a repository placed on a server, and finally a backup software that backs up the entire server.
On the other hand if you are a “One man team” you will get quite far without the Source Control, and just stick to CDP and regular backups.

What Source control does

  • When 2 or more people work on the same project an SCM helps you merge you changes without destroying each others work.
  • SCM’s let you label your files at any given time. A typical label could be “Version 1.1.4 (just shipped to customer X)”. Such a label enables you to go back later on and see what was actually shipped to customer X.
  • Source control is a good way to keep a backup of your code.


What Source control doesn’t do

  • SCM’s don’t keep track of all the changes you make to files. They only register changes when you do a “Commit”.

So basically, Source control is vital for programmers, but it isn’t enough. Since it lacks Continuous versioning of you files.

Why do I need continuous versioning?
As a programmer you always run in to situations where you have to redo work or you simply regret changes you made. The “undo” functionality is vital to any programmer. But ever so often “Undoing” isn’t enough. Lets give a couple of examples:

  • You are doing some bold refactoring, and the changes you make soon start to spread. After a while you have made changes to say 20 files and still haven’t got it to compile. You wish you had made a “Check in/Commit” before you started making the changes, but it’s a bit late for that now. Luckily you finally get it all to work though and you can continue with your other tasks. Some hours later you realize that the changes you made weren’t good, and you need to go back to the old solution…tough luck :(
  • You make changes to some GUI stuff in Visual Studio, and suddenly you can’t even open the GUI editor. “Undoing” doesn’t work. In the end the only solution is to go back to an old version and catch up with unsaved changes… tough luck :(
  • Here is another real life situation that I often find myself in. You continue work with a project that you haven’t been working on for several days, and can’t remember what you did last. Open your Continuous file versioning software and you can easily see what files were moderated last, how frequently they were changed and what was changed. Now it’s easy to remember what you were doing and to get back to work fast.
  • Sometimes when you rewrite an entire function you might “comment out” the old one. Why do you do this? Probably because you know that you might regret your changes or need parts of the old function in the future. This in itself is proof that you should be using some kind of continuous file versioning. The following day you might delete the “out commented” code thinking that you now know that you aren’t going to need it again, only to realize a couple of hours later that you actually do need it.

Basically continuous data protection saves you time, and makes life as a programmer just a bit more satisfying. It lets you work faster, make bolder changes to your code and helps you feel secure.

What we need from the CDP software
Once you start using file versioning you are going to use it more and more. It is quite normal to use it on a daily basis. This makes certain demands on the CDP software. It’s main job isn’t to take backups of your files (as a backup software is) neither is it to let you set labels and merge files as in Source control. Rather it’s most important job is let you easily look at old files or rewind files. And to be able to do this it needs to give you overview, it must be easy for you to see what has been going on: when were your files modified? what other files were modified before or after that? What was modified in the file?

What is History Explorer?
I’ve been looking for a software that gives you good overview of what has been going on, but I have failed to find anything. So I took on the challenge of creating the best continuous data protection software for programmers – History Explorer. History Explorer is easy to use, it’s a one user software and should be installed on each programmers computer, there is just about zero configuration. History Explorer is the only software that gives you a graphical overview, you can see when you files were changed as marks on a timeline, and most important of all you can look at a whole folder at once and see when changes were made in relation to other changes. I use History Explorer and love it. There are alternatives out there and the most important thing for you is to start using something…now. Once you get used to it your programming will be helped a lot.

Thanks for taking time to read this article. I really hope it helps you in your work.

Cheers
Peter Molyneux
Exendo

The best database for desktop applications

October 28th, 2009 Peter Molyneux 2 comments
desktop database - hands on

desktop database - hands on

This is a – hands on – practical article that will help you get started with desktop development in no time. I will tell you which is the best desktop database that you can use and what tools you should use with it and I will give you code and examples that will help you get it all up and running.

Not the only truth
First of all no one can tell you what database is best, since it is a matter of taste and very much depends on your demands. But to make it easier for you I am going to tell you what to use without much discussion. I wont recommend anything that demands a lot of configuration. All the tools are simple to install and use. Neither will I recommend any database that forces you to use text commands instead of a graphical user interface.

When I started developing one of my projects I did some research to find a suitable database. I did a lot of reading, downloading and testing, until one day I stumbled upon SQLite, which has been just great for so many reasons.

There are many alternatives like Microsoft Access, SQL CE, VistaDB, MySQL and many more. But none of them come close to SQLite when looking at the whole picture of development and distribution.

Why SQLite?
So why is SQLite so good?

  • SQLite is fast, it isn’t fastest, but not far from it.
  • SQLite is small, it’s only about 0,5 Mb (not that size matters that much)
  • SQLite is free
  • SQLite is well established, stable and competent.
  • SQLite has a big community, there is a lot of help on the web.
  • There are a lot of good and free tools for SQLite
  • SQLite doesn’t need to be installed
  • SQLite databases are contained in one file

The last points are really the most important ones. SQLite doesn’t need to be installed, there is no need for a server, and SQLite doesn’t need to be “running” for it to work. So what does all this mean? If you have created a small application you could put it on a CD or a flash drive. For the application to access the database it needs SQLite wish simply is a dll file that should be placed next to the application in the same folder. Then the application needs the database itself, and that is also a file that could end up in the same folder as the rest of the files. The fact that the database is contained in a file means that it easily can be moved, copied or emailed without any hassle. File contained databases are also great for any file orientated applications such as Excel, Word or any other application where you can simply double click on a file to actually start the program, and all the data needed is contained in that single file.

SQLite and .Net (Visual Studio)
So lets get to work. I use C# for my development, I find it to be a good base for application development. If you use .Net and SQLite there are some wrappers and tools that you can use. What you really need though is simply System.Data.SQLite. Download it and place it in some folder on your computer. Then reference it from your .Net project. System.Data.SQLite is SQLite for .Net, it delivers a dll that should go along side you exe when you distribute your application. It replaces the normal sqlite.dll with one specially made for .Net.

SQLite GUI (administration tool for the developer)
When developing you need some kind of administration tool so that you easily can view and alter databases. Since SQLite is nothing more than a dll, you have to look elsewhere for the GUI. Now there are a lot of good free alternatives out there, I have settled for one that I find simple and clean SQLite Expert. Try it out, install it, run it, add a few tables and save the database. Now remember, that this is a tool for your own administration, Visual Studio will never need to know anything about SQLite Expert, nor will you need to include anything extra when you create an installation and distribute your application. The only thing of interest is the file you save – the actual database.

Now you already have all you need to work swiftly and efficiently with database orientated software development.

A small wrapper for C#
You don’t need a wrapper, it is easy enough to work directly with System.Data.SQLite. However I found a wrapper that somebody had made, and then I configured it to my taste.
It does actually make life a bite easier. Here are a few lines from the wrapper:

public SQLiteWrapper(string dbFile)
{
    mBaseName = dbFile;
    OpenDatabase();
}

private void OpenDatabase()
{
    if (mInTransaction)
        return;
    string connectionString = "Data Source=" + mBaseName;
    mConnection = new SQLiteConnection(connectionString);
    mConnection.DefaultTimeout = 0;
    mConnection.Open();
}

The whole file is included in the sample code.

Sample code
Finally I want to end this by being as practical as possible. I have attached a complete C# project for you to compile and run: SQLite Example. By doing so you can easily see how everything works. I have also included the SQLite database dll and a small sample database that the sample application works against. The sample simply lists the contents of  a table in a grid and allows you to modify the data. It uses straight forward SQL queries as SELECT and INSERT, just to keep it simple and informative. The SQL wrapper returns data in List<string> which makes it easy to work with. If you prefer you could easily use a DataTable or the Visual Studio graphical support for connecting tables to data sources. You could even use LINQ if you are used to that. Finally if you want to check out the database of a real world application, Download History Explorer – Source control for one man teams and open the database that is placed in the App folder.

Small word of advice to avoid speed issues
There is one important thing that I missed in the beginning and that gave me speed problems. When doing several INSERTs or UPDATEs in a row you will notice that SQLite is very slow. The reason for this is that it needs to copy data whenever you modify the database so that it can do a rollback if something goes wrong. All you have to do tone user to avoid this problem is to call BeginTransaction() before all of your updates and then EndTransaction when you are ready.

Multi users / multi threading
SQLite is really a one user database. But I and many others use it in situations where many people access the database. It’s really quite simple and the wrapper I mentioned earlier contains this simple support. SQLite will lock the database whenever it is modifying it or when it is in a transaction. So if several users/threads are accessing the database it could be locked when you need it. But since SQLite is fast it probably won’t be locked for a noticeable amount of time. So add a “try catch” around your command, if the database is locked just wait for 0,01 seconds and try again. But then again, just use the wrapper, it already has that code in it.

Installing and deploying your application on a customers computer
As mentioned earlier this is one of the strengths with SQLite. You don’t need to install anything on your customers computer. You could basically let them run it all off a flash drive or CD. But normally you would want to make an installation of some sort. All you do is include the sqlite dll along side your exe file and that is it. You might also want to include or create a database file, but that can be placed anywhere.

So, hopefully this is all you need to get up and running. If not, do comment .)

Cheers,
Peter Molyneux
Exendo

Categories: Software development tools Tags:

The importance of avoiding expenses

October 16th, 2009 Peter Molyneux No comments

Count your cash
Are you starting up a Micro ISV? If you are you might not even of heard of the term before. A Micro ISV is basically a small one man business that develops and sells software.
Many of the shareware products on the web are actually produced by Micro ISV (guys like you and me).

When you start up you might just focus on producing the software itself. This is fun and can sometimes go fast, but as you will notice, programming the software is far from all the work. There are a lot of other aspects that you might find more or less inspiring along the way. This also means that there are a lot of places to put your money along the way. You need to keep it simple and keep it cheap.

When developing software you can pay for your development environment, you can pay for graphics, database, installation building software, GUI tools, license managing software and much more.

Keep it clean, simple and cheap or you will never make it to the end. When developing History Explorer I had decided to keep my expenses close to zero. But I did choose to pay for some services as I will let you know about in later posts.

If you expect to earn some cash on the software you produce, you will still want to hold on to your cash, It might well take some time before you see any cash rolling. The most important thing to avoid are the reoccuring costs. So avoid any monthly or annual licenses and find the low one time expences if you have to put in money. You might also need to market your product, spend some to get some, so save it for then.

It is quite thrilling to see how you can proceed step by step with out actually spending a lot of cash. Here is one example, I have worked at several companies that spent tons of cash on having an external part come in and design a logo for the company. Now your logo is important, but you can get good results for free.

If you have some graphical skills you can sit down with Word or with Paint.net and design a logo. If your skills are limited keep it simple and clean. When you are done ask a couple of honest friends what they think, since you most often can’t rely on your own judgement.
And if you feel that you can’t make it ask a friend to help you out, and if all else fails you are going to have to outsource it, but ther are designers out there who do a good and cheap job.

Good luck,
Peter

Categories: Micro ISV Tags:

In the beginning…

October 14th, 2009 Peter Molyneux No comments
How History Explorer came to be.

peterFor a long time I had been irritated at the way backup software never seemed to be quite what I wanted. I had this image of a program that graphically showed me all the versions of files that it contained and where I could simply click on any file to open it. Most backup programs demand that you do some kind of restore and you are never quite sure if you are going to lose your existing files.

During 2007 and 2008 my wife and I were in Cambodia doing some work for a NGO. I suddenly had a bit more time in afternoons and evenings and I started to think that maybe I could build that software that was at the back of my mind…

So I set out programming, looking for tools, creating a web site and all the things that need to be done when creating real software. I guessed the project would last a month or so… and here I am today, still going strong :)

History Explorer was released over a year later and since then I’ve continued improving and marketing it.

In these articles I hope to share some of my experiences and thoughts related to software development and marketing software.

There is som information on the philosophy and background of the company that you can read on this page.

Categories: Background Tags: