I've read a lot about dependency inversion principle but still, I can't apply it to my case. I just don't know when I should apply it and when not. I write a simple application in Java to generate invoices. For now, I have basic classes: Client
, Product
, InvoiceLine
and Invoice
. Should these classes communicate through interfaces? For instance, I have a method in Product
for getting name of the prductproduct:
public String getName() {
return name;
}
And I use this method in class Invoice
public void addLineToInvoice(Product product, int quantity) {
rows.add(new InvoiceLine(rows.size(), product.getName(), quantity, product.getPrice()));
}
Now, should I create an interface for Product
? Or is it unnecessary?