My digital notepad RSS 2.0
 Tuesday, September 01, 2009

Just a quick note, as much to my self as anyone else. I’m getting started with Git and wanted to use notepad++ as the editor for commits.

So I followed some basic instructions and tried setting it up like this:

git config --global core.editor "c:\Program Files (x86)\Notepad++\notepad++.exe"

and got this:

c:\Program Files (x86)\Notepad++\notepad++.exe: -c: line 0: syntax error near unexpected token `('
c:\Program Files (x86)\Notepad++\notepad++.exe: -c: line 0: `c:\Program Files (x86)\Notepad++\notepad++.exe \$@\'
error: There was a problem with the editor 'c:\Program Files (x86)\Notepad++\notepad++.exe'.
Please supply the message using either -m or -F option.

Helpful…

 

Different variations yielded the same results:

git config --global core.editor '"c:\Program Files (x86)\Notepad++\notepad++.exe"' 
git config --global core.editor 'c:\Program Files (x86)\Notepad++\notepad++.exe' 
git config --global core.editor "'c:\Program Files (x86)\Notepad++\notepad++.exe'" 

Until this Stack Overflow answer pointed me in the right direction:

git config --global core.editor "'c:/Program Files (x86)/Notepad++/notepad++.exe'"

So, keep those slashes going the right way

 
Tuesday, September 01, 2009 8:32:04 AM (Central Europe Standard Time, UTC+01:00)  #    Comments [0] -

 Sunday, February 15, 2009

A few days ago I started trying some frameworks for maintaining my database migrations in code. I tried Migrator.NET and it didn’t quite ring with me. Now, I’ve been trying RikMigrations which I initially liked better.

RikMigrations does the same as Migrator.NET, it allows you to define your database in code and define the migration steps to bring a database from one point in the development to another, and back again.

   1: public class Add_Event_Table : IMigration
   2: {
   3:     public void Up(Schema db)
   4:     {
   5:         Table t = db.AddTable("Event");
   6:         t.AddColumn<int>("ID").PrimaryKey().AutoGenerate();
   7:         t.AddColumn<string>("Name", 256).NotNull();
   8:         t.Save();
   9:     }
  10:     public void Down(Schema db)
  11:     {
  12:         db.DropTable("Event");
  13:     }
  14: }

Each migration step is a class implementing the IMigration interface: an Up() and a Down() method. Those methods contains the steps to move the database forward or backwards in the development, respectively. I haven’t used Ruby on Rails but from what I’ve seen, much of the inspiration from RoR.

The advantages for a tool like this is that your database is under source control, it’s easier for multiple developers to work on the same code and make changes to the database and you can roll back the database to a known state and point in time. You can also use it to deploy changes to the database into a test, QA or even production environment.

