Talking Distinctions

22 בדצמבר 2010

The Enumerable<T>.Distinct method is a very useful helper; it was definitely requited to complete the LINQ to SQL offering (to support TSQL’s DISTINCT), and the corresponding support in LINQ to objects is very nice indeed. However, since DISTINCT runs on primitives in the DB, and objects may be a bit more complex than a simple byte-to-byte comparison – the plot might thicken. This test passes easily. public void DistinctOnPrimitives() { var arr = new {1,...
אין תגובות

Another NHibernate 101?

17 בדצמבר 2010

Yesterday at the Alt.Net tools night I gave a short talk about how to get started with NHibernate. “Getting started” means we’re talking about Greenfield project, heavily favoring Conventions (and automappings) over Configuration, and not having to mess with existing, untouchable codebase or DB schema. The weird part was sitting there, after having used NH, a 5 year-old project, for about a week, and across the table sat Ayende, one of the main contributors to NH (and author of NHProf). Most of the time he wasn’t throwing heavy items at me, so I called that session a success....
4 תגובות

Build a Better BooleanToVisibilityConverter

17 במאי 2010

I feel dirty whenever I use XOR in my code. Then I’m proud of myself and suppress any previous feelings which may indicate that I did something wrong. Anyway, when WPFing and messing with visibility of items – the BooleanToVisibilityConverter is a very handy tool.  However, binding to a bool property means that you need the bool mean the same as the visibility, i.e. true for visible. If you need the opposite – you need to create an opposite property on the VM to bind to, or write an opposite converter. No more. ...
תגיות: , ,
2 תגובות

Small WPF4 RC bug

16 באפריל 2010

Just in case someone encounters this – WPF4 RC version has a small bug (fixed in the RTM) which has the unfortunate consequence of throwing an exception on a WPF thread (with no user code in the way to handle it), and crashing the application. Below are the three version of the TextBoxView.ClearLineVisual code (which cause the exception), from ver3, ver4RC and ver4RTM…private void ClearLineVisual(int lineIndex) { if (((this._viewportLineVisuals != null) && (lineIndex >= this._viewportLineVisualsIndex)) && (lineIndex < (this._viewportLineVisualsIndex + this._viewportLineVisuals.Count))) { this._viewportLineVisuals = null; ...
תגיות: , ,
אין תגובות

[RowTest] as Much as Possible

28 במרץ 2010

Mark wrote a post about unit tests structure, and the need for similar tests to look the same. Good points there. I like my tests to show their essence in a very visible way – the concrete values for the scenario and the assertion are more often than not just the primitives which vary between test case to another. If you read the subject of this post you already know where I’m going with this: I really like row tests’ ability to concisely describe the variance between cases. So much so that I’d advocate using even...
אין תגובות

Couple of Good Quotes

9 במרץ 2010

I’ve read a couple of things that got me smiling. I am a bit tipsy, so smiling may be the manifestation of a chemical imbalance or just a nervous tick. Karl Seguin’s post: Ultimately, the most important thing is that you have automated tests which aren't a nightmare to setup, maintain or run. Integration tests have more dependency and thus are more fragile, but can be an efficient way to verify correctness. Ayende’s post: TDD fanatic corner: I don’t really care about testable code, I care about tested code. If I have a regression suite,...
תגיות: , ,
אין תגובות

When Should Derick Specify Expected Parameters in Stub Methods?

Excuse the subject line. I wasn’t feeling creative. This post is in response to Derick’s post. Derick asks if he should program his stubs with exact arguments per expected method call, and ends with “I know the answer is ‘it depends’”, but me - I’m a man of extremes. I don’t think it depends, and you should probably never use it (specifications), or, if you do “have to use it” – consider it a code smell for the tested code. To me it’s like having more than one assert in you test: what happens if the method...
תגיות: , ,
אין תגובות

Upgrading to VS2008!

8 במרץ 2010

Yes, well… yes.   After a fascinating couple of weeks on VS2010RC – I’m going back, sir. Simply put – performance is shite. Yes, I’m using Resharper, yes, I have a lot of XAML, and yes WiX wasn’t always very kind to me (general purpose rant), but if I actually feel that everything takes longer, and VS hangs, and takes heap loads of memory, and running my tests take longer, and I need to always think about backwards compatibility, and all the available tools are beta-ish – than I think I can manage to wait...
תגיות: , ,
אין תגובות

Memory Issues? Not to worry.

3 במרץ 2010

In QuickUnit we develop a Visual Studio addin which allows developers to easily create quality unit tests. It’s a rather complicated, highly extensible, code-analysis and code-generation, .net application, with a rather complex UI layer (but with a simple UX). We use WPF (on MVVM) for the UI infrastructure, and make very heavy use of viewmodel objects, data bound to data templates. We’ve encountered a scenario where our memory consumption started growing, after every action which basically only re-rendered the UI. ProcessExplorer was kind enough to show us that the gen2 heap was growing steadily, and GC collections had...
תגיות: , , ,
אין תגובות