17
votes
Accepted
Simple object validator
Instead of using regular expressions to manipulate the expression string I prefer to do expression manipulation. While this can be a little daunting at first it turns out to be fairly simple. It ...
12
votes
Accepted
10
votes
Accepted
Selective updates to immutable types
You should be able to cut the code length and improve performance, by simplifying the algorithm. Here are some of the problems I've noticed in your implementation:
You're currently processing all of ...
9
votes
Declarative type comparer
Very nice implementation; I always like seeing your code here. I really only have five very minor opinions on this implementation:
I'm not sold on expr as an ...
8
votes
Building unusual IComparer<T> from expressions
I'd say this is far too complicated. It took me some time to figure out what those expressions are getting rewritten to, and the results do not look very efficient:
...
7
votes
Accepted
Immutable builder and updater
You use IList<> where you should use ICollection<>. I've rarely encountered a scenario where ...
6
votes
Simple object validator
I just noticed a couple of small issues.
First, IsValid(obj) may return true on null, whereas Validate(obj) has a special check ...
6
votes
Accepted
Quiz for random boolean expressions
Very fun game you created here, I like it. Your calculations for the probabilities are also impressive, and well tested.
Some small suggestions:
UI improvement: Print a message when "leveling up".
<...
5
votes
Building DebuggerDisplay strings
I'd personally like DebuggerDisplayHelper.ToString() to be an extension method, so I finagled it up as such:
...
5
votes
Calculate fingerprint for an object
Apart from the improvements suggested by Henrik Hansen and a couple of null checks I changed the list with tuples into SortedDictionary to avoid repetitive ...
5
votes
Simple object validator
Not much to say here.
Your code looks clean and is easy to read.
There is just a little bit what I would change, namely the "default" rule of the ...
5
votes
Accepted
Designing a basic Binary Expression Tree structure
While the expression tree is in fact a tree-structure, the elements in the tree are operators and operands. Using overly generic non-representative names makes it more difficult to follow the code. If ...
4
votes
Accepted
Simple generic sequence generators
It's a shame that you have to use such a complicated mechanism because the language doesn't support strong enough type constraints. Given the limitations of the language, this looks like an elegant ...
4
votes
Declarative type comparer
That looks nice.
A few notes:
Enums can have different underlying types, and some are larger than int, which can result in subtle bugs. Use ...
4
votes
Simple object validator
I managed to rewrite most parts of it and I think it's much better now. It shouldn't be anything fancy, just a simple data validation helper that I guess most of the time will just check if something ...
4
votes
4
votes
Simple object validator with a new API
As developer consuming your API ..
Usability
I find this a verbose way of constructing validation rules.
...
3
votes
Inserting into a binary expression tree with GOTO
Your insertion requirements are mighty strange, but I guess you have some reason for them, so I won't comment further on that.
One of the huge benefits of having a parent pointer in each node is that ...
3
votes
Calculate fingerprint for an object
Because I'm delightfully (or annoyingly) pedantic, I rather like having interfaces so that I can mock them for testing purposes. I also changed the constructor to be ...
3
votes
Selective updates to immutable types
I find this helper extension is not necessary at all. Having immutable types with multiple properties (>3) makes it quickly ugly to use because of the huge constructor. Up to three properties it can ...
3
votes
Simple object validator
Nice work!
One thing you could do is leverage polymorphism for the Validation class so that you have a separate type for Valid and Invalid results.
And then you ...
3
votes
Simple generic sequence generators
One other suggestion is that the expression you are building don't change based on the value you pass into the constructors (besides GeometricSequence which you still could make a parameter instead of ...
3
votes
Accepted
Declarative type comparer
Since you are reading attributes I would put the work in the static constructor. That will run only once per type otherwise you should make the Create method lazy as there is no point in building the ...
3
votes
Accepted
3
votes
Parsing and evaluating cron expression
overall looks like a great job.
Still, I wonder if you could save some CPU cycles with replacing Regex in favour of string ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
expression-trees × 41c# × 33
linq × 9
generics × 7
extension-methods × 7
reflection × 6
entity-framework × 4
java × 3
validation × 3
framework × 3
linq-expressions × 3
object-oriented × 2
immutability × 2
python × 1
c++ × 1
python-3.x × 1
c × 1
strings × 1
design-patterns × 1
.net × 1
sorting × 1
haskell × 1
datetime × 1
unit-testing × 1
comparative-review × 1