Skip to content

theRemix/ECMAScript-Mutable-Method-Naming

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ECMAScript Mutable Method Naming

Convention for JavaScript to mark methods as "dangerous methods" and methods with side effects

This is a living document to describe the usage of special method naming markers.

Discussions go in Issues.

Forking for proposed updates to the convention is encouraged.

This repo also includes some code samples of it's usage.

npm start

npm install to run tests

npm test

Mutating methods $

Lets methods that mutate the owner/context be easily readable.

let existingUser = User.findByUsername("jon");
console.log( existingUser.roles ); // Set { }

existingUser.grant$( Roles.ADMIN );
console.log( existingUser.roles ); // Set { Symbol(ADMIN) }

Side effect methods Δ

Lets methods that create side effects be easily readable.

let jon = new User({ username : 'jon', password : 'hunter2' });
jon.saveΔ();

Side effects are lies. - Uncle Bob

In this case, (and maybe all cases), a side effect does not have to occur

// mutates, without other side effects
datastore.add$( jon );

Delta Δ

it's purposefully a hassle to type so that the author is very aware of the decision to allow side effects.

open to suggestions for other markers

On Windows

Hold down the ALT key and type 0916 on the keypad Note: alt code greater than 255 are not universal and will only work in applications that support them such as Wordpad or Words

On Mac OS

Hold down the Option key and press J

Or Cmd+Ctrl+Space and search "Delta"

In HTML

Δ or Δ

About

Convention for JavaScript to mark methods as "dangerous methods" and methods with side effects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors