|
When two ways work, but I find one, shall we say "inelegant", I do it both ways, and run performance tests.
Here's the important bit: If the performance tests show that my preferred way doesn't give a worthwhile improvement, I drop the subject.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
Use Dependency Injection wherever there will be a need to swap out an implementation.
- Injecting different configurations
- Dynamic loading of functionality
- Replacing an implementation (eg repository) with a mockup for unit- or integration-testing
Mocking up "Now" is a common thing for unit testing date sensitive stuff. There are dozens and dozens of articles about doing this, and it's a classic example of why using static methods (eg DateTime.Now) can get you in trouble when it comes time to test.
cheers
Chris Maunder
|
|
|
|
|
I am currently working on my first greenfield project where I am using DI. I personally love it for testing purposes, but when it comes to utility classes THAT DON'T DEPEND ON EXTERNAL RESOURCES, I won't define an interface. Instead I'll just test their public API separately to know that the logic in that class is working as intended. I can then confidently test the code that uses that utility class as an external member.
|
|
|
|
|
Regarding your INowResolver which as stated below it's understandable especially for testing.
There are better ways to handle that.
From ayende.com[^].
public static class SystemTime
{
public static Func<DateTime> Now = () => new SqlDateTime(DateTime.Now).Value;
}
Then in tests
SystemTime.Now = () => new DateTime(2000,1,1);
ed
~"Watch your thoughts; they become your words. Watch your words they become your actions.
Watch your actions; they become your habits. Watch your habits; they become your character.
Watch your character; it becomes your destiny."
-Frank Outlaw.
|
|
|
|
|
Yeah, it's what I adopted in my own home made project!
I want my home made library of utilities to work out of the box!
I don't want to write lines of (obscure) initialization!
|
|
|
|
|
Super Lloyd wrote: what's your thoughts?
Not sure how often it occurs but it certainly often enough that I have seen people get 'stuck' on an idealization until it bites them - severely.
Probably comes about when they are at the stage where every new idea seems 'fresh and new!' and they want to try all of them out but can only fit a few in. Then someone decides to impose it as a mandate.
This isn't a new trend either. Plenty of examples in the past.
One should use idealizations or even concrete technologies because they are useful now and not because they might be useful at some hazy point in the future. And they should be used with restraint.
|
|
|
|
|
...other than the fact I am posting this from my Wii U.
What do you get when you cross a joke with a rhetorical question?
---
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
---
Do questions with multiple question marks annoy you???
|
|
|
|
|
Unbelievable, but true?!
|
|
|
|
|
Look -- Ow f**k! -- will you -- OW!! -- be careful with that ****ing sword!
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
What do you get when you cross a joke with a rhetorical question?
---
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
---
Do questions with multiple question marks annoy you???
|
|
|
|
|
Don't post to CP while you've got Zelda running.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
The only game I have for the Wii U is New Super Mario Bros. U, which is what was (and is) in the system.
What do you get when you cross a joke with a rhetorical question?
---
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
---
Do questions with multiple question marks annoy you???
|
|
|
|
|
OK.
Look -- Ow f**k! -- will you -- OW!! -- be careful with those ****ing fireballs!
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
For one, if the browser is active, the game is off. It's not exactly a multitasking environment.
What do you get when you cross a joke with a rhetorical question?
---
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
---
Do questions with multiple question marks annoy you???
|
|
|
|
|
Hmm.
Do you notice people around you sleeping, often?
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
For those of you who miss the perfect design principles, high-art styling, and glorious user-experience of FileMatrix[^], I am glad -- nay, honoured -- to humbly introduce you to Kameisi[^]!
What's that?
Jobs?
Steve Jobs?
Feh! A rank amateur!
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
Looks better than iTunes...
|
|
|
|
|
You're not using it right!
Contrary to popular belief, nobody owes you anything.
|
|
|
|
|
I seem to sense a deja vu here.
|
|
|
|
|
What, again?
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
Yes it happens a lot, or at least twice
|
|
|
|
|
Ow! My eyes!
According to my calculations, I should be able to retire about 5 years after I die.
|
|
|
|
|
Read the list of "music" and suddenly it all makes sense.
|
|
|
|
|
What gets me most with the FileMatrix screenshot is that I have no idea what has focus -- i.e. if you were to hit Enter, what would happen?
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
Swallow the red pill and find out.
Contrary to popular belief, nobody owes you anything.
|
|
|
|