Designing the Business Service Layer

A design approach for identifying the business service layers in a Web application

Follow this article and learn a design technique that identifies the business service layers of a Web application through use cases. This identification opens the way to an uncluttered development process as it enables simplified testing and maintenance.

Nalla Senthilnathan (nsenthil@hotmail.com), IT Consultant

Nalla Senthilnathan has worked as an IT consultant designing and developing enterprise Web applications for the past seven years. Nalla holds a Ph.D. in mechanical engineering from the National University of Singapore.



06 July 2004

A Web application typically contains three layers: presentation, business, and data. The presentation and data layers are where Web application developers often concentrate most of their design efforts. The business layer, unfortunately, often turns out to be a bunch of ad-hoc objects connecting the other two layers. Here you'll study a use case-based technique that systematically identifies the business service layers for a Web application. I use the simple mail-reader Web application that comes with the Struts download (see Resources) for illustration.

The Struts Mail Reader Web application

Most of you are familiar with the mail reader example (see Resources) that comes as part of the Struts download, and have seen the following screens:

  1. A welcome screen for general users with links to register or login
  2. A registration screen
  3. A welcome screen where members can edit their profiles
  4. An edit profile screen where members can edit their profiles and also manage their subscriptions
  5. A screen with a form for adding or editing a subscription
  6. A login screen

For the above screens you can write the use cases as:

  • user -> ( register )
  • member -> ( edit profile ) << include >> ( login )
  • member -> ( manage subscriptions ) << include >> ( login )

Business Service Layer components

The first step in identifying the components of your Business Service Layer is to group the use cases that have related goals. You can divide the use cases into two subsystems:

  • General user services labeled as RegistrationService:
    • user -> ( register )
  • Member services labeled as MemberService:
    • member -> ( edit profile ) << include >> ( login )
    • member -> ( manage subscriptions ) << include >> ( login )

The next step is to identify the components that these subsystems depend on. Based on the screen flow listed above, it is easy to see that you can write the components that the two subsystems depend on as:

  • RegistrationService { UserMgr }
  • MemberService { UserMgr, SubscriptionMgr }

where the UserMgr component provides services like createProfile(), getProfile(), updateProfile() and isValidUser(), and the SubscriptionMgr component provides services like getUserSubscriptions(), addUserSubscription(), updateUserSubscription(), and deleteUserSubscription().


Refactoring the layers

You now face a situation in which you must duplicate the UserMgr component in two different services -- something you clearly don't want. This suggests that you might have organized the views this way:

  1. A welcome screen for general users with links to register or login
  2. A registration screen
  3. A welcome screen with links for members to edit their profiles or manage subscriptions
  4. An edit profile screen where members can simply edit their profiles
  5. A screen to view current subscriptions and which has links to add, edit, and delete a subscription
  6. A screen for adding or editing a subscription
  7. A login screen

The above redesign of the screens divides into:

  • RegistrationService { UserMgr }
  • MemberService { RegistrationServiceInvokeMgr, SubscriptionMgr }

where you have added a new component, RegistrationServiceInvokeMgr. This new component invokes the RegistrationService to provide services like isValidUser(), getProfile(), and updateProfile(). Figure 1 illustrates the two subsystems and their dependencies.

Figure 1. Business Service Layer components
Business service layer components

Implementation notes

Use of such subsystems with a Struts Web front end means each action class needs to know only one subsystem interface to fulfill its goal. This reduces the complexity of coding involved in each Struts action class.


In conclusion

You have been presented with a design technique for identifying the business service layers for a Web application using a simple example. Use of this layered approach reduces the clutter in the Struts action classes. You can now test the business service layer for all use cases independently of the presentation layer. Add that to your can of tricks.

Resources

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Web development on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Web development
ArticleID=11938
ArticleTitle=Designing the Business Service Layer
publish-date=07062004