Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is a better design?
    text
    copied!<p>I have the following class:</p> <pre><code>class User { public function setName($value) { ... } public function setEmailAddress($value) { ... } public function setUsername($value) { ... } public function getName() { ... } public function getEmailAddress() { ... } public function getUsername() { ... } public function isGroupAdministrator($groupId) { ... } public function isMemberOfGroup($groupId) { ... } public function isSiteAdministrator() { ... } public function isRoot() { ... } public function hasModulePermission($moduleId, $recordId, $permissionCode) { ... } public function hasGroupPermission($groupId, $permissionCode) { ... } public function hasContentPermission($recordId, $permissionCode) { ... } public function hasModulePermission($moduleId, $recordId, $permissionCode) { ... } public function canLogIn() { ... } public function isLoggedIn() { ... } public function setCanLogIn($canLogIn) { ... } } </code></pre> <p>Is this becoming a "God Class?"</p> <p>I am unsure whether I should split this class up. The problem in doing so is that this class's methods are used by its domain to determine whether to show given UI elements on web pages, so there is not any behavior in the class.</p> <p>I suppose I could put the permission-related methods in some Permission class, making those methods static (eg. ::userIsGroupAdministrator(...), ::userIsMemberOfGroup(...) ::userHasGroupPermission(...), ::userHasContentPermission(...))</p> <p>Any suggestions on how this class could be better?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload