开发者

The most correct way of doing it

开发者 https://www.devze.com 2023-01-22 16:38 出处:网络
I have a member website, doesn\'t matter what language or framework as it is general question. A member can cancel his subscription fromthe inside and from outside. While member is inside i store his

I have a member website, doesn't matter what language or framework as it is general question. A member can cancel his subscription from the inside and from outside. While member is inside i store his userID in session and call a function called CancelSubscription() which gets userID from session and makes a call to DB to cancel subscription. Outside uses email from newsletter on which user can click to close subscription.

Question is what is the correct, based on your bad or good experience way to create both of these func开发者_运维问答tions.

Methods:

  1. Create CloseSubscription with userID(integer) and with userEmail(string) as separate functions.
  2. Create overridden function for CloseSubscription when it gets a string as param.
  3. Create function in which AddUserIDFromUserEMail get's userID, saves in session and then CloseSubscription is called.

or other...

thanks


None of those solutions, because (for each of the 3):

  1. You'll duplicate the delete code in the 2 delete methods
  2. It's confusing, and one day an (unintended) implicit conversion will break it.
  3. CloseSubscription shouldn't rely on the presence of a session id. What if you later want to delete a subscription offline?

Thus:

4: Create CloseSubscription with userID(integer).

Create CloseSubscriptionEmail(email as string), which looks up the UserID and then calls CloseSubscription.

0

精彩评论

暂无评论...
验证码 换一张
取 消