What about the time of structured programming? Has something changed that I don’t know? I still do structured programming. Maybe I’m a little confused about paradigms. One thing doesn’t eliminate the other. Even I would avoid assuming new paradigms without understanding this foundation and understanding why you are adopting a new paradigm in your project. Doing it because it’s fashionable is not a good reason.
Was there any problem and now doing OOP solves it? If not, there is no reason to change. Did wrong in procedural? Will do OO right? It’s harder to do object-oriented right.
I’m not a fan of getters/setters. And there’s language that makes little sense, one of the reasons I don’t even like UML anymore (and a lot of people are seeing that I don’t really like it). And there’s ideomethodology that preaches that it should not use. Even OOP says this in its purest form, although I always find an exaggeration.
The model seems to be above average. But that’s what I always say, I don’t know what the problem is, I can’t tell if it’s the right solution.
Pessoa
is abstract? It should. The diagram does not show this.
Still not using the constructor the right way, seems not to have read the links that I spent in the previous question.
I don’t know if Contato
It should be this way, but I am speculating on a problem I do not know. It may be the exact solution. Should address not have an independence? How is the relationship between the two structures made? If it is to persist as the relationship is managed?
I don’t know what that is Empresa
. What is written in the question does not tell me anything. Or says, it does not make sense. Whoever creates has to justify why he created. Never create something you can’t justify very well. But after the comments I saw that it does not make sense at all, for two reasons: the individual cannot be a company and the model is left crooked so may not even have a company, probably did not understand what it serves inheritance. This is what I said in the previous question: learn first how to use the tools before using it.
The lack of understanding of what you’re doing will make you make a lot of mistakes in sequence, and you can make them all your life if you don’t create a foundation. In this case you need to create an object that is a person, and you already have a type that defines that, it’s Pessoa
, You don’t have to invent anything else. Even though it’s abstract, and I’ve already said it should be, you can create concrete objects, through their derivatives, but store them in a type variable Pessoa
, and so already has what it needs. The object will be unique to that entity and will obviously follow exclusively one of the two existing current models: PessoaJuridica
or PessoaFisica
.
I don’t know if the tipo
should be string
, but could be, would need further deepening.
Are there any missing setters? Maybe not, but there is no lack of one or more methods that allow changing the data consistently?
Behold CPF or CNPJ field type in VARCHAR or INT database?.
In the comments speaks a lot in companies, company is only legal entity. It may be just the wrong term, but as I say, if you don’t even know how to use the right names of the things you don’t know what that means, what the role of that in the model, then the mistake is imminent, look for ontology and taxinomy, can help model better if you study more deeply.
This part is still easy, people make mistakes on what comes next. And I’m curious to see this later, the comments indicate good thing.
Does it make sense to have a Person without a CPF or CNPJ? If not, the Pessoa class should be abstract. And what would Company be? Why does she inherit from both people? If she is both, it wouldn’t make sense to have four classes; concentrating everything in Person would be much simpler. Missing field Contacts in Person to make association.
– Woss
And I wouldn’t put zip code, CNPJ, RG and CPF as integers. They’re strings composed only of numeric characters but not numerical values.
– Woss
I would put at least the last two as classes, because they are data that have associated behavior (i.e., the validation of this data). For example, CPF has a validation of the last two digits per module-11. It can be argued that address could be a separate entity (class), but I have no experience in implementing this type of scenario to justify. It doesn’t make any sense that Company inherits from an Individual. Tell what you really want to do for the staff to give suggestions of how it can be done.
– Piovezan
@Cleriston, you’re on the right track yes, you’ve improved a lot since your last question. The staff questions are interesting regarding the types of data used, we can go deeper into this now. Arriving home I can answer you more calmly. What would be the
tipo
? I think it’s time to separate the address information into one classEndereco
. It is also good to use class builders, it is clearer to instantiate them and know their dependencies.– Dherik
Thank you I will try to explain better the scenario I have in mind. I will have a client who can be a natural or legal person, the "type" represents another specific characteristic of the situation, for example, the client can be a "Mason" or a "Painter", My idea regarding the company class is for me to have only the client object(Company) and not differentiate between juridical and physical. If you have another suggestion I appreciate. Already the contact class represents that every customer can have 0 or multiple contacts like email or phone.
– Cleriston Martins Cardoso
@Cleristonmartinscardoso, got it. This
Empresa
became a little strange, because a PF may have company and PJ can be a company. If I may say so, I would not work with so many heritages but with composition, but from what I understand from your context some people expect you to use inheritance, so I will try to help you in this line of thought.– Dherik
@Dherik I thank you for your help. What do you think of having a company with physical and juridical person as composition?
– Cleriston Martins Cardoso
@Cleristonmartinscardoso, provided that PF and PJ have a company (and not the other way around), yes.
– Dherik
Sorry, I was a little short and thick in my comment. And I do not have so much experience, here is my apology. I also hope to learn from this example that we are discussing here. May I ask what is the scope of the project? (if it is a customer register, with the profession of each, or some other context?)
– Piovezan
In other words, what is the field of application?
– Piovezan
@Piovezan, I will have a register of companies clients and partners, these companies can be physical and legal person, each one will have the specific characteristics are forwarders or shipowners.. These companies will be customers or suppliers of commercial proposals that have entered into another scope. In the future, I intend to implement a register of salespeople and employees.
– Cleriston Martins Cardoso
Name should be in Person or in child classes? Shipowner and dispatcher are that? Which other "people" are involved? How to insert them into the model? Shouldn’t modeling be first conceptual and only later in the class diagram? Shouldn’t you start from use cases? Now I understand why is broad.
– Piovezan
To choose the role modeling (I suggest the standard 4): http://www.jot.fm/issues/issue_2002_09/column2/
– Piovezan
@Cleristonmartinscardoso The answer solved your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful to you. You can also vote on any question or answer you find useful on the entire site.
– Maniero