Interface segregation principle
This idea is simple:
- Make the interfaces only as big as needed.
- It's always better to have many smol interface than a few \Bigg one
- When you need 2 functions but have to implement 20, not cool
Now here is the given interface:
interface CreateReadUpdateDeleteOnDatabase{
fun createFromDatabase()
fun writeFromDatabase()
fun updateFromDatabase()
fun deleteFromDatabase()
}
Not bad, but sometimes just a few implemented function is enough and you don't want the programmer to implement things that will never be used. Like when did you last update your birthday or will you have more than one capital city?
interface DataModifier{
fun updateFromDatabase()
fun deleteFromDatabase()
}
interface DataCreater{
fun createFromDatabase()
fun writeFromDatabase()
}
As mentioned earlier, it was not necessarylly bad, but we know that it can create just as many boilerplate as it would normally avoid...