Студопедия

Главная страница Случайная страница

Разделы сайта

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






Variables






 

 

 

· Implicit declaration, explicit declaration, strong-typed weak-typed

· Guidelines

o Initialize each variable as it’s declared

o Initialize each variable close to where it’s first used

o Pay attention to counters

o Initialize class members in constructors

o Check re-initialization

o Take advantage of compiler’s warnings

· Scope

o Prefer short variable timespan

§ Variable lifetime – number of lines between first and last reference

§ Initialize early

§ Don’t assign before first use

§ Group related statements

§ Begin with restricted visibility, than expand if necessary

· Use each variable for exactly one purpose

· Naming

o Name must fully and accurately describe the entity the variable represents

o Use What vs how description

o 9..16 symbols

o Max, Min, Record, string, pointer – move to the end of name

o Common opposites

o Loop indexes

o Status variables (don’t use flag)

o Don’t use temporary names

o Boolean names

§ Done error found success

§ Is.. has..

o Enum names

§ Use Enum name

o Use naming conventions

o Abbreviations

§ Don’t omit letters

§ Abbreviate consistently

§ Create names you can pronounce

§ Use dictionary

o Names to avoid

§ Avoid names with similar meaning

§ Avoid using system names and misleading names

§ Avoid names that sound similar

§ Avoid numerals in names

§ SpellCheck

§ Avoid difficult English words that typically misspelled

§ Don’t differentiate solely on capitalization

§ Use English words (don’t transliterate)

§ Avoid hard-to distinguish characters (li, c, 0, 2 1; s5)






© 2023 :: MyLektsii.ru :: Мои Лекции
Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав.
Копирование текстов разрешено только с указанием индексируемой ссылки на источник.