What about the time of structured programming? Has anything changed that I do not know? I still do structured programming. Maybe I'm a bit confused about paradigms. One thing does not eliminate the other. I would even avoid taking on new paradigms without understanding this foundation and understand why you are adopting a new paradigm in your project. Doing it because it's fashionable is not a good reason.
Did you have a problem and now doing OOP resolves it? If not, you do not have to change. Was it procedural wrong? Are you going to do OO right? It's harder to do object-oriented right.
I'm not one of the more fans of getters / setters . And it has language that makes little sense, one of the reasons I no longer like UML (and many people are seeing that it was not to like). And it has ideo methodology that preaches that it should not use. Even OOP says this in its purest form, although I always find it overkill.
The model seems to be above average. But that's what I always say, I do not know what the problem is, I can not tell if it's the right solution.
Pessoa
is abstract? should. The diagram does not show this.
You are not yet using the constructor correctly, it seems to have not read the links I passed in previous question .
I do not know if Contato
should be this way, but I'm speculating on a problem I do not know. It might be the exact solution. Should not address have an independence? How is the relationship between the two structures made? If it persists how the relationship is managed?
I do not know what this Empresa
is. What is written in the question does not tell me anything. Or say, that does not make sense. Whoever creates must justify why he has created. Never create something that you can not justify very well. But after the comments I saw that it does not make sense at all, for two reasons: the physical person can not be a company and the model is crooked so maybe not even have a company, probably did not understand what is his heritage. This is what I said in the previous question: first learn how to use the tools before using it.
Failure to understand what you are doing will make you commit several errors in sequence, and you may commit your entire life if you do not create a basis. In this case you need to create an object that is a person, and already has a type that defines it, it is Pessoa
, you do not have to invent anything else. Even though it is abstract, and I said it should be, you can create concrete objects, through their derivatives, but save in a Pessoa
variable, so you already have what you need. The object will be unique to that entity and will obviously follow only one of the two existing models: PessoaJuridica
or PessoaFisica
.
I do not know if tipo
should be string
, but may be, would need a deeper.
Do not miss some setters ? Maybe not, but does not it lack one or more methods that allow you to change the data consistently?
See Type of the CPF or CNPJ field in the VARCHAR or INT database .
In the comments talks a lot in companies, company is only legal entity. It may just be the use of the wrong term, but as I say, if you do not know how to even use the right names of things, you will not know what that means, what role that is in the model, then the error is imminent, look for
04.07.2018 / 20:44