|
I just started a co-op (my first job programming), and one thing I see in a lot of the code is the following: private final int ONE = 1; private final double FIVE = 5.0; I always thought that was bad coding; why not just use 5.0 in the code. The only thing I can think of is if you want to be able to modify all references of "FIVE" in one location. However, it probably shouldn't be named "FIVE" if you want to do that, because if you change it to FIVE = 6.0, then the name of the variable isn't really useful anymore. Is this bad coding practice, or am I just stupid? They also do multiple return statements in methods often, which I thought was another no-no.
|
# ¿ Mar 18, 2008 22:40 |
|
|
# ¿ Apr 27, 2024 20:10 |
|
Hidden Under a Hat posted:Sorry I hate to quote my own question, but I really would appreciate any insight to this issue, even if it's to say that it doesn't matter if I have one class that is 10,000 lines long. Does that matter or should I really be finding a way to delegate some of the stuff in my main class to another class? Refactor it, break it into smaller pieces of functionality that make sense. Make sure you have tests so it doesn't break.
|
# ¿ Jun 29, 2011 04:04 |
|
Ulio posted:Thanks Jabor, I am working on it right now. How do you find the smallest number in a group of numbers? You go through and look at each number, and remember it if it is smaller than the previous smallest number you have found. So something like: code:
The "int... numbers" part of the argument says this method accepts any number of ints as an argument, including zero. It will also accept an array of ints as a valid argument. If there are no ints, we do some error handling.
|
# ¿ Jul 5, 2011 18:00 |
|
ComptimusPrime posted:I believe he really meant == 0 or < 1. yeah. That's why we unit test/code review!
|
# ¿ Jul 6, 2011 14:13 |
|
gotly posted:Just to make sure I have it 100% - in this case, MyClass will actually change BUTTS and leave CHEWBACCA alone? It assigns the value of CHEWBACCA to BUTTS.
|
# ¿ Sep 3, 2011 04:38 |
|
tripwire posted:Except for the glaring lack of compile-time immutable collections, and the violating liskov substitution principle thing. The fact that I have no idea whether a List can be modified is absurd; unsupported operations on interfaces are WTFTerrible. Oh, and one of the Collections has an improperly implemented .equals (pretty sure it is ArrayDeque).
|
# ¿ Sep 14, 2011 21:15 |
|
personally I prefer the: String line; while((line = scanner.nextLine) != null) { } syntax.
|
# ¿ Dec 2, 2011 23:34 |
|
How worried do I have to be about permgen space? I'm working on a large (700,000 lines of code probably?) application. I'm trying to make use of functional programming, so I'm using a number of Function classes to imitate true closures.
|
# ¿ Jan 23, 2012 02:30 |
|
Do you have a build script that generates the jar? You should. If so why do you care?
|
# ¿ Apr 8, 2012 17:53 |
|
Harold Ramis Drugs posted:Would that be using the "(Job)" cast in front of the call? If I do that, the program will compile but break when I try to run it with a Null Pointer Exception. Here's what I did: It would be waitJob = (Job)prime.data; right? Alternatively you can do ((Job)prime.data).run(100); if you don't want to store it in a variable.
|
# ¿ Apr 24, 2012 15:08 |
|
Hidden Under a Hat posted:Thank you! That cleared it right up. IntelliJ community edition
|
# ¿ Apr 29, 2012 15:39 |
|
Safe and Secure! posted:Let's say that I claimed in an interview that I was a Java wizard, and this set my interviewer off on a mission to ask me increasingly difficult questions about Java to if I was lying. What kinds of questions/topics would I be asked about? If I really wanted to stump someone, I would ask them to implement a singleton that is constructed when it is first requested, that has public static members, and does not synchronize on getInstace(). (hint: it's impossible) But that's only if I was being an rear end in a top hat. In general I don't care if someone knows the minutiae of Java, cause it doesn't mean they can write code worth a crap. Thermopyle posted:That all makes me feel pretty good. I don't feel like a Java expert at all (I only taught myself last year for Android development), but I feel like I have an ok understanding of at least half of the things mentioned in the previous few posts. Yay me. Understanding poo poo like that is worth roughly $0. Understanding all that stuff and knowing how to properly structure programs, lead product development, and in general get poo poo done would net you a lot of money as a senior lead.
|
# ¿ Jul 29, 2012 03:06 |
|
Jabor posted:Nope, it's definitely possible. awesome! learned something new
|
# ¿ Jul 30, 2012 03:17 |
|
I hate Maven. So, I have a project with a dependency tree that looks like this: [INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ cloudmine-javasdk --- [INFO] com.cloudmine.api:cloudmine-javasdk:jar:0.3-SNAPSHOT [INFO] +- junit:junit:jar:4.10:compile [INFO] | \- org.hamcrest:hamcrest-core:jar:1.1:compile [INFO] +- org.slf4j:slf4j-api:jar:1.6.4:compile [INFO] +- org.slf4j:slf4j-simple:jar:1.6.4:compile [INFO] +- commons-io:commons-io:jar:2.3:compile [INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.0.0-RC2:compile [INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.0.0-RC2:compile [INFO] | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.0.0-RC2:compile [INFO] +- joda-time:joda-time:jar:2.1:compile [INFO] +- org.apache.httpcomponents:httpcore:jar:4.2.1:compile [INFO] +- org.apache.httpcomponents:httpclient:jar:4.2.1:compile [INFO] | \- commons-codec:commons-codec:jar:1.6:compile [INFO] \- commons-logging:commons-logging:jar:1.1.1:compile and I have another project that depends on that jar [INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ coderunner-test --- [INFO] com.bigcompany.snippets:coderunner-test:jar:0.0.1-SNAPSHOT [INFO] +- com.cloudmine.api:cloudmine-javasdk:jar:0.3-SNAPSHOT:compile [INFO] +- com.cloudmine:coderunner:jar:0.0.1-SNAPSHOT:compile [INFO] +- org.slf4j:slf4j-api:jar:1.6.4:compile [INFO] \- org.slf4j:slf4j-simple:jar:1.6.4:compile Notice that according to this javasdk has no transitive dependencies. I wouldn't be surprised if I'm just doing something stupid cause I never use Maven, but does anyone have an idea why it isn't resolving these transitive dependencies? Right now, unless I manually copy over the dependencies, the code fails at run time with a NoClassDefFoundError. If it matters, cloudmine-javasdk was manually added using mvn install:install-file.
|
# ¿ Aug 2, 2012 19:39 |
|
Kruegel posted:I'm pretty sure the pom files tell maven what the dependencies are and since you probably just provided the jar file (and not the pom) for javasdk it has no clue what its dependencies are. Sedro posted:Did you run mvn install:install-file off the jar or the pom?
|
# ¿ Aug 4, 2012 14:19 |
|
|
# ¿ Apr 27, 2024 20:10 |
|
Kilson posted:
|
# ¿ Nov 20, 2012 19:00 |