Join Reynald Adolphe for an in-depth discussion in this video Related objects needed always, part of C# Best Practices for Developers.
- [Instructor] Okay, so we are ready…to test our second scenario.…That is where we always want to have access…to the agency within the actor object.…So, in this case, what we can do…is create a property for the agency inside the actor class,…and modify "Get Agency" to reference it.…So, let's go over to our actor class,…and, right above our last property,…I'll go ahead and create a new one.…
Propfull tab, and our type will be "Agency",…and this will be our current agency.…Public field will be called "Current Agency"…with a capital C.…And, now, we'll scroll on down…to where we have our Get Agency,…and let's comment out this line…where we're creating a new instance,…and we are now going to refer…to the property, Current Agency.…
And let's go ahead and create a test.…Let's go ahead and run our test "Get Agency",…and we'll see that it fails.…If we look at the bottom left-hand corner here,…it'll say that we have a "no reference exception",…and the reason why is because we need to go…to our Actor Class and create an instance…
- Naming and handling classes
- Running a unit test
- Using constructors
- Naming and handling methods, fields, and properties
- Using properties correctly
- Managing objects efficiently
- Common design patterns as best practices
Skill Level Intermediate
1. Best Practices: An Overview
2. Naming and Handling Classes
3. Naming and Handling Methods, Fields, and Properties
4. Managing Objects Efficiently
5. More Best Practices Resources
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.