Skip to content

Instantly share code, notes, and snippets.

View behnamazimi's full-sized avatar

Behnam behnamazimi

View GitHub Profile
@behnamazimi
behnamazimi / Add Android Platform
Last active October 19, 2016 14:10
Getting Started with Ionic 2 (Beeps.ir)
ionic platform add android
@behnamazimi
behnamazimi / Details Page Push
Last active October 21, 2016 20:39
Navigation in Ionic 2
this.navCtrl.push(Details);
@behnamazimi
behnamazimi / v-clean-code-01.js
Last active March 4, 2019 06:01
ES6 Assignment Clean Code
// Dirty Code
const a = Obj1.a
const b = Obj1.b
const c = Obj1.c
//Clean Code
const {a,b,c} = Obj1
@behnamazimi
behnamazimi / v-clean-code-02.js
Created March 4, 2019 06:00
Deep Copy with Assign
// this code will assign Obj1 with an
// empty object and put it in Obj2
const Obj2 = Object.assign({}, Obj1)
@behnamazimi
behnamazimi / v-clean-code-03.js
Last active March 4, 2019 06:07
Immutability Helpers Clean Code
// Dirty Code
const { Obj2 } = this.state
Obj2.value = "new value"
this.setState({
Obj2
})
// Clean Code
this.setState(update(this.state, {
@behnamazimi
behnamazimi / v-clean-code-04.js
Created March 4, 2019 07:12
Clean Code Not West Your Time
// Clean Code Not West Your Time
// It's hard to learn new things like ES6/5
// and use it's features in code
// Dirty Codes
const myArray = [obj1, obj2, obj3, ..., objn] // your static array
const myNewArray = myArray.foreEach(function(elm){
elm.value = elm.value + "new value"
})
@behnamazimi
behnamazimi / v-clean-code-05.js
Last active March 4, 2019 07:36
Pay Attention on Comments
// Comments in your code.
// Dirty Code
function priceFormatter(price, separator = '/') {
if (price == null) // return when price is null
return ''
let tmp_price = [],
tmp_c = 1; // initial variables
// Code DRY
// Dirty Code
export default App = (props) => {
return (
<div className="my-app">
<div className="custom-button">
<span className="icon icon-user"/>
<span className="content">Add New Member</span>
@behnamazimi
behnamazimi / v-clean-code-06.jsx
Created March 4, 2019 08:05
Use Functional Components
// Dirty Code
clas MyComponent extends Component {
render(){
return 'This is my Class Component'
}
}
// Clean Code
const MyComponent = (props) => {
@behnamazimi
behnamazimi / v-clean-code-07.js
Created March 4, 2019 08:10
Say By to .bind(this)
// Dirty Code
class MyComponent extends Component {
constructor(props) {
super(props)
this.handleOne = this.handlerOne.bind(this)
this.handleTwo = this.handlerTwo.bind(this)
this.handleThree = this.handlerThree.bind(this)
}