Doubts about class composition or inheritance

Asked

Viewed 154 times

2

I’m having some doubts in that composition between the ClienteJuridico and Clientephysics with the NotaFiscal. I did some research and saw that the objetos of these classes within another, in case it would be the composition, but how could I inherit the attributes of these classes in the class NotaFiscal?

UML

1 answer

4


I find it a little strange ClienteJuridico, and ClienteFisico, inherit from Pessoa. Not totally absurd, but it seems conceptually wrong, maybe it’s just a matter of name. Will these people one day not be able to be suppliers or have other roles? It will be weird. But that’s not the problem.

Do you have to decide, want to inherit or want to compose? They are essentially antagonistic. A NotaFiscal is a ClienteJuridico? How? I can’t imagine how this is possible, so inheritance seems discarded. The composition seems adequate. But there are problems. I can’t imagine why a customer should have a reference to a bill object. I also find it strange that the NF allows having both CPF and CNPJ.

The inheritance of NotaFiscal in Vendas It seems even more absurd (I’m not sure what this class does). My suggestion is to revise your concept of inheritance. There is material on the subject here on the site.

And I notice other problems in the model, but they are details that are not the focus of the question.

Note that the use of the term attribute is correct because this is UML, but when referencing in the language that’s called a field.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.