Announcement Announcement Module
Collapse
No announcement yet.
Dilemma: Write code in Java or glue in Spring? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dilemma: Write code in Java or glue in Spring?

    At the moment I`m facing a dilemma: when to write code in Java and when to configure in Spring. Spring is very extensible, so if I need something to configure in Spring, and Spring doesn`t have it, I can make it myself. So it is very easy to configure, wrap, transform and enhance beans that otherwise would be programmed in Java.

    But when do you draw the line? When do you say: stop glueing, start programming.

    [example]
    at the moment I`m doing a lot of threading with the jdk 5.0 concurrency library and with Quartz. I have a few components that need scheduling and I could use a MethodInvoker that calls one (or more) method, build a Runnable that executes that Method invoker, and drop that runnable in some kind of (Scheduled)ExecutorService. I can make it without any problem.. but is this the right way? In essence I`m now programming in Spring and not Java.. why is this better? Why is this worse?

  • #2
    I think the question--with Spring or any other framework--is does it make what you want to do easier? Will it be less code? Will it be more maintainable? Will it help you configure the application more easily? If you don't use the framework, will you end by building your own framework, which is usually not a good idea?

    On the one hand, using any framework just for the sake of it is a bad idea. But OTOH always building from scratch where there is an easier approach, just to avoid depending on third party code, usually works out badly.

    Of course, if what you want to do is reasonably generic, it may well be something that the Spring community is interested in, which is good for both your project and the community...

    Comment


    • #3
      Originally posted by Rod Johnson
      I think the question--with Spring or any other framework--is does it make what you want to do easier? Will it be less code? Will it be more maintainable? Will it help you configure the application more easily?
      That is the question I think both will be 'dirty'.

      If write it in java, I don`t think this will be the best code written. It is just a connector/'mediator' between a lot of component, but the component itself is not very interesting.

      But on the other side, if I`m doing it in Spring, I`m programming in an xml based language (that is a bad thing), and a lot of the system is untested (who unittests spring-scripts).

      Of course, if what you want to do is reasonably generic, it may well be something that the Spring community is interested in, which is good for both your project and the community...
      I have to think about what spring-specific objects I need from Spring. I need a MethodInvokerRunnable so I can create runnable`s based on method calls. And I have to think about the rest. One problem I have with the ScheduledThreadPoolExecutor(nice word for scrable) is that it schedules runnable`s and not runnable factories.. this is something I have to think about also. Another problem is how I can deal with the different namespaces of the backport and the java.util.concurrent in the jdk 5.0 version.

      Comment


      • #4
        Not sure if using XML based configuration is equivilent to programming. Its not like it's Jelly or its latest incarnation Marmalade. IE, there are no loops and conditionals that I'm aware of.

        I think config files should be tested as part of a 'functional' test. The Spring mock jar even has classes to make this less painful.

        But, I do agree with the gist of what you are saying. Until the tools catch up and really support this (no offense to Spring IDE) there are some problems. For example, your Java code could have great metrics, no cycles, but could this be subverted by cycles in the external configuration definations?

        Comment


        • #5
          Originally posted by Rod Johnson
          Of course, if what you want to do is reasonably generic, it may well be something that the Spring community is interested in, which is good for both your project and the community...
          Is there a way to speed up the proces? I have posted a feature request some time ago, but it is still unresolved.

          http://opensource.atlassian.com/proj...browse/SPR-784

          this is the new one btw:
          http://opensource.atlassian.com/proj...browse/SPR-914

          Comment


          • #6
            But on the other side, if I`m doing it in Spring, I`m programming in an xml based language (that is a bad thing), and a lot of the system is untested (who unittests spring-scripts).
            The org.springframework.test package in spring-mock.jar makes it possible to test XML configuration quickly. Although by definition it can't be unit testing.

            Comment

            Working...
            X