About Abstraction

When code evolves

We start out with a tiny function that doesn't do that much (pseudo code):

function download_from_aws (from, to) {
  do_something();
  result = aws_client.download(from);
  parsed_result = parse(result);
  filesystem.write_to_disk(parsed_result, to);
}

So azure enters the room.

Time to DRY?

function download_from_cloud (from, to, provider) {
  do_something();

  switch provider:
    case PROVIDER.AWS: result = aws_client.download(from);
    case PROVIDER.AZURE: result = azure_client.download(from);

  parsed_result = parse(result);
  filesystem.write_to_disk(parsed_result, to);
}
  • Where should this live?
  • What happens in case of some conditional stuff, e.g. just do_something() for only aws?
  • Do we always either end up with a big god-like switch-festival or abstraction hell?

I don't know.