Fork me on GitHub
#off-topic
<
2015-10-19
>
borkdude08:10:14

@agile_geek: don't know, I was hoping for something nice like linq2sql in C#

agile_geek08:10:28

@borkdude: yeah, seen linq, quite nice. Haven’t directly parsed XML for a while in Java but it was painful when I did.

borkdude08:10:08

don't need to parse, only write

agile_geek09:10:17

@borkdude: I’m afraid I haven’t done that for even longer!

doug kirk15:10:00

@borkdude: The Java community has pretty much embraced annotation-based XML serialization, and in that space Jackson is the most common (and fastest).

doug kirk15:10:02

I've done it two other ways: hand-written .toXml() methods and also Velocity template-based (this last is very nice IMO, and separates all knowledge of XML outside of the Java code).

joelkuiper16:10:31

@borkdude: I’ve used JAXB in the past, but not sure if I can recommend it https://jaxb.java.net/ & https://en.wikipedia.org/wiki/Java_Architecture_for_XML_Binding the use of Schema’s and XSLT for forward/backward compatibility was nice though. Other than it was a pain and not sure if it’s maintained anymore

borkdude18:10:56

@joelkuiper: Yeah, JAXB is what we have and I tried working around a stupid problem. But I already solved it the other way by going from @XmlAccessorType(XmlAccessor.FIELD) -> @XmlAccessorType(XmlAccessor.NONE) and explicitly annotating every field I want to pull in the xml

borkdude18:10:42

I came across this today (during a lecture about DDD): http://martinfowler.com/ieeeSoftware/whenType.pdf The guy presenting advocated for replacing simple string by specialized classes and cited that article by Fowler. It goes so against the Clojure way of just writing hashmaps. I wonder if some people are trying the (immutable) hashmap way in Java and get away with it.

borkdude18:10:39

I wonder if I could easily use clojure.java.jdbc from Java 😈

doug kirk18:10:18

It's not whether you can, since it all boils down to JVM bytecode, it's how painful is it?

doug kirk18:10:48

(of course now I see you wrote easily)

borkdude18:10:17

@kirked: yeah, obviously you can. I am updating a legacy Java code base now. The 'domain' is so huge. Every little 'thing' has its own class. Still can't believe how people can be productive that way.

borkdude18:10:30

The app imports json. In json it all looks so small and clear. Until it's unmarshalled into Java objects. Huge bloat.

borkdude18:10:08

OK, enough ranting for the day. Thanks for putting up with me 😛.

doug kirk18:10:14

Ah, enterprise coding at its finest!

borkdude18:10:30

@kirked: I wonder if there's a better way in Java.

colin.yates18:10:35

I really don’t miss the incredibly low signal->noise ratio in Java. There is just so much stuff that finding your domain logic is sometimes harder than where’s Wally simple_smile

doug kirk18:10:19

Using JS directly via ScriptEngine (with Java8 it's Nashorn)

doug kirk18:10:58

(or even better, cljs->JS on Nashorn?)

borkdude18:10:59

Probably the folks who started the project could better have dumped the JSON straight into MongoDB or Elasticsearch without writing one domain class.

doug kirk18:10:38

Yeah, I've seen a lot of really goofy stuff in Java codebases.

borkdude18:10:19

@kirked: if it was up to me, I would rewrite in Clojure, but it's not the reality. I don't even think this is goofy, it's just the way it's usually done in Java + mapping to relational databases (as far as I'm aware).

borkdude18:10:54

At least it's type safe! 😛

borkdude18:10:35

(until you make typos in xml configs)

doug kirk18:10:36

That's always been the problem with object-relational mapping: you need a compiler to tell you where you screwed it up, unless you wanna just wait until runtime

doug kirk18:10:06

And nobody's bother to take it that far (in Javaland)

borkdude18:10:47

I wonder if Clojure style (domain in 'just' hashmaps) catches on in other languages in the future.

borkdude18:10:08

case classes/Haskell records maybe are a bit similar approach?

borkdude18:10:08

I wonder if there is a name that catches this style: immutable domain model?

doug kirk18:10:26

Scala case classes are essentially named tuples with compiler-provided methods for equality, hashing, and copying ("modifying")

doug kirk18:10:47

I used regular Java HashMaps in an immutable way for one project. It worked well, but it would also have been nice to have compiler guarantees since others eventually took up the codebase.

doug kirk18:10:31

@borkdude You might also check out Apache Camel. It's a data flow toolkit essentially.

doug kirk18:10:44

Depending on your latitude with the codebase

borkdude19:10:46

@kirked: Yeah, I know it. Not relevant to this project I think.

borkdude19:10:29

@kirked: I share my office with an entire team of integration specialists working with Camel, Fuse, etc.

borkdude19:10:26

in my emphatic mode, I can even see why people were charmed by such a solution when all they had was Java