Infragistics JQuery controls

The mono project. The state of .NET on non Microsoft platforms.

Ubuntu too I've recently decided that I wanted to install linux on an older PC in my home.  Many moons ago, before most linux distributions could auto detect and configure your hardware, I had cut my teeth on Debian.  I've had a soft spot ever since for the aptitude package manager.  Naturally I wanted to use a distro that was based on Debian so I went with Ubuntu.  The Ubuntu CD that I have is dated (version 8.04) so I did some research and decided to upgrade to version 10.04.  I fired up a terminal and executed 'sudo do-release-upgrade -d' to apply an upgrade to my system. Watching LED dry The upgrade was a pretty long process, and I found myself watching the terminal window as all of the packages were added, upgraded, and removed.  As I watched, I noticed that quite to my surprise, there were many packages that relied on mono assemblies.  As a .NET consultant, of course this had sparked my curiosity.  I've followed the mono project, from a distance, for a while now but I knew that there was a following, however, I had no idea that mono had made it's way into the heart of the packages that make up an Ubuntu installation.   The current state of things I've decided to take a 1,000 feet view of the current state of the mono project.  As stated by the official website; The easiest way to describe what Mono currently supports is:Everything in .NET 4.0 except WPF, EntityFramework and WF, limited WCF.   That's quite a lot of functionality!  I had no idea that there had been so much work done on the project.  I can write a .NET 4.0 application, an ASP.NET MVC 2 web application and host it on a linux based Apache server.  Well at least that's what the website has told me. Perhaps I'll try to accomplish just that and write about how smooth the whole process actually is. Here are some links for those who are interested. The official mono homepage http://www.mono-project.com/Main_Page The mono project compatability http://www.mono-project.com/Compatibility The mono migration analyzer MoMA http://www.mono-project.com/MoMA Design apps for your iPhone or iPad using monoTouch http://xamarin.com/monotouch Design apps for your android device using mono for android http://xamarin.com/monoforandroid I hope you found something of interest.  Until next time.. ~/Buddy James   kick it on DotNetKicks.com  


.NET Enumerated Types Explained

  My codeproject article on .NET enumerated types. http://www.codeproject.com/Articles/91195/NET-Enumerated-Types-Explained Introduction The purpose of this article is to provide an introduction to .NET enumerated types. Background Code readability is a big factor when considering the quality of source code. The easier code is to understand, the easier it is to maintain. Have you ever found yourself using numbers to represent a range of variable values? For example:  Collapse | Copy Code Dim CalculationOperation As Integer = 0 CalculationOperation = _ GetOperation () Select Case CalculationOperation Case 1 ’ Addition _PerformAddition() Case 2 ‘ Subtraction _PerformSubtraction() Case 3 ‘ Multiplication _PerformMultiplication() End Select This requires you as well as any other developers that might touch your code to remember all of the possible numeric values that represents colors. This can be a maintenance nightmare! To solve this problem, VB.NET has enumerated types. Reasons to Use Enumerated Types Readability From Wikipedia: "In computer programming, an enumerated type (also called enumeration or enum) is a data type consisting of a set of named values called elements, members or enumerators of the type. The enumerator names are usually identifiers that behave as constants in the language." Enumerated types allow you to give an English description to a range of integer values. Perhaps an example will explain this.  Collapse | Copy Code Public Type CalculatorOperations Addition = 1 Subtraction = 2 Multiplication = 3 End Type Dim Operation As CalculatorOperations Operation = _ GetOperation () Select Case Operation Case CalculatorOperations.Addition _PerformAddition() Case CalculatorOperations.Subtraction _PerformSubtraction() Case CalculatorOperations.Multiplication _PerformMultiplication() End Select     This routine is easier to read. When coding a routine, be sure to consider numeric literals that represent a value other than the number itself as a possible reason to create an enumerated type. Enums as Routine Parameters Enumerated types are great as routine parameters. Consider the following example. Bad Example  Collapse | Copy Code Dim ApplicationState as Integer = 5 ‘lets say five stands for Fatal Crash! Sub _SetApplicationState(ByVal State As Integer) Good Example  Collapse | Copy Code Dim ApplicationState As AppState = AppState.FatalCrash Sub _SetApplicationState(ByVal State As AppState) If you are using Visual Studio, then you no doubt have noticed the benefit of using enumerated types as function parameters. While you are writing the code to call the routine, intellisense will show you all available members of the enumerated type. Compiler Type Checking Using enumerated types also provides type checking by the compiler. Consider the following block of code:  Collapse | Copy Code ‘Valid color values are 0 – 9 Dim CurrentColor As Integer CurrentColor = 12 ‘invalid color This is impossible with enumerated types. Enumerated types can make powerful return values. Consider the following code:  Collapse | Copy Code Dim LoginResult As Boolean = false LoginResult = _AttemptLogin() If LoginResult = True Then _Authenticateuser() End If If LoginResult = False Then _InitiateLogin() End If As you can see, true and false allow for two conditions:  Collapse | Copy Code Dim LoginResult As AuthResult LoginResult = _AttemptLogin() If LoginResult = AuthResult.Authenticated Then _Authenticateuser() End If If LoginResult = AuthResult.Failed Then _InitiateLogin() End If If LoginResult = AuthResult.Suspended Then _AlertSuspended() End If If LoginResult = AuthResult.AuthenticatedChangePassword Then _InitiatePasswordChange() _AuthenticateUser() End If Do you see the possibilities? Define the First and Last Entry as Loop Limits You may find yourself in a situation where you need to iterate through each member of your enumerated type. One suggested practice is to reserve the first and last element as loop limits.  Collapse | Copy Code Public Type RGBValue RGB_FirstValue = 0 RGB_Red = 0 RGB_Green = 1 RGB_Blue = 2 RGB_LastValue = 2 End Type Dim RGBVal As RGBValue For RGBVal = RGBValue.RGB_FirstValue To RGBValue.RGB_LastValue ‘process here Next Here is an example of iterating through an enum. 'Imagine if you had an enum for EmployeeTypes and you 'wanted to iterate over 'each employee type and perform an 'action. 'For instance Public Type EmployeeType  Cashier = 0  Supervisor = 1  Manager = 2  Executive = 3 End Type Dim employeeType As EmployeeType For employeeType = EmployeeType.Cashier To EmployeeType.Executive  CalculateRaise(employeeType) Next Conclusion Well, I hope I’ve illustrated some of the benefits of using enumerated types. All of your feedback is welcome.   kick it on DotNetKicks.com  


About the author

My name is Buddy James.  I'm a Microsoft Certified Solutions Developer from the Nashville, TN area.  I'm a Software Engineer, an author, a blogger (http://www.refactorthis.net), a mentor, a thought leader, a technologist, a data scientist, and a husband.  I enjoy working with design patterns, data mining, c#, WPF, Silverlight, WinRT, XAML, ASP.NET, python, CouchDB, RavenDB, Hadoop, Android(MonoDroid), iOS (MonoTouch), and Machine Learning. I love technology and I love to develop software, collect data, analyze the data, and learn from the data.  When I'm not coding,  I'm determined to make a difference in the world by using data and machine learning techniques. (follow me at @budbjames).  

Related links

Month List