7 ms·
I've been writing Java for a while now. I've never seen nor written code anything like that. Heavy use of generics is usually hidden away in APIs and don't us
by kaffiene 16y ago
I've been writing Java for a while now. I've never seen nor written code anything like that. Heavy use of generics is usually hidden away in APIs and don't usually occur in non-trivial ways in normal code.
- kujawa 16y agoYou mean code that was interesting to write, and not just another fucking web template?
- Jach 16y agoIt's not that much of a hyperbole... Map<String, Map<String, Map<String, Map<String, String>>> > meta_data = new LinkedHashMap<String, Map<String, Map<String, Map<String, String>>> >(); .... for (Map.Entry<String, Map<String, Map<String, Map<String, String>>> > schema : meta_data.entrySet()) { I really would rather just type: meta_data = {} .... for schema in meta_data.iteritems():
- julian37 16y agoThis has become a bit simpler with Java 7: http://weblogs.java.net/blog/forax/archive/2009/08/27/diamond-gate http://weblogs.java.net/blog/forax/archive/2009/08/27/diamon... EDIT: link to better article
- nevster 16y agoIf you've got a structure like that, you've got bigger problems than the verbosity of the declarations!
- Jach 16y agoOh come on, it's not that ridiculous to have a map only 4 levels deep. (Though I'll admit the code there is a patch-job over a much worse design that will all be refactored one day...) It's just ridiculous to express in Java. JavaScript's pretty much built on the idea of nested objects/maps. new Ext.Panel({ width: 400, height: 400, title: 'Pie Chart with Legend - Favorite Season', renderTo: 'container', items: { store: store, xtype: 'piechart', dataField: 'total', categoryField: 'season', //extra styles get applied to the chart defaults extraStyle: { legend: { display: 'bottom', padding: 5, font: { family: 'Tahoma', size: 13 } } } } });
- nevster 16y agoThat's fine. My point is, it's extremely uncommon to come across this kind of structure in Java-land. Typically, there'd be separate classes for these objects - so you'd end up with a Panel class with fields width, height, title, renderTo and items. Items would be another class with it's subsequent fields. And so on with no maps in sight. You're example Java declaration doesn't seem to actually capture the Javascript code you've got there - ie each initial string does not map to another Map - in some cases it just maps to an integer or string. By the way - I totally agree that the declarations of stuff in Java with generics is way too verbose.