Bird
0
0

You want to build a Spring Boot app that is easy to maintain and test. Which enterprise pattern combination helps achieve this best?

hard📝 Application Q15 of 15
Spring Boot - Advanced Patterns
You want to build a Spring Boot app that is easy to maintain and test. Which enterprise pattern combination helps achieve this best?
APut all logic in one class annotated with @SpringBootApplication
BUse layered architecture with @Controller, @Service, and @Repository layers
CUse only @RestController and skip service layer
DWrite all database queries directly in controller methods
Step-by-Step Solution
Solution:
  1. Step 1: Understand layered architecture benefits

    Separating concerns into controller, service, and repository layers makes code easier to maintain and test.
  2. Step 2: Evaluate other options

    Putting all logic in one class or skipping layers leads to messy, hard-to-test code.
  3. Final Answer:

    Use layered architecture with @Controller, @Service, and @Repository layers -> Option B
  4. Quick Check:

    Layered architecture = maintainable, testable [OK]
Quick Trick: Separate concerns into layers for clarity [OK]
Common Mistakes:
  • Mixing all logic in one class
  • Skipping service layer thinking it's simpler
  • Writing DB code in controllers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes