ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 28 - AD0-E722 discussion

Report
Export

An Adobe Commerce Architect runs the PHP Mess Detector from the command-line interface using the coding standard provided with Adobe Commerce. The following output appears:

The Architect looks at the class and notices that the constructor has 15 parameters. Five of these parameters are scalars configuring the behavior of MyService. The class also contains three constants referencing one other class.

How should the Architect fix the code so that it complies with the coding standard rule?

A.
Modify the code of MyService so that the number of different classes and interfaces referenced anywhere inside the class is fewer than 13.
Answers
A.
Modify the code of MyService so that the number of different classes and interfaces referenced anywhere inside the class is fewer than 13.
B.
Consolidate the constants referencing other classes into a string representation.
Answers
B.
Consolidate the constants referencing other classes into a string representation.
C.
Introduce a new class accepting those five scalars and use it in the constructor and the remaining logic of MyService.
Answers
C.
Introduce a new class accepting those five scalars and use it in the constructor and the remaining logic of MyService.
Suggested answer: C

Explanation:

The issue is being caused by the high coupling between objects (CBO) value of the class MyService.CBO is a metric that measures the number of classes that are coupled to a given class, either by method calls, property or parameter references, inheritance, or constants1.A high CBO value indicates that the class is too tightly coupled with other classes, which makes it more difficult to maintain, test, and reuse2. To reduce the CBO value, the Architect should introduce a new class that encapsulates the five scalar parameters that configure the behavior of MyService. This way, the constructor of MyService will only have one parameter of the new class type, instead of five scalar parameters. This will also make the code more readable and maintainable, as the new class can provide methods to access and manipulate the configuration data.The constants referencing other classes should not be consolidated into a string representation, as this would not reduce the CBO value and would make the code less clear and type-safe3.The number of different classes and interfaces referenced anywhere inside the class is not relevant for the CBO metric, as it only counts the classes that are coupled to the given class1.Reference:CBO coupling between object,Coupling Between Object classes (CBO),Cohesion and coupling of an object in OO programming

asked 02/10/2024
Mr Fraser Watson
32 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first