View
260
Download
3
Tags:
Embed Size (px)
DESCRIPTION
Presentation by Mike Jackson, Software Architect at the Software Sustainability Institute. Presented at the Digital Social Research: Sustainability Training Workshop at OeRC, Oxford on 12 December 2011.
Citation preview
Software Sustainability Institute
www.software.ac.uk
Sustainability Training
What makes good code good?
Software Sustainability Institute
www.software.ac.uk
Who are you…?
• Researchers who do some programming?
• Research/scientific programmers?
• Software developers?
Software Sustainability Institute
www.software.ac.uk
The Question
On 12th December 2011, Mike of the SSI asked 6 researchers in social sciences what makes good code good…
And they said…
Software Sustainability Institute
www.software.ac.uk
Software Sustainability Institute
www.software.ac.uk
A popular view
• Simple – concise but not cryptic• Readable – commented, sensible names, follows conventions• Modular – reusable building blocks• Layered – application/OS, model/view/controller, …• Designed – “thoughts are cheaper than debugging”, if you can’t
explain it easily it’s designed poorly• Efficient – fast, compact, takes only what’s needed + frees it when
done• Elegant – simple + efficient + brilliant • Clear – all of the above are an antidote to complexity• Clever hacks – because the world is not perfect
What makes good code good, Paul DiLascia, MSDN Magazine, 07/2004, p144 http://msdn.microsoft.com/en-us/magazine/cc163962.aspx
Software Sustainability Institute
www.software.ac.uk
Another view
• Correct – does what it’s intended to do• Readable – remember WORM (Write Once Read Many)• Testable – “if it’s not tested it’s broken”• Documented – not what/how but why/because• Robust and reliable• Maintainable – by you and others six months from now• Extensible, flexible + reusable but beware of YAGNI!• Efficient, performant + scalable• Secure• Discoverable – others can understand quickly + easily• Simple – modular
Bittermanandy, What is good code?, 10/09/2010
http://bittermanandy.wordpress.com/2010/09/10/what-is-good-code/
Software Sustainability Institute
www.software.ac.uk
And one from scientists
• Fit for purpose• Readable, well-commented and documented,
includes design rationale.• Elegant, concise but not needlessly cryptic• Well-designed and modular• Tests for correctness and ships tests with code• Optimised but not at expense of understandibility• Scalable• Usable• Portable
31 “scientists who do some programming” on the Effective scientific programming workshop, 20/06/2011
http://www.software.ac.uk/blog/2011-06-22-what-makes-good-code-good
Software Sustainability Institute
www.software.ac.uk
So which of them do you do?
Software Sustainability Institute
www.software.ac.uk
And what are the blockers?
Software Sustainability Institute
www.software.ac.uk
One for the road
XKCD, 844http://xkcd.com/844/
Software Sustainability Institute
www.software.ac.uk
Another view
• Reflects the problem it solves• Can be easily understood by programmers without experience in
your language• Generally short• Doesn’t require much thinking to understand• Very little coupling• Cohesive - definitions of functions + types required are not scattered
throughout the software• Documents any requirements for proper usage• Makes just as much sense to you one year from now, as it does now
Christopher Diggins, The Properties of Good Code, 27/09/2005,
http://www.oreillynet.com/onlamp/blog/2005/09/the_properties_of_good_code.html