Instantiating objects
Now that we’ve sufficiently improved our CanPassengerBoard
method, let’s look at how we can create objects and see a few simple improvements you can make that will simplify object instantiation in your code.
Terminology notes
New developers are often tripped up by a handful of phrases that are commonly used by developers. For example, in this section, we will talk about instantiating objects. This is a common way of phrasing this for developers, but all it means is the process of creating a specific instance of a class using the new
keyword. When you see the term instantiating, you can think of it simply as creating a specific instance of something.
This section’s code could come from anywhere, but we’ll focus on code found in a pair of methods in the PassengerTests.cs
file in the test project that accompanies this chapter.
Replacing var with explicit Types
The first line of code I want to focus on comes from one of our...