• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

JavaBean Example

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Many people says that the Business Logic is inside JavaBeans...
Could anyone show me an example of Javabean that have business logic inside?
 
Ranch Hand
Posts: 1376
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, there are all kinds of "business logic", from formatting to calculations to validation to persistence. Here's a very simple example, using formatting. The bean is called Name, and supports three attributes: first, last and middle. There are getters and setters for each attribute.
However, there is also one additional getter, getFull, which will return the formatted full name. For example, if the name attributes are "Joseph", "Dominic", and "Pluta", the getFull method will return the value "Joseph D. Pluta". This is the "business logic" for the Name method, and is encapsulated in the bean.

Joe
 
Willian Corcel
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually I don't beliave it is a BUSINESS LOGIC.
What you put in the Javabean would be a "PRESENTATION LOGIC", isn't it?
 
Joe Pluta
Ranch Hand
Posts: 1376
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ugh. Okay, now you're to the point of making very fine distinctions. I probably shouldn't have used a formatting example. If you wanted something specific to business logic, you would have something like this:

The business rule in place here is that the order line is only taxable if the item is taxable. Thus, the total taxable amount only includes those order lines whose items are taxable. Now, in this particular case the ultimate decision as to whether something is taxable is in the Item class. However, in other businesses, other rules may apply. That's what makes generalizing business rules so difficult.
Joe
 
reply
    Bookmark Topic Watch Topic
  • New Topic