← Back to Upcase

Tracking a user based on his performance


(Charlieanna) #1

Hi guys. Please help me how to approach this problem. A user registers on my website and we assume he has a pedometer. And we have no idea how the user is. Could be lazy, active, very active. So we would be giving the user a weekly challenge to gauge his performance and lifestyle. So he takes a up a weekly challenge like 70k steps in 7 days. And then based on what he done I need to tell him that since his comes in this bracket he should take a 400k steps a month challenge or a 500k steps a month challenge. And we always try to push him to the limits by trying to make sure he works out everyday.

I have a UserActivity class that tracks the users activity for a particular challenge. And I start him with a weekly challenge. So as soon as that challenge is over I want to show him another challenge that he should take like a 300k challenge which he should be able to do based on his weekly performance.
My question is which class should be responsible for tracking and suggesting challenges to a user? Should I have another class called UserTracker and who only responsible is to track the users history and another class called UserAdvisor whose only work is to advice what to do next.


(Daryl Prickett) #2

It depends. Based on reading your other post to Chad about your bosses pressuring you to get a product out the door and not wanting to use TDD etc, I would suggest using a state machine initially. I’m sure you could diagram the steps you would recommend to a user on a napkin so translating it to a state machine would be simple.

Lets say you have the 1 week assessment, the 70k, 100k, and 300k challenge. The first week you will want to measure the number of steps, use that data to “guess-timate” a monthly number of steps and then recommend an appropriate challenge (don’t recommend a 70k steps in a month if the user is doing 70k steps in a week). So once you have selected an appropriate monthly challenge, the next state is pass or fail, did the user successfully complete the challenge or not? If they do, recommend the next challenge otherwise repeat the current challenge. This type of algorithm could be implemented as a rails state machine and there are a few gems which make it easy to implement:
https://www.ruby-toolbox.com/categories/state_machines.html

So, once you move into a more mature product state you will probably want to go back and extract the state machine into something more sophisticated and manageable, either by the user or by a administrator. At that point you may consider refactoring and using models as you suggested but the core issue I believe lies in not using TDD because you are not writing the smallest amount of code necessary to satisfy the feature you are trying to build.


(Daryl Prickett) #3

Also, after you get your MVP out the door you will understand your problem domain better and have learned a few lessons. This will help you understand what needs to be improved in your next product iteration. You will not launch the perfect product the first time and you will quickly discover your “pain points” in your application after you have to use it a few times.


(Charlieanna) #4

Thanks @Daryl. That was sweet :smile:

Even I am getting frustrated by writing the implementation code without using the TDD. But the main thing is we all are still designing the product as we go. Till the last week we all thought we are not profiling the user and giving each user the same type of 300k challenge. Even yesterday I talked to each of the bosses and told them that we are missing one of the most important part of the product which is user profiling and giving him challenges according to his fitness.

So the problem is we are not yet fixed with the features and we are building this product just for user feedback so that the main features get locked in but not the ones that might change like the type of challenges.


(Charlieanna) #5

As soon as the weekly challenges gets over I want to give the user 2 options for a monthly challenge. One will be a base and other will be a upper level challenge. If he takes the base then he will get 1 point for each step he takes and even if the overshoots. But if the takes a upper level challenge and overshoots it then we will have double his points he earned above the base level.

Can you suggest me how to model this? :slight_smile:

Or should I put this in another forum post?


(Daryl Prickett) #6

A few things to consider:

  1. You are getting paid to implement features AND provide technical advice. As you mentioned in your previous post, the rest of your team is comprised of MBA’s who are considering non-technical business value aspects of the company. If you really believe that TDD will provide a higher quality product which is more flexible to build/maintain in the future then it is your duty to make that point clear to your boss. Understand, he may not agree with you but you should make every effort to explain the business value of TDD (ie, fewer bugs, low maintenance overhead etc). Considering it is a startup it may be better to just do TDD anyway and then explain how much time you saved by doing it. Sometimes demonstration is better than words.

  2. Why build a product just to get some feedback instead of using a focus group? If your boss is ok spending money to get you mentoring, he should be fine with enticing some college students to try a mock product for $5. For creating interactive, but fake, GUI’s you can just spike out some code (instead of TDD) and use the feedback to decide a direction on your actual product.

