Documentation of interfaces

I know how to document a function:

/**
 * Prints a greet message to the web page
 */
function greet() {
    echo "Hi!";
}

Or describe the usage of a variable:

/**
 * @type string $name The user's name
 */
$name = "Bas";

But I don’t know how to document an interface. It requires the classes which implement the interface to have the functions which are inside the interface, and that’s it.

Question

How do you document an interface?

2

Describe the purpose and usage of the interface, and the purpose and usage of the functions in the interface.

Here is an example from the .NET Framework (simplified for brevity). Note the “statement of purpose,” and the specific notes about jitting and internal hacks, things which would not at all be obvious just by looking at the interface code:

    // Implement this interface if you need to support foreach semantics.

    // Note that T[] : IList<t>, and we want to ensure that if you use
    // IList<yourvaluetype>, we ensure a YourValueType[] can be used
    // without jitting.  Hence the TypeDependencyAttribute on SZArrayHelper.
    // This is a special hack internally though - see VMcompile.cpp.
    // The same attribute is on IList<t> and ICollection<t>.
    public interface IEnumerable<out t=""> : IEnumerable
    {
        // Returns an IEnumerator for this enumerable Object.  The enumerator provides
        // a simple way to access all the contents of a collection.
        /// <include file="docIEnumerable.uex" path="docs/doc[@for="IEnumerable.GetEnumerator"]/*">
        new IEnumerator<t> GetEnumerator();
    }

It’s worth noting that some of the documentation you describe in your question is either unnecessary or redundant. Don’t document things that are obvious. Instead, make things obvious so that you don’t have to document them.

Documentation is just one more thing that you have to maintain and keep in sync, so document for the right reasons. Allow the code log to speak for itself, but document the relationships between methods and classes, explain obscure things, and in general be helpful without repeating yourself.

2

Describe the intended meanings and effects of the functions defined by the interface, along with the meanings of any parameters and return values. Code that implements the interface, and code that relies on it need to be written with a shared understanding of those meanings to be useful.

The interface doesn’t just require the classes that implement it to have the functions with the given names and types. It can also require other things of the class, which you can write in English in the documentation. PHP uses nominal typing, rather than structural typing, meaning classes that implement the interface must name it in their implements statement. By doing so they effectively self-certify that they follow any specifications written into the interface’s documentation.

A good example from PHP is PsrHttpMessageMessageInterface.

Of course you need to consider who your audience is, and if they are all your colleagues who can easily talk to you then you don’t need to be quite as detailed
or formal as the Psr interface, but it’s still worth documenting things that might not be obvious.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Documentation of interfaces

I know how to document a function:

/**
 * Prints a greet message to the web page
 */
function greet() {
    echo "Hi!";
}

Or describe the usage of a variable:

/**
 * @type string $name The user's name
 */
$name = "Bas";

But I don’t know how to document an interface. It requires the classes which implement the interface to have the functions which are inside the interface, and that’s it.

Question

How do you document an interface?

2

Describe the purpose and usage of the interface, and the purpose and usage of the functions in the interface.

Here is an example from the .NET Framework (simplified for brevity). Note the “statement of purpose,” and the specific notes about jitting and internal hacks, things which would not at all be obvious just by looking at the interface code:

    // Implement this interface if you need to support foreach semantics.

    // Note that T[] : IList<t>, and we want to ensure that if you use
    // IList<yourvaluetype>, we ensure a YourValueType[] can be used
    // without jitting.  Hence the TypeDependencyAttribute on SZArrayHelper.
    // This is a special hack internally though - see VMcompile.cpp.
    // The same attribute is on IList<t> and ICollection<t>.
    public interface IEnumerable<out t=""> : IEnumerable
    {
        // Returns an IEnumerator for this enumerable Object.  The enumerator provides
        // a simple way to access all the contents of a collection.
        /// <include file="docIEnumerable.uex" path="docs/doc[@for="IEnumerable.GetEnumerator"]/*">
        new IEnumerator<t> GetEnumerator();
    }

It’s worth noting that some of the documentation you describe in your question is either unnecessary or redundant. Don’t document things that are obvious. Instead, make things obvious so that you don’t have to document them.

Documentation is just one more thing that you have to maintain and keep in sync, so document for the right reasons. Allow the code log to speak for itself, but document the relationships between methods and classes, explain obscure things, and in general be helpful without repeating yourself.

2

Describe the intended meanings and effects of the functions defined by the interface, along with the meanings of any parameters and return values. Code that implements the interface, and code that relies on it need to be written with a shared understanding of those meanings to be useful.

The interface doesn’t just require the classes that implement it to have the functions with the given names and types. It can also require other things of the class, which you can write in English in the documentation. PHP uses nominal typing, rather than structural typing, meaning classes that implement the interface must name it in their implements statement. By doing so they effectively self-certify that they follow any specifications written into the interface’s documentation.

A good example from PHP is PsrHttpMessageMessageInterface.

Of course you need to consider who your audience is, and if they are all your colleagues who can easily talk to you then you don’t need to be quite as detailed
or formal as the Psr interface, but it’s still worth documenting things that might not be obvious.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Documentation of interfaces

I know how to document a function:

/**
 * Prints a greet message to the web page
 */
function greet() {
    echo "Hi!";
}

Or describe the usage of a variable:

/**
 * @type string $name The user's name
 */
$name = "Bas";

But I don’t know how to document an interface. It requires the classes which implement the interface to have the functions which are inside the interface, and that’s it.

Question

How do you document an interface?

2

Describe the purpose and usage of the interface, and the purpose and usage of the functions in the interface.

Here is an example from the .NET Framework (simplified for brevity). Note the “statement of purpose,” and the specific notes about jitting and internal hacks, things which would not at all be obvious just by looking at the interface code:

    // Implement this interface if you need to support foreach semantics.

    // Note that T[] : IList<t>, and we want to ensure that if you use
    // IList<yourvaluetype>, we ensure a YourValueType[] can be used
    // without jitting.  Hence the TypeDependencyAttribute on SZArrayHelper.
    // This is a special hack internally though - see VMcompile.cpp.
    // The same attribute is on IList<t> and ICollection<t>.
    public interface IEnumerable<out t=""> : IEnumerable
    {
        // Returns an IEnumerator for this enumerable Object.  The enumerator provides
        // a simple way to access all the contents of a collection.
        /// <include file="docIEnumerable.uex" path="docs/doc[@for="IEnumerable.GetEnumerator"]/*">
        new IEnumerator<t> GetEnumerator();
    }

It’s worth noting that some of the documentation you describe in your question is either unnecessary or redundant. Don’t document things that are obvious. Instead, make things obvious so that you don’t have to document them.

Documentation is just one more thing that you have to maintain and keep in sync, so document for the right reasons. Allow the code log to speak for itself, but document the relationships between methods and classes, explain obscure things, and in general be helpful without repeating yourself.

2

Describe the intended meanings and effects of the functions defined by the interface, along with the meanings of any parameters and return values. Code that implements the interface, and code that relies on it need to be written with a shared understanding of those meanings to be useful.

The interface doesn’t just require the classes that implement it to have the functions with the given names and types. It can also require other things of the class, which you can write in English in the documentation. PHP uses nominal typing, rather than structural typing, meaning classes that implement the interface must name it in their implements statement. By doing so they effectively self-certify that they follow any specifications written into the interface’s documentation.

A good example from PHP is PsrHttpMessageMessageInterface.

Of course you need to consider who your audience is, and if they are all your colleagues who can easily talk to you then you don’t need to be quite as detailed
or formal as the Psr interface, but it’s still worth documenting things that might not be obvious.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật