OOP: how much program logic should be encapsulated inside related objects / classes as methods?

I have a simple program that can have an administrator or a regular user. The program also has two classes: for UserAccount and AdminAccount. What the administrator will have to do (use cases) includes Add_Account, Remove_Account, etc.

My question is: should I try to encapsulate these use cases in objects?

Only someone who is an administrator logged in using AdminAccount should be able to add and remove other accounts. I could have a classless subprocess that adds new UserAccount objects to the system and is called when the administrator clicks the Add Account button. Alternatively, I could place this procedure as a method inside the AdminAccount object and fire a button event, for example, "Admin.AddUser (name, password)".

I'm more inclined to the first option, but I'm not sure how far this OO business should go.

+3
source share
2 answers

How much logic should be in objects?

All this.

- 101 , Account. - , , .

, , , . . , , , , .

, GUI .

+2

, , , - (, ), .

0

Source: https://habr.com/ru/post/1739245/


All Articles