Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • Inheritance of employees gets messy when you want to promote or demote an employee, or even move them to a completely different role entirely. You need a whole raft of functions to create new types of employees from others. By switching to composition, rather than inheritance, you can make all the roles into properties that an employee may or may not have. Re-grading then just becomes adding or subtracting roles on an existing employee. Commented Dec 2, 2014 at 12:40
  • There are a dozen ways to skin a cat. My response was more a clarification on what inheritance is and how it applies, as there seemed to be some question about that - there seemed to be confusion between the differences of the class definition itself, and an instantiation thereof. The better answer would be to use a combination of both. Employees will be employees - what job they hold should be part of that class, not the defining class itself. Commented Jan 8, 2015 at 16:37