From the course: C# Framework Design
Design frameworks - C# Tutorial
From the course: C# Framework Design
Design frameworks
- [Instructor] Let's talk about designing frameworks. A software framework in computer programming is an abstraction in which common code provides generic functionality that can be selectively overridden or specialized by a user's code providing specific functionality. A framework can be a library of code that performs a special task or a much more complicated foundation to your code base that handles complicated systems and even rendering logic critical for your application to run. Since we are focusing on C#, to write a framework, it's important to realize that you're already writing your code on top of another framework, which is .NET. .NET is a collection of APIs and services that helps you speed up your own development. And ideally, a framework is designed to help remove repetitive tasks or to allow you to speed up your own development when doing common functionality. When writing a framework, it's important to keep in mind that you'll want to create a goal and find the simplest solution to achieve it. Designing frameworks require a lot of planning and special architectural considerations. A framework is a lot different than just generic code that runs inside of an application. Since it has to be reusable or scalable, you'll have to think ahead and plan it out before you start writing. A framework represents a core pillar of a project's code. It needs to be bug free, easy to implement, and more, important scale for future changes or additions to the code base. And the final component of any good framework is portability. Can you isolate your framework and share it easily with others? Or do you have other dependencies that your framework requires? Making sure that your framework is easily shareable, so that others can use it, will ensure that your framework is adopted by other developers. Good code architecture isn't just about coding, it's about not trying to reinvent the wheel. While you may come up with a particular solution for a problem, make sure the problem actually exists. Are there other frameworks out there that do what you're trying to do? If so, see how you can modify them and build on top of them, instead of creating a similar framework, unless you have a better way of solving that problem. Some things to keep in mind when creating your own framework is to try to answer the following things. Is there an existing library that does what you're trying to do? If so, see if it's popular and try to use that. Next, can the framework stand on its own? If not, what does it depend on, and will others be able to use it? If your framework requires a lot of additional libraries, it may be too difficult for other developers to get up and running with, or it may add more code to project than they want. Make sure that your framework is as self-contained as possible. And finally, how can you simplify the functionality of the framework to its core components and only include those in your code base? A lot of the times we try to put the kitchen sink into our frameworks. Try to keep your framework paired down and as optimized to only what it needs as much as possible.