Out on HF and heard nobody, but didn't call CQ? Nobody heard you either. 73 de N7GH
Pito Salas wrote:Yes I've done lots of OO. Let me give you the context. I come from the Ruby community where people regularly exchange ideas about the 'best way' or the 'idiomatic way' to do something. It seems (because I've posted this in a couple of places) that this is not the way the Java community thinks about this.
Concrete example: It's legal to put a second, non-public, top level class in a file. Is there a conventional wisdom about when that's a good idea, if ever?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Both good books. It would be good if Bloch wrote a new edition of his book, which is getting on for 8 years old.Liutauras Vilda wrote:. . . Joshua Bloch "Effective Java" book, . . . "Clean Code" by Robert C. Martin, . . .
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Pito Salas wrote:The question I posed about putting a non-embedded non-public class in the same file as a public one. What have you seen/believe?
Pito Salas wrote:Actually on your reader example, why is it necessary (or is it) to declare String line outside the loop?
Paul Clapham wrote:I've seen a lot of open-source Java code and I've seen that done exactly once. I spent a lot of time searching for the source code of the secondary class before I figured out what was going on. So I would say that definitely is NOT a Java idiom.
Pito Salas wrote: The question I posed about putting a non-embedded non-public class in the same file as a public one. What have you seen/believe?
Paul Clapham wrote:However you're going to see that indexing style for a long time regardless of how obsolete it is, because there's a widespread programming methodology out there where you google for scraps of code which look like they do what you want and insert those scraps into your code base.
Paul Clapham wrote:
Pito Salas wrote:The question I posed about putting a non-embedded non-public class in the same file as a public one. What have you seen/believe?
I've seen a lot of open-source Java code and I've seen that done exactly once. I spent a lot of time searching for the source code of the secondary class before I figured out what was going on. So I would say that definitely is NOT a Java idiom.
Paul Clapham wrote:
I don't believe it is necessary. And I wouldn't make a fuss if you declared it inside the loop either.Pito Salas wrote:Actually on your reader example, why is it necessary (or is it) to declare String line outside the loop?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Paul Clapham wrote:That isn't the obvious way a beginner would write it, but it's the way it SHOULD be written in Java. Although that too has been superseded in Java 8 by
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Junilu Lacar wrote:I don't know why you'd spend a lot of time searching for the source code of the secondary class unless you're just browsing through the source on the web or in a plain text editor. Most IDEs can find it for you with a couple of clicks of the mouse.
Of course, a well placed comment to explain your motivation will be really helpful.
Rob Spoor wrote:The main question is, though: why not do something with line as a consumer?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:so why should I be forced to write a Consumer to probably do exactly what I was going to do in my for block? Let alone use a very "iffy" form of casting.
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |