views:

57

answers:

3

To learn ASP.NET MVC, I am thinking of creating a community forum like SO where people can rate posts, users etc. and the user can thereby gain points. I just can't figure out if the points should be added to the user profile whenever an action is done (post rated up/down, user created new post etc.) or if it should be calculated from the different activities the user has done.

I have a few pro's and con's for both ways of doing it:

Add rating:

Pro: Easier to implement, and much faster and less resource intensive.

Con: If the value of the different activities change, you can't do anything about it. No way of showing a history on how you have gotten your points.

Calculating rating:

Pro: Much easier to have a point-history for both the user and people viewing the account. Possibility to change the amount of points for a given activity.

Con: A little more difficult to implement. More resource extensive (can be prevented by caching the data, or creating a job which calculates the points).

+2  A: 

I think you've pretty much thought of everything. I can just offer some engineering tips. All things equal, always start of with what's easier to implement.

Now there are some cons with that as you say, so they're not equal, they don't offer the same functionality. So can you live without the history? If not, implement calculating first. Your model will be tight and well defined, which is always nice.

IF you determine later on that this is too cpu intensive, only then do you go about fixing it with a cache or a job. Good ideas, both, btw. 90% of the time, unless you really measure it, you'll be laboring on optimizations that are not necessary. Unnecessary optimizations are wrong.

Martin
Thanks, I like the point about unnecessary optimization.
Dofs
+2  A: 

It looks like you are trying to build something like stackoverflow, and Stackoverflow does have a history where your points came from. When you will use linq, the calculation method could be done purely in SQL, without a lot of effort on programming skills. (although it'd be a bit more advanced than the normal linq querys)

I'd go for the second option, merely because it's more interesting, you'll learn more about linq, caching, and MVC overall.

Stefanvds
A: 

You can use ActionFilter classs to catch every action that adds/deletes user points. Like AuditActionFilter class. This can be done just by putting action filter attribute on top of corresponding methods. In the audit action filter class, you can figure out which method is executed easility using filterContext object and track the progress of points for each user in a flat file or xml, which you can show/parse when he wants to see his history.

Anil
That sounds like a much harder way to do than to calculate the points by retrieving all post created x 5 points (or likewise).
Dofs