"Il y a peu de choses qui me soient impossibles..."
Fred Kleinschmidt wrote:Yes, this is the way you should do it.
As a side note, it is usually a good idea to ALWAYS use curly braces around the body of if-blocks and do loops.
"Il y a peu de choses qui me soient impossibles..."
Stevens Miller wrote:Yeah, I usually do and, as a Ranch bartender, I should follow best practices. I just like to have as few lines as possible in a SSCCE.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:...line 29 should still be:
List<Employee> staff = new ArrayList<>();
Tell, don't ask advocates would say that, before version 8, java.util.Map was missing an add() method because it is a distinct operation from a put().
I further say that the new method should have been called add() or insert(), not putIfAbsent() because the first two names are behavioural, while the last one is procedural.
"Il y a peu de choses qui me soient impossibles..."
Stevens Miller wrote:[Without wanting to seem like a believer in the self-documenting code fantasy, I do believe in the sense of descriptive names.
Junilu Lacar wrote:If you find that there are often more LazySlobs (and possibly others of the same ilk) than EagerBeavers, perhaps it's time to rethink your design and ask if it's appropriate to have that thing that only EagerBeavers do be a separate interface and segregate the EagerBeavers from the riffraff for this particular processing.
"Il y a peu de choses qui me soient impossibles..."
Junilu Lacar wrote:
Stevens Miller wrote:Without wanting to seem like a believer in the self-documenting code fantasy, I do believe in the sense of descriptive names.
Then I've been living a fantasy these past few years. Self-documenting doesn't mean you don't write comments when and where they are truly useful. I don't see where the cynicism comes from.
"Il y a peu de choses qui me soient impossibles..."
Stevens Miller wrote:When I don't have to cope with their code, that's fine. When I do, well... I've had my life's fill of people who believe they don't ever need comments, and the rise of the "self-documenting code" movement isn't helping me with that.
Stevens Miller wrote:I might quibble with you, there.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Junilu Lacar wrote:Well, you musn't let your bad experience with people who aren't doing what they say they're doing taint your impression of the idea of writing self-documenting code.
I for one am a big proponent of clear, intention-revealing code that doesn't require comments.
The example I always use to explain the concept of self-documenting code is this: https://www.industriallogic.com/xp/refactoring/composeMethod.html.
In my experience, less than 10% of developers I have met in the workplace have the awareness and sensitivity to recognize that a few simple applications of rename, extract, and compose method refactorings can go a long way to increase code clarity.
It's not unusual for me to spend 5 minutes with my programming partner(s) trying to find an appropriate name to assign to something. Sometimes it takes a lot of discussion and experimentation with the design to figure out what the appropriate name is but really what we're doing with all that time is discovering the real intent of the software and how these things fit into achieving that goal.
Again, this is not to say that I don't write comments either. I tend to write JavaDocs more often than not for public methods and I'll always leave a DEVELOPER NOTE or IMPLEMENTATION NOTE comment where I think an explanation of WHY something was done in a certain way is warranted and helpful. I let the code explain the WHAT and HOW it gets things done.
"Il y a peu de choses qui me soient impossibles..."
Winston Gutkowski wrote:I'm struggling to come up with a good example at the moment, but if I think of one, I'll let you know.
"Il y a peu de choses qui me soient impossibles..."
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.
Junilu Lucar wrote:the developers kept wanting to go down into the detailed implementation.
Tim Holloway wrote:This is a lot like Donald Knuth's Literate Programming concept, which, amusingly, I was doing before he published the concept.
Further, Tim Holloway wrote:Haven't done flow charts to speak of in years for the same reason.
"Il y a peu de choses qui me soient impossibles..."
Stevens Miller wrote:Giving names to our various sets of professional methodologies seems, to me, to risk becoming needlessly religious about how we write code.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:Several things about [Java 8] make me suspect that we are being "channelled" towards programming functionally, regardless of how familiar it is, or whether it's even applicable.
To me, Java's greatest asset is its flexibility. It allows us to program procedurally when we need to; use objects when they make sense; forget about memory management; and has a syntax that is familiar to many.
"Il y a peu de choses qui me soient impossibles..."
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.
Tim Holloway wrote:Functional Programming is nothing new. It dates back to the early 1960s, if not before. Lambda expressions are an integral part of LISP, which comes from that era.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:And it's one of my great regrets that I never learned it (along with Fortran).
"Il y a peu de choses qui me soient impossibles..."
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.
Stevens Miller wrote:When C++ emerged in the latter 20th century, most of my colleagues predicted that it would supersede C...
Hmmm, do I detect a change in opinion? I seem to remember a thread a few weeks back...C is still a good choice for certain things ... albeit at the expense of empowering those arrogant SOBs who wave their use of unsigned bytes around like some kind of national banner.
Nice. Do you know who sang it? She has a really nice voice.BTW, there is a delightful song about this topic. Take five minutes and listen, if you haven't heard it before.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Hmmm, do I detect a change in opinion? I seem to remember a thread a few weeks back...Stevens Miller wrote:C is still a good choice for certain things ... albeit at the expense of empowering those arrogant SOBs who wave their use of unsigned bytes around like some kind of national banner.
![]()
Nice. Do you know who sang it? She has a really nice voice.BTW, there is a delightful song about this topic. Take five minutes and listen, if you haven't heard it before.
"Il y a peu de choses qui me soient impossibles..."
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |