What I know is that, We name model having table name.
But what about the model which access multiple table.
What should be the naming standard for them?
What I know is that, We name model having table name. But what about
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming that you mean in the context of a MVC pattern, the Model is outward facing, for manipulation by the Controller and consumption by the View. The names of Model classes should be chosen to help the authors of View and Controller. I don’t agree that the names of an implementation detail of the Model (the database tables) is necessarily the correct basis for the names of the Model classes.
To take a simple example: Suppose we have a CUSTOMER table. Then we create a Customer class, all very nice we understand it perfectly. Now suppose that for performance reasons (In this contrived example, unlikely, but in real systems with legacy databases it happens) perhaps for the benefit of a completely different system, we decide to create a CUSTOMER_SUMMARY table containing only a few of the columns, and a CUSTOMER_DETAILS table, containing all the rest of the columns. Should we now rename our Customer class? It takes data from both tables, so we no longer conform to our naming convention, but from the perspective of the View it is the Customer data, it’s just what they need. I say “no”, the name is exactly correct, the implementation detail has changed, but that is not important to our consumers.
Similarly, if we have ORDERS, ORDER_LINES, PRODUCTS and a class that holds the information about an Order, which is likely to take data from all three tables, I’d call that class Order. If in the future I need summary data taken from ORDERS only I might us a Class OrderSummary. I try to choose a name that is easy to understand from the “outside”.