{"action":"opened","issue":{"url":"https://api.github.com/repos/kendaru/Solution-Finder/issues/3","labels_url":"https://api.github.com/repos/kendaru/Solution-Finder/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/kendaru/Solution-Finder/issues/3/comments","events_url":"https://api.github.com/repos/kendaru/Solution-Finder/issues/3/events","html_url":"https://github.com/kendaru/Solution-Finder/issues/3","id":57048701,"number":3,"title":"View logic los van application logic","user":{"login":"BerendWeij","id":5459758,"avatar_url":"https://avatars.githubusercontent.com/u/5459758?v=3","gravatar_id":"","url":"https://api.github.com/users/BerendWeij","html_url":"https://github.com/BerendWeij","followers_url":"https://api.github.com/users/BerendWeij/followers","following_url":"https://api.github.com/users/BerendWeij/following{/other_user}","gists_url":"https://api.github.com/users/BerendWeij/gists{/gist_id}","starred_url":"https://api.github.com/users/BerendWeij/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BerendWeij/subscriptions","organizations_url":"https://api.github.com/users/BerendWeij/orgs","repos_url":"https://api.github.com/users/BerendWeij/repos","events_url":"https://api.github.com/users/BerendWeij/events{/privacy}","received_events_url":"https://api.github.com/users/BerendWeij/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-09T15:54:55Z","updated_at":"2015-02-09T15:54:55Z","closed_at":null,"body":"```c\nfunction onAnswerClick(e){\n        e.preventDefault();\n\n\n        if (this.dataset.goto.contains(':')) {\n            var data = this.dataset.goto.split(':');\n            switch (data[0]) {\n                case 'info':\n                    console.log(data[1]);\n                    break;\n\n                case 'form':\n                    console.log(data[1]);\n                    break;\n\n                case 'overzicht':\n                    console.log(data[1]);\n                    break;\n            }\n\n        } else if (this.dataset.goto > 0){\n            setQuestion(this.dataset.goto);\n        }\n\n        progress.push({\n            \"value\": this.innerHTML,\n            \"question\": this.dataset.question\n        });\n        updateProgress();\n    } \n```\n\nBestand: https://github.com/kendaru/Solution-Finder/blob/master/main.js\n\nHoudt je view/interface/input code los van je applicatie logica. Nu is er een harde afhankelijkheid en is de logica niet te hergebruiken. Er is een harde koppeling naar waar je naar luistert (event) en hetgeen dat je wilt dat er kan gebeuren.\n\nEen goede les is het om eerst de applicatie logica te schrijven. Wat wil je dat er mogelijk is. Schrijf hiervoor alle functies. Bijvoorbeeld:\n- next()\n- previous()\n- load()\nDeze functies krijgen niet een event als parameter.\n\nVervolgens schrijf je view logica / controller logica om deze functies aan te roepen. Bijvoorbeeld een muisklik listener die één van bovenstaande functies aanroept. Dit maakt je code een stuk vrijer."}}