Wrox Programmer Forums
|
ASP.NET 4.5 General Discussion For ASP.NET 4.5 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4.5 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 22nd, 2013, 04:06 PM
Authorized User
 
Join Date: Dec 2011
Posts: 26
Thanks: 1
Thanked 4 Times in 3 Posts
Default best practice question

This may seem like a dumb question, but here goes:

I am going through the MVC 5 tutorial. So far all the properties in the Models are public.

What is the best practice? Should properties always be public since you want outside objects to be able to get/set them? Or is there any time you'd want them to be restricted or private?
 
Old November 22nd, 2013, 04:09 PM
Authorized User
 
Join Date: Dec 2011
Posts: 26
Thanks: 1
Thanked 4 Times in 3 Posts
Default sorry for title of forum

Sorry for the poor forum title BTW. I tried to rename it to something more specific, but I does not seem I can.
 
Old November 22nd, 2013, 11:05 PM
Authorized User
 
Join Date: Dec 2011
Posts: 26
Thanks: 1
Thanked 4 Times in 3 Posts
Default where to put dbcontext class

another beginner best practice question I have is where to put the dbcontext class. I put it at the root of my project, but I have seen others create a "Concrete" folder and put it there or others put it in the Models folder.
 
Old November 24th, 2013, 03:29 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

For View Models it doesn't really matter as they are dumb data stores anyway. You could make them internal so they are only visible within the assembly that defines them.

With regards to where you place the DbContext: it doesn't really matter. I typically have it in a separate assembly / Visual Studio project, but if it's within the same ASP.NET application you can place it anywhere you want. I prefer a sub folder for organization though as otherwise your root folder gets too cluttered.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP PRACTICE QUESTION rseni Beginning PHP 0 November 28th, 2010 07:31 AM
Best Practice Chapter Question Mikeos BOOK: Professional JavaScript for Web Developers 2nd edition ISBN: 9780470227800 1 September 28th, 2010 05:10 PM
Problems to practice with? kotozy Excel VBA 1 December 29th, 2009 12:21 AM
practice help with C++ mastrgamr C++ Programming 2 November 2nd, 2006 07:55 AM
Looking for some practice Vano2005 C++ Programming 2 July 7th, 2005 04:30 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.