Scott Hanselman has been on a roll lately with his posts and twits. Today he writes “Question to .NET Programmers: what is the difference between the System.* and Microsoft.* namespaces?”
This is an important question and one that I can’t say I truly know the answer too. I had always assumed it was based on either the idea that System.* was part of the core framework where as Microsoft.* was for Microsoft specific functionality. For instance, it would be expected that much or all of the System.* functionality would be replicated on many other platforms where as Microsoft.* would not.
Certainly this is true for the very basic feature set such as the common types but it is not true for System.Windows.Forms. Which begs the question that I always wondered: why is Windows.Forms where it is? I always expected it to be in Microsoft.Windows.Forms as it is a Windows specific implementation based on many of the Win32 controls.
EIPL, or English as the International Programmer Language, seems to have been brought up again around the blogosphere. It seems to have started on Scott Hanselman’s blog with a comment stating “If you don’t know English, you’re not a programmer!” Of course it does not end there: Bjoern writes about it in a blog post saying “In regard to translated documentation: I wouldn’t use it. Maybe it is because I learned programming during the dark ages when everything development related was English – it is even possible to claim I learned English through such documentation – or maybe the early days of localizations spoiled my conception of its quality.” And finally it appears here with generally the same attitude: that English is quickly becoming or should become the official language of programmers.
I believe that English should not be the official language. It is nice to know that variable names will generally be in a language I can understand, however I believe that this can be fixed in the future with language independent coding taking the place of what we do not. Visual Studio is already an incredibly powerful tool and it wouldn’t surprise me if within a decade or two it would begin to support the dynamic localization of variable names. It would be ignorant of me to demand or expect all source code to be in English.
However, the one caveat here is that non-English speaking programmers or wannabes should most likely learn English simply because features like the one mentioned above will take many years to come about and perfect. Furthermore, it can be said that English is somewhat of an international language. In Western cultures it is very easy to find someone who speaks English and it is quickly spreading throughout the tiny corners of the world. For evidence of this, look no further than the Olympics which was conducted in (I believe) three languages. If memory serves me correctly it was English, French and Chinese. This was due to the host country (China) and the IOC (Official Languages: English, French).
While on the subject of languages there is another potential problem. While languages based on Latin or in similar style (left to right) can be well understood by an immense amount of people in the community, vertical and right to left languages that feature non-alphanumeric characters can cause more problems than just being able to understand the meaning. I can’t imagine what source code written in Chinese or Japanese would look like.
This is from the most recent build of FGF:
Yes, it is my own implementation of the Aero style of windows done in XNA. What does this mean? Well I have decided that although the simple way of doing a menu system in games is fine for simple situations, I want something more powerful and prettier to look at. Thus I have started working on a new UI library for Thrust that is based on Aero and similar interfaces. I am doing it in a fully customizable but lightweight manner and working on Xbox 360 compatibility.
This is a fundamental topic in C# and if you plan to do any development at all with the language you need to know this. Override is used for changing the behavior of the original type’s method or property. The new keyword, in this case, is used for scratching the existing behavior but only in the current type. To better explain this, consider the following code.
1
2
3
4
5
6
7
8
9
10
11
| public class Foo{
public virtual void Print(){
Console.WriteLine("I am a Foo!");
}
}
public class Bar{
public override void Print(){
Console.WriteLine("I am a Bar!");
}
} |
If we declare a Bar and cast it to a Foo in the above code, we will still get “I am a Bar!” when we invoke the Print method. However, if we change the code to the following things will get messed up a bit.
1
2
3
4
5
6
7
8
9
10
11
| public class Foo{
public void Print(){
Console.WriteLine("I am a Foo!");
}
}
public class Bar{
public new void Print(){
Console.WriteLine("I am a Bar!");
}
} |
If we instantiate a Bar, we will get the new functionality. However, if we cast that Bar object into a Foo, we will get the implementation provided by the Foo. So be sure of what you are using and why!
Today, while coding Galactic Wars v2.0, I stumbled upon a problem I have been having with content since I started working with XNA. The following diagram shows how easy it is to create the problem and how devastating it can be to any application. In my case, I have two (or more) menus that are referencing a piece of content.
Each menu references the same managed object which is really a wrapper for a second managed object (Texture2D in this case). The second object is a managed wrapper for the underlying unmanaged data, again in this case it is texture data. The problem is when one menu is being phased out (unloaded) and another is being phased in (loaded). The menu being loaded grabs a reference to the content before the other menu can unload it. The ordering is done this way to ensure that a menu actually loads its content before the current menu is unloaded.
After the menu is done loading content, the second menu is unloaded which drops the content and releases the unmanaged memory. Aha! The problem stems from the last point: I am trying to manage unmanaged memory when I should just let the GC take care of it. The reason I do this is for performance reasons, primarily on the Zune. Instead of letting textures just sit around, I release them when they are no longer needed to avoid piling up the garbage.
So what is the solution?
- Dereference the Managed Object
I would love to do this but unfortunately it introduces a second problem. If every menu (object using the content) dereferences the asset, it still will not be collected by the GC. The AssetManager still holds a reference which is now being unused and thus memory is wasted. The upside to this is that I do not need to implement the second option…
- Reference Counting!
By implementing a counter on the asset itself and asking developers to always call Unload or Unload(ILoadable) on the AssetManager, I can guarantee that no Asset will be disposed while another object is using it. The downside is that it is an ugly implementation of something that is done in the GC anyways. The major upside is that even if developers use the previous method, the GC will still eventually catch the wasted memory.
So now Thrust’s AssetManager and IAsset require (and implement) reference counting to avoid the problem described above. And it works wonderfully.
Wow! I can’t believe I have been missing this for so long. It is the answer to all my command line woes in Windows. I have only touched the surface but love it already. Today I created my profile to change the prompt and add a command for copying my FGF binaries to my current working directories:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
| # Profile PowerShell Script
# Author: John Sedlak
# Site: http://focusedgames.com
$a = (Get-Host).UI.RawUI
$a.ForegroundColor = "White"
$a.WindowTitle = "WPS - Focused Games"
# This function changes the prompt.
function prompt{
$path = get-location
$b = Get-Date -format "HH:mm"
return "$b $path ?> "
}
# This function copies a bunch of FGF libraries to current working directories.
function fgfCopy{
# These are the platforms that need to be copied
$platforms = "x86","Zune","Xbox 360"
# An array of the destinations for copying
$destinations = "E:\Users\John Sedlak\Code\Games\GW3\trunk\Libraries\"
# The source directory and the suffix.
$source = "E:\Users\John Sedlak\Code\FGF\trunk\Bin\"
$sourceSuffix = "\Release"
# Loop through all the destinations and all the platforms
# For each platform, copy some files.
foreach($destination in $destinations){
write-host "Starting copy to"$destination
foreach($platform in $platforms){
# Build up the source and destination paths
$tempSource = $source + $platform + $sourceSuffix
$tempDestination = $destination + $platform
# Get a list of all DLL files that contain the word Thrust
$files = get-childItem $tempSource -force | ? {$_.extension -eq ".dll"}|where {$_.name -match "Thrust"}
# For each file, copy it!
foreach($dll in $files){
copy-item $tempSource\$dll $tempDestination
write-host "Copied"$platform\$dll
}
}
}
} |

The provider model’s goal is to allow for the abstraction of implementation to the nth degree by allowing for the choice between separate implementations of the same functionality. This design pattern is incredibly common in Microsoft’s ASP.NET, especially in the realm of security. Developers can choose between different providers for membership, roles and authentication for a single site. The point is that the core functionality of the site does not change, only the implementation. Below is a quick snapshot of how such a model is used in Vodka.
The driving force behind the provider model is the abstraction of the implementation. This is done via an interface.
1
2
3
| public interface IAuthenticationProvider{
bool Authenticate(string username, string password);
} |
What gives the provider model its meat and bones is the different implementations of the above interface. The two implementations below represent two authentication backends: an ActiveDirectory installation and an Sql database. Although the meat has been stripped from these two classes, it is clear that their implementations would differ enough to have the two separate classes. Read more »
Looks like Mono 2.0 is out. Dot NET development just got a little better (on Linux)!
Off topic, but anyone notice that in the second episode of the first season of West Wing a character by the name of Mandy runs her BMW E36 M3 right over a curb? Poor BMW…
It was a convertible too!
Ugh. It frustrates me how some companies can leave out even the most basic of functionality, like disabling the editing engine so you can edit XML straight like the following shows:
My senior project involves the study of highly extendible systems for the internet, mainly content management systems/solutions. I am building mine in ASP.NET 3.5 on WS2008, SQL2008 and .NET 3.5 (which includes WCF). The goal is to build a system that has plug-and-play services and is both quick and easy to use. Today I got the very first part of this system up and running and can be reached at jsedlak.homedns.org.
There is a lot of work to be done, but the base code (being built into FGF) is coming along very nicely. Once I can figure out security, the project should simply expand exponentially provided I have the time (ugh!). The two main [sub]projects here are FGDN (Focused Games Developer Network) and a simple CMS similar to that of WordPress, SharePoint, et al. The first is designed to allow users to submit bugs, feature requests, etc. easily much like Microsoft’s Connect. The latter is pretty self explanatory.
Because I am building this all as one interconnected solution, I have also started working on the idea that users that exist in Vodka [may] have access to many other parts of Focused Games. Primarily this means FGDN but also the SVN repositories. A user (you) can apply for access to one or more of the repositories I currently use for my source code. Once you are accepted, you are also connected to any other Vodka service I create. Pretty nifty, eh?