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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:14:24+00:00 2026-05-24T03:14:24+00:00

Say I have a Timer object which has a TimerDisplay object as one of

  • 0

Say I have a Timer object which has a TimerDisplay object as one of its properties. If I have a update(hours, minutes, seconds) method in the TimerDisplay object, which of the following (if any) are a good practice:

  • have an updateDisplay(hours, minutes, seconds) method in the Timer, which calls the corresponding update method in the TimerDisplay
  • allow a direct call to timer.timerDisplay.update(hours, minutes, seconds)

I’m just starting OO, by the way. The first seems to be more OO, but ends up with two almost identical methods. The second seems easier, but doesn’t it go again encapsulation?

Thanks in advance

  • 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-24T03:14:25+00:00Added an answer on May 24, 2026 at 3:14 am

    The direct access to timer.timerDisplay sounds like a bad idea (as public attributes are most of the time). If you don’t want to have the timer class bother with comunicating with the timerDisplay, then why have timerDisplay be a property of a timer? Just have the same guy that is updating the timer own the display himself then.

    On the other hand, if you want the Timer class to manage updating the display, then limiting it to managing only one display doesn’t sound that good. Why not have it keep a list of displays to notify instead? If you choose to have the Timer do the communication like this, then hiding it behind the Timer.update method sounds best at least.

    As an aside, if you don’t like the TimerDisplay having methods too similar to the timer, perhaps you can use a simpler method like

    TimerDisplay.updateFrom(timer)
    

    using timer.getHours(), etc instead of passing tons of parameters everytime.


    Lastly, depending on how complicated your problem is, you might get away with just fusing both classes into a single class. It is less modular, but simplicity also has its virtue.

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

Sidebar

Related Questions

Say I have Object A which has a member of type Object B.. and
Let's say I have a class which has three properties as below. public class
How can I convert seconds into (Hour:Minutes:Seconds:Milliseconds) time? Let's say I have 80 seconds;
So, I have a base class which has a private locking object like so:
Say I have an class which has three states: full screen, windowed, and minimized.
Currently I have a database object, vacancies which has a column (foreign key) CareerLevels.
Let's say I have objects which look very roughly like this: class object {
Say I have a 'Car' object which contains a 'color' column. I want in
I have a user object represented in JPA which has specific sub-types. Eg, think
Say I have a object Client that has a child StatusType object. Both implement

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.