简体   繁体   中英

CRUD itself in OOP design

I just started learning web programming. When I design class diagram for Leave Online Management system. II looked at this tutorial and started to get confused about my OOP knowledge. 在此处输入图像描述

I think, an object has only actions that it can do in the same way as it actually does. A Cow cannot milk itself. That must have 1 object like Farmer take milk from Cow or Farmer kill Cow (delete), change Cow (update). But my boss said that an object itself CRUD itself, it is OOP. The cow milked itself . I think Task cann't CRUD itself(exclude Create - Constructor). I think need a object like TaskManager for CRUD TASK . Where am I misunderstanding? Can anyone explain it to me? Thank you so much.!!!

P/s: Sorry for my English

But my boss said that an object itself CRUD itself, it is OOP

What he's describing is called the Active Record Pattern . In practice it's got significant downsides, and the Repository Pattern is now much more common.

Entity Framework implements the Repository Pattern, as the DbContext is a Repository that enables query, change tracking, and CRUD for the entity objects.

Entities can have methods and responsibilities in the Repository Pattern, but CRUD is handled by the repository.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM