Feeds

10 ways to improve your code

Think outside the curly brackets

3 Big data security analytics techniques

SD West 2008 Neil Ford's Software Development West presentation, 10 Ways to Improve Your Code, was aimed at Java programmers, but Ford's "advanced code hygiene" discussion had wisdom for coders of many stripes.

Ford is a senior application architect and "meme wrangler" at ThoughtWorks, an IT consultant that specializes in development and delivery of software, and that is home to object-oriented development, refactoring and agile authority Martin Fowler. Ford's talk covered a lot of territory, from test-driven development to advice on "good citizenship."

Ford advised attendees to:

1. Write the tests before writing the code. TDD stands for "test-driven development," but Ford believes it's more useful to think of it as "test driven design." "If you're rigorous about doing it, it has beneficial side effects on the design of your code that has nothing to do with testing," he said. Among those benefits: it discourages embedded object creation, forces mocking of dependent objects, and forces the earliest possible object interaction decisions.

2. Use static analysis tools. "If you're paying the static-typing tax in Java and C# anyway, you should take advantage of that in static analysis tools," Ford said. He cited two categories of these tools: byte-code analysis tools, such as the FindBugs open source tool; and source-analysis tools, such as PMD.

3. Practice "good citizenship" by paying attention to how well your objects interact with the outside world. "Never let them exist in an invalid state," Ford advised. "Mutations should always move from one known good state to another known good state." He also advised you should avoid the singletons, because they mix responsibilities by mixing static and state.

4. Avoid indulging in speculative software development. "The goal should be to build the simplest thing we need right now," he said. The practice increases software entropy, he added, which is a measure of code complexity.

5. Simplify essential complexity and kill accidental complexity. "It's the difference between, 'the problem we have is hard,' and 'we've made the problem we have hard,'" he said.

6. Challenge programming conventions, such as writing long, unreadable test names, and blindly following the JavaBean specification to the detriment of your code.

7. Embrace single level of abstraction principle (SLAP). The idea is based on advice from Kent Beck's book Smalltalk Best Practices and Patterns, Ford explained, which states that every public method should be as short as possible, and should consist of steps, each one of which is a private method. "Don't make abstraction leaps in your code," he said.

8. Leverage existing platforms with languages targeted at specific problems and applications. "This notion that there's this one true language that you should write everything in is melting away," Ford said. Coders should think in terms of "polyglot programming," because it takes advantage of "looming opportunities/ problems," such as massively parallel threading.

9. Learn every nuance of the languages you're using. If you're using Java as your everyday language, Ford said, there are a lot of "back alleys" worth investigating. For example: Java's reflection mechanism and regular expressions, which are widely misunderstood.

10. Change your perspective and consider "antiobjects." An antiobject is a kind of object that appears to do the opposite of what we think it should do, Ford explained. The object metaphor sometimes impedes the solution "by making us try to create objects that are too inspired by the real world."®

SANS - Survey on application security programs

More from The Register

next story
Android engineer: We DIDN'T copy Apple OR follow Samsung's orders
Veep testifies for Samsung during Apple patent trial
This time it's 'Personal': new Office 365 sub covers just two devices
Redmond also brings Office into Google's back yard
Batten down the hatches, Ubuntu 14.04 LTS due in TWO DAYS
Admins dab straining server brows in advance of Trusty Tahr's long-term support landing
Microsoft lobs pre-release Windows Phone 8.1 at devs who dare
App makers can load it before anyone else, but if they do they're stuck with it
Half of Twitter's 'active users' are SILENT STALKERS
Nearly 50% have NEVER tweeted a word
Internet-of-stuff startup dumps NoSQL for ... SQL?
NoSQL taste great at first but lacks proper nutrients, says startup cloud whiz
Windows 8.1, which you probably haven't upgraded to yet, ALREADY OBSOLETE
Pre-Update versions of new Windows version will no longer support patches
Microsoft TIER SMEAR changes app prices whether devs ask or not
Some go up, some go down, Redmond goes silent
Red Hat to ship RHEL 7 release candidate with a taste of container tech
Grab 'near-final' version of next Enterprise Linux next week
Ditch the sync, paddle in the Streem: Upstart offers syncless sharing
Upload, delete and carry on sharing afterwards?
prev story

Whitepapers

Designing a defence for mobile apps
In this whitepaper learn the various considerations for defending mobile applications; from the mobile application architecture itself to the myriad testing technologies needed to properly assess mobile applications risk.
3 Big data security analytics techniques
Applying these Big Data security analytics techniques can help you make your business safer by detecting attacks early, before significant damage is done.
Five 3D headsets to be won!
We were so impressed by the Durovis Dive headset we’ve asked the company to give some away to Reg readers.
The benefits of software based PBX
Why you should break free from your proprietary PBX and how to leverage your existing server hardware.
Securing web applications made simple and scalable
In this whitepaper learn how automated security testing can provide a simple and scalable way to protect your web applications.