greptilian logo

IRC log for #sourcefu, 2014-06-09

http://sourcefu.com

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

All times shown according to UTC.

Time S Nick Message
00:41 sivoais joined #sourcefu
00:51 sivoais joined #sourcefu
01:01 sivoais joined #sourcefu
10:10 pdurbin joined #sourcefu
11:28 tumdedum joined #sourcefu
12:53 pdurbin interesting chatter about desugaring Scala for comprehensions around 24:45 http://javaposse.com/java-posse-452
13:15 sulky joined #sourcefu
16:58 pdurbin http://www.reactivemanifesto.org via https://github.com/michbarsinai/PlayfulEye/blob/master/app/controllers/Application.scala
17:01 pdurbin and https://github.com/michbarsinai/PlayfulEye/blob/master/app/controllers/Examples.scala
17:06 semiosis scala.  bleh.
17:27 pdurbin semiosis: not a fan?
17:28 semiosis right
17:29 pdurbin why?
17:31 semiosis learning scala just made me appreciate java more
17:31 pdurbin :)
17:32 semiosis and i wonder if, long term, java will evolve to the point where scala is irrelevant
18:45 aditsu hi, how do people organize business logic and various services in a java application?
18:57 pdurbin aditsu: command pattern
18:57 semiosis aditsu: http://en.wikipedia.org/wiki/Domain-driven_design
18:58 aditsu pdurbin: haven't heard of that one
19:00 aditsu from the wikipedia article, it pretty much looks like the Runnable interface...
19:00 semiosis ?!?!
19:00 aditsu I mean this article: http://en.wikipedia.org/wiki/Command_pattern
19:00 semiosis oh
19:01 pdurbin aditsu: see how we import a bunch of command.impl here: https://github.com/IQSS/dataverse/blob/master/src/main/java/edu/harvard/iq/dataverse/api/Dataverses.java
19:01 pdurbin the idea is that you put your business logic in the command
19:01 aditsu semiosis: domain-driven design sounds good, but everything I've seen so far about fails to explain it before I fall asleep
19:01 pdurbin and then call the command from either an api or a gui
19:02 aditsu I'm looking for the practical application of the concepts... what kind of classes to write and how to access them
19:02 semiosis aditsu: DDD is fundamentally about having rich domain entities, instead of a complex service layer
19:03 semiosis aditsu: so for example, if we want to add a photographer to a campaign, we call campaign.addPhotographer(photog) instead of campaignService.addPhotographerToCampaign
19:03 semiosis then your services become thinner and more comprehensible
19:03 semiosis since you build a language around your domain objects
19:04 aditsu semiosis: so basically adding business logic to the model classes?
19:05 semiosis well kinda
19:05 semiosis it's about having model classes that closely model your domain
19:06 semiosis the business logic still goes in the service layer, but it's less complex because it relies on the rich domain objects
19:09 aditsu pdurbin: so you have a separate class for each action you want to do? seems a bit overkill
19:10 aditsu semiosis: how do you organize the service layer?
19:12 semiosis tbh we dont really have a service layer :)
19:12 semiosis our two main java apps are a rest api and a batch processor
19:13 semiosis rest apis are essentially CRUD, so the business logic is externalized to the caller
19:14 semiosis the batch processor is built with camel and is organized into operations that perform a specific task (resize, apply watermark, etc) which an upload is routed through
19:15 aditsu well, what does the rest api do? just access a database?
19:16 semiosis database, file storage, and queues
19:16 semiosis what little bit of business logic we have is right in the api endpoints
19:16 aditsu those are also a kind of services, right? how do you access them?
19:16 aditsu in terms of organizing the code
19:18 semiosis well there's a thin repository layer in front of the db which just executes queries or does basic CRUD
19:18 semiosis also a small client class for the queue (amazon sqs & s3)
19:20 aditsu right, do you use static methods? singletons? factory methods? dependency injection? how do you get access to those services from the classes that receive the requests?
19:20 semiosis spring for d/i
19:21 aditsu alright, in case of DI, I have a problem... my page classes need to be serializable, but I don't want to serialize services (even if I could)
19:22 aditsu how can I inject things and avoid serializing them?
19:23 semiosis what framework are you using?
19:23 aditsu wicket
19:24 aditsu and I'd rather avoid a big DI framework for now
19:24 semiosis not familiar with wicket
19:25 aditsu well, I would have a similar problem if I used servlets for example
19:25 aditsu oh, maybe not
19:25 aditsu ah, HttpServlet is serializable
19:27 semiosis i thought we used frameworks so we didnt have to deal with serialization directly
19:27 semiosis http://wicket.apache.org/learn/examples/helloworld.html doesnt mention serializable
19:27 aditsu I don't deal with serialization directly, but the framework does
19:28 aditsu WebPage implements Serializable
19:30 semiosis so, whats the problem?
19:32 aditsu the problem is I don't want to serialize injected service objects
19:32 semiosis that's a desire, not a problem :)
19:32 semiosis i mean, why would you have to do that?
19:32 semiosis WebPage should not be a service object
19:32 semiosis that's my impression at least
19:33 semiosis like i said, not familiar with wicket
19:34 aditsu let me rephrase: wicket serializes and deserializes pages in some circumstances; if I inject an object into a page, it will normally be not serializable, so serialization of the page fails
19:36 semiosis ah
19:37 semiosis there must be a wicket way to handle that
19:37 semiosis perhaps an annotation you can add or superclass you can extend so wicket can serialize your stuff
19:37 aditsu so you're saying I should use DI, and just find the way wicket gets around that problem
19:38 semiosis in jax-rs for example you use the JAXB annotation @XmlRootElement on your value classes (transfer objects) then jax-rs will automatically serialize them
19:38 semiosis seems like you'd run into this with or without DI
19:39 aditsu well, not if I use some static methods here and there :p
19:40 semiosis if you say so.  doesnt make sense to me, but thats ok
19:42 aditsu I mean, if I can get an object by calling a static method, it doesn't become part of the class, so it doesn't affect serialization
19:42 aditsu however, it's making the code quite messy
19:43 semiosis right, di keeps things clean
19:43 semiosis have you tried using transitive on the injected property?
19:43 semiosis transient
19:43 aditsu I thought about it, but then it would need to be re-injected upon deserialization
19:44 semiosis hmmm, maybe you need another layer
19:45 aditsu anyway, apparently people have solved the problem by using some kind of serializable proxies
19:45 semiosis so your value objects (like WebPage) dont have injected properties
19:45 aditsu currently they don't
19:46 aditsu well, I'm not sure if pages can count as value objects
19:46 aditsu they're more like controllers
19:46 semiosis i'm so confused
19:46 semiosis and have to get back to work
19:46 semiosis sorry i cant be more help
19:47 aditsu you already helped, thanks a lot :) sorry to keep you
19:49 aditsu if DI is the way to go, I should look into this more
19:56 tumdedum joined #sourcefu
20:09 aditsu yeah.. wicket has support for guice, and creates serializable dynamic proxies when injecting... I guess that means I have to use interfaces for injection
20:10 aditsu it also supports spring, but I'd rather go with guice
20:10 aditsu (well, I'd rather code the injection myself, but this is getting complicated)
20:21 semiosis there's basic DI in java now
20:21 semiosis http://docs.oracle.com/javaee/7/tutorial/doc/cdi-basic.htm
20:21 semiosis i think it's based on guice
20:21 semiosis or similar
20:24 pdurbin yeah, CDI
20:24 pdurbin "Contexts and Dependency Injection"
20:27 aditsu anyway, I'm not switching to DI just yet, but refactoring the code and organizing some service classes (with instance methods)
20:28 semiosis aditsu: you might also want to check out lombok if you haven't heard of it... http://projectlombok.org/
20:28 semiosis i can't imagine how I ever got along before lombok
20:29 semiosis if this doesn't convince you, nothing will: http://projectlombok.org/features/Data.html
20:31 aditsu the lombok guy is using "yava" :)
20:33 aditsu semiosis: seems nice, but I'm not sure how much I need it
20:33 aditsu this is all annotation processor stuff, right?
20:36 semiosis i guess you dont really *need* it, but it does make life a lot easier
23:33 pdurbin aditsu: ask me in a few months if it's overkill. I'm still getting used to it. :)

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

http://sourcefu.com