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

Friday, August 31, 2007

Why can't processes just hibernate?

OSs hibernate. Processes don't. Can anybody (functionally) explain me why not? Doesn't anybody feel the need to hibernate processes, saving memory usage? We know that OSs reclaim most of memory when not needed, but I can still find useful to hibernate some process in order to start another one, and switch them whenever necessary.

Entity Framework beta2

The Microsoft Entity Framework allows developers to close the gap between objects and our data stores. The second beta of the Microsoft Entity Framework is available now for developers to get a jump-start on exposing our data models as objects. This release also comes with the first beta of the Entity Framework Tools providing a graphical front-end to your entity data objects.

in: InfoQ

Thursday, August 30, 2007

List Predicates

Here's a great post about List Predicates from the BCL Team. It ends up with another link: Collections Best Practices.

Friday, August 24, 2007


Take a look at an experimental Silverlight-based interface to Live Search called Tafiti. Cool...

How to document use cases

Here's a great post about use cases. There I found this other great link about Five use case traps to avoid. Those are:

Trap #1: Use cases that users don't understand
Trap #2: Too many use cases
Trap #3: Overly complex use cases
Trap #4: Describing specific user interface elements and actions
Trap #5: Not using other requirement models

The first one is probably the one that trouble us the most.

Thursday, August 23, 2007

What I hate about the Zen Vision:M

Last year I was fortunate enough to win a 30GB Creative Zen Vision:M on TechEd at Barcelona. I was very excited with the video and capacity advantages over my good old 1GB Muvo. But for strange as it may seem, my usage experience was significantly worse. Let me tell you why.

Let's start with my usage. I use it for audio books and podcasts. Mainly podcasts.

So what's wrong about Zen Vision:M?

  • I cannot navigate by directory, so I have to rely on the providers categorization; and by god, they are not coherent, event from episode to episode on the same podcast. The worst case is Hanselminutes, which I cannot find neither by Album nor by Autor, making me choose by track - over a 30GB catalog!;
  • I cannot delete the current playing track - this is crucial for managing podcasts;
  • I cannot ear the podcast when playing forward - this is a great way to skip advertisement;
  • when I shutdown the device, the track will resume where it stop, as expected; but only for a couple of hours, if the device is kept disconnected for over 3-4 hours, the track is resumed from the start; this strange feature doesn't happen on the Videos;
  • the device is too heavy and clumsy to carry with you daily; it is, however, very well built;
  • the control cannot be "blindly" operated from the pocket - the Muvo can;

So the verdict is: Vision:M was not built to podcasts. It is great to play music, and just awesome to play video, but apart from the 30GB capacity, the Muvo is unbeatable.

And the worst experience developing for GPS mobile applications goes to....

... not carrying the development environment with you when real testing the application. Ok, I could carry my laptop around to our drivings, but I'm on holidays, it is hard enough to explain to my wife and daughter using the laptop on the hotel...

Yeap, it's darn disappointing to find you left an annoying balloon looping over you application when some "it will never happen" scenario you did anticipate but didn't bother to treat comes together... Let's all (most of us to be more precise) tank God for not having to write critical software for an intergalactic probe - we'd probably find it too stressful not to be able to correct one's mistakes...

Tuesday, August 21, 2007

Database denormalization on internet-scale sites

Arnon Rotem-Gal-Oz as posted about database denormalization on internet-scale sites (such as Amazon, eBay, Flickr , etc...).

The A&D 2007 : The eBay Architecture (Randy Shoup & Dan Pritchett) is triggering the discussion.

Examples of the denormalization:

  • disabling transactions;
  • denormalizing data;
  • [not circumscripted do DB] SOAing the operations by business classes;
Data denormalization is not news to us - I remember back in college to learn to normalize to the Nth Codd normal form, and then to denormalise if necessary. The fact that 3-tier arquitectures doesn't guarantee scalability is not news either. What really impresses me is the option to drop ACID transactions.

Duck Typing in C#

Let's be clear about it: there's nothing wrong about Duck Typing, as long as we used it on exceptional cases, and on a controlled environment like the duck typing project.

Here's a sample:

public interface ICanAdd
int Add(int x, int y);

// Note that MyAdder does NOT implement ICanAdd,
// but it does define an Add method like the one in ICanAdd:

public class MyAdder
public int Add(int x, int y)
return x + y;

public class Program
void Main()
MyAdder myAdder = new MyAdder();

// Even though ICanAdd is not implemented by MyAdder,
// we can duck cast it because it implements all the members:

ICanAdd adder = DuckTyping.Cast<ICanAdd>(myAdder);

// Now we can call adder as you would any ICanAdd object.
// Transparently, this call is being forwarded to myAdder.

int sum = adder.Add(2, 2);

Why restrict Duck Typing usage? Because (whenever possible) early interface identification lowers the typing mismatch. In my view, we should privilege early interface definition whenever possible.

WWMX - World Wide Media Exchange

Heard about the concept itself from my friend Nuno Ferreira. Nuno had the idea of crossing GPS and photo data in order to stamp GPS positioning into photo EXIF data by matching timestamps. I believe he did some implementations around the ideia but I lost track of his project. Here's another implementation of his concept: WWMX.

Diagram showing programming paradigms and their relationships

Here is a diagram showing the main programming paradigms and their relationships.

Have you notice the declarative / imperative tension?

taken from Lambda The Ultimate.

List of Free GPS Software

Here it is.

And here is GPX and GPX's applications.

And now that were talking about GPS, here's a nice (and frozen?) little project: GPSTracker. Not in a final and stable version, I'm afraid (I'm using Orcas Beta 2, hope some of the instability doesn't derive from it). Would you like to finish it?

PS: don't get me wrong, I just love gpsapi, but would it hurt to write some simple documentation?

PS2: I'm using the Microsoft.WindowsMobile.Samples.Location gpsapi library, is there anything better - and free? I'm considering SharpGPS, but I'm not sure about the lack of gpsapi support.

Saturday, August 18, 2007

How should I deploy Windows Mobile Applications?

It's been a while since I last wrote some code to a mobile device - I had an Everest with Pocket PC 2.0 and a modem on a cradle back in the late 90's.

The developing environment was ok, but some basic plumbing like ADO only came with 2.1. I had some trouble setting the VB runtime, so MFCs and even the big-switch model dominated the (in)utilities I wrote back then.

We came a long way 'till my current environment, but one thing is bothering me now: why do I have to sign a certificate to write an application on my mobile?

Is it for enterprise security sake? Probably. But why shouldn't people be allowed to use my in-utilities, other then the fact that they aren't useful at all? I've just wrote 2 perfectly useless utilities to try the gpsapi (a speed alarm and a clock setter), and I cannot push them to anyone. So how in hell's name will my in-utilities by trashed?! Not fair...

Definitely, I hate close systems. The Von Neumann machine as to re-enter the Windows Mobile...

PS: one cool feature gpsapi gives us is concurrent access to the GPS.

Friday, August 17, 2007

NHibernate slow "warm-up"

If I had to pick the thing that annoyed me the most about NHibernate (other than being so typeless on queries...), I'd had to choose: "the slow warm-up".

This is a problem that only arises when you start mapping too many HBMs. We're currently mapping over 60 HBMs, and the factory startup is taking something like 30 seconds on our dual core developing workstations. This as a negative impact on the development cycle.

Yes, I know, I should find out the solution first, and post it here. But as usual, I'll start googling for this soon after the posting of the question. This is supposed to be a diary, right?

Isn't it fun when user experience was supposed to be better?

Yeap. User experience is the main drive for AJAX applications. But what to do when user experience sucks because of AJAX?

That will often happen with low bandwidth. I've been experiencing this connecting via GPRS.

One of the worse AJAX experience you can get is with hotmail.com - but at least they give you the opportunity to use the non AJAX version.

Google Analytics is a nightmare - from far the worst experience over slow connection. No surprise here, being one of the best user experiences over normal bandwidth.

Google mail is decent over slow connections, which may come as no surprise, given that gmail offers a plain and simple user experience.

Blogger.com experience is also decent, and above all very tolerant to intermittent connectivity. This is one of the few applications that asserts lack of connectivity - the majority just fail silently...

Wednesday, August 15, 2007

GPRS sucks... but it works

I'm presently posting using a GPRS connection - yes, it's true, HTC 3300 doesn't support UMTS.

