251 reputation
24
bio website
location London, United Kingdom
age 31
visits member for 3 years, 9 months
seen Nov 27 at 11:35

Java Developer for GSA Capital


Nov
27
comment Should I accept empty collections in my methods that iterate over them?
And if it's invalid to have no items in a collection, then ideally the argument wouldn't be a java.util.Collection, but a custom com.foo.util.NonEmptyCollection class, that can consistently preserve this invariant, and prevent you from getting into an invalid state to start with.
Nov
27
comment Should I accept empty collections in my methods that iterate over them?
@Andy Even so, if the argument should never be empty - if it is an error to have no data to process - then I feel it's the responsibility of the caller to check this, when it's collating that argument. Not only does it keep this method more elegant, but it means one can generate a better error message (better context) and raise it in a fail-fast way. It doesn't make sense for a downstream class to verify the caller's invariants...
Sep
24
awarded  Autobiographer
Apr
2
comment Why have private static methods?
This is even more valuable when you need to pass derived (calculated) arguments to a superclass' constructor. The super(...) call must be the first line of your class' constructor, so you can't declare local variables to help you work out what to pass to the super call. However, you can call (private) static methods, which use as many lines as is necessary to work out the value to pass to the super constructor.
Jan
10
comment What is meant by “Now you have two problems”?
Didn't Uncle Ben also say "Perfect results, every time"? Maybe that's why people get so trigger happy with regexes...
Feb
26
awarded  Caucus
Feb
26
awarded  Constituent
Mar
1
awarded  Yearling
Aug
19
answered What are the benefits and disadvantages in the approaches of C#, Java and Scala to Closures/Lambdas/…?
Jul
19
comment Why don't all companies buy developers the best hardware?
Arguably that doesn't fully answer the question (it's more about the mechanics). The follow-up would then be why is the hardware budget undersized, if you accept the premise that you should spend e.g. 2% of developers' salary on workstations?
Feb
28
awarded  Supporter
Feb
28
awarded  Teacher
Jan
19
answered What are the things Java got right?