HomeChallengesRepsProblemsLeaderboardTake a challenge

The vendor’s field names, everywhere

A weather provider’s field names — main_temp_k, w_cond_str_v2, precip_mm_h — have leaked into the code that displays them. Put one adapter between the two so the day the provider renames a key, one file changes.

Intermediate20 min on the clock5 graded checks · 100 pointsCode Someone Else Can Change

See alsoThe gateway’s JSON, parsed in the business logicThe same boundary in C#, where the seam is an interface and the swap is a second class.

Graded by running your code against real cases.

What you build

  • An adaptWeatherResponse function that returns a domain model
  • Domain names: conditions, temperatureC, isRaining
  • The Kelvin conversion lives in the adapter
  • The display code mentions no vendor key at all
  • Each vendor key appears exactly once in the file

Done means

Renaming a provider key is a one-line change in one file.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else. Each one runs your code; it is not a search for keywords.

  1. The adapter returns a domain model+25Reshaping API data
  2. The display code names no vendor key+30Where code lives
  3. The Kelvin conversion is the adapter’s job+20Reshaping API data
  4. Each vendor key appears exactly once+15Where code lives
  5. Rain is decided once, as a boolean+10Enforcing the rules of your data

What it teaches

The rest of Code Someone Else Can Change