NH ProfGetting to zero friction
Here is a new (passing) integration test in the NHibernate Profiler:
Just to give you an idea, here is the implementation of this rule, which has to be one of the more complex ones that we have at the moment, because the data for it comes from several sources, so we need to actually execute the logic in an event, instead of directly.
public class TooManyRowsReturnedPerQuery : IStatementProcessor
{
private ProfilerConfiguration configuration;
public TooManyRowsReturnedPerQuery(ProfilerConfiguration configuration)
{
this.configuration = configuration;
}
public void AfterAttachingToSession(SessionInformation sessionInformation, FormattedStatement statement,
OnNewAction newAction)
{
statement.ValuesRefreshed += delegate { if (statement.CountOfRows == null)
return;
if (statement.CountOfRows > configuration.MaxRowCountThatWouldGenerateWarning)
newAction(new ActionInformation
{
Severity = Severity.Warning,
Title = "This query returned an excessive number of rows."
});
else if (statement.CountOfRows > configuration.MaxRowCountThatWouldGenerateSuggestion)
newAction(new ActionInformation
{
Severity = Severity.Suggestion,
Title = "This query returned a large number of rows."
});
};
}
}
This is what I when I am talking about zero friction software. Assuming that you understand the architecture of the system, which isn't hard, you can just plug things in. Not only that, but the system follows the Open Close Principle. By far, most changes to the system involves adding new code, rather than modifying existing code.
Another interesting aspect, notice just how many things are handled for you by the infrastructure, and what the resulting code looks like.
More posts in "NH Prof" series:
- (09 Dec 2010) Alert on bad ‘like’ query
- (10 Dec 2009) Filter static files
- (16 Nov 2009) Exporting Reports
- (08 Oct 2009) NHibernate Search Integration
- (19 Aug 2009) Multiple Session Factory Support
- (07 Aug 2009) Diffing Sessions
- (06 Aug 2009) Capturing DDL
- (05 Aug 2009) Detect Cross Thread Session Usage
- (22 May 2009) Detecting 2nd cache collection loads
- (15 May 2009) Error Detection
- (12 May 2009) Queries by Url
- (04 Feb 2009) View Query Results
- (18 Jan 2009) Superfluous <many-to-one> update
- (18 Jan 2009) URL tracking
- (10 Jan 2009) Detecting distributed transactions (System.Transactions)
- (06 Jan 2009) The Query Cache
- (05 Jan 2009) Query Duration
- (24 Dec 2008) Unbounded result sets
- (24 Dec 2008) Row Counts
Comments
Comment preview