Taking OO with C# to the extreme: decoupling from the basic value types

December 28, 2010

Hi, Did it ever happen to you that you hit a problem that you couldn’t solve, and even you’re convinced that it’s impossible, but then just by telling about it to someone you find the solution? I’m sure you did, it happens a lot. A boss I once had used to call this phenomenon “talking to a glass of water”: it would as well be a glass of water that you’re talking to for finding the answerJ Anyway, the reason I’m talking about this phenomenon is that I started to write this post with the following title: Frustrating limitations of C# with...

Debugging Fitnesse User Stories

December 21, 2010

In the recent project I’m working on we’re using Fitnesse, which is a very nice acceptance testing framework. Probably because Fitnesse was aimed initially at Java developers, it doesn’t have a very good integration story with VS. The main problem is revealed when you try to debug a User Story, because there isn't a "debug" button in Fitnesse. When you run a Fitnesse user story it invokes a new process (called Runner.exe) which calls your code, and finished very quickly, which makes it practically impossible to attach to it. The way other people in the team worked before I came...
2 comments

Elegant solution for the recursive iterator

Update: I attached the sources to this post. Hi again,As I mentioned in the earlier post, while I wrote it I realized that even though I can use recursive iterators, I must iterate though all the “child” elements from the parent iterator, which makes the algorithm less efficient (e.g. O(n*logn) instead of O(n)). On the other hand, when I tried to write the same algorithm without recursion I ended up in a pretty cumbersome and ugly code compared to the recursive version. I didn’t see a good reason why the C# design team couldn’t make it possible to “yield” another enumerator....

Traversing binary tree using an iterator

IteratorsTest.zip BinaryTreeIterator.zip BinaryTreeIterator2.zip This time I’m willing to explain a feature of C# that exists since version 2.0, but even though I find that many developers are either not familiar with, or don’t feel comfortable with, mainly because they don’t fully understand how it works. This feature is called iterators. I’m talking about these methods that return IEnumerator (or IEnumerator<T>, or IEnumerable or IEnumerable<T>) and use the yield return keyword. Another reason to explain this feature is that it is used extensively in Linq, and understanding how it works will allow you to use Linq better. ...
no comments

Creating ASP.Net CustomValidators that automatically creates the client-side (javascript) validation functions using expression trees – Part 2

Hi everyone! Last time I showed how you can use Expression Trees to create Custom Validators in ASP.Net that automatically generates the JavaScript code for the client-side validation. But there was one part I didn’t get into details and promised to explain it in the next post (this one), and that was how to translate specific methods and properties from C# to JavaScript. Of course that we could go with a trivial solution that simply maps the method and property names as strings, but that would have several disadvantages: The arguments of the method in C# may not match exactly those of...

Creating ASP.Net CustomValidators that automatically creates the client-side (javascript) validation functions using expression trees

Hi everyone! This is my first blog and my first post ever, so wish me luck Recently I started to learn ASP.Net from a book, and I reached the topic that discusses the various Validators, including CustomValidator. I was disappointed to find that when you create a CustomValidator you must create both the client script and the server script manually, even though normally you want them to evaluate exactly the same expression. Of course that’s a problem because in the client side the function should be written in JavaScript, while in the server it will be in C#, and...