Reduce repetitive code with OOP inheritance