× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

JQuery style in Angular. KISS principle

Alexey Naumov
May 26, 2016
<p>To wrap up our session I want to take a look on two things: coding with jquery style in angular and general KISS principe.</p> <p>When we start using Angular after other jquery style framework we trying to do same thing: query a DOM element and make manipulation on it. That's wrong! Angular separates code and UI. All logic lies in controller and all UI lies in template. Controller shouldn't know about DOM structure. It's essential, because we can change css classes, ids etc. without changing controller code. Or we can use same controller with different templates! Check out angular docs about that:</p> <p>https://docs.angularjs.org/misc/faq#common-pitfalls</p> <p> </p> <p>KISS principle</p> <p>We write code for humans, not for computers. Computers don't care about code, they can handle pretty awful code easily, but humans can't. Try to make all methods and functions simple to understand.</p> <p>Let's start from two simple things: </p> <p> - each function should be less than 20LOC. It it's larger we have to think about splitting it into parts.</p> <p> - function name should tell us about its job. For ex: 'getUserData' should get user data, or 'doesUserAngry' has to return true of false depending on user mode :)</p> <p>wiki: https://en.wikipedia.org/wiki/KISS_principle</p> <p> </p> <p>Check out a book about many other software design principles and general philosofy of software development. I really like it!</p> <p>Steve McConnell -  Code Complete</p>

Get New Tutorials Delivered to Your Inbox

New tutorials will be sent to your Inbox once a week.

comments powered by Disqus