Person Object Question

Today I wanted to look deeper in objects to get an idea how they can help me in my program and also how to improve my programming skills 🙂 So I looked at the general Person Object and I had some questions in my mind.

Why do I need/should use the

public Person(var name){ Name = name; } 

If I have getter/setter. It is clear for me why and I'm also pretty sure it is ok to not use it, but I thought of objects where I don't know if the property's exist so I can't declare them but I want to have the possibility to do this. So for this I thought you can just stay by the getter/setter.

So for the case where I create an object and there is a property where I'm not sure if it will exist I came up with http://ift.tt/1xdVXhY As example I thought not everyone has an "middle name" so why should I have this as a default value to pass while creating the object and in this case you can still declare the middle name since the property exists but not in the creating process.

My question now,

  • is this a good way to think about this?
  • would you do this in real environments?
  • do you maybe have a better way to look at this or explain based on a case?

Best, Mike

by the0MIKE via /r/csharp

Leave a Reply