...Or How I Learned to Stop Worrying and Throw My Code Away!
By Webysther Nunes (Own work) [CC BY-SA 4.0 ], via Wikimedia Commons
Martin Fowler
"duplication is far cheaper than the wrong abstraction."
Sandi Metz
app.factory('getUsers',['$http',function($http){
return $http.get('api/v1/users');
});
app.controller('home',[
'$scope',
'getUsers',
function(
$scope,
getUsers){
getUsers().then(function(response){
$scope.users = response.data;
});
}]);
export default () => {
return fetch('api/v1/users').then(function (response) {
return response.json();
});
};
import getUsers from './getUsers';
app.controller('home',[
'$scope',
function(
$scope){
getUsers().then(function(users){
$scope.users = users;
});
}]);
export default (param) => {
//Do Something
};
import myLogicFunction from './myLogicFunction';
class DummyButton extends React.Component {
render() {
return (
<div onClick={() => {myLogicFunction('This is a Value!'}}>
Click Me Bro!
</div>
);
}
}
import EventBus from 'EventBus';
class DummyButton extends React.Component {
onButtonClick() {
EventBus.dispatch('SOMETHING_HAPPENED','This is a Value!');
}
render() {
return (
<div onClick={() => {onButtonClick()}}>
Click Me Bro!
</div>
);
}
}
import EventBus from 'EventBus';
export default {
init:{
EventBus.on('SOMETHING_HAPPENED',(params) => {
//DO SOMETHING
});
}
};
"The only correct way to write JavaScript is whatever you were not doing last week."
Martin Fowler
"Sacrificial Architecture, sometimes it’s the fastest way to learn things"
f.strazzullo@extrategy.net
@TheStrazz86
https://github.com/francesco-strazzullo
https://medium.com/@TheStrazz86