Thursday, December 17, 2015

A better understanding

Well, I now have a better understanding of the get set accessors. I think the blog is a great idea. I have a coworker, K.C., that has been reading all my posts and reached out a few hours after I posted on Tuesday. K.C. and I spoke about my questions on Wednesday.  My team leader, Taylor, read and knew I had questions as well.I made sure to reread pieces of the book and look at the code I had written for the chapter to try and gain a better understanding before speaking with anyone at work. I spoke a few minutes with Taylor and he helped with my understanding. K.C. and I spent close to half an hour going over my questions.

Now, what did I learn? First, just like I said last time, I need to go back and create a list of vocabulary used so I can stop confusing the terms. I will be doing that this week. Maybe writing down the words and their definitions will help me retain them better. K.C. was great and gave me some history that the book didn't present. A property is a C# creation and not known by other languages. Without the idea of property there will be a few more lines of code (it actually looked like A LOT more coding).

The get portion of the property is used anytime the property is read and returns the value of our private property. The set accessor is called when the public property needs to be set and in turn can set the private object in the class. Anytime the private object changes, there may be other objects that need to be changed, hence our private object.

Constructors, no return value. Constructors allow us to initialize the private fields in a class.Then to change our private property we have to go through our public property to change the private field. Using the property will change everything needed to change (the reason for our private property).

Automatic Property: public int MyProperty { get; set; } - C# automatically creates the private piece needed when using the generic structure.
Field: Variable declared directly in a class

I had some co-workers speak to me about how I was putting my code and programs on the web. I have just been using my Google drive. What about something like Git? I will be working on that and my definitions list. 

1 comment:

Robert Jorgensen said...

I made a few mistakes:
Properties are public. Fields are private. Properties are known by other languages, but not all languages have adopted them. Thank you, K.C.!