Michael John Fransen

Michael John Fransen

Michael Fransen  //  I am a software developer from Minneapolis, MN, that enjoys cycling and reading in my spare time.

Apr 17 / 1:46pm

Birthday Party

             
Click here to download:
birthday-party-FvmnEnyGJfabBIqzsBhi.zip (6501 KB)

Posted from Minneapolis, MN

Comments (0)

Apr 16 / 8:29pm

Birthday Presents. Yay!!!

Posted from Sauk Rapids, MN

Comments (0)

Apr 16 / 7:18am

Goodbye Wordpress Blog

Today I decided to get rid of my Wordpress blog.  I’ve got better things to do with my time than sit and blog.  I changed my domain to point to Posterous for now.  I will use this forum for more personal things versus technical blogs.

Comments (0)

Apr 8 / 11:45am

Array Literals in Visual Basic 10/VS 2010

Prior to Visual Basic 10 the type and dimension of an array was required when declaring it. Visual Basic 10 introduces array literals in which the compiler infers the type and dimensionality based on the values you use to initialize the array. The compiler can handle some data type mismatches; however, it does not handle them all. Notice the forthArray. This array contains integers and strings. The compiler creates an array of type object. Also notice that in the last example the compiler knows to create a two dimensional, integer array.
[code='vb.net'] Sub Main() Dim firstArray = {1, 2, 3, 4, 5, 6, 7, 8, 9}Console.WriteLine("First Array Type: " & firstArray.GetType().ToString()) Dim secondArray = {1, 2, 3, 4, 5, 6, 7, 8, 9.9} Console.WriteLine("Second Array Type: " & secondArray.GetType().ToString()) Dim thirdArray = {"One", "Two", "Three", "Four"} Console.WriteLine("Third Array Type: " & thirdArray.GetType().ToString()) Dim fourthArray = {"One", 2, "Three", 4} Console.WriteLine("Forth Array Type: " & fourthArray.GetType().ToString()) Dim multiDimArray = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}} Console.WriteLine("Two Dimensional Array Type: " & multiDimArray.GetType().ToString()) Console.ReadLine() End Sub [/code] Output from running the above code: First Array Type: System.Int32[] Second Array Type: System.Double[] Third Array Type: System.String[] Forth Array Type: System.Object[] Two Dimensional Array Type: System.Int32[,]

Comments (0)

Apr 7 / 6:25am

Wishlist for iPhone OS 4.0

Tomorrow Apple is holding an event where they are going to discuss the upcoming iPhone OS 4.0. Here are the top five things I would like to see announced at tomorrow's event. 1) Multitasking - Apple does not currently allow for multitasking of third party apps even though native iPhone apps have this ability. You can listen to the iPod application while you are on Facebook, but you can't listen to Pandora while you are on Facebook. Apple has avoided this feature because of their concern of battery life. Instead, they released a half-assed solution called Push Notifications where they essentially funnel notifications through their servers and only maintain one connection with the phone. The ironic thing is that pretty much everyone complained of battery life when they enabled push notifications for the first time. You are also limited in what you can do. A push notification can only play a sound, show a badge number and/or show a message. If Apple does introduce this feature it isn't because they want to; it will be because Android forced them to. This is one feature where Android beats the iPhone. 2) Unified Message Box - Currently you have to go to multiple places to check multiple messages from different accounts. Email has a separate inbox for each account. To bounce between email accounts a user must take many actions. Text messages require you to go to a completely different application. Push notifications don't even have a history. iPhone users can only see the last push notification. Any previous ones disappear into thin air. I would like to have a Unified Message Inbox/View that allows me to see all my messages, regardless of their account, on one screen. This includes text messages and push notifications. Included in this feature is the ability to see a history of push notifications. 3) Multiple Exchange Accounts - For those of you that don't use Apple's MobileMe, you should know that it is the worst product on the planet in regards the web interface. It is down more than twitter and when it is up, it is slow as hell. It is the only other option on the iPhone that allows for push email, calendar, and contacts besides an exchange account. The iPhone currently only allows for one exchange account to be used. This exchange account is being utilized for my work account. I think this is the case for many people. Gmail allows you to connect via Exchange technology. If Apple allowed multiple exchange accounts I think I would ditch MobileMe for Gmail. 4) Flash - Apple has not added Adobe Flash to the iPhone because Steve Jobs has said it utilizes too much CPU. I think what he really means is that he doesn't want competition with the app store. Try to find a way right now where you can install an application without going through Apple's app store to get an app on a non-jailbroken phone. You simply can't do it. If developers were allowed to use Flash a user could play sophisticated games on the iPhone just by going to an address in their browser. No app store involved! 5) Navigation - I think Apple should add this just to be competitive with Android. Android currently offers a free app that allows for turn-by-turn directions. I already have the TomTom application for the iPhone, but it would be nice if there was a native application that integrated with other applications such as the address book. We will see tomorrow if Apple will deliver any of these features. The only two that I have some hope for are Multitasking and the Unified Message Box.

Comments (0)

Apr 6 / 11:48am

Optional and Named Parameters in C# 4.0

One new feature in C# 4.0/Visual Studio 2010 that Visual Basic has had for quite some time is optional and named parameters.  Having optional and named parameters can reduce code complexity by reducing the number of overloaded methods that you need.  You will find developers on both sides of the fence when it comes to optional and named parameters.  I lean towards using them for more simple code.  I would love to hear your thoughts in the comments though. Here is a code example of how things used to have to be done.  This simple console application has three Print methods that take in a different number of parameters.  I call it three times.  Once with three parameters, another with two, and a final time with one parameter.  The Print method with three parameters is always the method that ends up getting called to print the information out to the screen.
[code='c#'] using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace OptionalParameters { class Program { static void Main(string[] args) { Console.WriteLine("Calling Method with Three Parameters."); Print(1, 2, 3); Console.WriteLine("Calling Method with Two Parameters."); Print(1, 2); Console.WriteLine("Calling Method with One Parameters."); Print(1); Console.ReadLine(); } public static void Print(int x, int y, int z) { if (x != -1) { Console.WriteLine("X = " + x.ToString()); } else { Console.WriteLine("X was not set."); } if (y != -1) { Console.WriteLine("Y = " + y.ToString()); } else { Console.WriteLine("Y was not set."); } if (z != -1) { Console.WriteLine("Z = " + z.ToString()); } else { Console.WriteLine("Z was not set."); } } public static void Print(int x, int y) { Print(x, y, -1); } public static void Print(int x) { Print(x, -1, -1); } } } [/code]
The second code example here does the exact same thing only using optional and named parameters. You can see that we only need one Print method now. In the signature the parameters are set to -1. This is their default value if they are not passed in. I did add an extra call to the Print method where I used named parameters to show you how we can call the Print method setting the Y and Z parameters. This was not possible with the overloaded methods because if you called the Print method with two parameters it would call the Print method where X and Y were set. This is an example of where named parameters provides additional functionality that you can't accomplish with overloaded methods. You use named parameters in your method call by typing the name of the parameter followed by a colon and then the value.
[code='c#'] using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace OptionalParameters { class Program { static void Main(string[] args) { Console.WriteLine("Calling Method with Three Parameters."); Print(1, 2, 3); Console.WriteLine("Calling Method with Two Parameters."); Print(1, 2); Console.WriteLine("Calling Method with One Parameters."); Print(1); //Using named arguments the method can be called with values for X and Z which couldn't //be done with the overloaded methods. Console.WriteLine("Calling Method with X and Z parameters set."); Print(x: 1, z: 3); Console.ReadLine(); } //Because default values are set the parameters are optional. public static void Print(int x = -1, int y = -1, int z = -1) { if (x != -1) { Console.WriteLine("X = " + x.ToString()); } else { Console.WriteLine("X was not set."); } if (y != -1) { Console.WriteLine("Y = " + y.ToString()); } else { Console.WriteLine("Y was not set."); } if (z != -1) { Console.WriteLine("Z = " + z.ToString()); } else { Console.WriteLine("Z was not set."); } } } } [/code]

Comments (0)

Apr 6 / 5:29am

Implicit Line Continuation in Visual Basic 10

In C# you end a statement of code with a semicolon. If that statement spans multiple lines there is no worry because the compiler knows it is one statement until it sees the semicolon. This is not the case with VB. VB assumes that each statement is on one line of code. If your line of code is too long then you could use the underscore character to tell the compiler that the line of code continues onto the next line. In VB 10 the compiler is smarter and it tries to figure out where your statements end so you don't have to worry about the underscore in all cases. There will still be instances where you have to use the underscore though. In my opinion, Visual Basic code looks less elegant than C# code. This may sound like a small feature, however, it is a step in the right direction of making VB code more readable and simple. Here is an example of a piece of code using VB 9.  Notice the serialization attributes.  Those attributes are technically the same line as the class line and property line.  Because of this you had to add an underscore. [code='vb.net'] Imports System.Xml Imports System.Xml.Serialization Namespace BusinessObjects _ Public Class File _ Dim _path As String Public Sub New() End Sub Public Sub New(ByVal path As String) _path = path End Sub Public Property Path() Get Return _path End Get Set(ByVal value) _path = value End Set End Property End Class End Namespace [/code] Here is an example in VB 10 that compiles.   Notice that you don't need the underscore.  I gave you a rather simple example, but you can imagine that in a larger class it was possible for it to look very messy in VB 9. [code='vb.net'] Imports System.Xml Imports System.Xml.Serialization Namespace BusinessObjects Public Class File Public Property Path As String Public Sub New() End Sub Public Sub New(ByVal path As String) _Path = path End Sub End Class End Namespace [/code]

Comments (0)

Apr 5 / 5:20am

Automatic Properties - VB.NET 10 Feature

Many of the updates in VB.NET 10 are allowing for functionality that C# got in 3.0. One of those features is called Automatic Properties. Typically you have private fields for every property of your class. Often then you would have a property that would set and get that value. Often the property is doing nothing more than that. This feature allows you to reduce and simplify your code. Here is an example of the old way of implementing properties: [code='vb.net'] Public Class Person Private _firstName As String Private _lastName As String Private _age As Integer Public Property FirstName() As String Get Return _firstName End Get Set(ByVal value As String) _firstName = value End Set End Property Public Property LastName() As String Get Return _lastName End Get Set(ByVal value As String) _lastName = value End Set End Property Public Property Age() As Integer Get Return _age End Get Set(ByVal value As Integer) _age = value End Set End Property End Class [/code] Using Automatic Properties you can reduce the code above down to a few lines. Check out the way you can do this using VB.NET 4.0: [code='vb.net'] Public Class Person Public Property FirstName As String Public Property LastName As String Public Property Age As Integer End Class [/code]

Comments (0)

Mar 31 / 9:53am

Buy the Cheapest HDMI Cable Possible

This is soooo true!

Comments (0)