Deeptechtons
Deeptechtons

Reputation: 11125

Last Activity Date - Better Ideas for implementation

For a typical user registration and membership system i follow in ASP.NET website i would like to update the last activity date and time. Which of the below methods would be ideal to follow.

1

Whenever a request is made to a method that access the data from the user account table, automagically(O_o) update the last_account_activity date using GETDATE()

2

Call UpdateLastActivity() as a method external after a method is called from the membership system.

info:

In terms of reliability the #2 is ideal because i can't rely in #1 when user actively using data from other tables rather than user account table.

What do you think? U got another way for me to do it?

Specs

.NET Framework 2.0

Asp.net 2.0

Custom Membership Provider Implementation

Sql Server 2005 Database

Upvotes: 6

Views: 885

Answers (4)

Tigran
Tigran

Reputation: 62266

It's not very clear how your system is constructed (cause it's actually a root point), but considering that you say that #2 solution is better (from the call paths perspective), I would go for more reliable solution, naturally, unless it doesn't harm performance and not create frustration for my user.

If you're working on DataBase (it's not very clear from the question too), the common approach here is to use triggers bound to the table(s).

Upvotes: 2

Gokce Mutlu
Gokce Mutlu

Reputation: 101

In my opinion this is rather a design pattern question. I don't know much about your architecture so code may change but my basic idea would be defining each activity as a class implementing the same interface such as below:

public interface IMemberActivity {
   void Execute(IMemberActivityLogger logger);
}

Upvotes: 0

Digbyswift
Digbyswift

Reputation: 10400

My personal opinion is that the methods should be kept separate. This is purely because the name of a method should reflect its purpose. Therefore placing the "update" functionality in a method that isn't named as such is not great practice.

Upvotes: 1

Amar Palsapure
Amar Palsapure

Reputation: 9680

Approach 2 is better than 1.

Suggestion

You can do this in Async manner. You just fire the method UpdateLastActivity() and forget about the result. This way performance of your application won't get hampered.

Hope this works for you.

Upvotes: 5

Related Questions