2.interviewer: support user management functions: verification and ban
state lifecycle graph: state change (state machine graph)
data improve:user class : userid, name[10], hiddenpassword[10],int state
3.interviewer: a user will logout automatically after a period(safty design)?
using state machine graph to draw timeout
3-.a user can login from PC and ipad at same time?
conversation between user and server,eg: KFC session,if order twice=> get two ticket, get multiple sessions when logins different device
you should at least remember your sessionID
if no login still have session
how to realize in code: data improve:user class : userid, name[10], hiddenpassword[10],int state, vector sessionlist;
class session(session independent): sessionid, userid, time, deviceID
also add session table
OOD: inheritance design add to my user system design
table class : rest api, and row attribute
class user extends table : class attributes in row, and function
class session extends table : class attributes and function
4.find userId = 21(point search), userID are within 4,20?
point search: iterate:O(n) or index with hash: userid->hashcode:O(1)
range search: linear iterate O(n) or index with Binary Search Tree O(h),find beginning number first, and then inorder iterate(space: O(n), time: O(log2n))
5 interview: membership and lock
lock may have error
purchase execute,but system goes down:
solve: fixed bad case: write log first and then transaction,add recover log the log(rollback)
data in table repeat and shadow user(not exist user in same table)
solve: foreign key in database, in java:checker{checkregister and check duplicate}
user buy membership twice, pay too fast read the value is the value before first pay time, one pay buy twice membership
solve: add lock: synconize
blue screen
solve: copy data twice
data has two view: logical view (1 computer store data), actually physical view(3 computer store data), data can distributed storing in three machine
one more step: ACID
atomicity, all or nothing, money reduce and membership add time, do it together
consistency, checker
isolation, two transaction independent
durability, data store eternally, even the system goes down
class membership: userID, money, expiretime, addMoney(),buyMember()
question money,expiretime
question1: user number: IP, session
How to study
look at the question
answer it by yourself(with google)
check points with summary
add points as you go deeper with each query
how to study reference
read all, conception, difficult part, and how to solve
近期评论