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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:50:38+00:00 2026-06-04T17:50:38+00:00

Class X has three properties, left, right, and sum. Left + Right = Sum.

  • 0

Class X has three properties, left, right, and sum. Left + Right = Sum. They store precise value, for example, Left is 51.2584165861, Right is 55.8155984388, and Sum is 107.07401502496.

But on UI, I have to round them into two precision decimal. They will show Left = 51.26, Right = 55.82 and Sum = 107.07, which are incorrect. 51.26 + 55.82 should be 107.08.

I think it would be good to calculate one value of other two, for example, Sum – Left and then we get Right to show on Ui.

If I create a new class for Ui, I will move all properties to base class then change current class and ui class to derive from it. They will have only one difference, the original class with store precise value while ui class will store 2 precision value. Maybe I apply rounding in ui class constructor.

My question is, is it good to create class for Ui in this sample? What are pros and cons of create a class only for Ui?

  • 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-04T17:50:40+00:00Added an answer on June 4, 2026 at 5:50 pm

    is it good to create class for Ui in this sample?

    Yes.

    What are pros and cons of create a class only for UI?

    Pros: You’re managing the UI data in one place. Your controller, in a model, view, controller architecture, deals with the UI model, rather than the UI components individually.

    You can change the UI components without necessarily changing the UI model. As an example, you could change a check box to a toggle button without changing the model.

    Cons: Your UI data model tends to be global across the UI. By definition, your UI model is a singleton.

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

Sidebar

Related Questions

I have a Car class. It has three properties: id, color and model. In
I have entity called Customer and it has three properties: public class Customer {
I have a class that has 3 properties: class Three { int ID {
I'm writing a topic-based publish/subscribe system in C++. My generic Event class has three
I have a Product Class, Which has three fields:- id name price In my
I am writing a class to implement an algorithm. This algorithm has three levels
I have three files: one called sql.php witch has a class db that I
I have a complex value object class that has 1) a number or read-only
I have a data object which has a base class with three derived classes,
The change target framework dialog in the portable class library properties has a link

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.