⌘K
Flycodx

Builder Pattern: Complex Object Construction

Builder Pattern: Complex Object Construction

EasyLLD0% accepted

Implement the Builder pattern for constructing complex objects. Use case: building an HTTP request with optional headers, query params, body, timeout, and authentication. Compare with telescoping constructor anti-pattern.

Approach

Implement Builder pattern to construct complex objects with optional fields.

Input

Build GET request with auth header and 5s timeout

Output

HttpRequest req = new HttpRequest.Builder(url).method(GET).header(Authorization, Bearer+token).timeout(5000).build()

Scenarios & Expected Answers

Sign in to continue

Create a free account to view answers and mark progress.

  • Free forever — no credit card
  • Theory Q&A with detailed answers
  • Points, streaks & leaderboards
Auto Save On