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 9072083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:05:11+00:00 2026-06-16T18:05:11+00:00

This is a low level design question. I am trying to get a grip

  • 0

This is a low level design question. I am trying to get a grip on Object Oriented programming.

I am writing a Java class with a method that sets values of data members of a value object. These values are computed by my class according to some business logic. Finally my class is supposed to return the value object so populated. What is the most object oriented way of doing this?

One possible approach, where I seem to be headed is, creating compute() methods inside my Java class for each of the data members (of the VO) that I need to set. Each of these compute methods return the required value which I set using the respective setter method of the value object.
However, I think this approach is more procedural than object oriented as I am just calling these compute methods procedurally in a sequence and populating my value object.

So what design (…design patterns, maybe?) or best practices can I use / look at, so that this code becomes object oriented.

Representative code (what I have right now):

class Adapter {   // this is my Java class
    MyValueObject applyBusinessLogic(Input object)
    {
        MyValueObject vo = new MyValueObject();
        vo.setA(computeA());
        vo.setB(computeB());
        vo.setC(computeC());
        return vo;
    }

    String computeA() { ...some logic... return a;}
    String computeB() { ...some logic... return b;}
    String computeC() { ...some logic... return c;}
}

class MyValueObject {
      String a;
      String b;
      String c;

      public void setA(String a)
      {
           this.a = a;
      }

      public void setB(String b)
      {
           this.b = b;
      }

      public void setC(String c)
      {
           this.c = c;
      }
}
  • 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-06-16T18:05:13+00:00Added an answer on June 16, 2026 at 6:05 pm

    IMHO, it really depends on the responsibilities and what the calculation methods do. You should keep in mind the SRP (http://en.wikipedia.org/wiki/Single_responsibility_principle) to do you OO design. Also high cohesion and loose coupling principles.

    If computeA(), B and C are not related, then your Adapter class should be split. If they are related, then your Adapter class should be named differently to express what it really does. For instance: TaxCalculator.

    Then you could create a new class receiving a TaxCalculator and a MyValueObject which does the apply. Or just leave the apply in the calculator (though it would be two responsibilities for one class, which is usually bad). In the latter case, perhaps you could call the class TaxCalculationsSetter or something similar, and make the compute methods private. Et voila, you would satisfy again the SRP. 😉

    Always keep in mind that “what a responsibility” is, is a somewhat subjective thing.

    I hope this has clarified something.

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

Sidebar

Related Questions

I've been trying to get some insight on FIFO and this low level I/O
As a kind of opposite to this question: Is low-level embedded systems programming hard
I am looking at doing some low level programming, writing a basic operating system.
I know this is a low-level question but, not being a database person, I
Following this question: Handling exceptions in a Swing UI (low level to high level
This is more of a language design rather than a programming question. The following
I have no experience with low level programing and I need this piece of
I have this low level for loop I've written in C that a friend
The Gaelyk tutorial provides some nice low level wrappers to the datastore and this
I'm tring to create a class which does all sorts of low-level database-related actions

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.