Just sharing some of my inconsequential lunch conversations with you... RSS  

Wednesday, December 31, 2008

Unregistering Windows Services

Sorry, this isn’t the cool PowerShell version, just an ubiquitous one:

sc delete <windows_service_name>

Here a useful link to get more info.

Tuesday, December 30, 2008

Error connecting to undo manager of source file ‘<whatever>.designer.cs’

Arghh, here’s a recurring one I hadn’t posted yet. In my case, it happened after a hard checkout – I forced the checkout after offline changes, Visual Studio didn’t detect the changes – no Go Online…

Most of you suggest:

  1. exclude the file from the Web Application Project
  2. recompile
  3. re-include
  4. the recompiles

I just touched the ‘<whatever>.designer.cs’ file and recompiled it. Oh, I’ve finally undone the change :). It was suggested here.

Monday, December 29, 2008

5 Reasons for Software Developers to Do Code Reviews

Here’s a cool list of 5 Reasons for Software Developers to Do Code Reviews (Even If You Think They're a Waste of Time):

  1. Developers know their code will be evaluated, so they work harder.
  2. It improves a developer's own programming skills.
  3. It's an opportunity for mentoring, so the programmers you work with get smarter (and thus, more fun to hang around with).
  4. It creates consistency and a culture of quality across the project
  5. It encourages team bonding

Wednesday, December 24, 2008


Now that the holiday season is on, here a great way to help us through the season family and friend’s parties: UltraStar.

Ultrastar is a PC conversion of famous karaoke game - SingStar. It allows a computer to evaluate how good you are when you sing by analyzing your voice pitch.

Great way to waist some drinking time over the new years’ eve :)

Digital signature policy error installing an msi

I got a digital signature policy error message when installing a large Microsoft Windows Installer (VMWare 2) on an old box.

The problem seems to be related to insufficient virtual memory to represent all the msi. Here’s the patch that saved me.

Merry Christmas everyone :)

Monday, December 22, 2008

Failing to connect to a document library WSS3.

Arghh, this one is recurring with me. If you can’t open a WebDav document library on WSS3, check if the “WebClient” service is running!…

If not, try this.

Wednesday, December 17, 2008

Windows Live Essentials beta

We can now grab the beta of the Windows Live Essentials beta from download.live.com. Besides the new features and upgraded versions, we get a new installer that finally runs on Windows Server 2008. It's about time!

Monday, December 15, 2008

26 Ways To Know Your Software Development Project Is Doomed

Yes, I know, not a new topic, but I just can help loving these cool lists :)

Wednesday, December 10, 2008


Microsoft has released an open-source content management platform targeted to blogs or large Web sites. It's named Oxite, and it is available at CodePlex.

According to Microsoft:

Oxite is an open source, standards compliant, and highly extensible content management sample that can run anything from blogs to big web sites. We know this because it runs MIX Online.

Oh, did I mention that it is an ASP.NET MVC implementation? :)

Monday, December 08, 2008

Windows 7 - burning ISOs

Here's a new one: we can now burn ISO images on Windows 7. Unfortunately, we still can't open the ISO itself, for that you'll have to rely on Daemon Tools.

Sunday, December 07, 2008

Windows 7

Uhmm, I'm giving Windows 7 another try for a day or two. It has accepted all my Vista x64 drivers, some configuration features are just great, and the video experience is just awesome! With the same driver as my Windows Server 2008. Cool...

Installing Windows 7 on my Dell Latitude D830

Ok, after trashing my Windows Server 2008 with Azure .NET Services (yes, WCF stopped working), I've finally got the excuse I needed to install Windows 7.

The installed version was the PDC one, build 6801, a x64 version. Installed like a charme, asked for a serial but continue working without it.

To be honest, I didn't found much differences from Vista. Even on memory usage, on my D830 it used 848MB of mem on startup, and 15,8GB of disk.

About the new features most of them have already been written by others. About the experience, most applications that failed to install on my Server 2008 (because they were desktop apps) did install on Windows 7. I'm posting from Windows Live, without need of any hacking to install on Windows 7.

After writting this post I'll install a Windows Server 2008, or maybe a Vista just to get a better experience. So why didn't I kept Windows 7?

  1. It's pre-beta material, and for much that I wanted to try it, I still have to work for a living :)
  2. I've found explorer too buggy <update>Directly over a UNC path. Locally it seems to work sjust fine</update>
  3. I couln'd get to sync my HTP 3300
  4. I have a couple of important documents to write until next tuesday...

Until we meet again, Windows 7 :)

Wednesday, December 03, 2008

Apple Encourages Antivirus Software for Mac OS X

Apparently Apple started encouraging users to install Antivirus on Mac OS. Informed people did never believe on the virus-proof Mac OS theory, Mac users (me included, just using ClamAV on demand!) could afford not to use those just until the critical mass was reached. And it seem to have been reached now.

Is this a bad indicator to Mac OS? Hell, no! It's a natural consequence of Apple's growing market share. Good for them. Congratulations!

PS: if this info is confirmed Windows will receive an apology letter from Mr. Jobs, right?

Tuesday, December 02, 2008

Remote Desktop Manager

Here's a cool tiny utility: Remote Desktop Manager. It's the best to organize your remote connections, supporting Microsoft Remote Desktop, Terminal Services and RealVNC.

Here is the features list:

  • Free
  • Small size
  • Easy to install, easy to deploy, only one executable
  • Add name, image and description to your configuration
  • Run in tray icon
  • Quick access menu in the tray icon
  • Support import and export of remote desktop file (.rdp) [a must!]
  • Support Microsoft Remote Desktop and Microsoft Terminal Services
  • Support RealVNC
  • Search filter
  • Auto start on Windows startup
  • Auto update
  • Nice UI with theme support
  • Share settings between users
  • Compatible with Windows XP, Windows 2003 and Windows Vista (32 bits and 64 bits)

Friday, November 21, 2008

The easiest HttpHandler ever!

Not that HttpHandler is hard to create, but it can get quite intrusive mainly because of configuration issues.

The ashx extension simplifies all this process. Here's all you've got to do:

namespace MyProject
using System;
using System.Web;
using System.Web.Services;

/// <summary>
/// Summary description for FederationLogin
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class FederationLogin : IHttpHandler

public void ProcessRequest(HttpContext context)
// set content type to jpeg
// TODO: consider changing to smaller footprint png version

context.Response.ContentType = "image/jpeg";

// dump image according to credential presence
context.Response.WriteFile(Credentials != null ? "SignedInOnFederation.jpg" : "NotSignedInOnFederation.jpg");

// Oops, something went wrong: opt for a non-intrusive (but non-assertive)
// KISS approach: just assume no federation ticket was issued.
// Please note: no log is being issued.

context.Response.ContentType = "image/jpeg";

public bool IsReusable
return false;

This is a simple SignIn on federation button. But more about it later, I'm still on an NDA on this one.

IE 8 beta 2

You can find it at http://www.microsoft.com/ie8


Oops, I'm so embarrassed, I've got it since last August... oops...


Tuesday, November 11, 2008

Changing your SQL Server name

Cloning VM machine's is something we usually do, but SQL Server doesn't like it's machine's name to be renamed. Here's a cool one I didn't know of - I used to re-run the setup, it really didn't installed it again, just clean it up. But here's a better way:

sp_dropserver <old_name>

sp_addserver <new_name>, local

Now all we have to do is:

  • restart SQL instance

  • delete all logins associated with old machine's name

  • add them back

There you have it :)

Thursday, October 30, 2008

How to create and Publish your first Windows Azure application

Ok, I haven't the faintest idea how to do it other than the experience given by Olav Tollefen. I've applied for access and I'm still waiting - the list is long, I'm afraid. Here's the site to go: http://www.azure.com. Be sure to take your time reading Olav's great post!

PS: be sure to register soon, the list is getting bigger!

Wednesday, October 29, 2008

PDC Videos

Unfortunately I didn't find any site with the PDC videos. All I can find is channel 9 PDC videos sections. Here are some of Roy Osherove's recommendations:

Visual Studio 2010 and .NET Framework 4.0 CTP Direct Links

Here's a nice alternative to MSDN Downloads for downloading Visual Studio 2010 CTP - once you have the direct links :)

Enterprise Library 4.1

Enterprise Library 4.1 – October 2008 is Available for Download. Heard it on Guy Burstein's blog:

This release includes:

  • Support for Visual Studio 2008 and Visual Studio 2008 SP1.
  • Interception mechanism in the Unity Application Block.
  • Performance improvements.
  • Usability improvements of the config tool.
  • Fixes.

I'm always divided about EL adoption. Should we adopt best-of-breed libraries or incorporate best-of-breed concepts on a unique and consistent point? Oh well, until them I'll just use both :)

Tuesday, October 28, 2008

Windows Azure

Here's Windows Azure, not a classic OS as some could expected but many had already realized. Here's a cool presentation from Das:

Manuvir Das: Introducing Windows Azure

I've blogged about it some weeks ago, I'll be fun to see how are my forecasts :)

Monday, October 27, 2008

LINQ 'Row not found or changed'

This was pretty annoying... after a while getting an unexpected 'Row not found or changed', here's the solution:

disabled concurrency checks on *all* fields, then added them back one at a time.  Turns out the culprit was a string field that was nullable in the DB but not set as nullable in the designer.

Should probably have chosen EF. No comments...

Monday, October 20, 2008

LINQ to SQL Bug?

