Mar 03, 2013 11:00
viafanf,
drugs,
geeks,
computers,
horror,
uk,
programming,
funny,
society,
law,
twitter,
usa,
procrastination,
speed,
secrecy,
obama,
books,
waterstones,
psychology,
languages,
decriminalisation,
politics,
links,
libdem
Leave a comment
Comments 24
Reply
I'm totally with you on the naming of things. I like long, explanatory, names for things. Maintainability is vital.
Reply
As I understand it PHP has two main datatypes: scalars and associative arrays. This can cause complications when coming from a Perl background. In Perl $array[-1] gives the last element in an array, whereas in PHP $array[-1] is a legitimate hash key.
Reply
death_rates[i] = natural_mortality_rate*total_population[i] + disease_induced_mortality_rate*infective_population[i];
when I could be writing
death_rates[i] = d*N[i] + e*I[i];
which is not only easier to understand, but actually mirrors my equations.
The ternary operator is also brilliant for writing things like
infect_matrix[i] += N[i] ? beta_w * S[i] * I[i]/ (float) N[i] : 0.0;
or
prevalence = N_total ? (float) I_total / N_total : 0.0;Which helps to prevent divide by zero errors, whilst keeping the whole definition of what I'm getting on one line ( ... )
Reply
Reply
Reply
Reply
Thanks for the procrastination link. The general approach is gentle and sensible and doesn't try to tell me I ought to be more motivated. I needed that.
Reply
Reply
Reply
Leave a comment