| Conditions | 1 |
| Paths | 1 |
| Total Lines | 56 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | /* |
||
| 10 | define(['jquery'], function($) { |
||
| 11 | |||
| 12 | 'use strict'; |
||
| 13 | |||
| 14 | return { |
||
| 15 | |||
| 16 | defaults: { |
||
| 17 | options: { |
||
| 18 | pages: [] |
||
| 19 | }, |
||
| 20 | translations: { |
||
| 21 | orderPage: 'sulu_article.edit.order-page' |
||
| 22 | } |
||
| 23 | }, |
||
| 24 | |||
| 25 | initialize: function() { |
||
| 26 | this.$container = $('<div/>'); |
||
| 27 | this.$componentContainer = $('<div/>'); |
||
| 28 | |||
| 29 | this.$el.append(this.$container); |
||
| 30 | |||
| 31 | this.sandbox.start( |
||
| 32 | [ |
||
| 33 | { |
||
| 34 | name: 'overlay@husky', |
||
| 35 | options: { |
||
| 36 | el: this.$container, |
||
| 37 | instanceName: 'page-order', |
||
| 38 | openOnStart: true, |
||
| 39 | removeOnClose: true, |
||
| 40 | skin: 'medium', |
||
| 41 | slides: [ |
||
| 42 | { |
||
| 43 | title: this.translations.orderPage, |
||
| 44 | data: this.$componentContainer, |
||
| 45 | okCallback: function() { |
||
| 46 | } |
||
| 47 | } |
||
| 48 | ] |
||
| 49 | } |
||
| 50 | } |
||
| 51 | ] |
||
| 52 | ); |
||
| 53 | |||
| 54 | this.sandbox.once('husky.overlay.page-order.opened', function() { |
||
| 55 | this.sandbox.start([{ |
||
| 56 | name: 'articles/edit/page-order/page-grid@suluarticle', |
||
| 57 | options: { |
||
| 58 | el: this.$componentContainer, |
||
| 59 | pages: this.options.pages |
||
| 60 | } |
||
| 61 | }]); |
||
| 62 | }.bind(this)); |
||
| 63 | } |
||
| 64 | } |
||
| 65 | }); |
||
| 66 |