Skip to content
This repository has been archived by the owner on Nov 12, 2019. It is now read-only.

javascripts naming rules/refactoring threads #24

Open
yjlintw opened this issue Apr 19, 2017 · 2 comments
Open

javascripts naming rules/refactoring threads #24

yjlintw opened this issue Apr 19, 2017 · 2 comments

Comments

@yjlintw
Copy link
Owner

yjlintw commented Apr 19, 2017

No description provided.

@yjlintw
Copy link
Owner Author

yjlintw commented Apr 19, 2017

Naming Rules

Follow this one: naming convention

Functions

camelCase

// bad example
function MyFunction() {...}

// good example
function myFunction() {...}

Variables

  • Variables with multiple words should always use an underscore between words.
  • Confusing variable names should end with the variable type.
  • No Abbreviations
// bad example
var deliveryNote = 1;

// good example
var delivery_note = 1;

To use camelCase, when sometimes it is impossible to declare a function directly, the function variable name should match some patterns which shows that it is a function.

// good example
var doSomethingFunction = function () { ... };
// or
var tool = {"doSomething": function () { ... }};

// bad example
var doSomething = function () { ... };

Database related

All of the variables store information grabbed from the database (Settings) should end with _data
Example:

  • all_comic_data: store all of the comic data from the database
  • comic_data : store one comic data from the database

MVVM

ViewModel

filename should be *-viewmodel.js and put under ./renderer-process/viewmodels/

ViewController

filename shouldbe *-viewcontroller.js and put under ./renderer-process/viewcontrollers

@yjlintw yjlintw mentioned this issue Apr 20, 2017
@yjlintw
Copy link
Owner Author

yjlintw commented Apr 20, 2017

create guidelines wiki page link

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants