|
John Simmons / outlaw programmer wrote: This is a perfect example of "just because you can, doesn't mean you should".
But the corollary is "even though you shouldn't, it's just too much darn fun to do." For example, found in some of my unit tests:
20.ForEach(i => ...);
It's just fun!
public static void ForEach(this int n, Action action)
{
for (int i = 0; i < n; i++)
{
action();
}
}
public static void ForEach(this int n, Action<int> action)
{
for (int i = 0; i < n; i++)
{
action(i);
}
}
But the responses I keep getting are, well, not favorable.
|
|
|
|
|
In embedded systems, infinite loops are quite common. I really hate this 'while(1)', so I committed a module (in plain C) that contained a '#define ever (;;)' so that I could write 'for ever {...}'. A week later, one of the other programmers had edited all the 'for ever' to be 'while(1)' and put a very nasty comment in the SVN log that this kind of funny coding does not at all belong in the code base.
Oh, well, I'll just let him. Sort of 'What's in a name?' But when I write code that I fully control myself, I strive to make it readable. If a loop is intended to run forever, 'for ever' is a better way of stating it than 'while(1)'. (And, in the ITU Z.200 CHILL language, 'for ever' is defined in the base language - that's where I learned to write infinite loops that way.)
|
|
|
|
|
The first code base I worked on was C ported from Pascal and used a bunch of #defines to reuse the inverse logic looping from Pascal.
#define repeat do{
#define until(x) }while(!(x))
so the C code was
repeat
...
until (breakCondition);
It probably saved a lot of grief versus trying to invert all of the breakConditions.
|
|
|
|
|
I would have been (re)structuring my code just so I could use LINQ's .ForEach(), .Take(), etc.
So now I have a "data prep" step that's (more) LINQ fiendly...
etc.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I was going to say something witty like, "About time you learned...", but in reality, I'm just glad I'm not the only one...
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
Admitting you have a problem is supposed to be 95% of the cure.
(Of course, I think the person who said that should get a bullet in the head.)
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
In many cases, that IS a cure.
|
|
|
|
|
And then you get to 40 years and just say elephant it and code on
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
farfegnugen coding is quite common, or so I hear!
It takes a lot of experience and rewrites to write good yet simple code!
|
|
|
|
|
It's like the good old coding proverb of "If in a year's time you don't look back at the code and say 'why the hell did I do that?' you haven't learnt anything in that year".
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
Not quite 40 years, but agree. I've tried to make a rule to not solve problems which don't actually exist.
That's tough, though. Sometimes, it's just (or seems like) a tiny bit more work to make a nice generalization, to allow for a new hook you could anticipate coming, that sort of thing.
So, it's a balance that we're all finding our way on.
|
|
|
|
|
THANKS FOR ALL THE POSITIVITY YOU BRING TO THE FORUM JOHN!
Jeremy Falcon
|
|
|
|
|
Every artist needs someone to tell them when to stop; i.e. it's "good enough".
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Does pasteurized mean ordained to be a minister?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
as opposed to being homogenised?
Installing Signature...
Do not switch off your computer.
|
|
|
|
|
|
OriginalGriff wrote: pasteurized I thought it meant farther than you can see.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
No, it means it's going past you face (where your eyes are).
|
|
|
|
|
We butter milk this one for all it's worth?
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
That's abbot the silliest TotD you've submitted in a while.
If you think 'goto' is evil, try writing an Assembly program without JMP.
|
|
|
|
|
|
So doctor got all the papers and told us she is clean - no second server of chemo...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
|
Yay! That's excellent news!
I'm making those Chocolate Orange peels (I think it was you who gave me the recipe) for one of Herself's friends who has just been told she has a breast tumour, picked up on the regular scan - and it's her birthday on Sat as well ...
Fortunately it's too small to feel, so it's been caught nice and early, and the prognosis is good - but it's still going to be a worrying Dead Tree Worship Season for her, I suspect.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OriginalGriff wrote: Fortunately it's too small to feel How, exactly, did you find that out?
I have lived with several Zen masters - all of them were cats.
|
|
|
|