API in C#: The Best Practices of Design and Implementation
Learn how to design and implement types in C#
Featured on: May 5, 2018
This course is aimed at all the C# developers, from beginners to seniors. Topics which are covered in the course are relevant for all kinds of C# developers since all developers design and implement APIs. The topics complexity is very different. There are plenty of very simple topics, and at the same time, there are topics which require from you a solid C# background. There are plenty of code examples throughout this course, so you will learn both theoretical and practical material. Starting with characteristics and principles of a well-designed type you will go further, learning how to give names for different members, how many parameters a method should take, is it a good idea to take a Boolean as a parameter of a method and much more than that. Then you will learn what encapsulation really means. How to encapsulate a type? There are some trade-offs we will deal with encapsulating our types. There are many experienced programmers who don't know what encapsulation is in essence. Investigating this topic together we will see how to build a consistent and reliable type. After mastering the topic of types encapsulating you will face the great problem of exceptions handling. Yep, it's a hard nut to crack. We will start from discussing a question of why do we use exceptions as a mechanism of errors handling. And why C# team didn't invent any other mechanisms? In the end, we will look at how to fight with null values. As you may know, Tony Hoar said that the invention of a null value was his billion-dollar mistake. To sum up, the course covers the following topics: API development principles How to give better names for API members and what naming conventions exist in the .NET platform and suited for C#. Common problems encountered by C# developers in the process of designing and implementing APIs: classes vs structures, abstract classes vs interfaces, creational patterns vs constructors, how to implement dispose pattern (are you sure you understand this allegedly simple case?) Common implementation smells such as poor naming, excessively long methods, output parameters and so on. Common Architectural Design Smells such as Primitive Obsession, Hidden Dependencies, Violation of Law of Demeter and other. How to deal with errors. It is surprisingly hard to develop robust software where errors handling is based on exceptions. We will find out why this is so and how to struggle with problems of error handling. How to deal with Nulls. Null Vales have always been a pain the ass. NullReferenceException is a well-known and popular guest in our software. We will look at the possible ways of diminishing the disrupting power of null-values.