Cricket Score Calculator and Tracker

Object-oriented programming (OOP) is a crucial element of writing .NET applications. Proper OOP ensures that developers can share code easily between projects. You don't have to rewrite code that has already been written. This is called inheritance.

A lot has been written throughout the years on the topic of OOP. In fact, doing a search on the internet on the benefits of OOP will return countless results. The fundamental benefits of OOP, however, are the modular approach to writing code, the ease with which code can be shared, and the ability to extend the functionality of shared code.

These little building blocks (or classes) are self-contained units of code that each perform a function. Developers do not need to know what goes on inside the class when they use it. They can just assume that the class will function on its own and will always work. Should the class they implement not provide a specific functionality, the developer is free to extend the functionality of the class.

We will have a look at the features that define OOP, which are:

  • Inheritance
  • Abstraction
  • Encapsulation
  • Polymorphism

We will also have a look at:

  • Single responsibility
  • The open/closed principle

In this chapter, we will have a little fun. We will create an ASP.NET Bootstrap web application that keeps track of the cricket scores of your two favorite teams. It is with this app that the principles of OOP will become evident.

The Cricket Score Tracker app can be found on GitHub, and I encourage you to download the source code and make it your own. The GitHub repository URL is—https://github.com/PacktPublishing/CSharp7-and-.NET-Core-2.0-Blueprints/tree/master/cricketScoreTrack.

There are so many features that a person can build into an application such as this, but the topic of OOP has only a single chapter in this book to convey this topic. Therefore, the focus is on OOP (more than the hard and fast rules of cricket) and some liberties have been taken with certain functionalities.

Let the games begin!