Join Reynald Adolphe for an in-depth discussion in this video Method chaining, part of C# Best Practices for Developers.
- [Instructor] Something that you always want…to keep in mind…when you're creating your methods,…or just coding in general,…is to avoid code duplication.…And when we're dealing with methods,…one way to do this is to…by having the majority of the code…that is duplicated in one method,…and have other methods called the first,…that has the majority of the work.…So for example,…we have two book actor methods here.…We can minimize what's in here…on line 47 through 49,…and have the majority of the work…on our second book actor method.…
This is called Method Chaining.…That is, when one method calls another method…to get most of the work done.…Let's go ahead and modify this…to demonstrate what I'm referring to.…In this method,…I can just return the results…of calling our second book actor method.…And what I'll do,…is just pass in an empty string.…
And so I'll modify our second method…to handle what needs to get done when it has a date,…or if it's an empty string.…So after our first line here where it has the details,…which clearly was a duplication,…
- 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.