Bird
0
0

Why is it important to keep service layer functions free of HTTP-specific code like request or response objects?

hard📝 Conceptual Q10 of 15
Flask - Ecosystem and Patterns
Why is it important to keep service layer functions free of HTTP-specific code like request or response objects?
ATo keep business logic independent and reusable across different interfaces.
BBecause Flask does not allow accessing request objects in service layer.
CTo improve database query speed.
DBecause service layer functions must always return HTML.
Step-by-Step Solution
Solution:
  1. Step 1: Understand separation of concerns

    Service layer should focus on business logic, not HTTP details, to be reusable.
  2. Step 2: Evaluate other options

    Flask allows request access anywhere, but mixing concerns reduces flexibility; speed and HTML return are unrelated.
  3. Final Answer:

    To keep business logic independent and reusable across different interfaces. -> Option A
  4. Quick Check:

    Service layer = business logic only, no HTTP code [OK]
Quick Trick: Keep service layer HTTP-agnostic for reuse [OK]
Common Mistakes:
MISTAKES
  • Thinking Flask forbids request in service layer
  • Believing it improves query speed
  • Assuming service layer returns HTML

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes