IFormable<int>

Selina Lalau
2 min readDec 4, 2020

--

Today I learned about abstract classes, interfaces, and polymorphism. I found abstract classes to be very helpful being that it enables you to force a class inheritance. You can also void the abstract implementation if need be. For example, let’s say you are creating a database for a company to log their employee hours and pay rate. You have part-time, full-time, and intern employees. You can use an abstract class to assume the company name and credentials for each employee. Furthermore, you would want to create various scripts for the different wage groups. You can override it in order to insert the formulas as needed.

Interfaces I found to be more interesting because they are sort of like a contract. They allow you to create a universal script. In order to be accessible, the scripts inheriting an interface must include the same properties and methods. The thing I found most interesting is the ability to create multiple inheritances using the same interface implementation. From what I’ve learned so far, no other class can call for multiple inheritances.

Polymorphism means many forms. This enables you to pass different parameters for your objects ie: int, float. Because the various scripts are able to talk to each other through interface, polymorphism is attainable. This is a great way to clean up your code and allow each script to handle an action internally. When utilizing various forms, generic interfaces come in handy. They allow you to sum up different object Types.

As I move onward into C# script, I’m beginning to learn more ways to write efficient code that is clean, easily accessible, readable, and yet still very logical.

~Selina

--

--