Студопедия — Methods. The following rules outline the naming guidelines for methods:
Студопедия Главная Случайная страница Обратная связь

Разделы: Автомобили Астрономия Биология География Дом и сад Другие языки Другое Информатика История Культура Литература Логика Математика Медицина Металлургия Механика Образование Охрана труда Педагогика Политика Право Психология Религия Риторика Социология Спорт Строительство Технология Туризм Физика Философия Финансы Химия Черчение Экология Экономика Электроника

Methods. The following rules outline the naming guidelines for methods:






The following rules outline the naming guidelines for methods:

Ø Use verbs or verb phrases to name methods.

Ø Use Pascal case.

Ø Do not add information about parameter types in method name (use overloading instead).

The following are examples of correctly named methods.

RemoveAll()

ProcessCharArray()

Invoke()

Properties

The following rules outline the naming guidelines for properties:

Ø Use a noun or noun phrase to name properties.

Ø Use Pascal case.

For example:

ParentElement

Current

Next

Events

The following rules outline the naming guidelines for events:

Ø Use Pascal case.

Ø Use an EventHandler suffix on event handler names.

Ø Specify two parameters named sender and e. The sender parameter represents the object that raised the event. The sender parameter is always of type System.Object, even if it is possible to use a more specific type. The state associated with the event is encapsulated in an instance of an event class named e. Use an appropriate and specific event class for the e parameter type.

Ø Name an event argument class with the EventArgs suffix.

Ø Consider naming events with a verb. For example, correctly named event names include Clicked, Painting, and DroppedDown.

Ø Use a gerund (the "ing" form of a verb) to create an event name that expresses the concept of pre-event, and a past-tense verb to represent post-event. For example, a close event that can be canceled should have a Closing event and a Closed event. Do not use the BeforeXxx/AfterXxx naming pattern.

Ø Do not use a prefix or suffix on the event declaration on the type. For example, use Close instead of OnClose.

Ø In general, you should provide a protected method called OnXxx on types with events that can be overridden in a derived class. This method should only have the event parameter e, because the sender is always the instance of the type.

The following example illustrates an event handler with an appropriate name and parameters:

delegate void MouseEventHandler(object sender, MouseEventArgs e);

The following example illustrates a correctly named event argument class:

public class MouseEventArgs: EventArgs

{

int x;

int y;

 

public MouseEventArgs(int x, int y)

{

this.x = x;

this.y = y;

}

 

public int X

{

get

{

return x;

}

}

 

public int Y

{

get

{

return y;

}

}

}







Дата добавления: 2015-09-07; просмотров: 480. Нарушение авторских прав; Мы поможем в написании вашей работы!



Кардиналистский и ординалистский подходы Кардиналистский (количественный подход) к анализу полезности основан на представлении о возможности измерения различных благ в условных единицах полезности...

Обзор компонентов Multisim Компоненты – это основа любой схемы, это все элементы, из которых она состоит. Multisim оперирует с двумя категориями...

Композиция из абстрактных геометрических фигур Данная композиция состоит из линий, штриховки, абстрактных геометрических форм...

Важнейшие способы обработки и анализа рядов динамики Не во всех случаях эмпирические данные рядов динамики позволяют определить тенденцию изменения явления во времени...

Именные части речи, их общие и отличительные признаки Именные части речи в русском языке — это имя существительное, имя прилагательное, имя числительное, местоимение...

Интуитивное мышление Мышление — это пси­хический процесс, обеспечивающий познание сущности предме­тов и явлений и самого субъекта...

Объект, субъект, предмет, цели и задачи управления персоналом Социальная система организации делится на две основные подсистемы: управляющую и управляемую...

Демографияда "Демографиялық жарылыс" дегеніміз не? Демография (грекше демос — халық) — халықтың құрылымын...

Субъективные признаки контрабанды огнестрельного оружия или его основных частей   Переходя к рассмотрению субъективной стороны контрабанды, остановимся на теоретическом понятии субъективной стороны состава преступления...

ЛЕЧЕБНО-ПРОФИЛАКТИЧЕСКОЙ ПОМОЩИ НАСЕЛЕНИЮ В УСЛОВИЯХ ОМС 001. Основными путями развития поликлинической помощи взрослому населению в новых экономических условиях являются все...

Studopedia.info - Студопедия - 2014-2024 год . (0.008 сек.) русская версия | украинская версия