Posts

Showing posts from November, 2016

Enhanced your programming skill with Assert and Unit Test

Enhanced your programming skill with Assert and Unit Test Sources http://www.pgbovine.net/programming-with-asserts.htm http://stackoverflow.com/questions/1375786/whats-the-point-of-nsassert-actually https://www.youtube.com/watch?v=BbPPnxhcdHo Why you need Assert in your program? 1/ What is Assert? + Assert is the way you make sure a condition in your program must be matched. Otherwise, the app will crash. 2/ What is the point of Assertion? + Using assert will guarantee your program always act like your assumption. => For instance, you write a function with a lot of input and in some situation, inputs mus be valid. Let's say input_1 must comes with input_2. In that case, writing if else and return value is not fit, because you have to handle a lot of return value & error => So that, you will use Assert to make sure your function is used properly. This is very important when you working in a team while writing functions for other people to use. Or even if