<< August 30, 2003 | Home | September 1, 2003 >>

The Elusive Separation of Layers

Writing business applications used to be easy. Something like this will do:

Application
  Init:
    con = SqlConnect("server", "username", "password")
  Window:
    Menu:
      Exit:
        Quit()
    Field:
    Button:
      Clicked:
        SqlExec(con, "update table1 set column1 = :Field")

Then they said, "We need to separate business logic from the presentation logic." So we change:

Application
  UI:
    Init:
      BO.init()
    Window:
      Menu:
        Exit:
          Quit()
      Field:
      Button:
        Clicked:
          BO.Action(:Field)
  BO:
    Init:
      con = SqlConnect("server", "username", "password")
    Action(Field):
      SqlExec(con, "update table1 set column1 = :Field")

Then they said, "We need to separate business logic from the data access logic." So we change:

Application
  UI:
    Init:
      BO.init()
    Window:
      Menu:
        Exit:
          Quit()
      Field:
      Button:
        Clicked:
          BO.Action(:Field)
  BO:
    Init:
      DA.init()
    Action(Field):
      DA.Action(Field)
  DA:
    Init:
      con = SqlConnect("server", "username", "password")
    Action(Field):
      SqlExec(con, "update table1 set column1 = :Field")

They also said a lot of other things: "use a web server, turn UI to HTML", "use an app server, turn BO into remote calls", "use an abstract persistence layer, turn DA into EJB QL", "use XML, turn remote calls to web services", "use XML schema and WSDL to define BO interfaces", etc., etc.

We can do all of these without too much thought. There is probably an XDoclet module that will do any of these for us. All we have to to is to add gazillion Javadoc tags to the real object.

But have we made real progress? Does it help to have twelve layers that all look alike?

I want an XDoclet module that writes the Javadoc tags for me!