c# - Domain Driven Design Question -


i have scenario in need advice on. have application there 2 kinds of users student , teacher. student , teacher share of common properties firstname, lastname, email, username, password etc. reason derive student , teacher classes user.

now, problem there times don't know if user student or teacher. when implementing custom membership provider , in getuser function. getuser takes username lost should return.

for student functions have created istudent , iteacher teachers. want return user , not care if student or teacher. returning base class not seems idea too.

update:

i think idea return user , not have student , teacher classes. student , teacher roles , can managed studentservices , teacherservices.

a classic scenario , classic runaway problem. yes there pain work inheritance constrain. benefits occur when inject behavior class(es). seems have decided jut using user class , not having user base , child classes teacher , student. can idea if make teacher , student roles, handling them in separate services... smells opinion. you'll end duplicate code in these services since both need handle user logics.

the fact if start fend off difficulties compensate in service layer, that's road anemic domain model logic leaks out domain layer gui or service layer. unique teacher , student , logic/behavior differs should represented in domain layer.

you can use inheritance (maybe best solution) or making these role make role custom enum - @ (i think) jimmy bogard how extend custom enum behavior.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -