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

  • SEARCH
  • Home
  • 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 6248241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:01:21+00:00 2026-05-24T13:01:21+00:00

My original question was quite incorrect, I have classes (not POJO ), which have

  • 0

My original question was quite incorrect, I have classes (not POJO), which have shortcut methods for business logic classes, to give the consumer of my API the ability to use it like:

Connector connector = new ConnectorImpl();
Entity entity = new Entity(connector);
entity.createProperty("propertyName", propertyValue);
entity.close;

Instead of:

Connector connector = new ConnectorImpl();
Entity entity = new Entity();
connector.createEntityProperty(entity, "propertyName", propertyValue);
connector.closeEntity(entity);

Is it good practice to create such shortcut methods?

Old question

At the moment I am developing a small framework and have a pretty nice separation of the business logic in different classes (connectors, authentication tokens, etc.), but one thing is still bothers me. I have methods which manipulates with POJOs, like this:

public class BuisnessLogicImpl implements BusinessLogic{
    public void closeEntity(Entity entity) {
        // Business Logic
    }
}

And POJO entities which also have a close method:

public class Entity {
    public void close(){
        businessLogic.closeEntity(this);    
    }
}

Is it good practice to provide two ways to do the same thing? Or better, just remove all "proxy" methods from POJOs for clarity sake?

  • 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-24T13:01:22+00:00Added an answer on May 24, 2026 at 1:01 pm

    You should remove the methods from the “POJOs”… They aren’t really POJO’s if you encapsulate functionality like this. The reason for this comes from SOA design principles which basically says you want loose coupling between the different layers of your application.

    If you are familiar with Inversion of control containers, like Google_Guice or Spring Framework— this separation is a requirement. For instance, let’s say you have a CreditCard POJO and a CreditCardProcessor service, and a DebugCreditCardProcess service that doesn’t actually charge the CC money (for testing).

    @Inject
    private CardProcessor processor;
    
    ...
    
    CreditCard card = new CreditCard(...params...);
    processor.process(card);
    

    In my example, I am relying on an IoC container to provide me with a CardProcessor. Whether this is the debug one, or the real one… I don’t really care and neither does the CreditCard object. The one that is provided is decided by your application configuration.

    If you had coupling between the processor and credit card where I could say card.process(), you would always have to pass in the processor in the card constructor. CreditCards can be used for other things besides processing however. Perhaps you just want to load a CreditCard from the database and get the expiration date… It shouldn’t need a processor to do this simple operation.

    You may argue: “The credit card could get the processor from a static factory”. While true, singletons are widely regarded as an anti-pattern requiring keeping a global state in your application.

    Keeping your business logic separate from your data model is always a good thing to do to reduce the coupling required. Loose coupling makes testing easier, and it makes your code easier to read.

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

Sidebar

Related Questions

My original question regarding Consuming Custom Request Methods with Android seems to have garnered
Original Question What I'd like is not a standard C pre-processor, but a variation
Original Question: i read that for RESTful websites. it is not good to use
My original question can be found here , for which I've gotten some great
Edit: original question below, but I revise it now that I have some code
This is a very basic regex question, but I'm not quite sure where I
UPDATE : My original question wasn't quite clear. I'm looking for the name of
This question has been asked here in one form or another but not quite
I'm not sure if this question has been either asked or quite possibly already
Original Question: I am new to SQL server and can't quite find what I

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.