❔ File naming convention preference
In VS, the I have a folder for ReadModels and another for WriteModels. I then have a file in each for User.
Would you name this file User.cs or ReadUserModel.cs (/Write).
User.cs is simpler and nicer, but then the VS tabs for your files all just say User.cs, and I have to click in to know what actual file that is.
So which way do you go?
I know I can also get an extension to change this header name, let me know if you do that too
11 Replies
You can't share the User type?
I'm not sure what you mean?
What's in User.cs? Why do you need two of them?
oh that was really just an example
the point is you have a file with the same name, but in 2 completely different folders
I generally don't care if the files have the same name but if it really bothers you then sure, name them something distinct. I don't think there is a common existing convention for this.
fair enough then
thanks
general rule of thumb for C# is "file name matches class name"
what I'd ACTUALLY do for this setup, personally, would probably be....
or something very similar
I usually establish one as what should be considered the User. Then just further define the other.
For example, mvvm? There's a User and UserViewModel. User gets passed around for business logic easily and usually gets turned into UserViewModel before hitting the UI.
Same for a rest API. There's a main User that usually correlates to what gets saved in the database and maybe it's even what you get in a GET. Then I might have CreateUser, UpdateUser, etc for the other endpoints. All of these might share some interfaces too like IUser and ICreatable or something
Just my .02
sounds like DDD
Hm. I've never studied it but I may be influenced by proxy
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.