Serving the Quantitative Finance Community

 
User avatar
neuroguy
Posts: 0
Joined: February 22nd, 2011, 4:07 pm

Handy, one-liner, rule-of-thumb, dos/donts in any language

July 11th, 2014, 10:51 am

R9: functions/methods should do one thing and one thing only. Their names should be adjectives or based on adjectives and describe what they do. If you have problems giving a function a simple name in this manner then it probably needs refactoring.
 
User avatar
neuroguy
Posts: 0
Joined: February 22nd, 2011, 4:07 pm

Handy, one-liner, rule-of-thumb, dos/donts in any language

July 11th, 2014, 10:51 am

R10: Refactor little, refactor often.
 
User avatar
Jim
Posts: 1
Joined: February 1st, 2002, 5:20 pm

Handy, one-liner, rule-of-thumb, dos/donts in any language

July 11th, 2014, 12:12 pm

R11: Never get involved in a land war in Asia. -- but only slightly less well-known is this: R12: Never go against a Sicilian when death is on the line!
 
User avatar
Cuchulainn
Topic Author
Posts: 23029
Joined: July 16th, 2004, 7:38 am

Handy, one-liner, rule-of-thumb, dos/donts in any language

July 11th, 2014, 12:26 pm

R13: Every software entity should have ONE (and only one) major responsibility. R13_A special case: Single Responsibility Principle (SRP).
Last edited by Cuchulainn on July 10th, 2014, 10:00 pm, edited 1 time in total.
 
User avatar
Traden4Alpha
Posts: 3300
Joined: September 20th, 2002, 8:30 pm

Handy, one-liner, rule-of-thumb, dos/donts in any language

July 11th, 2014, 12:32 pm

R14 Break the rules sometimes but document it!
 
User avatar
bluetrin
Posts: 2
Joined: September 9th, 2005, 6:41 am

Handy, one-liner, rule-of-thumb, dos/donts in any language

July 11th, 2014, 12:33 pm

R15: Unitary testing is a very important part of testing R16: Design solutions with maintenance and day to day operations in mind
Last edited by bluetrin on July 10th, 2014, 10:00 pm, edited 1 time in total.
 
User avatar
Hansi
Posts: 41
Joined: January 25th, 2010, 11:47 am

Handy, one-liner, rule-of-thumb, dos/donts in any language

July 11th, 2014, 1:40 pm

QuoteOriginally posted by: Traden4AlphaR14 Break the rules sometimes but document it!Ugggh yeah... this has been in our code for three years now without re-affirming the code below it to the correct rules:
 
User avatar
Hansi
Posts: 41
Joined: January 25th, 2010, 11:47 am

Handy, one-liner, rule-of-thumb, dos/donts in any language

July 11th, 2014, 1:47 pm

QuoteOriginally posted by: bluetrinR16: Design solutions with maintenance and day to day operations in mindBest one yet.R17: Try to comment on anything that's non-obvious with the comment focusing on why and what rather than how.R18: Don't leave commented out code in source files; delete it and if you need it back go to version control.R19: Make sure to use logging where applicable in terms of giving the user/developer more data about what is happening internally in a function for tracing any possible errors.
 
User avatar
neuroguy
Posts: 0
Joined: February 22nd, 2011, 4:07 pm

Handy, one-liner, rule-of-thumb, dos/donts in any language

July 11th, 2014, 3:50 pm

QuoteR17: Try to comment on anything that's non-obvious with the comment focusing on why and what rather than how.R18: Don't leave commented out code in source files; delete it and if you need it back go to version control.R19: Make sure to use logging where applicable in terms of giving the user/developer more data about what is happening internally in a function for tracing any possible errors.I like the ASCII dragon! But it does go to show what happens when someone comments on underdeveloped code, or warns about it rather than just fixing it: It tends to stay put!R18: is a particular pet hate of mine. Whenever I see that I am like WTF! R19: So, so true. One role of exception handling is just to have everything unwind in a way that you can understand. Rather than just being left with some cryptic message (if you are lucky) from withing some forgotten recess of the bowels of the code.
Last edited by neuroguy on July 10th, 2014, 10:00 pm, edited 1 time in total.
 
User avatar
Polter
Posts: 1
Joined: April 29th, 2008, 4:55 pm

Handy, one-liner, rule-of-thumb, dos/donts in any language

July 11th, 2014, 4:02 pm

R20: "Names should be pronounceable. It is hard to discuss something that cannot be pronounced."// From C++ Coding Style Guide (POCO C++ Libraries)I like this one: http://stackoverflow.com/questions/1846 ... es#tab-top
Last edited by Polter on July 10th, 2014, 10:00 pm, edited 1 time in total.
 
User avatar
Hansi
Posts: 41
Joined: January 25th, 2010, 11:47 am

Handy, one-liner, rule-of-thumb, dos/donts in any language

July 11th, 2014, 5:08 pm

QuoteOriginally posted by: outrun"HERE BE DRAGONS"I'm currently helping out at a bank with a propper independent validation team. The team asks for docs, makes 300 remakes when they're done with the model-, tests-, docs- and code-review after 4 months, and it won't get into production before *all* remarks are adresses during all iterations.Their first remark in this case would be: can you remove that dragon ASCI ART and document what goes on below?Sadly I'm my own validation team (seriously where do these banks get the headcount and viable candidates for stuff like that?).QuoteOriginally posted by: PolterR20: "Names should be pronounceable. It is hard to discuss something that cannot be pronounced."QuoteOriginally posted by: outrunAnother handy practice is to add good descriptions about the changes you've made when committing to a repository.I put both of these in our style guide, well it says you should not use shorthand variable names (vi, vj, vk blah blah) and aim for readability.Commits with only "Update" as comment means I will yell at you. Normal for us is "[Library Component or project] - Description of change [Pair programming initials where applicable]"
Last edited by Hansi on July 10th, 2014, 10:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Topic Author
Posts: 23029
Joined: July 16th, 2004, 7:38 am

Handy, one-liner, rule-of-thumb, dos/donts in any language

July 11th, 2014, 6:08 pm

R21: Maintenance is like the weather; everyone talks about it but no one does anything about it. R22: What you lose on the swings you gain on the roundabouts.
Last edited by Cuchulainn on July 10th, 2014, 10:00 pm, edited 1 time in total.