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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:17:14+00:00 2026-05-15T05:17:14+00:00

This is a design question better explained with a Stack Overflow analogy: Users can

  • 0

This is a design question better explained with a Stack Overflow analogy:

Users can earn Badges. Users, Badges and Earned Badges are stored in the database. A Badge’s logic is run by a Badge Condition Strategy. I would prefer not to have to store Badge Condition Strategies in the database, because they are complex tree structure objects.

How do I associate a Badge stored in the database with its Badge Condition Strategy? I can only think of workaround solutions. For example: create 1 class per badge and use a SINGLE_TABLE inheritance strategy. Or get the badge from the database, and then programmatically lookup and inject the correct Badge Condition Strategy.

Thanks for suggesting a better design.

  • 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-15T05:17:15+00:00Added an answer on May 15, 2026 at 5:17 am

    I don’t see why you should store a strategy in DB – strategy is mostly expressed in code (possibly with some configuration parameters which, in turn, can be stored in DB, but that is a different issue to me).

    OTOH I would keep the Badge and its condition strategy in one class, which eliminates your lookup problem. In Java, a good domain model would be to represent badges as an enum, with an overridable method to determine whether a given user has earned that specific badge.

    Update here is an example:

    enum Badge {
      EPIC() {
        public boolean isEligible(User user) {
          // determine whether this user is eligible for the Epic badge
        }
      },
      CRITIC() {
        public boolean isEligible(User user) {
          // determine whether this user is eligible for the Critic badge
        }
      },
      ...
      ;
    
      public abstract boolean isEligible(User user);
    }
    

    But if you really want them separated, then in the constructor of e.g. LegendaryBadge you say this.strategy = new LegendaryBadgeConditionStrategy();

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

Sidebar

Ask A Question

Stats

  • Questions 427k
  • Answers 427k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Doing if/while or while/if is not necessary, since "while(reader.read())" will… May 15, 2026 at 12:58 pm
  • Editorial Team
    Editorial Team added an answer I got it mostly working without a custom msbuild script.… May 15, 2026 at 12:58 pm
  • Editorial Team
    Editorial Team added an answer Handling events in a GUI application is not generally considered… May 15, 2026 at 12:58 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.