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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:38:55+00:00 2026-05-25T02:38:55+00:00

Often I find the need to engineer objects with configurable functionality. To exemplify, assume

  • 0

Often I find the need to engineer objects with configurable functionality.

To exemplify, assume I’m creating a DateIterator. The configurable option(s) might be whether to iterate the closed interval [start, end] or the open-end interval [start, end).


  • (1) The, in my opinion, ungraceful solution – limited to only one true/false configuration option
new DateIterator(boolean openInterval);
  • (2) The typesafe enum way – typically a bit bulky
new DateIterator(Interval.OPEN_END);
  • (3) The unconventional attempt – nice but not too straight forward
new DateIterator().openEnd();
  • (4) The inheritance approach – often over-engineering
new OpenEndedDateIterator();

To this comes a few alternatives which I consider inferior, like integer-based configuration new DateIterator(Interval.OPEN_END); or property based configuration.

Are there any other approaches? Which approach you do you prefer?

  • 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-25T02:38:55+00:00Added an answer on May 25, 2026 at 2:38 am

    I’d say the Builder pattern makes sense here:

    DateIterator di = 
      DateIterator.builder()
                  .withStartDate(new Date())
                  .withOpenEnd()
                  .build();
    

    That way your actual DateIterator can be immutable, while the builder returned by DateIterator.builder() does the configuration work.

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

Sidebar

Related Questions

I often find the need to do something along these lines: public class OperationResult
Often I find myself filling ASP.NET repeaters with items that need the CSS class
Here at work, we often need to find a string from the list of
When programming for the iPhone, I find that I often need to use the
In web development, I often find I need to format and print various arrays
Thank you for your reading. I often find that I need to apply a
I find myself often with a situation where I need to perform an operation
I often find myself in need of very complex SQL examples when testing abstraction
I often* find myself in need of a data structure which has the following
In Emacs, I often find myself in a situation where I need to jump

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.