title: Modular java ee application
body: <p>I need to refactor a Java EE application because the current design isn't very modular, in fact it is quite a mess. There is a Business Facade but as the application has been developed by several people and therefore the original design has been ignored several times. The application is currently running on tomcat with JSF but it will be ported to websphere soon. I already did some research about different design patterns to encapsulate the business logic from the view and also how to make the application modular so that it will be easy to put more functionality to it because the application will be enhanced in the future . I've read about OSGI but I think that would be an overkill. </p>
  
  <p>The application is already split into layers. But I'm far away of defining API's. I've already cleaned up the application a bit. Now all the beans access the business logic through the business facade methods. But the business facade consists of about 40 methods which I think isn't very nice.</p>
  
  <p><strong>3rd party edit</strong> </p>
  
  <p>For example I have these model classes </p>
  
  <ul>
  <li><code>ManageLdap</code> with methods like <code>createAccount</code> and <code>deleteAccount</code></li>
  <li><code>GroupManager</code> which manages the ldap groups </li>
  </ul>
  
  <p>In the business facade I have a method <code>createAccount</code> which </p>
  
  <ul>
  <li>calls the <code>ManagerLdap</code> class to create an ldap account and</li>
  <li>does some logging and also</li>
  <li>calls <code>GroupManager</code></li>
  </ul>
  
  <p>This pseudo code</p>
  
  <pre><code>package Model.ManageLdap
  
  public class ManageLdap 
  {
    public ldapAccount createAccount() {  }
  
    public ldapAccount deleteAccount() {  }
  }
  
  public class GroupManager
  {
    public bool addAccountToGroup(var account) {  }
  }
  </code></pre>
  
  <p>And in the business facade </p>
  
  <pre><code>package BusinessFacade.Foo
  
  public class SomeFoo
  {
    public ldapAccount createAccount() 
    { 
      var ldapAccount = new ManageLdap.createAccount();
      Logger.log("Account created");
      var accountWasAdded = GroupManager.addAccountToGroup(ldapAccount);
    }     
  }
  </code></pre>
  
  <p>Now if I want to put additional functionality to the application like the option to create a subversion repository for a user</p>
  
  <ul>
  <li>i have to implement a model class to create repos, </li>
  <li>put some methods in the business facade and </li>
  <li>create an additional bean to be accessed by the view. </li>
  </ul>
  
  <p>That makes the facade even bigger and confusing but beside that, this isn't what I call a modular design.</p>
  
  <p>So how can I seperate the business logic from the view without having a huge business facade?</p>