• Post Reply Bookmark Topic Watch Topic
  • New Topic

Pre-moan analysis  RSS feed

 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two possible ways to do a computation.
The first way is to find an appropriate whizz-danger of a data type and write a diddly little dongle that does the job. So smooth...
But for 95% of the computation using that data type is rather overkill as far as efficiency is concerned.
The second way is is choose an even more appropriate data type, use that for the 95% of the calculation, and then with a flick of my wrist do the last 5% of the job with the necessary whizz-danger data type.
Now what to do? YAGNI tell's me to do the first option, I just have to print a few numbers on a screen and I'm done.
Now my dark past tells me to have pride in producing an efficient result, look at the quality, feel the width.
Which to choose?
-Barry
 
Marilyn de Queiroz
Sheriff
Posts: 9080
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Either way may be appropriate depending on the implementation.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got no nice answer to that one, Marilyn.
Another point: to get one of the numbers computed, I can used some simple Noddy Programmer Maths, OR... being brilliant, as well as modest, I can perform a wonderful magical mathematical trick. But a Noddy Programmer might not get it without some tedious explanation which would probably baffle him anyway. Ok it's not my fault he didn't do his sums well at school and that sort of thing, and I would definitely like to show I'm A1 at maths, if not at coding this stuff.
BTW I guess you can read Newbie for Noddy, but there is a distinction.
Any more subtle hints?
-Barry
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[i]But for 95% of the computation using that data type is rather overkill as far as efficiency is concerned.[i]
Are you really, really sure about this? In the topsy turvy world of self-optimizing compilers, stochastic processes and hand-tuned libraries, such "common sense" can not always be relied on.
It's almost a "zen" thing:- clearing your mind of all thoughts of efficiency leaves you free to design a truly simple solution, and can often actually lead to more efficient code
 
Michael Matola
whippersnapper
Ranch Hand
Posts: 1838
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Barry Gaunt:
Another point: to get one of the numbers computed, I can used some simple Noddy Programmer Maths, OR... being brilliant, as well as modest, I can perform a wonderful magical mathematical trick. But a Noddy Programmer might not get it without some tedious explanation which would probably baffle him anyway.
Well, I'm a liberal arts graduate, and I was able to figure out wonderful magical mathematical trick #1 on this assignment on my own.
And when I saw wonderful magical mathematical trick #2 on this assignment, I exclaimed "So, that's what that's for!"
So any more subtle hints?
Google is failing me so I'll quote from memory now, and edit later when I can look this up from hardcopy at home.
"The value of fortunetelling is that is shows how perfectly useless it is to have the correct answer to the wrong question." -- Ursula LeGuin, The Left Hand of Darkness, loosely, from memory
In jest, Michael
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks pals, I think got the general buzz.
Where's my towel, lie me down, comfy? Off we go...
 
David Mason
Ranch Hand
Posts: 56
Android Chrome Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean
Where's my towel
? I sassed you as a hoopy frood who knew where his towel was.
Is this the one where you show that signed whatsit is missing, then write it again so it works?
The 95%-5% approach didn't work here either !
Then it becomes an incredible shrinking program - And it's optimised; there's nowt left !
Minimalism, don'tcha love it ?
 
Bert Bates
author
Sheriff
Posts: 8945
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems to me that clear code beats optimized code about 999 times out of 1000.
Sure every once and a while you have to write some code for the Hubble telescope, that has to run on a space hardened 386, in 768 bytes of memory...
But usually, you want to write code that's easy to debug, easy to enhance, and that the next guy / gal will enjoy reading. 'Write your code as if the next person who has to work with it is a homocidal maniac, with a short temper, who knows your home address.'
-Bert
 
Pauline McNamara
Sheriff
Posts: 4012
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bert Bates:
'Write your code as if the next person who has to work with it is a homocidal maniac, with a short temper, who knows your home address.'

Hey! Don't talk about Marilyn like that! (She might have your home address )

Pauline
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!