"Go" writing high-quality Code 157 recommendations for improving C # programs--Recommendation 137: Delegate and event types should add ancestor suffixes

Source: Internet
Author: User

Recommendation 137: Delegate and event types should add ancestor suffixes

The delegate type itself is a class, considering that the name of the derived class is suffixed with the base class name. The event type is a special kind of delegate, so the event type also follows this recommendation.

The proper naming methods for delegates and events are:

     Public Delegate voidHttpcontinuedelegate (intStatusCode, System.Net.WebHeaderCollection httpheaders);  Public Delegate BOOLValidatevaluecallback (Objectvalue);  Public Delegate voidAsyncCallback (IAsyncResult ar);  Public Delegate voidPropertychangedcallback (DependencyObject D,dependencypropertychangedeventargs e);  Public Delegate voidMouseEventHandler (Objectsender, MouseEventArgs e);  Public Delegate voidSizechangedeventhandler (ObjectSener, Sizechangedeventargs e);  Public Delegate voidUnhandledexceptioneventhandler (Objectsender, UnhandledExceptionEventArgs e);

In the traditional way, we may not see these types as having a base class, but the keyword delegate and event for delegates and events already indicate that the base class of the latter type is delegate. The delegate is divided into delegate end and callback end according to the function of the delegate type, we must pay attention to distinguish this point when declaring the delegate. If the delegate is used for the callback nature, the callback end is used.

The naming of the delegate and the event is inappropriate, that is, the type is not visible from the name, as follows:

     Public Delegate void DoSomething (intint  b);      Public Delegate void MouseClick (intint b);

Turn from: 157 recommendations for writing high-quality code to improve C # programs Minjia

"Go" writing high-quality Code 157 recommendations for improving C # programs--Recommendation 137: Delegate and event types should add ancestor suffixes

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.