
12-11-2011, 06:43 AM
|
 |
|
|
Join Date: Dec 2005
Location: Netherlands
Posts: 3,537
Благодарил(а): 0 раз(а)
Поблагодарили:
0 раз(а) в 0 сообщениях
|
|
Quote:
Originally Posted by ChrisTERiS
Programming is a very strange job. You can do the same thing in several ways and all of them to be correct, but at the same time to have their bad points. Let me explain:
1.- About Rating. The current way of use (and most used among programmers) is to store ratings in a seperate file, saving there the userid, the raterid and the rating. That's good. But when it comes to show the rating you must add one more query to check that table. Especially in this case the query is more heavy as it not looks for a single records, but for all records with userid=xxx and then calculate the average. Imagine that this way the queries must be execute even for users who have none rating. My way is different. I'll add in user table 3 more fields: Votes, Rating, Voters. When someone posts a rating it will calculate at THAT time the average rating. What you'll solve with this way. No extra query at all. Just print the rating value on the screen.
2.- Another point that I don't agree with the canonical programming has to do with showing "Rate him" instead of the rating (depending if you have rate him or not, or if you have permissions to rate or not), or a gray icon (eg contact) instead of the normal icon depending or your permissions to contact. Why? Let's say that I'm visiting your memberlist, just to see your members and nothing more. The system will perform a dozen of queries without any special reason. So my approach is: Show the rating, and ONLY if the visitor wants to rate the user, ONLY THEN perform the query to check if he has rated before or not, or if he has right to rate etc etc.
Chris
|
That sounds sensible. I hope that the new version will be able to cope with thousands of concurrent users. Thanks.
|