Tilt your extra monitor to portrait

January 27th, 2012

I, of course, have two monitors for my development computer.  (sometimes three but that is subject for another post)  The extra monitor I have is tilted to portrait so it is higher than wide.  I strongly recommend it.

We write code with the flow going from the top to the bottom.  Having a high monitor makes me see more code and keep less in the RAM part of the brain.

One could argue that methods should be short and there hence is no need for a screen that is so high that two methods are visible at once.  One could also argue that cars should be fragile so as to feel the need for avoiding collisions. Or calculators to calculate wrongly so we learn to do it manually instead.

Try tilting your extra monitor to portrait today!  You might not like it – hacking queries is better done wide, spreadsheets is often wide, presentations are wide – but then you have your other landscape monitor for that.

You might have to rearrange some tools in your favourite development environment but that is easy done.

I dare you to try it and leave a comment.

 

TortoiseSVN and code.google

January 27th, 2012

The quick and dirty documentation found for instance here hints at one should write the project name and user name together with the https source path.  So is not the case if one uses TortoiseSVN.

So the string

https://compulsorycat.googlecode.com/svn/trunk/ compulsorycat --username myusername@gmail.com

should really be

https://compulsorycat.googlecode.com/svn/trunk/

Not that hard to figure out really.  But it took me a while.  I even missed it at this helping side.

Just for information.  Nothing fancy.

Communicate, communicate, communicate – and what I have learned

January 24th, 2012

Cccommunicate news letter is out.

Communicate, communicate, communicate – and preteens on the internet

January 10th, 2012

Communicate, communicate, communicate – and preteens on the internet

Communicate, communicate, communicate – and playing games

December 21st, 2011

Communicate, communicate, communicate – and playing games

Convert dotnet DateTime to Sqlserver SqlDateTime

December 9th, 2011

The SqlDateTime has a narrower span than the Dotnet ditto; dotnet starts from year 0 but sqlserver from 1753.  This means that uninitialised DateTime fields in dotnet will give runtime execution errors when trying to persist them in a sqlserver database.

I write together a small and simple method for making sure the DateTime interval is inside the valid SqlDateTime interval.

public static class DateTimeExtensions
    {
        /// <summary>This method returns the datetime fitting into min/max of Sqlserver
        /// as per http://codebetter.com/petervanooijen/2008/08/21/valid-date-time-values-in-sql-server-sqldatetime-vs-datetime/
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static DateTime ToValidSqlserverDatetime(this DateTime dt)
        {
            //  Must cast System.Data.SqlTypes.SqlDateTime.MinValue: http://codebetter.com/petervanooijen/2008/08/21/valid-date-time-values-in-sql-server-sqldatetime-vs-datetime/
            if (dt < (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue)
            {
                return (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
            }
            else if (dt > (DateTime)System.Data.SqlTypes.SqlDateTime.MaxValue)
            {
                return (DateTime)System.Data.SqlTypes.SqlDateTime.MaxValue;
            }
            else
            {
                return dt;
            }
        }
    }

The code is easier to read at pastebin.

Honour those who should.

 

 

 

 

 

 

Communicate, communicate, communicate – and replacing a medium with another

December 6th, 2011

Communicate, communicate, communicate – and replacing a medium with another

Scope_Identity doesn’t return an Int in sqlserver but a Decimal

December 5th, 2011

This is an old item.  Scope_Identity in Sqlserver doesn’t return an Int but a Decimal.  So in Dapper the call is

                var id = conn.Query<Decimal>(...

Honour those who should.

VB.Net and lambda

November 30th, 2011

Using the terse lambda syntax used in C# also in VB.Net is also (almost) possible.

Here is a short example:

var nameList =
 myFacade.GetData().
 where( x => x.ID = 42 ).
 select( x => x.Name ).
 ToList();

which in VBNet becomes:

Dim nameList =
 myFacade.GetData().
 Where( Function(x) x.ID = 42 ).
 Select( Function(x) x.Name ).
 ToList()

Note that the periods have to be at the end of the line, otherwise the multi line capability of Vbnet doesn’t work.  This can be remedied by the old trailing underscore of VB.

If you need to set the type of x it is also doable:

Dim nameList =
 myFacade.GetData().
 Where( Function(x As MyClass) x.ID = 42 ).
 Select( Function(x As MyClass) x.Name ).
 ToList()

Unit tests, TDD, BDD

November 28th, 2011

Maybe we shouldn’t think of unit tests, TDD or BDD but more of go no go tests. Whatever you automatically test it has a Go/NoGo, Yes/No, Success/Fail result.