Where should I instantiate the objects?

Asked

Viewed 74 times

0

In POO there is a certain degree of theory and good practice for writing classes and interfaces.

They are inside folders with established nomenclatures. The class name must be identical to the file name. The class shall be preceded by the command package that matches the folder structure of the class itself.

But it seems that there is no theory about how objects should be written and architected.

Is that right? Likes the programmer?

1 answer

4


They are inside folders with established nomenclatures. The class name must be identical to the file name.

No, object-oriented programming has nothing to do with it, and it doesn’t preach anything in that sense. It’s a myth you must have read somewhere written by someone who doesn’t understand the subject, or else you misinterpreted something.

The class must be preceded by the package command that matches the folder structure of the et cetera class itself.

Maybe you’re talking about Java, but this is technology-specific.

But it seems that there is no theory about how objects should be written and architected.

Is that right? Likes the programmer?

It is not like the programmer, it is necessary. The programmer must understand the problem as a whole and assemble what is necessary as it is necessary. And that’s only possible with a lot of experience. That you only get by doing various projects, participating in teams with well qualified people (which is rare), seeing the mistakes of others and improving their understanding. You always have to be open-minded to see new things. Which is a little problematic nowadays because people want everything fast, skip steps and don’t get the foundation to think for themselves. Then she looks for magic formulas to make it look like she’s doing it right.

There is a lot of confusion of concepts in the question. Objects are not written, classes are written. Architecture is something much wider than this.

Objects must be instantiated where they are needed, even before, and obviously never after. I hope you understand what you are talking about, otherwise go back a few houses on the board to learn these concepts first. Don’t use names for things you don’t know. Knowledge builds a concept well understood at a time and never jumps to a concept that requires the understanding of its dependencies.

Browser other questions tagged

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