I fully acknowledge that Python and Java are different programming languages and should be used differently. That said, "Program to an interface, not to an implementation" is good language-agnostic programming advice.
Say I have some DAO interface in Java:
public interface DataDao {
Object load();
void update();
void delete();
}
Programming to that interface allows me to persist data in files while I'm prototyping, swap that out for a database as I get further along, etc. rather painlessly as long as I honor the contract of the DataDao
.
What's the Pythonic approach/version (if any) to programming to a contract to keep your classes orthogonal, modular, and enable frictionless implementation changes?