Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 239973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:37:42+00:00 2026-05-11T20:37:42+00:00

I am part of a team that is developing a web application using a

  • 0

I am part of a team that is developing a web application using a proprietary mvc framework.
This framework behaves a bit like a very poor man’s struts! It has a central controller, configuration in properties file, torque like generated database action classes and no form beans.

Say you have a user account editing screen, Here is a typical piece of code that developers are writing:
public class Handler extends StupidFrameworkBaseHandler{

// This is analogous to Struts Action
// Handlers are invoked by your controller.
    public void execute() {
        // get form elements
        }
    }
    }

To introduce the concept of form beans, an abstract getFormBean() method was declared extending the StupidFrameworkBaseHandler class. This method would be invoked by the BaseHandler class. So for now the code looks like this:

public class Handler extends ExtendedStupidFrameworkBaseHandler {

public void execute() {
UserEditFormBean bean = (UserEditFormBean) baseBean;
// business layer classes.
}

public BaseBean getFormBean() {
// get HTTP Request parameters and build an object.
UserEditFormBean bean = new UserEditFormBean();
bean.setUser(httpRequest.getParam("whatever"));
// other setters...
}
return bean;
}

In earlier applications that were developed using this framework, coders would code everything into the Handler – getting db connection, business logic etc. In order to change that the concept of business and DAO layer was introduced in my current application.

So final code looks a bit like this:

    public class Handler extends ExtendedStupidFrameworkBaseHandler {

    public void execute() {
        UserEditFormBean bean = (UserEditFormBean) baseBean;
        UserBO busObj = new UserBO();
        busObj.validateUserDetailsAndSave(bean); // I know this sucks..
    }

    public BaseBean getFormBean() {
        // grab user input from form and return a form bean instance.
    }

}

And the business layer looks like this:

   public UserBO extends BaseBO {

    public void validateUserDetailsAndSave(UserEditFormBean bean) {
    UserDAO dao = factory.getDao("user");
    // call getters on bean, do some validations, throw business exceptions.
    User objUser = new User();
    object.setUserName(bean.getUserName());
    // few more setters here on User -> that is the model.
    dao.update(objUser);
    }

    }

I find this overall design HORRIBLE, for many reasons:

  1. UserBO is a class that has no state.
    It is just a set of methods with
    procedural code.
  2. If you are calling these as layers,
    then each layer shouldn’t depend on
    the other: UserBo would always
    expect one type of FormBean for each
    method and if I were to ignore HTML
    and re use the same BO class from a
    standalone java application, I would
    never be able to without creating
    FormBeans as params.
  3. Code looks horrific and
    unmaintaineable.

So, my question here would be:

Shouldn’t you develop a business layer independent of your presentation layer? I would rather code my business objects with proper state, validation and exception throwing?

Isn’t the code provided as example above, really bad non-Java way of doing it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T20:37:42+00:00Added an answer on May 11, 2026 at 8:37 pm

    what I would suggest you is to take a look at the Spring Framework. It has a concept of IoC container (Inversion of control) and heavily relies on the dependency injection pattern. The latter pattern is extremely useful in decoupling your objects which is the major thing you have to assure when structuring your application layers. Your layers should be completely independent. So for instance your business layer should NEVER EVER reference things from your presentation layer. To assure that you can thing for instance of the following situation where you have the same business layer for a web presentation layer as well as for a standalone client application (presentation layer). If that’s possible than you’re on the right path.

    To decouple your layers, you should always define clear “contracts” through according interfaces. So for instance you should have your business (or service) layer class MyService.java and an according IMyService.java (or MyServiceImpl.java and MyService.java as you prefer), where the IService.java is the interface defining the methods that are exposed by the actual implementation of the MyService class which basically contains your business logic. And so your presentation layer will just use the interface for connecting to your business layer. And here’s where Spring comes into play with it’s dependency injection. On your presentation layer you would have:

    ...
    public void someMethod(..){
      IService service = new MyService();
      service.doSomething(...);
      ..
    }
    

    As you can see, this would again couple your layers by using the MyService() object. Therefore such instantiations are usually avoided and Factories are used to make it more independent (you already did something similar as I saw), such as defining it somewhere declaratively in a configuration file etc. Spring does this for you. I’m planning to write a post about these advantages of a layered architecture with Spring, however not before July since I’m currently quite busy.

    Hope this gave you a rough idea on how it should be done.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 189k
  • Answers 189k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The solution I found is ugly, but just as ugly… May 12, 2026 at 5:47 pm
  • Editorial Team
    Editorial Team added an answer To get IE to handle the content of the script… May 12, 2026 at 5:47 pm
  • Editorial Team
    Editorial Team added an answer You will want to create a component (or a part… May 12, 2026 at 5:47 pm

Related Questions

I am the CTO and sole developer for my company. I'm getting ready to
I am part of a high school robotics team, and there is some debate
The expressiveness of the query languages (QL) provided with ORMs can be very powerful.
I am working on an SWT project as part of a team. We are

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.