Wednesday, 25 December 2013

Galaxy S3 keeps notifying of "Download Complete" of photo

Since the latest Android update my Galaxy S3 keeps informing me of "Download Complete" of a photo.jpg.

I fixed this by navigating to the Download app and then deleting all of the downloads shown.

Wednesday, 18 December 2013

RESTful design

Get Operations should be idempotent - performing the operation should not alter the underlying resource in any fashion. It can be performed n times and it always returns the same result.

POST should be used to create resources.

PUT should be replace the entire copy of the resource. If it exists it will overwrite it. If it doesnt exist it will create it: PUT can be used for first time creation and updates also. The difference between a POST and a PUT is that a PUT must have the resource identifier available, whereas a POST will not. So you can only PUT to create a resource if the resource identifier was generated external to the save operation.

PATCH should be used for updating part of the resource - perhaps a single field.

http://martinfowler.com/articles/richardsonMaturityModel.html

Monday, 16 December 2013

Case namings

I've always referred to Camel Case as the case whereby the first letter is lower case and all compound Words thereafter are uppercase.

e.g. backColour or orderRefundId

this is how you'd name fields in .NET.

and Pascal Case is whereby the first letter is capitals (e.g. properties in .NET).

e.g BackColour or OrderRefundId

....confusingly though Camel Case can refer as upper camel case (Pascal case) or lower Camel Case. Typically though if it is not specifically mentioned then Camel Case is lower camel case.

Saturday, 16 November 2013

FIX: Battlefield 4 - 2 player disconnect on a home LAN

If you play Battlefield 4 with 2 players with separate copies and separate accounts on a home network you may find an annoying problem whereby when one user logs in the other is disconnected.

 This can be solved by:

1. Log in to your home router and disable uPnP.

 then, for both computers:

2. In Windows, Go to Start > Run and type in Services.msc
3. Stop the "UPnP Device Host" service.
4. Stop the "SSDP Discovery" service.

 And restart BF4. Hey-presto - it works!

Monday, 11 November 2013

Adding a SqlParameter with a null reference - Procedure or function 'Foo' expects parameter '@Name', which was not supplied.

I was debugging a historical issue raised in some legacy code over a year ago.
The problem was reported that the database was raising an error under peak load whenever a payment service was unavailable.

The database error was:

 Procedure or function 'Foo' expects parameter '@Name', which was not supplied.

After some digging it transpires that the error was due to a little gotcha in the database access code.
The code was similar to:

using (var connection = new SqlConnection("Server=localhost;Database=TestDatabase;Integrated Security=SSPI"))
{
    connection.Open();
    using (var cmd = new SqlCommand())
    {
        cmd.Connection = connection;
        cmd.CommandText = "Foo";
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(
            new SqlParameter
            {
                ParameterName = "@Name",
                SqlDbType = SqlDbType.NVarChar,
                Size = 255,
                Value = results.Reference
            }
            );
        cmd.ExecuteNonQuery();
    }
}

If results.Reference is a .NET null reference, then the SqlParameter is NOT added. In this scenario if you want to add a NULL database value then you would need to modify the code to:


    Value = results.Reference ?? DbNull.Value;

Monday, 21 October 2013

In-House NuGet

ProGet is package that can be used to source in-house NuGet feeds.

Monday, 12 August 2013

StyleCop versus FxCopy versus Code Analysis and MSBuild integration

What is the difference between StyleCop and FxCopy? It is described here.

StyleCop and FxCop overlap in functionality. But StyleCop analyses source code whereas FxCop analyses binaries, so StyleCop is able to pick up on source code rules whereas FxCop cannot.  FxCop tends to focus more on design rules and StyleCop is focusing on coding style (casing, white space, indents, etc).

Code Analysis in Visual Studio contains FxCop plus mode (code metrics etc).

StyleCop can be manually added to the project so that it runs as part of MSBuild. However there are issues about it sharing the same custom dictionary as Code Analysis.