Hope this helps!


(Daryl Prickett) #7

For the scenario you described there are many ways that you could implement it. With a state machine you are providing the user with an option of two different state paths. The current state, or selected challenge, will determine the score multiplier. You have multiple options of how you want to track the multiplier. If a particular challenge always has the same score multiplier then it sounds like information that could be stored in a data structure inside the model. If the multiplier is independent of the challenge and only tied to a users progress at the time of selection, the it is probably best to store it in a “user progress” model for later reference.

In my opinion, go for the easiest possible method of implementation that makes sense to you. Considering your environment you want to have something to show soon just to get some feedback. I highly recommend using unit tests to ensure your models are behaving as expected.


(Charlieanna) #8

I have a user class and a challenge class and whenever a user joins a challenge I create an object of UserActivity class. This object stores the performance of the user and the daily steps he has taken to far. But I think UserActivity comes into picture only after the challenge has started. Who should be responsible for showing the right challenges to the user based on his fitness? So a fitter guy gets an option to choose from 300k and 400k challenge while I get a 200k and 300k challenge and after the challenge I want to be adding gamification elements to keep pushing him and motivating him so that he can acheive that goal.


(Daryl Prickett) #9

It sounds like another external process, possibly a daily job, would be running through UserActivity making recommendations based on the data. As you stated, this is only for users currently enrolled in a challenge. As for recommending initial challenges, it would have to be based on a survey or other initial assessment of the user. You would take the users initial information and offer appropriate challenges based on the perceived fitness level.

Gamification can be as simple as adding rules to send emails if the user hasn’t signed in within a certain time period, or when the user hits a certain goal give them an achievement to post on Facebook. It can also be as complicated as using some machine learning to make suggestions based off other ‘successful’ users progress points. Hope this gives you some ideas!


(Charlieanna) #10

so you mean to say it is the responsibility of the UserActivity class to recommend based on the user’s profile. As soon the user logs in, I need to check if the user is a newbie or not. If he is newbie i give a weekly challenge so judge him. Right now we don’t ask him any questions. As soon as the weekly challenge is over I need to show him 2 other challenges.

My question would be who is “I” here? Who is responsible for tracking the user? If you were to join a gym then “I” would be a physical trainer or the dietician who keeps a daily check on oyu and also recommend your next exercise based on your fitness level. I am trying to model this in a OOPs manner.

:smile:


(Charlieanna) #11

Or should I model in such a way that as soon as he joins and takes a weekly challenge, form there on it becomes the responsibility of that class to show him the next challenge? Then when he joins a monthly challenge then that UserActivity becomes responsible for showing him the next challenge based on his current and previous record.


(Daryl Prickett) #12

To me it sounds like the questions you are asking means that the MVP of the product is not fully fleshed out. Your team needs to decide which features will be implemented and how they need to work. As Chad suggested in the other post, and in his screencast, you can storyboard out how you want the application to work and use that to help answer the implementation questions.

When you get to implementation, all of the options you have given sound viable. I don’t think you have mentioned any implementation suggestion that just struck me as being wrong. The main part is to have implementations that are well tested and implement a MVP feature. You want to avoid over-engineering and building unnecessary functionality.


(Charlieanna) #13

Actually the core features have been decided but not the gamification and the challenges part. That is something we are trying to figure out. The core features would have tracking the user and also social elements. We just know how to do the gamification part and the challenges. And that is a business part. We are making a product just like any other startup whose challenge is more technically.

How can we be sure what gamification elements to put if we ourselves are not clear about it. That is why we are making the prototype to get some user feedback. And the part that is locked has already been documented.