Campbell Ritchie wrote:You should not combine two methods into one. You should normally divide large methods into several smaller methods.
Campbell Ritchie wrote:For the few nanoseconds it might save, you may have hours of work if you need to update the class.
SCJP 5, SCWCD 5
SCJP 5, SCWCD 5
Donald Knuth wrote:
The real problem is that programmers have spent far too much time worrying about efficiency in the wrong places and at the wrong times; premature optimization is the root of all evil (or at least most of it) in programming.
Jesper de Jong wrote:When you write code, you should never try to write it in a "clever" way because you think that your clever tricks will make the program "more efficient". The fact is that you don't know if clever tricks really help or not...
Mike. J. Thompson wrote:In the words of Donald Knuth, "premature optimization is the root of all evil".
Tim Harris wrote:I suppose the point is that calling a method in of itself is not that resource intensive, so chained method calls really don't add up that much?
Tim Harris wrote:I've seen things like System.currentTimeMillis() and using the manager package, but they don't seem very accurate.
C.A.R. Hoare wrote:“There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.”
Tim Harris wrote:I read a few articles on why shorter methods are better (like this one), but doesn't it take more processing power to make multiple method calls as opposed to having logic bumped into longer, more verbose methods?
Bear Bibeault wrote:¹ Unless and until there's a demonstrable performance issue that needs to be addressed.
If you scroll down, you find soebody else's opinion of “dumb code” (in the same link).In that interview, Brian Goetz wrote:Write dumb code.
And I spelt it wrongly, which I shall correct.A few minutes ago, I wrote:. . . If you use bubble sort you will find your sorting much slower than if you use merge sort or quick sort. . . .
Even when followed by, “shoot all of ***,” or similar?Bear Bibeault wrote:. . .
Strike "wouldn't it be faster to ..." from your vocabulary
. . .
Campbell Ritchie wrote:
Even when followed by, “shoot all of ***,” or similar?Bear Bibeault wrote:. . .
Strike "wouldn't it be faster to ..." from your vocabulary
. . .
Tim Harris wrote:There's been lots of good feedback in this thread, and I thank everyone for their input - special thanks to Jesper for informing me of JMH, which I'd like to use to further use to explore the issue in my own time (and probably prove everyone here right.)
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote: If your program simply won't run quickly enough, and you have a magic bullet that provably speeds it up, I say: use it, whether it's PO or not.
The problem with stuff like that is not the doing of it, it's:
a. Understanding that you are optimizing, and being able to justify it.
b. Remembering where you did it.
c. (probably most important) Planning for refactoring if a time ever comes when it's not needed.
I should add that I'm a great believer in POITROAE, but there are occasions - albeit extremely rare - when it's unavoidable.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
fred rosenberger wrote:PO in my mind is "i want my program to run as fast as possible so i'll try THIS because i just KNOW it will speed things up". What you describe is (at least in my mine) simply "optimization".
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Aaaaaand ... we're on the march. Stylin. Get with it tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|