So how slow is GPRS? Here is the result from my device on bandwidthplace.com/speedtest: 2.4 mbps.

2.4 mbps?!?! Eh, eh, eh, I 'm using Opera Mini, all traffic is proxied :) Now from IE: 48,8 kbps.

48,8 kbps is in the range of V90 modem and RDIS. According to Wikipedia, I should have at most something like:

  • 80 kbps downstream / 20 kbps upstream
  • 60 kbps downstream / 40kbps upstream

What about the cost? I'm using an enterprise bundle which comes with base traffic usage from which all of us can take traffic. It usually gets exhausted on day 22 of each month, and from then on we have to pay 0,085€ / MB, on 100KB slots.

It's true, GPRS is darn slow, but it keep me informed and posting from just about anywhere.

I hate closed systems!

I'm on holidays. And what's best about holidays? Getting to start those development projects that are really fun.

So yesterday was my time to start developing on my HPC 3300. I started with an "Hello World" app to test the 2008 beta 2 developing environment, tried to deployed it and got some dreadful "sorry, no certificates, no can do". Arghh!!!

It's probably just a question of configuration - at least I hope so. I'll start googling for the solution and post it here.

[update] here's what I need: Signing an Application During Day-to-Day Development

To Sign a C# or Visual Basic .NET application:

  1. In Solution Explorer, right-click the project, and then click Properties.

  2. Click the Devices tab.

  3. Select the Authenticode Signature check box.

  4. Click Select Certificate.

  5. Do one of the following:

  6. On the Authenticode Signing page, click OK.

Strange wattmeter reading

When I plug my old Celeron to the wattmeter, I get a reading of 28W with the system down! Can it be possible?

I finally got myself a wattmeter

I've bought it for 26€ on AKI. It measures:

  • tension (V)
  • current (A)
  • power (W)
  • work (kW/h)
  • cost

I just tried it on the remainings of my datacenter. And here are the first results (as informal averages):

  • Celeron 2400: 100 110W
  • 600VA UPS: 75 30W (oops...)
  • Wireless Router + ADSL Modem: 25 18W (arghh, 2 separate sets... must combine them to save power)
  • 17' TFT: 15W
  • Wireless Phone: 3 4W

My next readings will be over:
  • my chargers room (as a good geek, I have a bunch of gadgets who love sucking up power) ;
  • on the equipments I usually standby;
  • my battery chargers;
  • on my laptops (particularly on my laptop disconnected chargers);
  • and finally on the fridge.

[update] I'm paying something like 0,12€ per kW/h , so we're talking about 15€ / month. To save energy, I will:
  • continue to move servers from my silly datacenter into hosting infrastructure;
  • disconnect my UPS;
  • continue to disconnect standbys;

Tuesday, August 14, 2007

Transaction context

Business object often have the need to enrolled on transaction. In order to implement it, we have the following choices:

1. Pass transaction to every business object;
2. Simply assume a pragmatic one transaction per session.

I'm presently choosing this last one on most of my implementations for simplicity sake. HEre are some of my implementation details:

a) create a session manager:

/// Handles creation and management of sessions and transactions. It is a singleton because
/// building the initial session factory is very expensive. Inspiration for this class came
/// from Chapter 8 of Hibernate in Action by Bauer and King. Although it is a sealed singleton
/// you can use TypeMock (http://www.typemock.com) for more flexible testing.

public sealed class NHibernateSessionManager

b) in the session manager, handle context by session:

/// Since multiple databases may be in use, there may be one transaction per database
/// persisted at any one time. The easiest way to store them is via a hashtable
/// with the key being tied to session factory. If within a web context, this uses
/// instead of the WinForms specific .
/// Discussion concerning this found at http://forum.springframework.net/showthread.php?t=572

private ITransaction ContextTransaction
if (IsInWebContext())
return (ITransaction)HttpContext.Current.Items[TRANSACTION_KEY];
return (ITransaction)CallContext.GetData(TRANSACTION_KEY);
if (IsInWebContext())
HttpContext.Current.Items[TRANSACTION_KEY] = value;
CallContext.SetData(TRANSACTION_KEY, value);

c) involve it on a TransactionContext class that derives from IDisposable, making use of NHibernateSessionManager for usage simplicity sake.
 using (TransactionContext transactionContext = new TransactionContext())
