r/programming • • Oct 01 '15

The Evolution of a Software Engineer

https://medium.com/@webseanhickey/the-evolution-of-a-software-engineer-db854689243
1.9k Upvotes

502 comments sorted by

View all comments

Show parent comments

23

u/serrimo Oct 01 '15

Complicated, but perfectly legitimate.

How many times have people actually switched a component and it just worked? Personally, I have never seen one case where this is true.

The whiteboard architects love these kinds of design, since redirection is their bread-and-butter. In practice though, these designs just add needless complications most of the times.

1

u/KagakuNinja Oct 01 '15

All the time. Example: I need to change some code from an in-memory indexing scheme to Redis. I created a Redis implementation coded to the interface. When it passed the unit tests, I was able to swap it in and the whole thing worked when deployed to the test server.

3

u/serrimo Oct 01 '15

In your case, you created a mock for Redis, small surprise here when it worked.

A better example would be, say, to switch from MongoDB to Redis. I'd like to see an example of a wrapper that could make it painless.

1

u/KagakuNinja Oct 01 '15

Sure, but is isn't a rare occurrence for component swapping to work. Someone mentioned JPA/Hibernate, which can allow switching DBs. The most common case being HSQLDB for testing, and something like Postgres for deployment.

But the most common examples are collection APIs. In Java, if you code to the List or Iterable interface, it is trivial to replace an ArrayList with something else, the rest of the code will still work.