November 2007 - Posts
Sonu published a great article on DotNetSlackers today entitled An Architectural View of the ASP.NET MVC Framework by Dino Esposito.
This is a really great article for anyone who wants a quick, detailed overview of the up and coming MVC framework in ASP.NET.
I love property intializers, both in C# and F# and just think that they can be so useful and convenient especially with stuff like WinForms and WPF where you often find yourself newing up some element and then in the next 2 or 3 lines setting some properties to specific values.
Anyway, this post isn't about C# - I've talked a bit about C# 3.0 over the last 16 or so months and I don't really want to bore myself, however, not a new feature in F# but a little unknown feature is that you can do the same here albeit with slightly different syntax.
C#
Window w = new Window() { Title = "Tooo many properties!!", ...};
F#
let w = new Window(Title = "Tooo many properties!!", ...)
Note: this is the first time I have created a WPF project in VS 2008 Beta 2 and it look's so much prettier than Cider did. Its funny how during the CTP's and Betas of WPF I used it quite heavily and then it RTM'd and I've hardly touched it! Something wrong there!
This is a minor release but the Data Structures and Algorithms (DSA) library continues to expand.
Some new additions in DSA 0.2.3 include BinarySearchTreeCollection<T>, and a host of new algorithms, utility methods and issue resolutions.
Visit the project site here, or download DSA 0.2.3.
The next release will be DSA 0.3 and will include a significant amount of new features, you can check out what DSA 0.3 is penned to have here.
DSA provides great VS debugging and LINQ support and all data structures can be used the same as those found in the BCL (they all implement the standard interfaces). The majority of the algorithms are implemented as extension methods to provide seamless integration with the rest of the .NET stack.
As you may of guessed DSA drops require VS 2008.
Download DSA 0.2.3.
I must admit this post is mainly down to my ignorance in playing with the compiler switch before, I knew that the F# compiler could produce documentation in xml form but never knew that it could go ahead and gen some html docs.
Bad news is that some of the summary text is cut off :-( so a few words are missing. A quick fix is to increase the font size on you're browser and they magically appear - it's not pretty but it does the job.
Here is the switch - --generate-html --html-output-directory "C:\<yourdir>"
I think I'll stick with the -doc switch for now and use one of the many SandCastle tools to build the viewable docs.
Today I switched my PC on and after 5 minutes my Zune's firmware and Software was updated looking shinier than ever!
I must admit I wasn't really a fan of the black UI of the previous software - looked kind of rubbish to me.
So far I have owned an iPod and Zune and I am far happier with my Zune, mainly due to the fact that my library is mainly wma's but I really like the form factor and software and firmware updates seem to come out all the time for the Zune - some might ask the question why they come out so often, but to me it shows MS cares about my Zune's welfare which is a good thing :-)
If you are not getting the update in the Zune software just check for software updates and that will spark everything off.
I see this question pop-up every now and then on various forums and generally within conversations.
By default in languages like C# and C++ (and tonnes of others) copy-in semantics are used when dealing with the objects of formal method parameters.
Each can be viewed as read (copy-in), write (copy-out) and read-write (reference).
Although I have not checked my assumption is that modern, sophisticated compilers will in fact embrace the most efficient semantics in any particular scenario, e.g. say I have a method that takes a single argument by default I am using copy-in semantics and in the method I am not writing to that parameter only reading thus the compiler under the hood could just pass by reference which is more optimal.
Copy-in can be expensive if the formal parameter's are large in nature, e.g. large data structures etc, copy-out semantics are also expensive as they copy-in and then "push" the data back out again writing, references do neither but are more error prone.
using System;
namespace CopySemantics
{
class Program
{
static void Main()
{
Person p = new Person("Granville", "Barnett");
CopyIn(p);
Console.WriteLine("{0} {1}", p.FirstName, p.LastName);
CopyOut(out p);
Console.WriteLine("{0} {1}", p.FirstName, p.LastName);
Reference(ref p);
Console.WriteLine("{0} {1}", p.FirstName, p.LastName);
}
public static void CopyIn(Person person)
{
/* copy-in semantics, this method uses a local copy of
* the formal parameter if value type otherwise person
* pointer value */
person.FirstName = "Alan";
person.LastName = "Shearer";
}
public static void CopyOut(out Person person)
{
/* Same as copy-in semantics but value is written to
* formal parameter object/value type. */
person = new Person("John", "Edwards");
}
public static void Reference(ref Person person)
{
/* no copy-in or copy-out semantics used here, we are
* always dealing with the object passed in the formal
* parameter */
person.FirstName = "Bill";
person.LastName = "Gates";
}
}
class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public Person(string firstName, string lastName)
{
FirstName = firstName;
LastName = lastName;
}
}
}
Hopefully that clears some stuff up - but I would expect the C# or C++ compiler being used to go ahead and do some checks and then use the most efficient semantics anyway.
Apologies if the example is poor, I just did this off the top of my head this minute :-(
Note: copy out semantics are not in C++, you must use reference (read-write) semantics (&).
Note: these semantics don't just apply to modern C++ compilers or the C# compiler, rather this is what most commercial grade compilers will do in some optimisation phase.
I know that generally the design patterns promote programming to an interface not an implementation - and this provides more loose coupling, and helps keep inheritance trees down.
My personal opinion is that component based programming is really nice, but I see few people actually implementing the component based methodology in their source code.
My question to the reader is this - do you actively apply interface based programming?
Note: I didn't want to start a new post announcing the release of Windows Live Writer (RTW) but it got released today (I think) and here is the link. Also this version unlike Beta 2 work on x64 machines...thank goodness!!
Sonu just announced on DotNetSlackers a brand new competition entitled "Peers Contest".
The rules are pretty simple, simply register on the DotNetSlackers forums and start answering the questions and/or asking questions to your peers.
The competitions officially launches on October 5th.
Prizes:
This is an awesome competition with some equally stunning prizes! Go sign up and enter now!!!
I'm loving what I'm reading on Herb Sutter's blog after his trip to the ISO C++ standards meeting in October.
Among the things Herb raises, my favorites include:
- nullptr - finally a nice literal from C++/CLI is approved and we can all stop using 0 which although is not that confusing is also not that clear, and also the horrible macro NULL - I don't know why, but I hate using NULL...I think it's just because it's in caps and requires a little more effort when typing.
- threading library - about time, enough said.
I am absolutely loving what I'm reading about C++0x!
More Posts