Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In object-oriented design we frequently encounter scenarios where similar functi

ID: 3828501 • Letter: I

Question

In object-oriented design we frequently encounter scenarios where similar functionality is implemented independently in multiple concrete classes. This typically happens because multiple developers are independently implementing concrete classes. This could also happen due to cut-and-paste programming, an anti-pattern we have studied in this class.


A solution to this anti-pattern is superclass abstraction. From your textbook, "Superclass abstraction. This refactoring applies to two or more similar classes. A superclass abstraction creates an abstract class that merges the common implementations of several concrete classes. To perform a superclass abstraction, the program transformation involves: (a) transformation of similar method signatures to common method signatures, (b) creation of an abstract superclass, (c) code modification to merge selected implementations, and (d) migration of common methods to the abstract superclass. "

Show an example object-oriented design, distinct from examples presented in your textbook, that illustrates this anti-pattern and another object-oriented design that fixes it by applying the superclass abstraction. Your example may be modeled after other examples.

For this homework, along the side of your designs (using diagrams and class descriptions), you may include programming code if it is necessary to illustrate your design.

Explanation / Answer

Hi,

Please find below the answer-

Superclass abstraction- If we have 2 classes which have both attributes and functions in common, then we could define a shared superclass for them and then move all the common methods and attributes into that class.abstract class is a class which cannot be instantiated, meaning you cannot create new instances of an abstract class. The purpose of an abstract class is to function as a base for subclasses.

bstract class is a class which cannot be instantiated, meaning you cannot create new instances of an abstract class. The purpose of an abstract class is to function as a base for subclasses.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote