Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 09, 2012 01:41 AM by CodeHobo
Apr 09, 2012 01:30 AM|LINK
In this tutorial: http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/getting-started-with-mvc3-part4-cs
This instruction: "In the same file, add the following
I was taught that each class should be in it's own file. For the tutorial of course I will follow the instructions. I'm wondering about doing it for real. Is it normal practice to have more than one class in a file in situations like the one in the tutorial?
Apr 09, 2012 01:41 AM|LINK
In terms of performance, there is no difference, it's exactly the same. But for maintainability and easy of use, it's often considered best practiceto place each class in it's own file.
The movies tutorial is a getting started tutorial and aimed at beginners which is why the context is created in the same file. In a real application, you would have the context in it's own .cs file and the each model in it's own file as well.
I try to keep each class in it's own file. There are a few exceptions of course,but in general I like to keep each class in it's own file.