Reputation
372
Top tag
Next privilege 500 Rep.
Access review queues
Badges
1 10
Impact
~3k people reached

  • 0 posts edited
  • 0 helpful flags
  • 88 votes cast
Aug
13
comment Simplifying Some Probabilistic If-Then Spaghetti Code
Should ou really be calling for a different random each time (as in the four first calls to random(20))? Or should you actually create a single random number, and sequentially test if it is larger than 2, then 5, 14 and 18?
Aug
13
comment Excessive LINQ chaining - Is it considered a code smell, and why?
@MichaelT thank you for your elaboration, it's a lot clearer to me now!
Aug
12
comment Excessive LINQ chaining - Is it considered a code smell, and why?
@RobertHarvey Excuse me, but I'm confused... The Law of Demeter is not an anti-pattern, it's a principle, isn't it? And I fail to see how a Train Wreck is not a violation of that law...
Aug
12
comment Is code like this a “train wreck” (in violation of Law of Demeter)?
That's the same suggested here: c2.com/cgi/wiki?TrainWreck "Create a method which represents the desired behavior and tells the client what to do. This follows the "tell, don't ask" principle. "
Aug
12
comment Excessive LINQ chaining - Is it considered a code smell, and why?
@RobertHarvey Well, some call it so... "The train wreck anti pattern occurs..." c2.com/cgi/wiki?TrainWreck
Aug
12
comment Excessive LINQ chaining - Is it considered a code smell, and why?
@outis Interesting! Since I posted the question in quest for a "well known name" for this smell / anti-pattern, would you say that "train wreck" is known enough that searching for it would guide me to what I need to know to solve it? Because if the answer is "yes", then you could put it as an answer (unless you can't do so because of the duplication issue).
Aug
12
asked Excessive LINQ chaining - Is it considered a code smell, and why?
Aug
8
revised MVVM in Photoshop-like application: What object has the responsibility for composing the document?
deleted 49 characters in body
Aug
8
comment MVVM in Photoshop-like application: What object has the responsibility for composing the document?
If you use an Image control instead of subclasses of Shape, you can bind a Source from the ViewModel, and from there you can render it in a lot of ways (DrawingImage/GeometryDrawing, RenderTargetBitmap, etc.). It is a good way to transfer visual knowledge from the View to the ViewModel without breaking the MVVM/DataBinding structure. It is also a way to have retained-mode drawing, so that now the model knows the lines are connected, and if you drag its connection, the underlying model will be changed and the View will update accordingly in a "smarter" way.
Aug
8
answered MVVM in Photoshop-like application: What object has the responsibility for composing the document?
Aug
7
comment Connect PC application to a group of similar hardware devices, using TCP
This seems odd, but I had an accepted answer and it just... disappeared??
Aug
7
accepted How to choose NOT to use a framework (Caliburn.Micro, etc.) in a given MVVM application?
Aug
6
asked Connect PC application to a group of similar hardware devices, using TCP
Jul
16
comment Is there a name for this pattern?
The TryParse pattern might be slightly related to this. It is a .Net idiom where you return a boolean with true when something executes fine, and false if some internal (and expected) exception happened: stackoverflow.com/a/17207748/401828
Jul
12
comment Is there a name for this pattern?
@Deduplicator This answer gives some reasons to support its point, but your comment doesn't. Why is is to be considered good code instead of the clever anti-pattern?
Jul
12
comment Is there a name for this pattern?
I agree this is a somewhat commont practice, and it might have its use, and calling it by name is for this very reason yet more important. But I believe it is not a "pattern" in the sense of a design pattern (these must be very formally defined, for what I know). Perhaps a better way to call it is an idiom, because it's very idiomatic of C-based languages (so as they call something "pythonic" when it is idiomatic in python, and some constructs are idiomatic in C#/Linq, or in functional languages, etc.) en.wikipedia.org/wiki/Programming_idiom
Jul
12
comment Is there a name for this pattern?
You might want to take a look: stackoverflow.com/q/2576571/401828
Jul
12
comment Is there a name for this pattern?
I guess some would argue this is an anti-pattern, because it violates the command-query separation principle and makes the code intention a bit less clear, not to mention the "one-liner" assignment/test makes it a bit harder to spot an error in case of debugging.
Jun
22
comment Drawing concentric circles without gaps
Also, I would consider number "5" to be an acceptable result. Did you consider it good? And if not, why?
Jun
22
comment Drawing concentric circles without gaps
@beppe9000 Imagine you draw the inner cicles first, and then the outer ones. The innermost circle, the tinyest one, would be a single pixel. Then the second one would depend on what "contiguous" mean: if you need the pixels to be side-contiguous, then you'd get only squares, unless you accept more than one pixel thickness... Can you visualize it?