Krzysztof Cwalina and Brad Adams from Microsoft held a presentation on best practices for framework design, based on experiences with evolving the .Net framework itself.
"Learn about guidelines that have helped the Microsoft .NET Framework grow into the most popular developer framework Microsoft has ever created. After ten years of use, we have an enormous amount of real customer data about what makes great framework design. Whether you are building your own framework or just want to get the most out of the .NET Framework, this is a must-attend talk! Join Krzysztof Cwalina and Brad Abrams, authors of the Dr. Dobbs award winning "Framework Design Guidelines" book, and get a sneak peek at the content from the 2nd edition (first available at PDC2008)."
Here are some key takeaways from this session.
- Lazy constructors. They should do minimal amount of work and instanciation
- Use extention methods where appropriate
- Type design
- Prefer broad, shallow hierarchies
- Consider making base classes not constructable (i.e. abstract)
- Virtual methods - use by following the Liskov substitution principle ("virtual methods is what
distinguishes a framework (that you can extend) from a Library (that you just use)")
Common problems for framework development:
- Too complex up front design (over engineering based on requirement assumptions)
- Pressure of delivery drives you to slash your design - partial solutions
- Solution: Do as little as possible now to ensure room for extensibiliy in the future (defer your own lagacy..)
- Take care of your dependencies - adhere to dependency rules
- Do not allow upwarde dependencies
- Avoid horizontal dependencies
- Type groups:
- Libraries (types not passed between components),
- Primitives (passed around a lot, e.g. String) typically in lower layer
- Abstractions (library that needs passing around..)
- Consider placing library types higher in the stack
- Keep primitives policy free (simple)
- Do NOT create abstractions unless you know what you are doing. These give you trouble..
The secret of achieving great productivity. Make your framework as easy to use as falling into a Pit!
- Use Test Driven Development! Design for testability and simplicity.
- Use IoC and dependency injection
- "The power of Sameness" principle (e.g. Naming conventions)
- Do not abbreviate! Use meaningful names (Search engine test)
- Principle of least surprise (for developers using your framework)
- FxCop is used to verify/check for "power of sameness"
- Framework Design Studio (http://code.msdn.microsoft.com/fds)- Allows you to load two versions of the same assembly and extract the changes/differences
- Dependency management Tool (http://code.msdn.microsoft.com/fxarch) FxCop for dependency management
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment