So far we've experimented with C# by typing basic code into the REPL. If we want to write entire programs, we'll need to save our code in files. Well, in this next section of the C# .NET pre-work, we're going to learn how to do exactly that by creating C# console applications. A console application is a program that is run within our terminal, or command line interface.
Separation of UI and Business Logic. We'll continue to separate code that deals with our business logic and code that handles our user interface logic.
Separation of Concerns. We'll continue to separate our code into multiple methods (and classes) that focus on one purpose, instead of doing multiple things.
We'll use a package manager and download packages from a shared registry. We used node package manager (
dotnet project manager and install packages from the NuGet package registry. There are some differences between the tooling, but the basic concepts are the same.
We use a
.gitignore to manage which files are saved to our remote repos. We'll continue to have files that we want to ignore. These files are auto-generated project dependencies, similar to the
npm installs for us.
We use a
README.md to describe our applications. This is a standby, and crucial to get other developers to run your app and give yourself credit for the work that you've done.
We'll also notice other similarities between the two languages. For example, classes and constructors are much the same.
The Process of Building the C# Shape Tracker
When we're done creating our C# Shape Tracker, our project directory will look like this:
| |_ Triangle.cs
But how will we get there? We'll start with our business logic, and then move onto our user interface logic:
- We'll start by creating a simple "Hello World" application that has nothing to do with our Shape Tracker app. This will give us the opportunity to understand how C# compiles and executes programs.
- Then we'll start creating our Shape Tracker project. We'll first create the structure and learn about the namespaces in our project.
- Then, we'll create our business logic model. We'll learn how to create custom classes, constructors, methods, properties, and more by creating a
Triangleclass. In the process, we'll learn about new C# concepts.
- Finally, we'll build out our user interface. This will handle asking the user for three lengths and tell the user what type of triangle they have.
We'll end this pre-work section with a review of C# conventions, a more in depth look at compilation, and taking a look at debugging tools.
Testing and Debugging in the Next Pre-Work Section
In the next pre-work section we'll learn about some debugging tools as well as how to use MSTest to write and run tests. We'll recreate our Triangle business logic following the Red-Green-Refactor workflow. This will be a combination of a refresher of Test-Driven Development concepts and learning new tools with MSTest.