greptilian logo

IRC log for #friendlyjava, 2015-11-07

##friendlyjava on freenode

| Channels | #friendlyjava index | Today | | Search | Google Search | Plain-Text | plain, newest first | summary

All times shown according to UTC.

Time S Nick Message
00:09 jennyb joined ##friendlyjava
00:34 HEGX64 joined ##friendlyjava
02:35 bluezone joined ##friendlyjava
04:24 jennyb joined ##friendlyjava
05:04 jennyb joined ##friendlyjava
05:44 jennyb joined ##friendlyjava
11:00 kk joined ##friendlyjava
11:00 kk hello
11:00 kk i'm learning java
11:01 kk want to know when to use nested class
11:34 pulsar usually, when you need the nested class not very often and just in the containing class
11:37 pulsar for instance event listeners which cant be inlined / anonymized or simple data containers to group a bunch of properties in a nice object with no relevance to the "outside world"
11:52 pdurbin I use a nested classed called TestUser within a integration test class. I think of it as a very simplified mock user that has just enough information need for the test to execute: https://github.com/IQSS/dataverse/blob/e6df62a569057411b625ae8ebc250133b12a1193/src/test/java/edu/harvard/iq/dataverse/api/SearchIT.java#L1057
12:26 kk i still dont get it
12:26 kk when to use nested class
12:26 kk static or non static
12:26 pdurbin kk: if you can't think of a reason to use them, don't bother using them. don't worry about it
12:27 kk i saw singleton pattern using it
12:28 pdurbin kk: can you link to it?
12:29 kk okay
12:29 pulsar there are some rare situation when you want to access the outer-class "this" pointer inside a nested class. iirc you can only do that when nesting.
12:30 pulsar so, class Inner { ..... Outer.this.outersPrivateFieldOrMethod }
12:31 pulsar but as pdurbin said, you shoudl not worry about that. 90% of the use cases boil down to personal preference in terms of code / file structure
12:31 kk https://en.wikipedia.org/wiki/Singleton_pattern#Initialization-on-demand_holder_idiom
12:31 pulsar 8% can be omitted as anonymous implementaions will also work
12:31 pulsar and 2% would be very obscure
12:35 pulsar IMHO that singleton example is rather .... how to put it nicely... syntax / classloader masturbation?
12:37 kk Why generics gives problem pulsar
12:37 kk i'm using upper bound generics currently
12:37 kk <T extends Object>
12:37 pulsar gist / pastebin / etc. plz
12:37 kk k
12:40 kk http://pastebin.com/gYpqg3Ca
12:41 kk error >> Type mismatch: cannot convert from Date to T
12:51 kk pulsar
12:58 pulsar generics are a compile-time construct and the compiler cant detect the return type in your case.
13:00 kk why pulsar
13:01 pulsar dunno, ask a generics expert ;) most of the time ppl use generics, interfaces would also do
13:01 pulsar this is how i feel about generics in java.
13:38 kk pdurbin
14:47 pdurbin kk: hit 'p' on this slide to see some notes on generics in our code: http://iqss.github.io/javaone2014-bof5619/#31
14:48 pdurbin 'submit is a generic method, allowing type-safe execution of any command. If you try to assign the return value of a command to the wrong type you'll get an "incompatible types" error at compile time. The CreateDatasetCommand returns a dataset. The engine prevents you from assigning the result to a DataFile, for example.'
19:15 pioneer joined ##friendlyjava
19:15 pioneer left ##friendlyjava
23:38 jennyb joined ##friendlyjava

| Channels | #friendlyjava index | Today | | Search | Google Search | Plain-Text | plain, newest first | summary

##friendlyjava on freenode