NH Prof: Getting 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.
Comments
No comments posted yet.