-
Notifications
You must be signed in to change notification settings - Fork 10
Recommended naming
Programming best practices say, that meaningful names must be given to variables, methods, classes etc. Inevitably, all delegates, delegate varbiables and constants, which are used for PL/SQL Developer callbacks, must be assigned some names. Of course, different names, maching your naming convention, can be used since names do not affect signature. The aim of this article is to provide some recommendations on the naming, which helps keeping the relation with the original callback name, still preserving readability and maintainability of the code.
The main recommendations are:
- Looking at the name of the delegate you should easily map it to the name of the callback in the PL/SQL Developer's API documentation.
- Looking at the name of the delegate variable you should easily understand, which callback is being called.
- Looking at the name of the constant you should easily understand, index of which callback it holds.
As the example, IDE_RefreshMenus callback will be used in this article.
| Index | Name | Signature |
|---|---|---|
| 64 | IDE_RefreshMenus | void IDE_RefreshMenus(int ID) |
- Take the original callback name (
IDE_RefreshMenus). - Remove underscores (
IDERefreshMenus). - Use PascalCase notation (
IdeRefreshMenus).
delegate void IdeRefreshMenus(int id);Note that the name now matches C# notation and the original callback name is recognizeable (and pretty straightforward).
- Take the delegate name of the callback (
IdeRefreshMenus). - Remove the prefix, which is one of the
Ide,SqlorSys(RefreshMenus). - Append
Callbacksuffix (RefreshMenusCallback). - Use camelCase notation (
refreshMenusCallback).
private IdeRefreshMenus refreshMenusCallback;Note, that:
- Name keeps straightforward mapping to the delegate.
- Original callback name is still recognizeable.
- You clearly distinct delegate from the variable.
- Take the original callback name (
IDE_RefreshMenus). - Separate each word with the underscore (
IDE_Refresh_Menus). - Make the name upper case (
IDE_REFRESH_MENUS). - Append
_CALLBACKsuffix (IDE_REFRESH_MENUS_CALLBACK).
public const int IDE_REFRESH_MENUS_CALLBACK = 64;Note, that:
- Name keeps straightforward mapping to the delegate and the callback.
- Original callback name is still recognizeable.
Introduction
Main concepts
- Anatomy of the plug-in
- Exporting DLL functions
- Using callbacks
Misc
- Using menu items
- Accepting commands in the command window
- Validating DLL exports
- Working with color preferences
- Referencing external C# assemblies