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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:30:28+00:00 2026-05-11T12:30:28+00:00

Sorry for the bad question title. Let’s say that I have DateRange class that

  • 0

Sorry for the bad question title.

Let’s say that I have DateRange class that basically just consists of a start date and and end date.

My question is: How might I represent computed date ranges such as ‘This Week’, ‘The Past Two Weeks’, ‘Last Month’, and ‘This Quarter’, such that multiple clients can use these computed date ranges in a consistent way? That is, I’m going to have multiple objects of multiple classes that all need to know what ‘This Week’ is.

I could build them into DateRange, but that doesn’t seem like a good solution because more might be added or some may become obsolete over time….in fact this will happen most certainly. I could make DateRange abstract and extend it, but then I’m going to have a bunch of tiny classes. I could create some kind of static helper class that computes these dates. How might you approach this problem?

dateRange = new DateRange(RangeEnum.THISWEEK));

or

dateRange = new ThisWeek();

or

dateRange = DateHelper.getThisWeek();

or

?

To throw an additional wrench into this thing, let’s say that I also need to represent a range like ‘the work week containing the date May 1, 2008’. Upon stating that, I’m leaning towards the helper class…it just feels awkward having a big lump of goofy methods.

  • 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. 2026-05-11T12:30:28+00:00Added an answer on May 11, 2026 at 12:30 pm

    I would go the way with the helper class.

    DateRange dr = Helper.getThisWeek(); 

    You’re right, you’ll get a bunch a methods, but if you would subclass something you’ll get a bunch of classes. This way you know for sure where to look.

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

Sidebar

Related Questions

Sorry for my bad English. Just like what I asked. I have this class
Sorry for bad english and bad title! I have the table post id title
Sorry for the bad title, I wasn't sure what else to call this question.
OK sorry for my bad question.well my project is a asp site that a
Sorry for the bad title of the question apologies if it's a duplicate. I
Sorry for the bad title, I've no idea what to call this question. I
Sorry about the vague question title, but I have these typedefs here: typedef std::list<AnimationKeyframe>
I am sorry for my bad english. I just try to description my question.
Sorry if question is not clear. My vocabulary for terminology is bad. Anyways I
sorry for the bad title, I don't know how to describe my problem. 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.