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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:57:11+00:00 2026-06-11T01:57:11+00:00

I am trying to design the points system for a game application, and having

  • 0

I am trying to design the points system for a game application, and having some issues figuring out the best way to setup the models. The basic needs are:

  • Each user can be assigned essentially a “PointsCalculator” object, responsible for keeping track of the points that the user is earning

  • Each user’s “PointsCalculator” logic could potentially be different. For example, one user might earn an extra 100 points every time he plays for more than an hour consecutively. Another user might earn double points between the hours of 8PM and 10PM.

We are trying to figure out the best way to create a model setup that will allow us to store logic that can be customized for each user, but is still DRY and testable.

I don’t need anyone to write code for me – I would more just appreciate the feedback of more experienced developers, or anyone who has tackled a similar issue in the past.

Note: Above has been edited for additional clarity, but let me know if it is still unclear.

  • 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-11T01:57:13+00:00Added an answer on June 11, 2026 at 1:57 am

    Difficult question which depends on your complexity level:

    • If all Points Calculator are well defined, you should head towards Single Table Inheritance (STI). The most simple case.

    • But if much flexibility is demanded, this becomes harder and you should consider the inclusion of methods dynamically, a la DCI. It’s the most complex. See details below.

    Ex: you store a list of calculator behaviors in a serialized object within your model:

    behaviors = [ 'behavior1', 'behavior2' ]
    

    Each behavior is linked to a class or module with the same name, eg: Behavior1 and Behavior2.

    Then you add behaviors to your object on the fly whenever you need them, for instance in an after_initialize.

    after_initialize :set_behaviors
    
    def set_behaviors
      behaviors.each do |b|
        self.extend(b.constantize)
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to figure out the best design for a custom floating pallet
I'm trying to figure out how to best design Mongo DB schemas. The Mongo
I'm trying to design a theme on WordPress (version 3.3.2) but I am having
After switching to AS3, I've been having a hell of a time figuring out
I'm trying to design an odds system that goes from 1-100, however it also
I am trying to design the package and module system for a programming language
For some reason, the output of this: public void msgNeedParts() { // Blabla... System.out.println(name
I am trying to design an event driven system where the elements of the
I have some problems trying to figure out what is wrong with my object
I'm trying to design a model for a application allowing 2 people to bet

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.