Reputation
1,250
Next privilege 2,000 Rep.
Edit questions and answers
Badges
10 14
Newest
 Yearling
Impact
~51k people reached

Jul
22
comment Why does internal instance become null
You also asked this question on the wrong site.
Jul
22
comment Why does internal instance become null
You assigned myA to myC.myself, then assigned myC.myself to myC. myA never set its own .myself, so that's what myC.myself is now null.
Jun
30
comment How do you compare Languages?
I see how each language rates on the J. Evans Pritchard scale and choose accordingly.
Apr
30
comment Injecting collections as constructor dependencies
@IgnacioSolerGarcia, in your latest example, I still see no need to inject the internal dictionary. You have Add and Remove methods. Your unit tests should confirm that Add works as anticipated, from a consumer perspective. If I add an item twice, what happens? If I remove an item I've added X times, what happens? You don't need to control for what .Contains returns, that's an implementation detail! You just need to know Add and Remove do the right things. How they do the right things is not important and can change.
Apr
29
comment Injecting collections as constructor dependencies
Your example doesn't demonstrate why you would need to inject the collection. You have a method FillListAndDoSomething. Presumably, you're doing something with the filled list! What are you doing? Is it being written somewhere, displayed, returned? These are the things you test. You abstract away the things that prevent you from being able test this independently. The list is not one of those things.
Apr
29
comment Injecting collections as constructor dependencies
If the class owns the list, the class adds things to it, and the class wants to peek inside of it to see what it put in there, these are implementation details! If your tests need to control for these interactions, I dare say you are doing something very, very wrong. Abstracting over such simple things as collections is the path to madness.
Apr
29
answered Injecting collections as constructor dependencies
Sep
27
awarded  Yearling
Sep
27
awarded  Yearling
May
31
comment How Much Of A (Broken) Legacy Framework To Keep
You might want to get a copy of Working Effectively With Legacy Code.
May
29
comment I don't understand how TDD helps me get a good design if I need a design to start testing it
If you have read Robert C. Martin's work or maybe watched one of his videos, you'll see that he often has a design in mind but he isn't married to it. He believes that his pre-conceived notion of the right design will emerge from his tests, but he doesn't force it to. And in the end, sometimes that design does, and sometimes it does not. My point here is that your own prior experience will guide you, but the tests should drive you. Tests should be able to develop or debunk your design.
May
24
comment Is there a specific name for the “Square inherits from Rectangle” paradox?
@gnat, if a method had a rectangle, it might assume mutating the width would have no effect on the length. Maybe it doubles with width and expects the area to similarly double. When given a square, that assumption is out the window, provided that the square is correctly implemented. Double the width, the area quadruples. It also begs the question of whether the square needs separate width and length accessors/mutators.
May
24
awarded  Nice Answer
May
24
comment Most human-friendly way to order class method definitions?
Related: programmers.stackexchange.com/questions/186418/…
May
23
comment Agile MVP (Most Valuable Player/Programmer)
If my team ever did this, I would want the option to kindly opt out of such nonsense. I don't want a biweekly pat on the back.
May
23
comment Should I write compact code or code with lots of spaces?
"I have noticed that when I look at the Javascript code of most professional websites, they usually use the second style, so there might be something to it." What you need to understand is most professional developers are terrible.
May
14
comment Why do people consider Python a weak language?
Don't switch. Add. Either (or both) of C# or Java would be good to have in your repertoire. As would other languages and paradigms. However, from a pragmatic standpoint, become an expert in the languages and tools that you think are going to get you where you want to be.
May
8
comment How to unit test method that returns a collection while avoiding logic in the test
Osherove would have your head on a platter for having 3 asserts. ;) The first one to fail means you never validate the rest. Note also that you didn't really avoid the loop. You just explicitly expanded it out into its executed form. Not a hard criticism, but just a suggestion to get some more practice isolating your test cases to the minimum amount possible, to give yourself more specific feedback when something fails, while continuing to validate other cases that could conceivably still pass (or fail, with their own specific feedbacks).
May
7
comment How to unit test method that returns a collection while avoiding logic in the test
@Izbata, his question specifically mentions that ordering is important. His words: "others will be set to a value which is dependent on their position in the collection." There are plenty of collection types in C# (the language he references) that are insertion ordered. For that matter, you can also rely upon order with lists in Python, a language you mention.
May
7
comment How to unit test method that returns a collection while avoiding logic in the test
I recommend not looping. If your test is that the third thing has its Bar set to Frob, then write a test to specifically check that the third thing's Bar is Frob. That's one test by itself, go straight to it, no loop. If your test is that you get a collection of 5 things, that's also one test. That's not to say you never have a loop (explicit or otherwise), it's just that you don't often need to. Also, treat Osherove's book as more guidelines than actual rules.