Skip to main content
replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

It sounds like you have a few user types. Why don't you create a hierarchy of menu classes so at the top is an AbstractMenu and at the bottom are StudentMenu, TeacherMenu etc.? See also the accepted answer for this code reviewthis code review, which suggests to use an interface instead of an abstract class.

Besides that you may consider creating Menu and MenuFactory classes so that you could for example call MenuFactory->getStudentMenu() and obtain a concrete instance of Menu that suits a Student user. Then details of creating user-type-specific menus will be encapsulated in separate methods.

You can even combine these approaches and have static information populated in class constructor and dynamic information added by a factory.

It sounds like you have a few user types. Why don't you create a hierarchy of menu classes so at the top is an AbstractMenu and at the bottom are StudentMenu, TeacherMenu etc.? See also the accepted answer for this code review, which suggests to use an interface instead of an abstract class.

Besides that you may consider creating Menu and MenuFactory classes so that you could for example call MenuFactory->getStudentMenu() and obtain a concrete instance of Menu that suits a Student user. Then details of creating user-type-specific menus will be encapsulated in separate methods.

You can even combine these approaches and have static information populated in class constructor and dynamic information added by a factory.

It sounds like you have a few user types. Why don't you create a hierarchy of menu classes so at the top is an AbstractMenu and at the bottom are StudentMenu, TeacherMenu etc.? See also the accepted answer for this code review, which suggests to use an interface instead of an abstract class.

Besides that you may consider creating Menu and MenuFactory classes so that you could for example call MenuFactory->getStudentMenu() and obtain a concrete instance of Menu that suits a Student user. Then details of creating user-type-specific menus will be encapsulated in separate methods.

You can even combine these approaches and have static information populated in class constructor and dynamic information added by a factory.

deleted 2 characters in body
Source Link
mkalkov
  • 311
  • 2
  • 8

It sounds like you have a few user types. Why don't you create a hierarchy of menu classes so at the top is an AbstractMenu and at the bottom are StudentMenu, TeacherMenu etc.? See also the accepted answer for this code review, which suggests to use an interface instead of an abstract class.

Besides that you may consider creating Menu and *MenuFactory*MenuFactory classes so that you could for example call MenuFactory->getStudentMenu() and obtain a concrete instance of Menu that suits a Student user. Then details of creating user-type-specific menus will be encapsulated in separate methods.

You can even combine these approaches and have static information populated in class constructor and dynamic information added by a factory.

It sounds like you have a few user types. Why don't you create a hierarchy of menu classes so at the top is an AbstractMenu and at the bottom are StudentMenu, TeacherMenu etc.? See also the accepted answer for this code review, which suggests to use an interface instead of an abstract class.

Besides that you may consider creating Menu and *MenuFactory* classes so that you could for example call MenuFactory->getStudentMenu() and obtain a concrete instance of Menu that suits a Student user. Then details of creating user-type-specific menus will be encapsulated in separate methods.

You can even combine these approaches and have static information populated in class constructor and dynamic information added by a factory.

It sounds like you have a few user types. Why don't you create a hierarchy of menu classes so at the top is an AbstractMenu and at the bottom are StudentMenu, TeacherMenu etc.? See also the accepted answer for this code review, which suggests to use an interface instead of an abstract class.

Besides that you may consider creating Menu and MenuFactory classes so that you could for example call MenuFactory->getStudentMenu() and obtain a concrete instance of Menu that suits a Student user. Then details of creating user-type-specific menus will be encapsulated in separate methods.

You can even combine these approaches and have static information populated in class constructor and dynamic information added by a factory.

Formatting changes inspired by Konrad's edit
Source Link
mkalkov
  • 311
  • 2
  • 8

It sounds like you have a few user types. Why don't you create a hierarchy of menu classes so at the top is an AbstractMenuAbstractMenu and at the bottom are StudentMenuStudentMenu, TeacherMenuTeacherMenu etc.? See also the accepted answer for this code review, which suggests to use an interface instead of an abstract class.

Besides that you may consider creating MenuMenu and MenuFactory*MenuFactory* classes so that you could for example call MenuFactory->getStudentMenu()MenuFactory->getStudentMenu() and obtain a concrete instance of MenuMenu that suits a StudentStudent user. Then details of creating user-type-specific menus will be incapsulatedencapsulated in separate methods.

You can even combine these approaches and have static information populated in class constructor and dynamic information added by a factory.

It sounds like you have a few user types. Why don't you create a hierarchy of menu classes so at the top is an AbstractMenu and at the bottom are StudentMenu, TeacherMenu etc.? See also the accepted answer for this code review, which suggests to use an interface instead of an abstract class.

Besides that you may consider creating Menu and MenuFactory classes so that you could for example call MenuFactory->getStudentMenu() and obtain a concrete instance of Menu that suits a Student user. Then details of creating user-type-specific menus will be incapsulated in separate methods.

You can even combine these approaches and have static information populated in class constructor and dynamic information added by a factory.

It sounds like you have a few user types. Why don't you create a hierarchy of menu classes so at the top is an AbstractMenu and at the bottom are StudentMenu, TeacherMenu etc.? See also the accepted answer for this code review, which suggests to use an interface instead of an abstract class.

Besides that you may consider creating Menu and *MenuFactory* classes so that you could for example call MenuFactory->getStudentMenu() and obtain a concrete instance of Menu that suits a Student user. Then details of creating user-type-specific menus will be encapsulated in separate methods.

You can even combine these approaches and have static information populated in class constructor and dynamic information added by a factory.

Expand answer to mention a related code review
Source Link
mkalkov
  • 311
  • 2
  • 8
Loading
minor formatting changes (for readability)
Source Link
Konrad Morawski
  • 9.8k
  • 4
  • 39
  • 58
Loading
Source Link
mkalkov
  • 311
  • 2
  • 8
Loading