Say I have the following code in
Employee.h
namespace Company
{
class Employee {};
}
Manager.h
namespace Company
{
class Manager {};
}
When the user drags an inheritance line between Manager and Employee, we will generate the following code in Manager.h…
Manager.h
namespace Company
{
class Manager : Company::Employee {};
}
Your feedback on the following issues will be appreciated.
- Note that we didn’t generate the “#include Employee.h” in Manager.h file. Would it be reasonable to assume that the user will have to deal with inserting proper include statements in the Manager.h file?
The following are some of the reasons that deter us from doing it ourselves
· Redundant #includes may introduce clutter, may cause compilation errors
· It will be difficult to find the correct path to Employee.h
· What if the user #includes everything in a precompiled header
· What if the #included header requires other #includes before it? Many headers do not embed #includes for dependent headers, instead relying on the .cpp to #include the dependent headers separately. We cannot figure out what is ‘right’ without a proper dependency graph.
· Yes what we generated won’t compile but at least we just did what the user requested. It is in a better state, than actually generating something more than what the user requested and that causing more compilation errors.
- Would you prefer that we generate “Company::Employee” or just “Employee” as the base name? If we do the short name the generated code will be…
namespace Company
{
class Manager : Employee {};
}