Here a great little LINQ to SQL bug. Consider the following code:

    IEnumerable<MasterEntity> masters = db.ExecuteQuery<MasterEntity>(
@"select * from MasterEntity master join DetailEntity detail on master.id = detail.MasterId

Not imagine if you have the same name column both on MasterEntity and DetailEntity, let's say 'IsMandatory'. When you try and get a this property form a MasterEntity object, what should you get?

  1. MasterEntity.Name?

  2. An exception, as Name can be ambiguous?

Well, on my code it happen to return... DetailEntity.Name! Yes, on my dev box the implementation seems to return the first projection by name. If you really want MasterEntity.Name to get returned, you'll have to get:

    IEnumerable<MasterEntity> masters = db.ExecuteQuery<MasterEntity>(
@"select master.* from MasterEntity master join DetailEntity detail on master.id = detail.MasterId

Funny, right? I'd expect MasterEntity.Name to get returned, as your asking for a MasterEntity object, right? No ambiguousness here, or am I wrong?

Wednesday, October 15, 2008

Mac buyers pay Apple tax

Nothing new here except for the confirmation of what we already new: the return of the Microsoft / Apple wars!

Here a great chart (original chart here):

Mac buyers pay Apple tax

Yes, it's a tax. It's called a luxury tax, and only those who can afford it will pay it. It's not fair, it's not rational, but's that's how it is.

Yes, from the hardware value, the price we pay for Macs is too high. The value has been centered on the exclusivity, and that is changing as we can see by Apple's crescent market share, price dropping and Microsoft's discomfort.

Daily I use XP, Vista, Windows Server 2008, Mac OS X and Ubuntu. If I had to choose, I didn't have to think twice: I had to choose Windows. For it's maturity, for it's completeness, for it's application support, for it's hardware support, for it's backward compatibility, for it's great development experience.

But I believe in diversity, so I'm happy with Mac OS X raise on the market. And this is the turning point to Apple, has they seem to already have saturated the market of geeks and people that buy luxury products. Though comfortable with the consumer market, let's see how they cope with the price dropping. And finally, let's see if Apple continues to feel uncomfortable on Microsoft's stronghold: the enterprise market.

CSS Techniques

Whenever I have to create the structure of a site using CSS I usually end up here. Mind as well share it :)

Silverlight 2 Released

Silverlight 2 has been released! Let's see how deep can it go. For me, I've bought the concept - boy, won't HTML/javascript ever go away?...

Monday, October 13, 2008

Windows Cloud again

No, not blogging about the rumor on the name Strata - strata.com is taken, and unless Microsoft has already purchased the domain name, no strata here for them.

Just posting wikipedia's definition on cloud computing:

It is a style of computing in which IT-related capabilities are provided “as a service”, allowing users to access technology-enabled services from the Internet ("in the cloud") without knowledge of, expertise with, or control over the technology infrastructure that supports them. According to the IEEE Computer Society, "It is a paradigm in which information is permanently stored in servers on the Internet and cached temporarily on clients that include desktops, entertainment centers, table computers, notebooks, wall computers, handhelds, etc."

Cloud computing is a general concept that incorporates software as a service (SaaS), Web 2.0 and other recent, well-known technology trends, in which the common theme is reliance on the Internet for satisfying the computing needs of the users. For example, Google Appsprovides common business applications online that are accessed from a web browser, while the software and data are stored on the servers.

Uhmm, and what can Microsoft offer us here? Let's try and guess: well, they have been investing like crazy on huge datacenters, so they will clearly sell “as a service”, but what? Besides the obvious storage and databases, Microsoft can provide a desktop in a cloud to manage it (Live Mesh?), integrated with officelive.com, above the "interconnecting devices" paradigm. They will probably start offering on the cloud all enterprise as services products they offer today as servers (ex: Exchange and Sharepoint) on multitenancy. They will probably lend their platform to others on the SaaS (sorry, Software + Services), making use of the BizTalk Services platform. Finally they can bring a huge marketplace with UDDI and infrastructure services, along with identity, claiming and federation.

On the client, all of this will probably run mostly over a cross-platform desktop application, not over browser. And what about the connected / disconnected model? Well, it has to be supported by a cross-platform framework, and there is where Silverlight can play a significant role. Though Microsoft has not yet decided what is the disconnected persistence framework to adopt, I'd love if they chose something like Bamboo Prevalence over a classical relational based engine.

But what about the consumer market? Lately Microsoft has been traditionally in trouble on consumers. Can they pull an anti-iTunes service? Most unlikely. Can they capitalize their not so cool Mobile Platform by integrating into the Cloud? Well, there's a cool way to go, though traditionally Windows Mobile support is always the last one to get updated.

Let's wait and see.

Sunday, October 12, 2008

A Cray for $25k

I was reading InfoQ's article on MPI.NET and the trend keeps on going: hardware is getting cheaper! Yes, this post is not about MPI, is about getting a Cray CX1 for $25k!

On the early 90's I remember a lecture at college where about a distributed system of Unix servers taking over the responsibility of a Cray supercomputer - apparently the only reason the Cray wasn't disconnected was for the tape library it controlled.

So then I believed Cray were a dying breed of dinosaurs. I was wrong, they are alive and kicking, and you can get one for the price of a regular server 10 to 15 years ago.

I never had so much need for computational power has I did on project SADPOF, an operational decision system for the forest. I'm talking about Simulated Annealing with multi-objective evaluation, huge parallel processing needs of huge chucks of data, with inner LP solving problems. When I'm talking about huge data, I'm talking about simulation variables of matrixes of floats of 6000 x 36 x 32 x 15. And calculating about 30 complex restrictions and a huge objective function.

Our test box was a 2x Quad core and it costed about $5K. A Cray would be welcomed, though MPI doesn't seem to much appealing to work with. What seems appealing is PLINQ, which will no doubt updated to work on HPCs using MPI.

Saturday, October 11, 2008

jQuery strange caching behaviour on IE8 beta

I hate javascript. And the more you hate it, the more you'll like jQuery. Usually it shelves us from browser implementations, this time it didn't.

I have a standard pair of dropdowns with depending values I'm loading with jQuery. Something like:

"ID=" + $(dropdownlistFrom).val(),
function(data) {

On Firefox all works as expected. But on IE8 beta, it activates the caching mechanism! I had to rewrite it to something like:

url: "myJsonService",
cache: false,
dataType: "json",
success: function(data) {
data: "ID=" + $("dropdownFrom").val()

I've also tested on Chrome and Opera working as expected, not caching the data.

Finally I've tested on Safari 3 on Windows, and it just didn't work, cache or no cache! Strange, as jQuery should work on Safari.

Man, I hate javascript...

Tuesday, October 07, 2008

Deploying ASP.NET MVC on a production server

I've just installed my first ASP.NET MVC application on a IIS6 staging server. It's was a Preview 5, and here's how to:

  1. Dependencies: just what you'd expect: Windows Server 2003 and .NET Framework 3.5 (just missed an opportunity to use Microsoft Web Platform Installer Beta);
  2. Web Setup: Created a Web Setup as usual. For some reason it didn't detect System.Web.Abstractions.dll and System.Web.Routing.dll as dependencies, so I had to add them manually. Above all, I didn't have to add assemblies to GAC. Run it as usual;
  3. Tweaking: on my first install I had to set wildcard mapping for aspnet_isapi.dll, as my beautiful restful pages kept returning 404... Here's my first approach, courtesy of Steve Sanderson (option1):

This tells IIS 6 to process all requests using ASP.NET, so routing is always invoked, and there’s no problem. It’s dead easy to set up: open IIS manager, right-click your app, go to Properties, then Home Directory tab, then click Configuration. Under Wildcard application maps, click Insert (not Add, which is confusingly just above),  then enter C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll for “Executable”, and uncheck Verify that file exists.

Done! Routing now just behaves as it always did in VS2008’s built-in server.

Option 1 is a temporary one, I have some time to choose the final one. This solution raises the performance problem posed by Omar AL Zabir that I'll have to address.

Monday, October 06, 2008

Looking out for development info

Searching for development information is paradoxically getting easier and harder. Easier because there is more data to search. Harder for the same reason.

Though Google is always an option, it may be too broad place to search. So I often look for .NET related info on http://searchdotnet.com/, and probably should use more often the http://pipes.yahoo.com/pipes/ concept.

A cool site that has been re-launched http://blogsearch.google.com/. It's a bless if you're lost on a sea of results. One feature I just love is the published date filtering.

Mono 2!

Mono 2 has been released!

Here are my highlights from Mono's highlights:


Microsoft Compatible APIs

  • ADO.NET 2.0 API for accessing databases.
  • ASP.NET 2.0 API for developing Web-based applications.
  • Windows.Forms 2.0 API to create desktop applications.
  • System.XML 2.0: An API to manipulate XML documents.
  • System.Core: Provides support for the Language Integrated Query (LINQ).
  • System.Xml.Linq: Provides a LINQ provider for XML.
  • System.Drawing 2.0 API: A portable graphics rendering API.



  • C# 3.0 compiler implementation, with full support for LINQ.


Windows.Forms: New Controls

  • ToolStrip and MenuStrip
  • DataGridView
  • WebBrowser (based on Gecko!)
  • TableLayoutPanel
  • FlowLayoutPanel
  • SplitContainer


Pretty cool. Can't wait to get it on my Mac OS - hopefully I can get Windows.Forms to work there, Apple has broken Mono's Windows.Forms on 10.5. Let's see if can get back to writing cross-platform Windows.Forms apps again :)

Microsoft Web Platform Installer Beta

The Web Platform Installer Beta (Web PI) provides a single, free package for installing and configuring Microsoft's entire Web Platform, including IIS7, Visual Web Developer 2008 Express Edition, SQL Server 2008 Express Edition and the .NET Framework. Using the Web Platform Installer’s simple user interface, you can select specific components or install the entire Microsoft Web Platform onto your computer. To help you stay up-to-date with product releases, the Web Platform Installer always contains the most current versions and new additions to the Microsoft Web Platform.

Haven't tried  it yet, but Hanselman has mentioned some cool options like "PHP Developer" or "Classic ASP Developer".

Saturday, October 04, 2008

Best practices for creating websites in IIS 6.0

Now that IIS6 is being replaced by IIS, here a cool set of best practices. Don't worry, most of them should be used on IIS - you just have to figure out where they are hidden :)

The best of Steve Ballmer

Well, Microsoft clearly is not as cool as Apple. But with this man as CEO, they seem to be on the right track:

Yes, I know, some of you must be saying: "are we aiming for cool or goofy? ". Well, it seems to work, as Microsoft developers seem to feel supported by this approach. And it is cool to work on technology on a company still lead by techies, not by suits.

Be sure to follow the related videos. Here's one about MacBook Air:

Microsoft's new operating system

Ballmer is announcing a new operating system, Windows Cloud, at the company’s annual developer conference later this month, on a series of presentations.

Yesterday he did it again in Lisboa at Dreamway - unfortunately I couldn't attend, but everyone that I talked with was quite excited about it.

Microsoft has been working on the software + services for long (for instance in devCatharsis: Microsoft is Googling up, Software+Services != Software as a Service and Microsoft Architect Forum 2007 :: Session1: Software+Services), but this is the first time it is branded as a Cloud Operation System. Will the PDC show us a really all new concept, or just a service placeholder for connecting OSs to?

Pararede branding

On the early 2000s I remember having a conversation with a friend about name branding, and used Pararede as an example.

Pararede started its business on networking infrastructures, hence the name (in english something like "For-net"). But the company grew out of its early market and the name just stopped making sense.

On that conversation I advocated Pararede should change its name. My friend disagreed, as a brand's name is a value asset that takes ages to build.

Well, it seems like Pararede opted to change it's name after all. Now it's called Glintt. How strange, a Web2 like name on a company like Pararede...

If you're reading this post, my friend, I'm imaging your reaction: "this doesn't mean they are right, they could be making a big mistake". Well, you're right, Borland did go forth and back to Inprise, only time will tell.


Well, Glintt is not really Pararede rebrandind, is more like the result of Pararede and Consiste merge. Still Pararede is acquiring Consiste...


A common MVC mistake

One of the first errors I've detected on my early MVC code was the tendency to load some list of values directly on the view. For instance:

    <%= Html.FormHelper().Select(
new Hash(selectedValue => new[] { ViewData.Model.Item.MyListOfValuesID }, firstOption => "")

This loading is clearly a controller's responsibility, but I've found it very easy and natural code to write. Too easy.

That brings's me a question: aren't we making a design error when we write controller and views on the same assembly? Shouldn't we make sure all behavior a view could get their hands on should be given by controllers, and never by services? We do it for ages on other layers, for instance we don't expose data layers to UI.

That said, it's really strange no MVC project I got my hands on has ensured this isolation. Probably because these project are all demos, and demos have to be short and concise.

Tuesday, September 30, 2008

WCF refusing connections after 10 requests

Today I learned the hard way the problem of assuming behavior. I assumed IDisposable would clean up the session, but I was wrong.

It seems like we still have to invoke Close explicitly. The documentation clearly recommends the following pattern:

catch (CommunicationException e)
catch (TimeoutException e)
catch (Exception e)

I wasn't closing the client proxy, so I was reaching the default WCF 10 concurrent calls limit. The funny thing is that the integration tests were working fine, but not the corresponding ASP.NET usage. Why? Here's a possible explanation:

Hopefully, you were clued in enough to know you need to dispose these objects... but the problem is that (...) the (...) code blocks will cause major problems in a production environment. The choice the WCF developers made here is questionable at best and goes against everything you thought you knew about the IDisposable interface. Everywhere else in the .NET framework, you can count on Dispose cleaning up your object... not so in this case. The problem is that Dispose actually calls Close, and if you are using something like the WsHttpBinding, Close doesn't just clean up resources managed by the object. Close actually needs to make a call to the server and tell the server to clean up your session before it shuts down. When that call back to the server can't be made for any reason--which can happen quite often--Close fires an exception and the object is not disposed. There is another method, Abort, which you need to call to clean up the object's state.

Announcing Visual Studio Team System 2010

Microsoft has published some information about Visual Studio 2010 and the .NET Framework 4.0 today. Here are some links about it:



Visual Studio Team System 2010 Week on Channel 9:


Heard about it here.

Sunday, September 28, 2008

jQuery and Microsoft

Uau!... Scott Guthrie as just announced that Microsoft is distributing jQuery with Visual Studio!

This is awesome, instead of re-creating what already exists, Microsoft is learning to integrate. Wouldn't it be incredible if Microsoft didn't have to re-create a DI, a logging platform, a full blown ORM mapper, among others?

Keep them coming. You're on the right track :)

What's wrong with Android?

Ok, Android is a cool phone, but it still lacks a bunch of obvious features like:

  • using it as a modem connected to your laptop;
  • no sync with your computer, pushing Google's mobile web-based applications;
  • no Exchange support;

My old WM6 does it all.

Finally I've got myself a MVC project!

Yes, is true, I finally got myself a real project willing to accept the ASP.NET MVC Preview 5. I'll save my impressions for a future post, for now I'm just interested on sharing my options.

My first thing I had to opt was how to express the model. I've opted by a strongly-typed approach. For the backoffice models I've decided to create the following classes:

    /// <summary>
/// Base class for data driven models.
/// </summary>
public abstract class BaseViewData
private readonly List<string> displayList = new List<string>();

/// <summary>
/// List of messages to display.
/// </summary>
public IList<string> DisplayList
return displayList;

This is the base class for all the models - for now it just hold the list of messages to display. Please note that this is the MVC model, not the domain model.

Let's move to the first implementation: ListViewData<T>. This class is a generic of domain model entity classes, and represents a simple listing view data:

    /// <summary>
/// Model view data for simple listing pages.
/// </summary>
/// <typeparam name="T">Domain model entity class.</typeparam>
public class ListViewData<T> : BaseViewData
/// <summary>
/// List of items of type T.
/// </summary>
public IList<T> Items { get; set; }

Not precisely rocket science, but if simplicity is important to software process in general, adn according to my readings, it seems to be critical for the success of MVC implementations. Armed with this simple classes, we can now do a simple change to the view code behind:

    public partial class List : ViewPage<Models.ListViewData<DomainModel.MyEntity>>

So we can now fire away our view and code something like:

    <%= Html.DisplayMessages(ViewData.Model.DisplayList)%>

DisplayMessages is a simple extension that implements... the messaging displaying itself...

Now for the grid. I've opted for the MVCContrib Grid implementation. Ok, not as cool as rendering the markup from scratch, but what can I say, I'm lazy.

column => {
column.For(p => p.Name, "Name");
column.For(p => p.Description, "Description");
column.For(p => Html.ActionLink("Edit", "Edit", new { id = p.ID }), "Edit").DoNotEncode();
column.For(p => Html.ActionLink<MyEntity>(
c => c.Delete(p.ID),
new { onclick = "javascript:return confirm('Confirm operation?');" })

The only radical option I had was not to use ASP.NET server-side controls (like repeaters, textboxes and others). If I understand correctly, though these controls can be use on MVC, they are not MVC-ecosystem friendly, as they are fat, not always XHTML compatible, don't guarantee support for accessibility and still depends on ViewState for some operations.

For editing the entity itself, I wrote an equivalent class, ViewData<T>:

    /// <summary>
/// Model view data for simple editing pages.
/// </summary>
/// <typeparam name="T"></typeparam>
public class ViewData<T> : BaseViewData where T : new()
private T item = new T();

/// <summary>
/// An item of T.
/// </summary>
public T Item
return item;

item = value;

Same with the view code behind:

    public partial class Edit : ViewPage<Models.ViewData<DomainModel.MyEntity>>

And with the view itself:

    <form action="<%= ViewData.Model.Item.ID != 0 ? Url.Action("Update", new {id = ViewData.Model.Item.ID}) : Url.Action("Insert") %>" method="post">
<td><%= Html.TextBox("Name", ViewData.Model.Item.Name)%></td>
<td><%= Html.TextBox("Description", ViewData.Model.Item.Description)%></td>
<td><input type="submit" value="<%= ViewData.Model.Item.ID != 0 ? "Update" :" Insert" %>"/></td>

Naturally not all models depend entirely on a sole Domain Entity. Some do depend on depending entities, like:

column => {
column.For(p => p.Name, "Name");

But for the rest of the scenarios, we should define a class for the model. Something like:

    public class MySpecialListViewData : ViewPage<Models.ListViewData<DomainModel.AnotherEntity>>
public bool ShowSomething { get; set; }

Dependent on NDepend

I spend a considerable part of my time reviewing and refactoring code. Code written by interns I coach, master thesis students I accompany, external projects I'm asked to audit, and last but not least my own code.

For ages, code reviewing and refactoring was considered a luxury most projects could easily live without, but on the last years it finally got mainstream acceptance - yes, today I can even explicitly add refactoring tasks to my projects planning :)

Tools have been accompanying this trend. Tool like Resharper on what Patrick Smacchia refers as the micro level (i.e methods' body structuring). But when projects fail technically, they usually do it on a macro level (i.e class, namespace, assembly structuring), and here is where NDepend comes to the rescue.

NDepend is a tool that analyze .NET code base structure against a set of design rules, suggesting refactoring and allowing version metrics comparisons. Yes, making part of my job. Oopss...

Here are some of the basic metrics anyone would expect to find:

And here are some cooler ones:

  • Afferent coupling (Ca): The number of types outside this assembly that depend on types within this assembly. High afferent coupling indicates that the concerned assemblies have many responsibilities.
  • Efferent coupling (Ce): The number of types inside this assembly that depends on types outside this assembly. High efferent coupling indicates that the concerned assembly is dependant. Notice that types declared in framework assemblies are taken into account.
  • Lack of Cohesion Of Methods (LCOM): The single responsibility principle states that a class should not have more than one reason to change. Such a class is said to be cohesive. A high LCOM value generally pinpoints a poorly cohesive class. There are several LCOM metrics. The LCOM takes its values in the range [0-1]. The LCOM HS (HS stands for Henderson-Sellers) takes its values in the range [0-2]. A LCOM HS value highest than 1 should be considered alarming. 
  • Relational Cohesion (H): Average number of internal relationships per type. Let R be the number of type relationships that are internal to this assembly (i.e that do not connect to types outside the assembly). Let N be the number of types within the assembly. H = (R + 1)/ N. The extra 1 in the formula prevents H=0 when N=1. The relational cohesion represents the relationship that this assembly has to all its types.
  • Instability (I): The ratio of efferent coupling (Ce) to total coupling. I = Ce / (Ce + Ca). This metric is an indicator of the package's resilience to change. The range for this metric is 0 to 1, with I=0 indicating a completely stable package and I=1 indicating a completely instable package.
  • Abstractness (A): The ratio of the number of internal abstract types (i.e abstract classes and interfaces) to the number of internal types. The range for this metric is 0 to 1, with A=0 indicating a completely concrete assembly and A=1 indicating a completely abstract assembly.
  • Distance from main sequence (D): The perpendicular normalized distance of an assembly from the idealized line A + I = 1 (called main sequence). This metric is an indicator of the assembly's balance between abstractness and stability. An assembly squarely on the main sequence is optimally balanced with respect to its abstractness and stability. Ideal assemblies are either completely abstract and stable (I=0, A=1) or completely concrete and instable (I=1, A=0). The range for this metric is 0 to 1, with D=0 indicating an assembly that is coincident with the main sequence and D=1 indicating an assembly that is as far from the main sequence as possible. The picture in the report reveals if an assembly is in the zone of pain (I and A both close to 0) or in the zone of uselessness (I and A both close to 1).

Most of this metrics come with recommendations. For example:

Methods where NbLinesOfCode is higher than 20 are hard to understand and maintain. Methods where NbILInstructions is higher than 40 are extremely complex and should be split in smaller methods (except if they are automatically generated by a tool).

Or this:

Code where the percentage of comment is lower than 20% should be more commented. However overly commented code (>40%) is not necessarily a blessing as it can be considered as an insult to the intelligence of the reader. Guidelines about code commenting can be found here.

Let's give it a try against a small R&D project written with NetTiers. I'll use VisualDepend, the interactive tool. A command line utility is also available, but I'll save it for a future post on continuous integration.

The rules are expressed using a cool DSL for code metrics: Code Query Language (CQL). You can express queries like:

// <Name>A stateless type might be turned into a static type</Name>
SizeOfInst ==0 AND
NbInterfacesImplemented == 0 AND // To be accurate, this constraint doesn't take
// account of types that implement some interfaces.
!IsStatic AND
!IsGeneric AND
// It indicates stateless types that might eventually be turned into static classes.
// See the definition of the SizeOfInst metric here http://www.ndepend.com/Metrics.aspx#SizeOfInst

Cool, you can use the set of rules that come defined out-of-the-box, and you can always write your own.

Here's another favorite of mine:

// <Name>Fields should be marked as ReadOnly when possible</Name>
WARN IF Count > 0 IN SELECT FIELDS WHERE IsImmutable AND !IsInitOnly

// A field that matches the condition IsImmutable is a field that is assigned only by constructors of its class.
// For an instance field, this means its value will remain constant throught the lifetime of the object.
// For a static field, this means its value will remain constant throught the lifetime of the program.
// In both cases, such field can safely be marked with the C# readonly keyword (ReadOnly in VB.NET).

// The condition IsInitOnly matches fields that are marked with the C# readonly keyword (ReadOnly in VB.NET).

And look, we can see it against the metric view:


Oopos, lots of potential refactoring here (the blue components)... This view components are directly proportional to the metric - in this case, number of fields by type. Yes, NetTiers appications tend to do it.

As expected, NDepend help you identifying dependencies. For a start, it does it graphically:


But graphical dependencies are hard to scale, so the matrix representation is my favorite one to keep track of dependencies:


Finally an important artifact to give you an idea of where you stand is this graph that represents abstractness and stability:


I read a lot of code - anything I can get my hands on.  One thing I've been doing lately is running NDepend against all the code I can - I find it most educating.

The tool itself is very drillable and effective. The only problem I had with it was the lack of support on some actions on x64, but since version 2.10 full 64 bit support was added.

Give it a try. A must.

Friday, September 26, 2008

Silverlight 2 RC0

Guthrie has just announced it.

I'm having some troubles with visual studio sudden disappearance (the dreadful .NET Runtime version 2.0.50727.3053 - Fatal Execution Engine Error (742A5E00) (80131506)) after SP1 or Silverlight 2 beta2 installation, so I'll probably skip this one.

Sunday, September 21, 2008

Windows 7 M3 Build 6780 Pictures

Here they are Not much revolution here, it looks like some minor shell changes, some old applications got to be redesigned with the Office ribbon, a lighter media player, among others. And UAC seems to be less poppy. Hopefully it will be less resource hungry.

Is Microsoft finally learning to keep their secrets?...

Google is still kicking (Microsoft) asses

The trend doesn't stop: Google search keeps rising, Microsoft plunging. The latest data reports Microsoft US Search dropping below 1 Billion hits last August.

And with respect to Mobile things are preparing to get worse: in a couple of days T-Mobile will release the first Google based phone. A phone with Google's brand and usability and opened to application development will surely eat much of Microsoft's share.

On the browser market, IE is still loosing space against Firefox (ok, Firefox is not Google, nevertheless Google pays 85% of Firefox's bills). And Chrome will rise, the only doubt is who will give away more market share to Google.

So what should Microsoft do about it?

  • Buying out on the search market doesn't seem to help - the obvious choice failed (besides, they are also on a loosing trend). Unless Microsoft can find  a revolutionary search company, Microsoft as to earn this market.
  • Mobile is not as bad as it seems the minute we put a decent shell above it. It looks like some shell and some core apps might do the trick. Here Microsoft as a strong position on the AD/Exchange integration, but that doesn't say much for the consumer market.
  • The browser market is moving the right way: toward W3C compatibility. Though many advogate IE should adopt an open source rendering and javascript engine, Microsoft needs to keep control on IE if not for others, to support it's intranet strategy.
  • Microsoft need to invest more on less resource-hungry systems.

The time to sell just using Microsoft's brand as come to an end. Worse, Microsoft is experiencing a brand erosion effect, at least when compared to Apple and Google's branding.

So part of the solution is on the march: the PC Is not a Stereotype campaign. Ok, it doesn't work against Google, just Apple, but still a great start.

Wednesday, September 17, 2008

Java versus .NET

When talking about Java and .NET people tend to get radical and irrational - I know I do. So I'll try to be write this post as objectively as the sacred .NET and heretic Java deserve.

On the beginning there was C and C++. Well, not exactly the beginning, let's say at the beginning of this war.

Then some enterprises embraced VB as a RAD platform, and VB ruled. VBScript and ASP came following and also ruled.

Then the Devil created Java. Java was beautiful on the blueprints, but lacked maturity. The ubiquity it observed made some believe it would be the solution for enterprise integration - they were wrong, the dictatorship of one language just failed. But slowly Java appeared as a solid enterprise environment, so it started to gain position on the financial markets.

Then God create .NET. It was basically a Java ripp-off, a virtualized environment with a great and well organized class library armed with a solid garbage collector. Where Java environment was multi-platform, .NET was multi-language - yes, today JVM supports a lot of languages, but not back there.

.NET was everything Java wanted to be. Solid, well designed, learning from the Java errors, it only had a problem: it was locked to Windows.

So .NET was immediately accepted even by most of those who hated Microsoft. More, Microsoft promoted a different kind of community, much broader and open-sourced, and it worked! .NET was now the new Java! More, it learned to incorporate Java concepts with ease, so kept growing side-by-side with his evil brother.

.NET had another advantage: it was drawn from one division, so it grew solid and consistent.

So where are we now in respect to Java / .NET war? Well, from my experience:

  • generally .NET is still gaining terrain over Java;
  • Java keeps gaining terrain over .NET on SOA;
  • Java's stronghold is still the financial market;
  • some alpha-geeks lost interest of .NET;
  • Windows Forms desktop application continue to loose interest;
  • Other cool languages and environments still didn't hit the enterprise

Here are some cool links about it:

Monday, September 15, 2008

Mozy doesn't work on my Windows Server 2008

Arghh, I have some hundreds of megs of file standing on Mozy and can't get them into my Windows Server 2008:

MozyHome may not be used for server backups.

What you can do:

Transfer your MozyHome license onto a valid desktop or laptop, or sign up for a MozyPro Server license to back up your server.

Arghh, how can you explain Mozy I use Windows Server 2008 as a desktop?... Well, seem like I have to use Mac to restore them.

Could someone please extend mail?

I waste a lot of time archiving mail by project. So the question is: why can't we just extend mail fields?

Just imagine:

  • Fields would be urn based, and a set of basic fields would define:
  • Mail applications could create templates extending fields;
  • Fields would be sent on reply;
  • When filling fields, mail applications could select from a used list of values.

If we could extend mail, a "Project" field would probably the first one we's use. a

PS: here's how I use the "Project" field today: I embed it on the subject field, something like "[Project A] Kick-off meeting".

Friday, September 12, 2008

I just love guidance

Ok, automated guidance in context is cool, but you can't just replace good old classic guidelines. Here they are, from the patterns & practices App Arch Guide 2.0 Project:

  • Architecture and Design Guidelines
  • Presentation Layer Guidelines
  • Business Layer Guidelines
  • Services Layer Guidelines
  • (from the Guidelines Index page).

    Here's the announcement from J.D. Meier.

    Project location is not trusted on a local drive

    I've been getting some "Project location is not trusted" on my local drive. I've finally decided to google it, and found out the answer here. And yes, it makes sense, the problem arises when downloading code from zip files, leaving the files blocked on a low thrust zone.

    Unblocking all the files is a tedious task, so ZoneStripper is a life safer!


    I'm trying a free account of Dropbox, a easy to use sync and share tool. For now I'm syncing a Windows and Mac, but I'll probably install it on my Linux desktops. My favorite features: desktop integration (though pretty much Tortoise-like icons...) and version control.

    Here's a cool list of sync utilities: Five Best File Syncing Tools.

    Thursday, September 11, 2008

    Chrome cool links

    I was reading Hanselman's Microsoft IE8 and Google Chrome - Processes are the New Threads and found this cool Chrome links:









    Wednesday, September 10, 2008

    Scrolling through tabs shortcuts

    Scrolling through tabs is a common operation that can be achieved through CTRL-PageUp and CTRL-PageDown shortcuts. It works on Excel, Firefox, Chrome, but strangely isn't supported on IE8 beta2. Did it stop working, or IE never implemented this useful feature?

    Persistence Ignorance (POCO) Adapter for Entity Framework

    Let's face it: Entity Framework suffers from a huge architectural problem: the business entities are tightly couple with Entity Framework.

    Here a band-aid: Persistence Ignorance (POCO) Adapter for Entity Framework.

    It uses an adapter layer that will translate between POCO objects and Entity Framework-aware objects and provide services on top of POCO objects, such as:

    • Change tracking (snapshot-based and proxy-based when possible)

    • Transparent lazy loading

    • Immutable Value Objects

    • Queries (LINQ and Entity SQL)

    • Shadow state (maintaining certain persistence-related fields outside of entity class)

    It includes a library helper and a code generator which generates the adapter layer.

    And here's Kowalsky's article about it.

    Tuesday, September 09, 2008

    Google just launched a High-resolution satellite

    Google has just launched a High-resolution satellite. The corporation that Claims Ownership of Everything You Create on Chrome, From Blog Posts to Emails, the same that holds much of our mails, consumer habits and search trends, the company that wants a sub-continent-wide radio-frequency, the company that want's to control the internet end-to-end with Chrome (and a sure to come supporting Google OS), that very same corporation now can take high-res pictures for their own usage.

    For some strange reason, people just feel comfortable with this.

    Arghh, I give up.

    Monday, September 08, 2008

    Market Share

    After a brief discussion about Firefox / IE market share with my colleagues, I've (arbitrary) decided to trust MarketShare to tell me this kind of info. According to them, IE falled to 72.15%, and Firefox is still gaining track with 19,73%. Last October it was 78.36% / 14.97%.

    Can you suggest a better stats report?

    Sunday, September 07, 2008

    What is Oslo?

    Douglas Purdy is on his way to PDC, where he will begin unveiling project Oslo. So what is Oslo?

    • A tool that helps people define and interact with models in a rich and visual manner
    • A language that helps people create and use textual domain-specific languages and data models
    • A relational repository that makes models available to both tools and platform components

    So what else is new, Oslo is the modeling platform that will allow us expressing DSLs. But wait, here's what I like about Douglas's vision:

    Oslo is the first step in my vision “to make everyone a programmer (even if they don’t know it)”.

    And this can very well be the first step toward The future of my profession.

    The New Windows Consumer Campaign

    Here is the first Seinfeld / Gates ad. Good news is that is not being offensive to Apple, the bad news is that you must have a master in advertisement to understand it.

    Friday, September 05, 2008

    Google Chrome task manager

    Google Chrome task management is one of the cooler features. And the task manager is just awesome. The only problem I have is that, until the rich RIA applications start poring down on our browsers, the resource we all know that wastes CPU and networking is Flash. And it looks like their is only one and only reference to the Flash plug-in on Chrome task manager:


    That being said, I'd risk to predict that for this class of resource usage, Chrome won't help us identifying the guilty tab for most of our present cases.

    Still a great feature and browser.

    Team Development with Visual Studio Team Foundation Server

    Here's a great TFS guide. Thanks for the tip, Cab_Ux.

    Wednesday, September 03, 2008

    Chrome Privacy?

    Oops, I'm not the only lunatic. Here's another one.

    PS: my hand is raised :)


    Here's another one: Google on Chrome EULA controversy


    AdBlock for IE8

    Here's a cool IE8 add-on: AdBlock Pro. I've been using it for a week, and it works fine.

    Ad blocking your browser is one of the feature most geeks can't live without. I have mixed emotions about them. Business that depend upon them advertising just hates them. Google will be happy to control ad blocking over their new browser, but until them, you'll have to stick to Firefox and IE to get it done.

    Thanks for the tip, Pita.

    Google Chrome

    Nothing much to say here. Google now has it's browser, Google Chrome. It is opensourced, light and minimalist, fast and easy to use. WebKit is a fast rendering engine, V8 promises to be a faster javascript engine. RIA experience will most probably explode, and this is the best news. Tab fault isolation is my preferred feature. Next is the well designed tab memory management,

    Not all Chrome's features are new - Firefox and IE8 share some if not most of them.

    For now it is quite harmless, but when armed with a future Google minimalist OS, and over Google minimalist window manager, will bring end to end autonomy to Google. Can't it be possible that nobody cares about being totally controlled by Google?

    Now I'm beginning to understand those conspiracy theory lunatics warning us about aliens and underground politics ...


    My current experience: IE8 is now the browser that uses less memory. Followed by Chrome (it problably didn't have a chance to make use of it tab memory management features). Firefox3 is absolutely disastrous - please note, I'm loading 7 or 8 add-ins. Some thing with startup time.


    Clone Detective for Visual Studio

    Here's an integrated code duplication analyzer: Clone Detective. A Simian like Visual Studio integrated tool. Cool!

    Monday, September 01, 2008


    I've already blogged about it, but now it seems more mature - and named differently? Anyway, here's a tool to follow. It can help us produce elegant and consistent code. As Fowler wrote:

    Any fool can write code that a computer can understand. Good programmers write code that humans can understand

    Protecting Your Cookies: HttpOnly

    Atwood warned us of an old way to defeat a class of cross-site-scripting. Yes, it deserves a re-issuing and refreshing, but above all we do it the guidance way. Yes, it is there...

    Accessing HyperV over wireless adapter

    It is not new, and quite obvious, the way to access HyperV networking over the wireless adapter. Here's why we can't do it directly:

    The reason for this is because in order to perform our virtual networking - we implement an OSI layer 2 filter driver that creates network packets with the MAC address of the appropriate virtual machine. Unfortunately the wireless networking standard explicitly forbids the creation of network packets with different MAC addresses to that of the physical computer (for security reasons). To handle this - when we detect that we are using a wireless network adapter we create packets where some of the MAC addresses in the packet match that of the virtual machine - while the other MAC addresses match that of the physical computer.
    It seem like it was too much AP dependent - sometimes it worked, sometime it didn't.

    Saturday, August 30, 2008

    Microsoft Pro Photo Tools

    I have mixed feelings about this tool. It is simple to use, allows GPS data to be added to my photos, integrates with Virtual Earth, and finally: it is a .NET application :)

    On the other side it seems quite unpolished. For instance, it often crashes upon unexpected scenarios, and uses the regional settings to load the NMEA data. Yes, I have to change my settings in order to run this tool... Another particularity about this piece of software is that its first versions weren't obfuscated.

    It's a pity that the application I use for my photo capture workflow, Adobe LightRoom, doesn't support it yet. But wait, there's a plugin, geotag-lightroom-plugin. I'll give it a try.

    Friday, August 29, 2008

    IE8 rocks!

    Though using IE, Firefox, Opera and Safari, the truth is Firefox is the browser I end up spending more time in. This trend may change with IE8 beta2. After a disappointing and unstable Firefox3 (and the first IE8 beta), IE8 Beta 2 is finally showing it's claws!

    IE8 is full of new features like WebSlices, Accelerators, auto complete, multiple-engine support (IE7, IE8 compatible and native mode), InPrivate browsing and other cool safety features, out-of-the-box developer tool and finally a decent firefox-like text search tool.

    Having the possibility to make the sites compatible is an important  asset, now that Microsoft decided to pay the price for not following the standards. What I still lack is the cool FireFox add-ins. Wouldn't it be great if someone developed a Firefox/IE addin translator?...

    Thursday, August 28, 2008

    When trains and software converge

    In the 30s of the last century, the Lisboa-Porto line was never on time. Though users kept complaining about delays, the train records kept logging no such delays, and both train and station managers stood by those logs.

    Something was terribly wrong, so the train company's president himself decided to take a train to sort it out. For each and every station the train arrived later and later, and for each and every station the train and station managers logged it as being on time. It was quite amusing, being as late as 30 minutes and hearing the station's manager screaming "On table!!!".

    The  president confronted the data with the train and station managers, and they finally told him what was wrong: it was impossible to keep the proposed timetable, so they opted to fake the logs. The president took two obvious measures: updated the timetable and fired those who faked the logs.

    Why am I talking about trains on what should be a geek's blog? Because in a way we also suffer from this problem. As we presently are still unable to predict correctly our project's effort we keep getting late on our timetables. And for the same strange reason as with the train people, some people don't report the delay as soon as we should, not leaving too much track to recover from.

    Right now we have no way to anticipate correctly our timetables. But once our train starts, we can measure our effective speed and measure where we are against these timetables. Though our project management practices already enforce these measures, they are only as accurate as the information they receive, so the teams should be trained to log delays as soon as possible. I'm talking about intra-task delays and that gut feeling only the team can sense as that all the estimation is going down after just a week's work.

    And finally, as timetables are presently hard to do accurately, we should do something about it: better effort history management, and sharing the timetable's risk with our client. At least until our project's effective speed is taken.

    Tuesday, August 26, 2008

    NHibernate: 2 - Entity Framework: 1

    Sorry, couldn't help picking on Entity Framework. Ayende has annouced it, NHibernate 2 final is out! May the best win. Wait, better yet, may they both win.

    Monday, August 25, 2008

    Converting NMEA format to KML

    I've been doing some off-trail hiking on this holidays, and logging them on my GPS. To convert them into KML, I've started using an online tool, GPSVisualizer. This is a cool converter, but I really needed an offline tool, so here are a couple of free tools that also run on Mac OS:

    Thursday, August 21, 2008

    Windows, Not Walls

    Microsoft finally got tired of Apple's advertisements of bad manners, and decided to answer with the same guns. For ages, Apple has been investing on a series of bad taste advertisements thrashing Microsoft, so they come up with a new $300 million advertising campaign, devised by a newly hired ad agency.

    Microsoft enlisted Jerry Seinfeld in its ad battle against Apple, but this is just one of the new troops on the way.

    To be honest, I'd rather Apple stopped the bad manners trend. Unfortunately, this won't happen, and Microsoft is lowering the war to Jobs level.

    Development Catharsis :: Copyright 2006 Mário Romano