exam questions

Exam MB-500 All Questions

View all questions & answers for the MB-500 exam

Exam MB-500 topic 4 question 5 discussion

Actual exam question from Microsoft's MB-500
Question #: 5
Topic #: 4
[All MB-500 Questions]

HOTSPOT -
You have a Dynamics 365 Finance environment.
You have the following code: (Line numbers are included for reference only.)

For each of the following statements, select Yes if the statement is true. Otherwise, select No.
NOTE: Each correct selection is worth one point.
Hot Area:

Show Suggested Answer Hide Answer
Suggested Answer:
Box 1: Yes -
Class extension - Method wrapping and Chain of Command.
The functionality for class extension, or class augmentation, has been improved. You can now wrap logic around methods that are defined in the base class that you're augmenting. You can extend the logic of public and protected methods without having to use event handlers. When you wrap a method, you can also access public and protected methods, and variables of the base class. In this way, you can start transactions and easily manage state variables that are associated with your class.

Box 2: Yes -
In the following example, the wrapper around doSomething and the required use of the next keyword create a Chain of Command (CoC) for the method. CoC is a design pattern where a request is handled by a series of receivers. The pattern supports loose coupling of the sender and the receivers
[ExtensionOf(classStr(BusinessLogic1))]
final class BusinessLogic1_Extension
{
str doSomething(int arg)
{
// Part 1
var s = next doSomething(arg + 4);
// Part 2
return s;
}
}

Box 3: Yes -
Instance and static methods can be wrapped by extension classes. If a static method is the target that will be wrapped, the method in the extension must be qualified by using the static keyword.

Box 4: No -
Wrapper methods must always call next.
Note: Wrapper methods in an extension class must always call next, so that the next method in the chain and, finally, the original implementation are always called. This restriction helps guarantee that every method in the chain contributes to the result.
In the current implementation of this restriction, the call to next must be in the first-level statements in the method body.
Here are some important rules:
✑ Calls to next can't be done conditionally inside an if statement.
✑ Calls to next can't be done in while, do-while, or for loop statements.
✑ A next statement can't be preceded by a return statement.
✑ Because logical expressions are optimized, calls to next can't occur in logical expressions. At runtime, the execution of the complete expression isn't guaranteed.
Reference:
https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/extensibility/method-wrapping-coc

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Einestien
Highly Voted 4 years ago
The answer of the question is correct Yes,Yes,Yes and No
upvoted 25 times
...
Aghenon
Most Recent 11 months ago
Yes, Yes, No, No Static methods cannot be wrapped or extended using the Chain of Command (CoC) pattern.
upvoted 1 times
Gince40
8 months, 2 weeks ago
Instance and static methods can be wrapped by extension classes. If a static method is the target that will be wrapped, the method in the extension must be qualified by using the static keyword.
upvoted 1 times
...
...
Prollyx
3 years, 1 month ago
Yes - Yes - Yes - No
upvoted 2 times
...
jovank
3 years, 2 months ago
New version of question asks about adding conditional logic on line 18. I suppose the answer is yes, although the question is weirdly formulated.. it doesn't say if the next call will be in the conditional logic.
upvoted 2 times
...
Pir
4 years, 3 months ago
Last 4th option is Yes, on following link there are multiple example of class extension instantiation: https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/extensibility/class-extensions
upvoted 1 times
Santhini
3 years, 9 months ago
Please don't mislead other users. For 4th option answer is 'No'
upvoted 8 times
...
Bulhy
4 years, 3 months ago
I do not agree with you. On given link I haven't been able to find any mentioned code, that would instantiate a extension class. If you extend any class (talking in X++ logic here, which is via decorator [ExtensionOf]), the (original) extended class shall recognize any new methods and members, so why would you instantiate the extension class? You just instantiate the original/extended class and you get access to the new methods and members.. In your given link there are multiple code snippets, which support my explanation: 1. Look here at the second code snippet - https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/extensibility/class-extensions#instance-methods - they instantiate the original/extended MyClass "MyClass c = new MyClass();", they DO NOT instantiate the extension class (THIS IS WRONG) "MyClass_Extension = new MyClass_Extension();" 2. Same goes for this code snippet - https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/extensibility/class-extensions#instance-state So the 4th option is NO, iyam
upvoted 14 times
...
...
Pir
4 years, 4 months ago
In my opinion, answer to all options is Yes. Specially last one.
upvoted 1 times
m463r
3 years, 8 months ago
cannot instantiate an extension class like that, it will result in compilation error
upvoted 3 times
...
...
Bulhy
4 years, 4 months ago
I think it is stated very clearly: "modify the clculatePrice() method in the EXTENSION class", thus it is indeeed correctly marked as TRUE.
upvoted 1 times
...
BigFritz
4 years, 4 months ago
Sure that the second one is right? I can add (extend) some logic. But I can't modify the base method.
upvoted 1 times
TBM1987
4 years, 4 months ago
It says modify in Extension class. So I think it's correct. We can modify it in Extension class. But, yes, I agree it's written very trickly
upvoted 2 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago