Day one Design to transform Pwani Edition @swahilipot @D2T
wamae254
Hello, I am Benson Wamae I created wamae 254 to help other programmers who might be starting out and may have little to no experience; by blogging about my challenges as an engineer and upcoming tech.
Thursday, 8 September 2016
Wednesday, 3 August 2016
Monday, 1 August 2016
Sunday, 19 June 2016
Monday, 13 June 2016
Loop optimizations
for(i;i<list.length;i++){
}
Looks familiar?
Well loops help us in writing less code, we use the everyday but do we use them effectively.
Here are some tips:
1. Avoid queries in loops.
If you put a query in a loop it means the loop has to do a trip to db each time.
2. If you are going to use conditions break them down and try to organize them logicaly.e.g.
for(i;i<list.length;i++){
if(condition)
if(condition)
for(k;k<list.length;k++){
The logic is the first condition is never met the second loop will never run, but the second condition has to be met too.
