Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Именуване на идентификатори в кода
- Always use English for naming identifiers
- Трябва да избягваме съкращаването на наименуванията
- Трябва да пишем имената на променливите достатъчно описателно, дори и да са сравнително дълги
- Wrong: dtbgRegExPtrn
- Correct: dateTimeBulgarianRegExPattern
- Дали даден идентификатор е достатъчно показен за това какво прави конкретната променлива, клас и т.н. се определя от контекста, в който се намира променливата, класа и т.н. Т.е. :
- Correct:
- Generate() in the class LabyrinthGenerator
- Find(string fileName) in the class FileFinder
- Wrong:
- Generate() in the class Program
- Find(string name) in the class Program
- Types in C# (classes, enumerations, interfaces):
- Correct: RecursiveFactorialCalculator, IEnumerable, Color, XmlDocument
- Wrong: recursiveFactorialCalculator, RECURSIVE_FACTORIAL_CALCULATOR
- Use the following format:
- - [Noun]
- - [Adjective] + [Noun]
- Examples:
- Student, FileSystem, CheckBox, Constants
- Correct: class called ReportGenerator
- Wrong: class called GenerateReport
- If there are a lot of constants (10 or more) they should be placed in a separate class
- Interfaces (In C#):
- - I + [Verb] + ‘able’
- - I + [Noun]
- - I + [Adjective] + [Noun]
- Examples:
- IEnumerable, IList, ICommandExecutor
- Enums:
- In C#:
- enum Color { Red, Blue, White }
- In JavaScript:
- enum Color { RED, BLUE, WHITE }
- Special classes:
- Attribiutes:
- Wrong: WebService
- Correct: WebServiceAttribute
- Collection classes:
- Wrong: ListOfStrings, Strings
- Correct: StringsCollection
- Delegate classes:
- Example: DownloadFineshedDelegate
- Namespaces:
- Correct: Microsoft.WinControls.GridView
- Wrong: Microsoft_WinControlsGridView
- Naming files in JavaScript:
- - There are “-“ between different words
- Correct: jquery-1.8.2.min.js, widgets.js
- Wrong: jQuery_classes.js, Widgets.js, MyAjax.Library.js
- Types’ names can be as long as we decide
- When we have to name a group of things:
- Correct: accounts, customers
- Wrong: accountsList, customersList
- Method names should consist of:
- - [Verb]
- - [Verb] + [Noun]
- - [Verb] + [Adjective] + [Noun]
- Boolean variables should be postive:
- Correct: isPrime, customerFound, hasPendingPayment
- At the end of counter variables there should be “Count”
- Examples: ticketsCount, customersCount
- State – there should be “State” at the end of the variable
- Naming temporary variables:
- Correct: oldValue
- Wrong: temp
- Naming constants:
- In C# - in PascalCase
- In JavaScript – in UPPER_CASE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement