Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Salesforce Exam B2C Commerce Developer Topic 4 Question 87 Discussion

Actual exam question for Salesforce's B2C Commerce Developer exam
Question #: 87
Topic #: 4
[All B2C Commerce Developer Questions]

A developer needs to perform the same additional checks before completing multiple routes in a custom controller, in order to decide whether to render a template or redirect the user to a different page.

According to SFRA best practices, what is the correct approach to improve code reusability in this scenario7

Show Suggested Answer Hide Answer
Suggested Answer: A

Contribute your Thoughts:

Marguerita
1 months ago
Ah, the age-old question of code reusability. I bet the developers at SFRA have seen it all - even developers trying to create their own 'super routes' to save time. Middleware is the way to go, folks!
upvoted 0 times
...
Pete
1 months ago
Using the superModule property? That's an interesting idea, but it might not be the most straightforward solution. I'd prefer a more direct approach like the middleware function.
upvoted 0 times
Darci
16 days ago
User3: I agree, it's a cleaner solution than using the superModule property.
upvoted 0 times
...
Iesha
18 days ago
User2: Yeah, it would make the code more reusable and easier to manage.
upvoted 0 times
...
Merri
1 months ago
User1: I think using a middleware function is the way to go.
upvoted 0 times
...
...
Eve
2 months ago
Creating a separate controller cartridge just to handle this use case feels like overkill. Why complicate things when we can just use a middleware function?
upvoted 0 times
Mozelle
8 days ago
D) Use the superModule property in the existing routes to extend their functionality.
upvoted 0 times
...
Sarina
17 days ago
Creating a separate controller cartridge just to handle this use case feels like overkill. Why complicate things when we can just use a middleware function?
upvoted 0 times
...
Leota
1 months ago
A) Define a new middleware function and use it in the existing routes.
upvoted 0 times
...
...
Reed
2 months ago
Appending a new function to all the routes? That's just adding more complexity and making the code harder to maintain. Definitely not the best solution here.
upvoted 0 times
D) Use the superModule property in the existing routes to extend their functionality.
upvoted 0 times
...
Norah
23 hours ago
That's a good point. Using middleware would definitely help keep the code clean and maintainable.
upvoted 0 times
...
Yuriko
22 days ago
C) Replace the existing routes by creating a controller in separate new cartridge.
upvoted 0 times
...
Carmela
2 months ago
A) Define a new middleware function and use it in the existing routes.
upvoted 0 times
...
...
Ronnie
2 months ago
But wouldn't creating a controller in a separate new cartridge be a better option for code reusability?
upvoted 0 times
...
Nelida
2 months ago
A middleware function sounds like the perfect way to encapsulate the common logic and improve code reusability. It's a much cleaner approach than modifying the existing routes.
upvoted 0 times
Elza
1 months ago
A middleware function is definitely the way to go. It will make the code cleaner and more reusable.
upvoted 0 times
...
Denny
2 months ago
A) Define a new middleware function and use it in the existing routes.
upvoted 0 times
...
...
Clorinda
2 months ago
I disagree, I believe appending a new function to all the existing routes with the server module is the way to go.
upvoted 0 times
...
Ronnie
2 months ago
I think the correct approach is to define a new middleware function and use it in the existing routes.
upvoted 0 times
...

Save Cancel