You add multiple classes for multiple migrations and specify the order of the migrations in assembly directives:

   1: [assembly: Migration(typeof(Add_Event_Table), 1)]
   2: [assembly: Migration(typeof(Alter_Event_Table_Add_start_and_end_date), 2)]
   3: [assembly: Migration(typeof(Alter_Event_Table_Add_Description), 3)]
   4:  
   5: namespace GeekBeer.Data.DBMigration {
   6:     public class Add_Event_Table : IMigration
   7:     {
   8:         public void Up(Schema db) ...
   9:         public void Down(Schema db) ...
  10:     }
  11:  
  12:     public class Alter_Event_Table_Add_start_and_end_date : IMigration
  13:     {
  14:         public void Up(Schema db) ...
  15:         public void Down(Schema db) ...
  16:     }
  17:  
  18:     public class Alter_Event_Table_Add_Description : IMigration
  19:     {
  20:         public void Up(Schema db) ...
  21:         public void Down(Schema db) ...
  22:     }

(method implementations removed for clarity)
 
I can run my migrations from code, for instance in this ASP.NET MVC project I just ran the migrations in the Global.aspx file, so that my database was always up-to-speed (I wouldn’t recommend this for a production application). I could
 
   1: protected void Application_Start()
   2: {
   3:     // Run the database migrations, making sure that the database is up to speed. 
   4:     var rootWebConfig =
   5:         System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/");
   6:     var connString = rootWebConfig.ConnectionStrings.ConnectionStrings["GeekBeerConnectionString"];
   7:     Data.DBMigration.MigrateDatabase.Migrate(connString.ConnectionString);
   8: }
   9:  
  10: public class MigrateDatabase
  11: {
  12:     public static void Migrate(string connectionString) {
  13:         DbProvider.DefaultConnectionString = connectionString;
  14:         DbProvider db = new MssqlProvider(null);
  15:         MigrationManager.UpgradeMax(Assembly.GetExecutingAssembly(), db);
  16:     }
  17:  
  18: }

Works like a charm.

Is it useful?

Short answer, for me personally: No. YMMV.

I’m pretty comfortable with creating and changing SQL tables, columns and relations in SQL Management Studio. I’m not that comfortable with doing it in what’s effectively a new DSL for creating and editing databases. It adds friction that I don’t need and I don’t really see the need to learn a new language for SQL editing. SQL does that job pretty well and with SQL Management Studio I can use designers and have my change code generated for me (though it’s not always that nice code…)

It would most likely get easier over time, most likely, but I have other things I feel is more important to learn. There are also things that are not easily expressed in the current API, such as indexes.

This is also a problem with Migrator.NET which I tried last time.

The concept of database migrations is still interesting to me though, but I think I’m going to go for one of the solutions that uses plain SQL scripts for the migration. I think I’m going to try DBDeploy.NET next.

 
Sunday, February 15, 2009 1:53:52 PM (Central Europe Standard Time, UTC+01:00)  #    Comments [0] -

 Thursday, February 12, 2009

Today I tried to find a good way to include the SQL schema in my code and thus in source control. Having bookmarked a couple of frameworks in the past I finally got the change to look closer at some.

Migrator.NET

This seems to be the fairly well maintained, it has commits in the past month and lots of patches in the discussion group, which is good. A few typos in the documentation wiki that were pointed out months ago without being fixed is not so good. Also, the documentation assumed some features that were only present in the source tree, not in the release package.

The API interface leaves me somewhat lacking

   1: Database.AddTable("Event",
   2:     new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
   3:     new Column("Name", DbType.String, 
   4:         ColumnProperty.Indexed | ColumnProperty.NotNull),
   5:     new Column("StartTime", DbType.DateTime,
   6:         ColumnProperty.Indexed | ColumnProperty.NotNull),
   7:     new Column("EndTime", DbType.DateTime, ColumnProperty.Null)
   8: );

I would have wished for a more fluent interface, but it works.

Each migration is a class, inheriting from Migration and implementing the Up() and Down() methods. It uses class attributes to figure out the order of the migrations and if they have been run.

   1: [Migration(20090211235701)]
   2: public class AddEventTable : Migration {
   3:     public override void Up() {
   4:  
   5:         Database.AddTable("Event",
   6:             new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
   7:             new Column("Name", DbType.String, 
   8:                 ColumnProperty.Indexed | ColumnProperty.NotNull),
   9:             new Column("StartTime", DbType.DateTime,
  10:                 ColumnProperty.Indexed | ColumnProperty.NotNull),
  11:             new Column("EndTime", DbType.DateTime, ColumnProperty.Null)
  12:         );
  13:       
  14:     }
  15:  
  16:     public override void Down() {
  17:         Database.RemoveTable("Event");
  18:     }
  19: }

Information about which migration have been run against a database is stored in a SchemaInfo table.

The database must be created in advance since the migration tool connects to the database before running any migrations scripts.

Migrations.NET support several databases, including MS SQL, Oracle, MySQL and SQLite.

One problem I had was that ColumProperty.Indexed does not work and there is no way to add an index to a table without adding custom SQL, thus negating some of the db-independence.

In the end, I’ve come to the conclusion that it’s nice, but missing some features and that I don’t really like the API. Putting it aside for now.

Rikmigrations

Rikmigrations uses the same Up()/Down() pattern but with a slightly different API interface that I liked better. Here, the attributes are set on the assembly level instead of the class level. I liked the class attributes from Migrator.NET better, but this works too.

   1: using RikMigrations;
   2: [assembly: Migration(typeof(BlogMigration1), 1)]
   3: [assembly: Migration(typeof(BlogMigration2), 2)]
   4: namespace Blog.Migrations
   5: {
   6:   public class BlogMigration1 : IMigration
   7:   {
   8:     public void Up(DbProvider db)
   9:     {
  10:         Table t = db.AddTable("Blog");
  11:         t.AddColumn("ID", typeof(int)).PrimaryKey().AutoGenerate();
  12:         t.AddColumn("Name", typeof(string), 64);
  13:         t.Save();
  14:     }
  15:     public void Down(DbProvider db)
  16:     {
  17:         db.DropTable("Blog");
  18:     }
  19:  
  20:   }
  21:   public class BlogMigration2 : IMigration
  22:   {
  23:     public void Up(DbProvider db)
  24:     {
  25:         Table t = db.AlterTable("Blog");
  26:         t.AddColumn("Description", typeof(string), int.MaxValue);
  27:         t.Save();
  28:     }
  29:     public void Down(DbProvider db)
  30:     {
  31:         Table t = db.AlterTable("Blog");
  32:         t.DropColumn("Description");
  33:         t.Save();
  34:     }
  35:   }
  36: }

 

It has some cool features like using generics to specify the data types:

   1: Table t = db.AddTable("Blog");
   2: t.AddColumn<int>("ID");
   3: t.AddColumn<string>("Name", 64);
   4: t.Save();


and inserting default data into a table:

   1: db.InsertDataInto("Table1", new { ID = 1, Name = "Hello World" }, true);


It looks like it’s also missing the feature to add an index, but from what I’ve glanced at the code, it shouldn’t be that hard to implement (this might just come back to haunt me…)

The documentation isn’t much and what little there is seems to be pretty old, but the code doesn’t look that hard to just figure out so I don’t think it will be much of a problem.

I didn’t get a chance to try this today but tomorrow I’m going to take it for a spin. There’s a couple of others I’d like to try as well. Watch this space for more.

 
Thursday, February 12, 2009 12:58:58 AM (Central Europe Standard Time, UTC+01:00)  #    Comments [0] -

 Wednesday, February 11, 2009

Last week I talked at NNUG Stavanger about the SOLID principles and after Fredrik had his TDD talk I had a small talk about BDD. The slides I used are below, you can download them from Slideshare as well. They are licensed under Creative Commons BY-NC-SA.

Some slides from the SOLID presentations doesn’t show right in the Slideshare viewer so if you find it interesting you might want to download it.

Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.

 
Wednesday, February 11, 2009 7:52:29 PM (Central Europe Standard Time, UTC+01:00)  #    Comments [0] -

Guinness Vi kopierer suksessen de har hatt i Oslo og arrangerer GeekBeer i Stavanger.

Onsdag 4. mars, kl 19:00 på Timbuktu

Kommenter gjerne her hvis du har tenkt å bli med, ellers kan jeg kontaktes på glenn krøllalfa henriksen punktum no eller på Twitter som @henriksen.

Det er ingen krav til deltakerene men det er en fordel at du er sånn passe interessert i utvikling. Om det er i .NET, Java, PHP, Ruby eller noe annet er det samme.


image Vi organiserer, du står for din egen drikke.

GeekBeer er også på Facebook så du kan melde deg på der og!

 
Wednesday, February 11, 2009 1:00:22 PM (Central Europe Standard Time, UTC+01:00)  #    Comments [8] -
Conferences
 Friday, January 30, 2009

image If you’re attending one conference this year, you should be in Oslo on the 17th through 19th of June, at the NDC 2009. The line-up is fantastic and I’ll challenge anyone to show me a development conference with a better speaker line-up.

Mary Poppendieck, Mike Cohn, Scott Hanselman, Michael Feathers, Robert C. Martin (uncle Bob), Ted Neward and many more. And there’s even more on the way. This is the A-Team of speakers!

If you’re not a full time developer, but work more as a project manager, check out the last day, the Norwegian Agile Day, a whole day dedicated to sessions on agile software development, with, amongst others, Mary Poppendieck, an authority in lean development and Mike Cohn, the founder of both the Agile Alliance and the Scrum Alliance.

It doesn’t matter where you’re from, this is the conference to attend!

Don’t miss it!

 
Friday, January 30, 2009 1:46:00 PM (Central Europe Standard Time, UTC+01:00)  #    Comments [0] -
Conferences | Programming
 Thursday, December 18, 2008

Regjeringen har i disse dager sluppet en løsning for elektronisk reiseregning på nettet. De har at på til sluppet den som fri programvare, noe som egentlig bare skulle mangle med tanke på at det er skattepengene som har blitt brukt.

Den er, ved første øyekast, ganske grei å bruke. Det er ikke alt jeg er like enig i, men med tanke på det grusomme programmet vi bruker på jobben er dette en kjempeforbedring.

Men ved nærmere ettersyn er det en del ting som ikke er som de burde vært. De tekniske løsningene er ikke så bra som de burde vært. Mange har referert til disse og jeg skal ikke gjenta de her, men det er én ting som virkelig plager meg (utenom sikkerhetsproblemet).

All forretningslogikk ligger i Adobe Flex klienten, den klienten som lastes ned og kjøres på klienten. De har noen web services som kjører men det ser ut til at de ikke gjør noe mer enn å lagre informasjon og å lage PDF-er. Hvorfor kunne ikke logikken vært lagt på webserveren, eksponert gjennom en web service? Da kunne de laget et standard XML Schema for å representere en reiseregning, tatt det i mot, gjort de nødvendige beregningene og returnert det ferdige resultatet. Logikken for å regne ut en reiseregning har ikke noe behov for å endre seg fra klient til klient. Ved å sentralisere dette gjør man det mulig å lage mange forskjellige klienter som tar i mot data fra ett eller annet sted, gir det til reiseregningen.no for å få det regnet ut etter de til enhver tid gjeldene regler og få tilbake et resultat for så å gjøre hva man vil med det.

Det hadde gjort det mye, mye enklere å lage alternative UI-er eller å integrere en reiseregning i et annet produkt eller arbeidsflyt.

Om ikke annet så hadde logikken vært implementert i C# og ikke i ActionScript, et språk med mye mindre utbredelse enn C#...

 
Thursday, December 18, 2008 1:30:19 AM (Central Europe Standard Time, UTC+01:00)  #    Comments [2] -

 Tuesday, November 25, 2008

This is kinda cool:

Typemock are offering their new product for unit testing SharePoint called Isolator For SharePoint, for a special introduction price. it is the only tool that allows you to unit test SharePoint without a SharePoint server. To learn more click here.

The first 50 bloggers who blog this text in their blog and tell us about it, will get a Full Isolator license, Free. for rules and info click here.

 

Sweet! :)

 
Tuesday, November 25, 2008 10:05:15 PM (Central Europe Standard Time, UTC+01:00)  #    Comments [0] -

 Friday, October 17, 2008

I was looking at the source of a Twitter plugin to Windows Live Writer and found this gem of a comment:

TwitterApi.UpdateStatus(Username, Password, status);
                
// Updating Twitter often happens so quickly that
// it doesn't feel like enough time has passed for
// it to have worked. So sleep for 250 millis to
// make the user feel like something happened.
Thread.Sleep(250);

Fantastic!

 
Friday, October 17, 2008 9:10:13 AM (Central Europe Standard Time, UTC+01:00)  #    Comments [0] -

image Microsoft has released a beta of the Microsoft Web Application Installer, an installer that will present you some popular open source web applications like Grafitti, DotNetNuke, WordPress, OSCommerce and more (yes, PHP apps too!).

It will check your machine for pre-requisites you’ll need, provide links for downloads, configure IIS, allow you to enter basic configuration items and install everything.

Microsoft making it easier to install OpenSource? What’s the world coming too…? :)

Scott Hanselman has more details too

 
Friday, October 17, 2008 8:22:14 AM (Central Europe Standard Time, UTC+01:00)  #    Comments [0] -

 Sunday, September 28, 2008

JQuery Microsoft have announced that they will start shipping JQuery as part of Visual Studio and offer full support for it.

They will be shipping the original, open-source, version under the original MIT license. They will not be forking it or changing it and will contribute patches and changes back to the JQuery project under regular patch review process.

I think this is a fantastic idea! I’m glad people in MS sees that not everything has to be invented there and that they are able to a) include open-source stuff in their product and b) not take it over and make an incompatible version.

I believe that this way of doing things is symptomatic to the change in attitude I’ve been seeing in the developer part of Microsoft for some time now, they are more open and communicating better with the community.

Good things ahead.

 
Sunday, September 28, 2008 10:57:15 PM (Central Europe Standard Time, UTC+01:00)  #    Comments [1] -

Links
Twitter updates
    Archive
    <September 2009>
    SunMonTueWedThuFriSat
    303112345
    6789101112
    13141516171819
    20212223242526
    27282930123
    45678910
    About the author/Disclaimer

    Disclaimer
    The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

    © Copyright 2012
    Glenn F. Henriksen
    Sign In
    Statistics
    Total Posts: 46
    This Year: 0
    This Month: 0
    This Week: 0
    Comments: 31
    All Content © 2012, Glenn F. Henriksen
    DasBlog theme 'Business' created by Christoph De Baene (delarou)