-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -337,6 +337,41 @@ Many of my styles have been from the many pair programming sessions [Ward Bell]( | |
} | ||
``` | ||
- Note: If the function is a 1 liner it consider keeping it right up top, as long as readability is not affected. | ||
```javascript | ||
/* avoid */ | ||
function Sessions(data) { | ||
var vm = this; | ||
|
||
vm.gotoSession = gotoSession; | ||
vm.refresh = function() { | ||
/** | ||
* lines | ||
* of | ||
* code | ||
* affects | ||
* readability | ||
*/ | ||
}; | ||
vm.search = search; | ||
vm.sessions = []; | ||
vm.title = 'Sessions'; | ||
``` | ||
```javascript | ||
/* recommended */ | ||
function Sessions(data) { | ||
var vm = this; | ||
|
||
vm.gotoSession = gotoSession; | ||
vm.refresh = function() {data.refresh();}; // 1 liner is OK | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Siyfion
Contributor
|
||
vm.search = search; | ||
vm.sessions = []; | ||
vm.title = 'Sessions'; | ||
``` | ||
- **Defer Controller Logic**: Defer logic in a controller by delegating to services and factories. | ||
*Why?*: Logic may be reused by multiple controllers when placed within a service and exposed via a function. | ||
|
@@ -483,7 +518,6 @@ Many of my styles have been from the many pair programming sessions [Ward Bell]( | |
*Why?*: Setting functions as you go can be easy, but when those functions are more than 1 line of code they can reduce the readability and cause more scrolling. Defining the callable interface via the returned service moves the implementation details down, keeps the callable interface up top, and makes it easier to read. | ||
```javascript | ||
/* avoid */ | ||
function dataService () { | ||
|
Why don't you use short syntax here ?
vm.refresh = data.refresh;