O'Reilly logo

Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries by Brad Abrams, Krzysztof Cwalina

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. Usage Guidelines

This chapter contains guidelines for using common types in publicly accessible APIs. It deals with direct usage of built-in Framework types (e.g., Collection<T>), implementing common interfaces, and inheriting from common base classes. The last section of the chapter talks about overloading common operators.

Arrays

This section presents guidelines for using arrays in publicly accessible APIs.

DO prefer using collections over arrays in public APIs. Section 8.3.3 describes details of how to choose between collections and arrays.

public class Order {
    public Collection<OrderItem> Items { get { ... } }
    ...
}

DO NOT use read-only array fields. The field itself is read-only and can’t be changed, but elements in the array can ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required