Saturday, December 3, 2011

spring framework, dependency injection, junit

I just joined a new team which is very different from my old team. I don't want to go into the details too much but it was out of my control.

My old team was very much into using the Spring Framework, dependency injection, and writing unit tests using JUnit.
However my new team is very anti Spring, dependency injection, and unit tests. They had some unit tests but they let them fall into abandonment.

My old team was pretty much a new development team that didn't really do much support other than warranty after a release.

My new team does production support and fixes but also does new development.

I got into a conversation with one of the team members because I was using Spring context XML file.
He was like it's so complex it took me a while just to figure out the project.
This was really counter intuitive because I always thought that proper dependency injection made things less complex. But he likes to press f3 and see everything defined so he can clearly trace from the beginning to the end of the app. He saw it as introducing something overly complex into the application.

He went out of his way to say it was even evil and that we shouldn't use anything that new college graduate wouldn't be able to use. This seems rather silly since we don't hire that many college graduates, they teach mostly theory, and little about practical tools to be productive. I answered him we should use any tools that will make us more productive and writing boiler plate code all the time.


Let me ask this of the reader, do you agree you shouldn't use anything a college graduate couldn't figure out?


It seems now with the newest version most all that the XML is gone from Spring and with JEE 6 there will be less of a need for spring but the concepts are still there.

Here's the benefits of Spring I see:
- Bean life-cycle management
- Promotes Dependency Injection
- Has some nice DAO and Templates for ORM
- Transactions management
- Manages singletons instead of coding them
- Focus writing code you need to instead of boiler plate code
- Has some nice utilities to aid in unit testing (I like the simple JNDI stuff so to eliminate container resource dependencies)


Let me ask this of the reader, is the Spring Framework really that complex and is there a set of problems where it's overkill?


Then he came and asked me if I thought dependency injection was good.
I came back and said yes with the following points:
-It allows you to more easily write JUnit Test Cases externalizing the dependencies
-It allows for classes to be single purpose principal and allow for separation of concerns.
-It's getting built into the Java and JEE specs in the future (not sure which versions but we're not there yet)


Let me ask this of the reader, you see value in dependency injection?


I've gotten my projects setup on the continuous integration server so I can get complexity bugs from both Findbugs and PMD which is the kind of complexity I think we should really be concerned about.

This brings me back to the type of team it is. I'm thinking this is more of a classical programming team where they don't care if they introduce issues in prod because they can just fix them. They spend more time fixing that unit testing which is more costly in the long time. They don't see the connection between the production maintenance bug fixes and the lack of unit tests. This also seems to me the difference is this team is more focused on programming rather than software development. They don't do any sort of code reviews either which really surprises me. Part of me thinks it's the culture that the main guy is getting older and doesn't want to learn new skills to the point he doesn't accept things very easily. He probably never has worked anywhere else in his life and cares very little about changes in the industry and things stay relatively the same.


Let me ask this of the reader, have you been in a similar situation? What did you do?

Sunday, October 16, 2011

GWT and HTML Canvas

I started to learn Google Web Toolkit this weekend and am very pleasantly surprised.
I installed it via Eclipse update site and got right to work.
I was able to manipulate the base project and look at the demos to figure out stuff.
I was interested in creating a demo site using HTML 5 Canvas. With little effort and writing zero JavaScript I was able to get an effective Demo.
I used mainly base GWT classes but I did use some of the classes in gwt-g2d. The main classes appear to be partly integrated into GWT so I mainly just used the support classes. It would be nice if gwt-g2d did some of the things it had on it's list and wrapped GWT's canvas classes.
GWT's tooling was very refreshingly fast and easy to use.
I was able to write a little demo artificial intelligence app to show off different programming techniques I had learned in the class I'm taking.

It would be nice if I could fail over my canvas to something else for browsers that don't support HTML 5. LimeJS appears to do this autmatically. LimeJS is probably better for writing HTML based games but I don't want to write a bunch of JavaScript which is why I like GWT. GWT automatically converts all my Java code into JavaScript for me.

Another thing is it puts the war contents in a war directory. All the conventions I've seen it is always a WebContent folder. Also the default source and test directories don't match the standard Maven structure which I imagine I could manually change but it's nice to be able to do it when creating a new project.

Saturday, October 1, 2011

WebGL and game development

I would like to create a game with WebGL and have mainly a Java background.
I don't have much game development experience and no professional experience.
I have worked with OpenGL but it was years ago in college.

I would like to know what engine/framework others would recommend.
I don't really want to pay for a license or pro features so free would be one stipulation.

Akka Actors

I really like the notion of using akka actors in Java. Basically it is trying to solve the problem of easily writing thread safe code. It does this by passing immutable messages to actors which process them. The idea is that the actor should be stateless and only act upon the immutable object it's given. They also appear to have Software Transactional Memory (STM) for when you do need mutable object and locking.


I have doubts novice programmers which couldn't write a correct singleton or proper thread safe class would be able to use akka to write thread safe code. I could see them creating all kind of actors which are not thread safe.


I did find it was really easy to get a lot of concurrency almost to a fault where my laptop was maxed out and overheating. Of course that may have been my fault as I gave it an infinite computation to work on.


I don't understand why packages don't have remoting support built for the Servlet API. Akka has a remoting support but I always work in a full J2EE container so getting ports opened and bypassing it would not be an option. I would like to know who needs stand alone remoting and is not working with at least Tomcat.

I'll definitely check akka out in more depth.

Guava

I really like the Guava libraries. One of the best things in there is ImmutableList. I like the idea of using ImmutableList on an interface. This way you don't have to worry about synchronizing the list because the list won't change on you and throw a concurrent modification exception. The builders are awesome. Unlike Apache Commons Collections it supports Generics on collections which is awesome. There's other Immutable collections and objects in this library too.

I do find a lot of other useful utility classes in Guava but it is not as complete as Apache Commons Lang and Collections. So I find myself using all three.