In: Computer Science
8.
Assignment Instructions:
Please respond with at least 100 words. Your initial post should address each of the topic below thoughtfully.
Topic: What do you think some of the relevant issues to consider when determining whether to use protected or private members in a base class. Are there any risks involved with using the protected member access specifier instead of the private member access specifier?
Relevant issues to consider when determining whether to use protected or private members in a base class:
1. In case of using protected members in a base class, there
should be a trust level between the programmers so that the
protected members are not misused by the programmers of derived
class.
2. In case of using private members in a base class, it must be
kept in mind that these members are not common fields but rather
specific to the base class only.
Risks involved with using the protected member access specifier instead of the private member access specifier:
1. Using protected members, we are at a risk of exposing these
fields to the outside world by the child classes.
2. In case of code modification due to some requirement change,
these members are hard to change and the code may break if not
updated in all the child classes that are referencing the base
class.
3. Good understanding of base class is required so that the
protected members are not misused by the derived classes.