+ 1
Naming conventions
If you have a class called Car public class Car{ } How do you name properties of this type the private variable can be _car private Car _car; the public part would be public Car xxx { get; set; } Would is on the place of the xxx I would like to put Car on the place of the xxx. But you can't because you named your class already Car. Is there a naming convetions for this situations or a good practice ?
8 Respostas
+ 2
Good solution
Have good memories on delphi and pascal who had every type named Txxx like TCar.
If
a view is a xxxView
a viewModel is a xxxViewModel
can a Car be a CarModel ?
+ 2
Then, I think that in this case 'Car' fits perfectly as a property name.
But still, if you don't want to use it, you may write 'OwnedCar' instead.
+ 1
I did hesitate because I was afraid it is confusing but may be it is not confusing at all
+ 1
Yes I understood that.
Your solution is a good solution which will make the code more clear and easy to read.
But I am the designer, of the Car-class and also the designer of the classes that have the properties.
I am at the beginning of a new project, so I can choose good naming conventions now and benefit from it in the years to come.
+ 1
I'd say it depends on what's the purpose of that variable.
You may call it CarInstance, Instance or something like that.
If you tell us what you're using that variable for, than we may suggest you a better name
+ 1
https://code.sololearn.com/cBIXfeZ17hxl
This is what I want to make.
Just a object with another object inside
I like my type-names to be simple
So Car would be the perfect naming for a object that defines a Car
but I also like to use it for the property name
Just assume that every person has one Car.
Then Car would be perfect naming for the property that defines this persons Car
Console.WriteLine(Person1.Car.Brand);
+ 1
Thanks
+ 1
Will keep that in mind.
Thanks rudolph