New Year Sale 2026! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Salesforce Certified B2C Commerce Cloud Developer (Comm-Dev-101) Exam - Topic 4 Question 87 Discussion

Actual exam question for Salesforce's Salesforce Certified B2C Commerce Cloud Developer (Comm-Dev-101) exam
Question #: 87
Topic #: 4
[All Salesforce Certified B2C Commerce Cloud Developer (Comm-Dev-101) 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:

0/2000 characters
Armando
2 months ago
Middleware is definitely the way to improve reusability!
upvoted 0 times
...
Annelle
3 months ago
I disagree, appending functions can get messy fast.
upvoted 0 times
...
Junita
3 months ago
Definitely not replacing routes with a new cartridge, that's overkill.
upvoted 0 times
...
Santos
3 months ago
Surprised that using superModule is even an option here!
upvoted 0 times
...
Aretha
3 months ago
A new middleware function sounds like the best way to go!
upvoted 0 times
...
Latrice
3 months ago
Using the superModule property sounds familiar, but I can't recall if it's the right approach for this scenario. It might complicate things.
upvoted 0 times
...
Hillary
4 months ago
I practiced a similar question, and I feel like creating a separate cartridge might be overkill for just adding checks.
upvoted 0 times
...
Hassie
4 months ago
I'm not entirely sure, but appending a new function to all existing routes seems a bit messy. I remember something about keeping routes clean.
upvoted 0 times
...
Janet
4 months ago
I think defining a new middleware function could be the best way to handle those checks without duplicating code. It feels like a common practice in SFRA.
upvoted 0 times
...
Queen
4 months ago
I'm feeling pretty confident about this one. I believe the correct approach is to use a middleware function, as that will allow me to centralize the additional checks and apply them consistently across the routes.
upvoted 0 times
...
Gail
4 months ago
Okay, I think I've got this. The key is to find a way to reuse the additional checks across multiple routes without duplicating code. I'll carefully consider each of the options.
upvoted 0 times
...
Veta
5 months ago
Hmm, I'm a bit confused by the wording here. I'll need to review my notes on middleware and route handling in SFRA to make sure I understand the correct approach.
upvoted 0 times
...
Leslie
5 months ago
This looks like a tricky one. I'm going to carefully read through the question and think about the SFRA best practices I've learned.
upvoted 0 times
...
Marguerita
10 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
Elvera
8 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
...
Cordelia
8 months ago
C) Replace the existing routes by creating a controller in separate new cartridge.
upvoted 0 times
...
Susy
8 months ago
A) Define a new middleware function and use it in the existing routes.
upvoted 0 times
...
...
Pete
10 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
9 months ago
User3: I agree, it's a cleaner solution than using the superModule property.
upvoted 0 times
...
Iesha
9 months ago
User2: Yeah, it would make the code more reusable and easier to manage.
upvoted 0 times
...
Merri
9 months ago
User1: I think using a middleware function is the way to go.
upvoted 0 times
...
...
Eve
10 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
9 months ago
D) Use the superModule property in the existing routes to extend their functionality.
upvoted 0 times
...
Sarina
9 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
...
Leota
10 months ago
A) Define a new middleware function and use it in the existing routes.
upvoted 0 times
...
...
Reed
10 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
Deonna
8 months ago
D) Use the superModule property in the existing routes to extend their functionality.
upvoted 0 times
...
Norah
8 months ago
That's a good point. Using middleware would definitely help keep the code clean and maintainable.
upvoted 0 times
...
Yuriko
9 months ago
C) Replace the existing routes by creating a controller in separate new cartridge.
upvoted 0 times
...
Carmela
10 months ago
A) Define a new middleware function and use it in the existing routes.
upvoted 0 times
...
...
Ronnie
10 months ago
But wouldn't creating a controller in a separate new cartridge be a better option for code reusability?
upvoted 0 times
...
Nelida
11 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
10 months ago
A middleware function is definitely the way to go. It will make the code cleaner and more reusable.
upvoted 0 times
...
Denny
10 months ago
A) Define a new middleware function and use it in the existing routes.
upvoted 0 times
...
...
Clorinda
11 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
11 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