Description
This class will explain how code based on the Revit software API can be refactored to simplify usage, isolate functionality, and improve maintainability. Class material will cover the use of C# language features and industry best practices to refactor code in Revit software add-ins and supporting library modules. A detailed look will be taken at extension methods, the Action and Func delegate classes, Microsoft LINQ, and design patterns. We will show specific before and after samples of code running in a production add-in. We will explore extension methods to show how you can attach functionality to the responsible object. We will use delegates to encapsulate code, making it less complex and more maintainable. We will demonstrate LINQ by selecting and processing groups of objects. Finally, we will show design patterns that separate command functionality from the user interface.
Key Learnings
- Learn how to add extension methods to existing Revit API objects to add functionality
- Learn how to utilize Action class delegates combined with lambda expressions to encapsulate functionality and simplify code
- Learn how to create LINQ expressions to select and process operations on groups of objects
- Learn how to use design patterns to separate code responsibilities and provide uniform code interfaces