// do some stuff

Although this is an NHibernate implementation, the patterns themselves are general to transactions.

Battle of Aljubarrota

On August 14, 1385, a small and poorly equipped Portuguese force wan the battle for independence over a 5 to 6 times in number Castile army of knights. On this battle, King John I of Portugal, D. Nuno Álvares Pereira and those 6000 extraordinary men wan also the battle of the new social order over the old medieval aristocracy.

This battle presents us some valuable lessons we can always use when building software - or just about anywhere:

  • fight for what we believe;
  • be humble (the Portuguese knight fought on foot);
  • be prepared and informed, anticipate the future (obviously the Castillian didn't think a lot about Crecy or Poitiers);
  • what isn't your core, outsource (the Portuguese didn't had archers, so they've outsourced them from England);
  • don't ever underestimate your adversary;
  • smaller groups can have an agility advantage;

Transaction management: the last one please close the lights

When managing transactions on business layers we often cross upon the following pattern:

  • if the transaction was opened here, a commit will be issued;
  • if the transaction was opened by the caller, it's the caller responsibility to commit the data;

Now you know why I'm calling this post "the last one please close the lights".

Often this implementation is encapsulated on a method that know if the transaction was opened here. There's a tendency to name this method Commit, subverting the commit semantics.

So I've been calling it SetComplete - in memory of good old MTS. Yes, I know, SetComplete was a little widder (it enrolled transactions), but clearly better than Commit. Here's a sample:

void businessMethod1()
using (TransactionContext transactionContext = new TransactionContext())


void businessMethod2()
using (TransactionContext transactionContext = new TransactionContext())
// do some stuff


We can now safetly invoke businessMethod1 or businessMethod2 without worrying about transactions. And if we want to use them withing another transaction, we just have to honor the "all TransactionContext should be closed with a SetComplete()".

Have you notice no context was passed among business objects? This will be the subject of my next post.

Monday, August 13, 2007

How to measure maintainability

Here's a great way to do it, according to Ayende:

  1. Go into the room and say: "Guys, the client want to change something"
  2. Measure the strength of the groans.

And how about it, it works :)

Saturday, August 11, 2007

Storage news

A friend of mine just told me gmail is suggesting selling extra storage for those whose mailbox is near the limit. Well it seems like Google is looking for the shorter and less imaginative way to make business...

Microsoft also as news on storage: they launched its Live.com online storage solution, called SkyDrive

Thursday, August 09, 2007

Working with Data in ASP.NET 2.0

Scott Mitchell gave us these great data access tutorials covering ASP.NET 2.0 and VS 2005:

19 Eponymous Laws Of Software Development

I earn about it at DotNetRocks and had to post about it. It came from haacked. Here are my favorites:

Parkinson’s Law

Work expands so as to fill the time available for its completion.

Pareto Principle

For many phenomena, 80% of consequences stem from 20% of the causes.

Sturgeon’s Revelation

Ninety percent of everything is crud.

Hofstadter’s Law

A task always takes longer than you expect, even when you take into account Hofstadter’s Law.

Brook’s Law

Adding manpower to a late software project makes it later.

and last but not least:

Wirth’s law

Software gets slower faster than hardware gets faster.

Finally HTML5!

At last, some new HTML:

Hypertext Markup Language (HTML) 5 introduces new elements to HTML for the first time since the last millennium. New structural elements include aside, figure, and section. New inline elements include time, meter, and progress. New embedding elements include video and audio. New interactive elements include details, datagrid, and command.

The Hacker, the Geek and the Nerd

Sorry, were you expecting a joke? What do these mean for us? Well, here's my definition:

  • Hacker: someone who gets out of computer systems more than they were designed to deliver, doing it on an elegant and efficient way;
  • Geek: someone that believes technology doesn't have to serve a purpose, but is the purpose itself; and that past technology is no fun, no mater how reliable may it be;
  • Nerd: basically a geek with no social capabilities;

So that said, I'm declaring my self guilty as charge as Geek.

At last my blog errors are gone

After some reports of errors opening my blog on some IE I've decided to re-create my blogspot.com template.

The process is not immediate. I had to:

  • create the template
  • edit the template in order to add tag cloud support
  • edit the template in order to add ClustrMaps support
  • edit the template in order to add Google Analytics support
  • personalize the template

Watch out for the template saving - it doesn't save you the data itself (ex: link list)

Wednesday, August 08, 2007

Job interviews and résumés

Here's a great interview posting from Daily WTF. I myself have a bunch of this stories taken from interviews, but I'm not comfortable with the idea of sharing this stories with the blogosphere. Not until I retire, anyway.

Anyway it is not uncommon to discover some mismatches between résumés and actual experience. So what can you do about it? Maybe the solution is on the community. Shouldn't we just make our resumes public and let the community freely post about them?

And what about blogs? Would your rather choose a developer from a résumé or from his/her technical blog?

Dr. ORM or: How I Learned To Stop Worrying And Love The Database changes

There was a time when database refactoring would set up the project alarm, and everybody would worry about stopping for a day or two. ORMs somehow help us here. But not only when refactoring, also on changes. Let me tell you about it.

We've been working on a database that was modeled by others, and just discovered (late on the project) that some of the foreign keys didn't point to primary but to alternate keys. The problem here is not about the modeling itself - it's not greenfield so it's out of our hands. The problem is that all the queries that joined these tables would have to be rewritten.

And here's what's great about ORMs: we only had to change one reference on the mapper.

NHibernate: 1 - silly way to model databases: 0

Monday, August 06, 2007

Interception NHibernate activity

We intercept NHibernate activity for the following reasons:

  • logging
  • authorization validation
  • generic validation
  • trigger events
The intercepting mechanism is a generic one, where we deliver each of the life cycle triggers to the super class all domain model classes derive from. On this implementation we've just derived this parent of all classes from NHibernate.IInterceptor as virtual methods with empty implementations - other than the generic logging. For example:

public bool OnFlushDirty(object entity, object id, object[] currentState, object[] previousState, string[] propertyNames, NHibernate.Type.IType[] types)
Model.EntityObject entityObject = entity as EntityObject;

if (entityObject == null)
return false;

return entityObject.OnFlushDirty(entity, id, currentState, previousState, propertyNames, types);

The way we hooked generic logging is quiet simple: we've intercepted OnFlushDirty and are just logging object[] currentState.

The entity update upon trigger is not immediate. Other than just setting properties on parameter entity, we have to set currentstate:

currentState[(int)propertyNames["MyProperty"]] = ...;

There goes the strongly typed advantage...

Sunday, August 05, 2007

Entity Life-Cycle in NHibernate: IInterceptor Interface

Here's a great little article about NHibernate Entity Life-Cycle.

[update] Here's another one about session management in general.

Paradox: are closed options the best options?

I'm currently in the process of shutting down my personal datacenter. It has served me well, but it is too costly on power and ecologically unacceptable. Oh, and it also a bit noisy.

I had a bunch of servers with a bunch of virtual machines serving a bunch of my personal sites, through an expensive domain I was paying to NetworkSolutions served by ZoneEdit dynamic DNS free service. I'm moving all of this to GoDaddy Deluxe hosting. Not as fun to administer nor flexible, but dam cheaper.

One of the decisions I had to make was for the OS. I chose Windows, and let me explain why.

I'd like to keep my old Mambo/Joomla sites, and a bunch of little projects I've done when there was no match for PHP to an old C++ programmer, but still wanted to experiment serving personal ASP.NET sites (ASP.NET sites are my way of living, but I've never did it with my personal sites for lack of licenses).

So the obvious answer was Windows, because of Microsoft's closed model. I can run PHP and mySQL on Windows, but I can't run (decent) ASP.NET on Linux.

It isn't the only example of closed option as the best one. Look at the Apple closed model: we can run Windows and OS X on Apple hardware, but cannot run OS X on non Apple machines. Again the closed model has the upper hand.

I know, this isn't fair, but that the way it is.

[update] I've just found out that the Windows account at GoDaddy doesn't support PHP - only mySQL. Due to the Metropolis low Microsoft support, and because I travel with some project baggage, I'm now trying to change my account back to Linux. The world may not be as unfair to Linux as I supposed... Only unfair to those who refuse to choose to stay only on one side of the fence...

Thursday, August 02, 2007

CodeSmith 4.1 is now available

I've been a long time user of CodeSmith - where I chose to port my old generaters to, and I'm still using it with NetTiers and with my NHibernate mappers. The latest version supports:

* Microsoft Visual Studio 2008 "Orcas" Support - CodeSmith has been updated to support the latest version of Visual Studio codenamed "Orcas"

* Linq to Sql templates - Generates LINQ classes as well as manager classes to make it easier to execute common queries, manage validation, and add business rules. It's "SQL Metal" on steroids.

Some considerations:
  • Good: CodeSmith is very active and responsive to market changes;
  • Bad: pricing is not what it used to be;
  • Undefined: does CodeSmith still makes sense for new projects? Targeting SQLMetal doesn't seem enough for surviving... The LINQ to SQL and LINQ to Entities designer makes SQLMetal too poor to use other than in demos.
And now that we are taking about it, what about GAT/GAX implementations other than the P&P ones? Where are them?

Drop-down list versus combo box

from wikipedia:

A combo box is a user interface control GUI element. It is a combination of a drop-down list or list box and a single-line textbox, allowing the user either to type a value directly into the control or choose from the list of existing options. An example of this use is the address bar of graphical web browsers.


The term "combo box" is sometimes used to mean the same thing as "drop-down list," owing to the variability of terms. This usage is likely the result of Visual Basic, and later the Visual Studio suite using the term "combo box" for both types of control.

Uau, this is crazy! When Microsoft consolidated input text and textarea on ASP:TextBox, this was a good thing. Merging DropDownList and ComboBox was also a good thing if DropDownList was the choosen naming...

So I am with those who believe:

This usage is sometimes made more precise as "non-editable combo box" (or something similar). Nevertheless, there are those who consider this usage incorrect, and apply the term "combo box" only to controls that allow edits.

Query Composition using Functional Programming Techniques in C# 3.0

Here's a great post about query Composition using Functional Programming Techniques in C# 3.0. I can relate to the conclusion:

In the end, I believe that programming in the FP style is useful and powerful. I think that in some circumstances, imperative code is more readable than FP code, so I am not an advocate of doing everything only in the FP style. As my learning evolves, I'll certainly expose my learning process publically.

Here are the links:

1. Introduction to the FP Tutorial

Introduces functional programming, mentions some of the core ideas, and the main hurdle (lazy evaluation) that users of LINQ will have to jump.

2. What this Tutorial Covers

Gives a quick overview of what the tutorial covers.

3. Quick Intro to Query Expressions

Capsule summary of query expressions and explicit notation.

4. Lambda Expressions

Introduction to lambda expressions, their syntax, and their semantics. Lambda expressions are one of the key tools that you will use when doing functional programming.

5. Extension Methods

Introduction to extension methods, and their applicability to functional programming.

6. Local Variable Type Inference

Anonymous types are key to FP, and in certain circumstances, to use anonymous types, you must use local variable type inference.

7. Object and Collection Initializers

To use anonymous types, you must use object and collection initializers. This introduces them.

8. Tuples and Anonymous Types

Tuples are important for creating intermediate values (and sometimes final results) of queries. This introduces tuples as implemented via anonymous types.

9. The Yield Contextual Keyword

Yield blocks are the foundation on which lazy evaluation is based. Yield blocks were introduced to C# in version 2.0.

10. Lazy Evaluation

This introduces and discusses what may be the most difficult hurdle that OO programmers must get over when using LINQ.

11. Aggregation

Aggregation is a core tool that you will use to develop results when using FP.

12. Programming in a Functional Style

Introduces the idea of declarative programming (vs. imperative programming).

13. Procedural Analogs

Presents an analog to the switch procedural construct.

14. Pure Functions

Refactoring in FP consists of creation of pure functions. This defines pure functions and tells why you want to use them.

15. Parsing WordML

This introduces our main example that we'll use in this tutorial. This example pulls together all of the previously introduced topics, including lambda expressions, extension methods, tuples (including type inference and object initializers), lazy evaluation, aggregation, and pure functions.

15.1 The Word Document to Parse

This topic contains the Word document that we'll parse using FP techniques.

15.2 Retrieving the Paragraphs

Develops a query that returns all of the paragraphs in a Word document. Creates an intermediate result using an anonymous type.

15.3 Refactoring using a Pure Function

Refactors the previously introduced query using a pure function. The resulting query is easier to read.

15.4 Retrieving the Text of the Paragraphs

Modifies the query to retrieve the text of each of the paragraphs. Adds the text to the tuple.

15.5 Separating Out the Code and Comments

Modifies the query to determine whether a paragraph is code or comment, or anything else.

15.6 Retrieving the Two Code/Comment Groups

Introduces a new query operator, GroupOnChange, implemented as an extension method on IEnumerable.

15.7 Filtering Out the Groups that we Don't Want

Modifies the query to retrieve just the groups that we want.

15.8 The Final Results

Modifies the query to retrieve exactly what we want. This is the end target of this example.

15.9 Complete Listing of ParseWordML

Contains the complete listing of our example.

16. Overview of a Functional Transform

Introduces the idea of doing transformations in a functional programming style. Contains the code for the transformation.

16.1 PurchaseOrders.xml

Contains the source XML document for our transformation.

17. Conclusion

Final thoughts about functional programming.

How to stop a development team for over an hour

Yesterday all of our development environments just stopped working over some sub-set of our model. As we had been doing a lot of refactoring, we started rolling back the changes (HBM + Model) until it worked. Yes, it's true, if something fails, we first look at NHibernate.

Another team was having their share of problems. They complained about some problems with NHibernate - it wasn't mapping correctly some data from the database. After some debugging I found the problem: this team didn't commit the changes they were doing at the database! So NHibernate was innocent.

The first team finally come to me with good and bad news:

  • after the rolling back, the application started working;
  • after unrolling it back, the application resumed working!
Boy, were we in trouble. We confirmed the version control to me sane, and then it hit me: this team was sufering from the table locking from the first team!

The second team was using TOAD to edit some data over the database. Apparently TOAD got a table lock when editing over the datagrid, so all of the inserts the first team tried just blocked. As NHibernate was the new kid on the block, he got the blame.

Good for you, NHibernate. Bad for you, TOAD.

BDD - Behavior-driven development

Scott Bellware [MVP] has just posted about BDD, where he says:

"What it is" is the model. "What it does" is the behavior.

We prefer to talk about the behavior of the system because we communicate more stuff with fewer efforts than talking about the model.

Wednesday, August 01, 2007

Mapping SQL Server Errors to .NET Exceptions (the fun way!)

Tom Hollander has just posted about mapping SQL Server Errors to .NET Exceptions, where he ends up with the following code and statement:

Database db = DatabaseFactory.CreateDatabase("MyDatabase");
db.ExecuteNonQuery("spMySproc", param1, param2);

catch (Exception ex)

if (ExceptionPolicy.HandleException(ex, "Data Access Policy"))



This is a lot nicer, but it still requires that the boilerplate exception logic is included in every data access method. But with the magic of the Policy Injection Application Block, you don't even need to do this. By configuring a policy in the PIAB configuration, or decorating your data access class or individual methods with the [ExceptionCallHandler] attribute, you can get the desired behavior with no exception handling logic in the code at all!

LINQ to SQL Debug Visualizer

Scott Gutrie has just posted about how to enable SQL debuger visualizer on LINQ - we no longer need to read the log file :)

Dam! I've just finish a LINQ internal demo with the log files - I'll have to update it...

Generating Word Documents on the server

Here are 2 clean links from mszCool on how to generate Word documents on the server:


I've been catching up ARCast, and finally decided to post about DinnerNow after earing Ron Jacobs's ARCast DinnerNow series. From the DinnerNow.net site:

DinnerNow is a fictious marketplace where customers can order food from local restaurants for delivery to their home or office. This sample is designed to demonstrate how you can develop a connected application using several new Microsoft technologies.

The demo utilizes several technologies including: IIS7, ASP.NET Ajax Extensions, Linq, Windows Communication Foundation, Windows Workflow Foundation, Windows Presentation Foundation, Windows Powershell, and the .NET Compact Framework.

The DinnerNow sample application is now available for download. You can download the entire DinnerNow sample code from CodePlex.

Is it all you can eat from .NET3? Is it the swiss army knife of .NET3! No, it's DinnerNow!

Development Catharsis :: Copyright 2006 Mário Romano