Wednesday 2 May 2012

Thursday 19 April 2012

Grovr Apps Support

If you're having any problems with a Grovr Nokia Store app, please email me on support@grovr.co.uk or leave a comment belwo and I'll get back to you as soon as I can.

Matt

Monday 12 December 2011

Does knowing a specific programming language matter?

This post is mostly inspired by a suggestion Steve McConnell makes in Code Complete: "Don't program in a language, program into it" (emphasis mine).


The traditional method of recruiting software developers is to go "We are writing our program in C++ so we should get a guy who does C++". I imagine many recruiters and companies use keyword filters on CVs to filter out candidates who don't have experience in the particular language used on the job. The basic premise of this post though, is that this is not necessarily going to get you the best man for the job.


My main points are:
  • The time needed to learn a new language is shorter than it was and isn't that long
  • 3 years doing 3 different languages is a better sign of a good and keen programmer than 3 years of 1 language
  • The overhead of learning a new language becomes a smaller proportion over time and is overridden by the extra productivity of a "better" employee
  • If you've only hired say, Ruby developers and then stop doing Ruby you can be in trouble
I should be clear and say that given 2 near-identical programmers, one with experience in the language you are using and one without, I would choose the one with experience in the language, but rather the point I'm making is that you shouldn't be afraid to hire someone who looks like a better programmer but doesn't have direct experience in the language.


A collegaue of mine recently said that you can grasp the basics of a language in about a month and start being confident and expressive in about 3 months and I agree. After that roughly 3 month stage, you start seeing diminshing returns on learning more particulars of that language (perhaps an example of the Pareto principle). The time taken to learn a language has dropped over the years, thanks to the wealth of information available on the internet in tutorials, blog posts and places like StackOverflow, as well as the reduction in the costs of publishing meaning more people are able to produce books on specific programming languages.


A good basing in a variety of languages, of different styles (eg OO vs functional, static vs dynamic typing) and a willingness to learn something new (I still don't quite believe that some people who were interviewed for my current role didn't want to learn JavaScript, I mean why wouldn't you want to learn something new?) are I believe, a better base for a productive programmer than just having experience in 1 language but for more years. This brings me to another point made in Code Complete applicable across all langauges (not just programming ones), that the language you know can actually affect the thoughts you are able to think. Being able to say "I know we're meant to be writing this in Java but there's a really easy and elegant way of doing it in Haskell" is of more value in my opinion that just steaming in and writing a sound Java implementation of every problem you come across. Importantly, experience in a variety of langauges is also a good sign that you've got someone who's interested in software development and does stuff outside of work rather than someone who just rolled into a say, Java job out of uni and then stayed in Java because that's what they'd done before and have never done any programming outside of work and education.


Now obviously, someone who's experienced in a language is going to be quicker to start writing in it than someone who isn't but that initial overhead will become a small proportion over the course of a long term employment (and hopefully you're hiring the kind of people you want to keep for a long time). The 3 month timescale I suggested above is obviously up for debate, but the argument here is based on the assumption that multi-language programmer will turn out to be more productive than the single-language programmer and thus cancel out the overhead, however large it is.


My final point is that hiring language specific programmers can seriously backfire if you decide to stop using the language. Kevin Rose of Digg raised this point at LeWeb conference where he said about hiring PHP developers to build out the Digg site "you end up with lots of PHP developers, but at some point, PHP isn’t a problem anymore and you are stuck with all of those developers". This is especially relevant I would think for startups, whose business direction is not as fixed as large corporations and may decide to pivot from say web development to iOS development and therefore suddenly need to be able to program in a different language.


Now obviously there will be some jobs where in-depth knowledge of the specifics of a language are going to be extremely useful, for instance in performance or safety critical applications (though many performance problems are best solved at the architectural level and so aren't very language specific anyway) but I don't believe that the majority of jobs are like that. Also I'm particularly biased in this discussion because I was hired into my current role as a JavaScript developer with no experience of JavaScript.

Sunday 11 December 2011

Test-Driven Development Review

This post is a review of Test-Driven Development - By Example by Kent Beck

The book is organised into 3 parts. Firstly, Kent takes the reader through an example of using TDD to drive a simple few classes for dealing with money in different currencies, secondly, in a fun bit of meta-ness, he takes the reader through test-driving a unit testing framework from scratch, using the framework he is writing to test itself! The final chapter consists of a large number of patterns for TDD.

The book is written in a very casual, conversational style which makes for easy reading. There are a few times in the book where the author states that he cannot think of something or a better way "at the moment" though I would guess these were more a way of suggesting exercises for the reader than placeholders left over from the editorial process.

Some of the more interesting points I found in the book were:
  • Eliminate duplication, including duplication in tests of things in the production code
  • First make tests compile with stubs
  • When writing a test, invent the interface you would like to have
  • First make a test pass, then refactor bit by bit, keeping the test passing until the code is clean
  • 2 ways to quickly get to "green" (tests passing) - Return constants and gradually replace with variables until you have real code - use the real implementation straight away
  • Value Objects - represent a value, value never changes, operations return new value objects
  • Letting a test of 1 function depend on another function working is an educated risk
  • TDD cycle:
    1. Write a test
    2. Make it compile
    3. Run it to see that it fails
    4. Make it run
    5. Remove duplication (clean code)
  • you can entertain a brief interruption but never interrupt an interruption ( use a to do list to stop forgetting things)
  • "Sometimes you should just ask the computer" - make a change and run the tests
  • Sometimes write tests not to test external functionality but to inform future readers
  • After you've finished your todo list, review the code
  • 3 A's of tests: Arrange - create objects, Act - invoke methods on them, Assert - check results are as expected
  • If a test you write requires lots of changes to be made to pass, write smaller test cases and then reintroduce the big test
  • Isolating tests from each other encourages orthogonality in your code
  • Write the asserts in a test first and work backwards
  • Try to avoid mirrored data, eg 2 / 2 won't notice if arguments are wrong way round
  • First tests can be extremely simple but allow to decide where the function belongs and what inputs and outputs it should have step by step
  • Leave a broken test case at the end of a session so that you have something to work on next time, which will get you back into the same frame of mind
  • Abstract (ie return more than constants) only when you have 2 or more examples (tests)
  • If the obvious implementation is really obvious then just use that but fall back to faking and triangulation if you get red bars
  • Composite Object - treat collection of objects as if it were a single one of the objects
  • Seeing more than one message sent to another object in a method is a smell
  • "In TDD the tests are a means to an end - the end being code in which you have great confidence"
  • Keep tests that exercise the same path through the code is they convey different information to the reader
  • TDD leads to "just-enough" design
One of things I would recommend to do as was suggested by the author was to actually write the sample programs as you go through the book. This is because the book itself did not always provide an overview of all the classes at every stage and also because it's more normal for most people to look at code on a computer rather than in a book.

A point often made against TDD is that much time is spent writing test code as opposed to production code, and whilst the author believes that it is time well spent, he does also suggest that if you do start using TDD you should measure your productiveness so that you can see for yourself whether it works for you and your organisation.

In summary, the books serves as a very useful introduction to TDD and inspires in the reader the want to try it out. I would have liked to see more patterns about how to write code that is easy to test but that was not within the main aim of the book.

Link to buy the book at Amazon.com  

Saturday 26 November 2011

Peopleware Review

This post is a review of Peopleware: Productive Projects and Teams (Second Edition) by Tom DeMarco and Timothy Lister

Peopleware is a book that I read with great expectation. It had been mentioned in other books and online review with high reverence so I was expecting much from it and it certainly delivered. A point to get out the way early on is that the book is really aimed at managers of programmers rather than programmers themselves but I still think it is a book that every programmer should read. The usefullness for programmers comes from a couple of things, firstly, that some of the points made can be applied to your home environment and projects and secondly it contains great ammunition for negotiating workplace practices and environment with your boss in the form of reasoned arguments and evidence from studies.

The book is written in a relaxed and casual style which makes for easy reading but doesn't stop the authors from bringing out dry statistics when required to prove a point. It covers a wide range of managerial topics, from building successful teams to setting up the most productive workplace environment.

I didn't end up making too many notes on the book, because of the irrelevence of some parts of the book to me in my current role, but the book will be a very useful reference to have on hand when negotiating about the workplace with managers. Some of the points I did find interesting and relevant enough to note down were:

  • Failing projects are more often caused by sociological problems than technical ones
  • Often projects spend too much time trying to get things done and not enough time asking if they should be done
  • Most overtime tends to be followed with compensatory "undertime"
  • "People under time pressure don't work better; they just work faster"
  • People tie their self-esteem to the quality of a product, not the quantity
  • Increased quality -> increased motivation -> increased productivity
  • Parkinson's Law doesn't apply to work you enjoy ( and apparently the law was never backed up with any evidence in the first place)
  • In a 1985 study, the most productive projects had no time estimate or schedule
  • "The manager's function is not to make people work, but to make it possible for people to work"
  • Music lessons creativity as they are both right side of the brain activities (evidence in study)
  • The Hawthorne Effect: "people perform better when they're trying something new"#
  • Think of a work team as a choir not as a football team
The point about developers (and likely people in general) tying their self-esteem to the quality of a project rather than the quantity is something I'll be trying to keep in mind at work. The quality required for maximum business value is often going to be less than the level a developer would be most proud of, so I'll have to remind myself of this when a manager wants to release a product when I would consider it too early. Though I'd be very happy if my manager took interest in the follow up point that better quality leads to better motivation leading to better productivity.


In conclusion, I don't think the average programmer will find too much of immediate practical use in Peopleware but I'd still recommend that they read it for the insights it provides into the workplace environment, it's usefulness as a negotiating tool with managers and in case they ever want to step into management. As with my review of Mastering the Requirements Process, this is the first book I've read on the subject, this time management, and so I don't have much to compare it to, but as a developer I feel that if a manger were to implement the suggestions of this book then I'd be a happier and more productive developer and in some cases the book contains the statistics from trials to back up this feeling.

Link to buy the book at Amazon.com

Friday 18 November 2011

The Pragmatic Programmer Review

This post is a review of the book The Pragmatic Programmer: From Journeyman to Master by Andrew Hunt and Dave Thomas

It may be having read a number of similarly scoped books recently, or sitting next to someone who raves about this book but I didn't learn as much as I expected from this book. As mentioned, I don't actually think this is down to the book not being full of useful information and insights, becasue it is, but rather because the content overlaps with many other books (many of which were actually written after this book).

The Pragmatic Programmer has a very practical focus, most of the content concerns writing code from a  variety of perspectives, from architectural, through functions, down to line to line coding. The coverage is very solid and feels quite complete in it's covering of many areas, though as the Authors say themselves they don't go into deep detail in every area.

The things I found most interesting or new from the book were:
  • The DRY principle not only refers to functions but also to pieces of knowledge or assumptions. You should only have to change 1 thing if these change.
  • Comments that basically repeat the code break the DRY principle
  • "Don't rely on the properties of things you can't control"
  • Try and abstract away things like, which kind of database you're using, which OS, whether you're client/server or just client etc.
  • Tracer code - develop an entire vertical slice to check it all works and you're on the right track and keep that code (different to prototyping)
  • Prototype to learn
  • Leave assertions on in production code
  • Exceptions couple routines and their callers
  • Encapsulate resources into classes using the constructor to allocate them and the destructor to clean them up. Means garbage collection will clean up resources and in non-GC environments it will help remind you to clean them up
  • "Abstractions in code, details in metadata"
  • Design for concurrency even in non-concurrent environments - makes temporal couplings obvious
  • Software is like gardening 
  • Don't try to refactor and add functionality at the same time
  • "think of Unit Testing as testing against contract"
  • "Don't use Wizard code you don't understand"
  • When faces with a problem, write down all ideas no matter how stupid and check that whatever makes them stupid actually stands
  • Organise teams around functions of the product
  • "Failure to meet usability criteria is just as big a bug as dividing by zero"
  • Test your tests by purposefully breaking the code
  • "Find bugs once" write test to detect bugs that you discover
The idea of using metadata extensively in a program is a new one to me. On the one hand I can see it adding some complexity at first for the code that reads the metadata from it's source (the Authors highly recommend plain text files for many reasons), also adding complexity in that you can't tell exactly what the code is going to do without having to look at both the code and the metadata. On the other hand, there is the obvious advantage of not having to recompile your code when some program you're dependent on starts sending you 6 messages at a time instead of 5. Also I've come across many situations where test code needs a copy of the details that the production code doesn't expose which if they both got the details from metadata would reduce the number of  changes needed from 2 to 1.

The book has obviously been a success and the respect the community gives to the authors has allowed them to publish an entire range of books, with the Pragmatic moniker, the website of which is here http://pragprog.com/. It is a sign of the confidence the book inspires in me about the authors that I've now purchased another book from their range and have a few more on my Amazon wish list.

Someone who has read many books on general programming practice may only gain a few insights from this book, but for someone with little reading in the area then this book comes highly recommended compared to it's competition.

Link to Buy the book on Amazon

Saturday 29 October 2011

Code Complete Review

This post is a review of the book Code Complete: A Practical Handbook of Software Construction by Steve McConnell

Code Complete is an immensely practical book focused on software construction. This means that after reading the 800+ pages, you'll have dozens of tips and new ideas that you can put straight into use in your day to day programming.

Code Complete is the most important book on programming I have ever read. If a budding programmer asked me to recommend a single book to them, this would be it. I was fortunate enough to read Code Complete just a few months into my professional career and it vastly improved my code. My degree is in Computer Science and whilst this made me aware of many tools and techniques in programming and why these techniques are how they are, there was little discussion of how to use the tools well, which is what Code Complete covers perfectly. Whilst reading through the book for a second time, many of the points seemed obvious to  but then things are only obvious if you know them and I still found plenty of new and interesting points that I hadn't remembered from the first read through.

Interesting comparisons can be drawn between Code Complete and Clean Code as they are both focused on writing code (though Code Complete is broader). Firstly, Code Complete cites a wealth of research and other books to provide evidence fro the points made, whereas Clean Code's arguments are more along the lines of logical persuasion. This point becomes more involved in places where the two books disagree, for example, in Code Complete, Steve McConnell cites research that says comprehension of a routine doesn't drop until it gets over a couple of hundred lines whereas Clean Code recommends to make routines shorter and then shorter still and most of the examples given in the book are less than 10 lines long (despite the evidence saying comprehensibility isn't reduced in routines 200 lines long, I'm currently more in favour of the Clean Code very short routine style). Commenting is another are where the two books disagree, with Code Complete devoting an entire chapter to comments and recommending leaving the comments in from the Pseudocode Programming Process (more on this later) whereas Clean Code encourages removing as many comments as possible in favour of shorter routines.

One of the main contributions of Code Complete is the Pseudocode Programming Process whereby when writing a routine, Steve McConnell recommends starting with comments describing the intention of that routine and then refining the comments iteratively until it would be easier to write the actual code. Then for each comment left, you write what should be a few relatively simple lines of code and leave the comments in to describe, on a higher level of abstraction, what each section of code does. The authors of Clean Code would change each comment into a routine containing the lines of code associated with it and the routine name would convey the same information that the comment previously did. This would work well as the comments at the end of the PPP should be a single level of abstraction above the code that is written.

Here are the things that I found new or particularly interesting:
  •  Languages (including natural ones) and what you can express in them, may limit your ability to think certain thoughts
  • Programming "in" a language - limit thoughts to constructs of language vs programming "into" a language - decide what you want to express and then work out how to express those thoughts via the language
  • Final design should be neat and tidy but the path to tidiness isn't tidy (similar to writing unclean code and then cleaning it as expressed in Clean Code)
  • To manage complexity - reduce accidental complexity and minimize how much essential complexity you need to remember at any one time
  • Abstraction - you can look at a higher-level. Encapsulation - you can only look at a high-level
  • The easier it is to call a module (int terms of setting up the right arguments) the looser the coupling
  • Don't think of Abstract Data Type's as mathematical objects, but as a way of letting you work in the problem domain rather than low-level implementation
  • Class = ADT + inheritance + polymorphism
  • final for functions in Java is equivalent to non-virtual in C++
  • inheritance tends to contradict reducing complexity
  • Routines 100-200 lines long are no more error prone than shorter routines
  • Correctness - never returning an invalid result, better no result at all vs Robustness - try to keep the software operating
  • Consider creating a project specific base exception class
  • Original coding (and review!) in pseudocode and leave pseudocode in as comments once code written
  • Avoid "Just One More Compile" syndrome
  • If you have to "figure out" a piece of code, refactor it
  • Use positive boolean variables names to avoid double negatives
  • Abbreviate consistently - not only just one of num/no. but also don't use Number and Num
  • Create names you can pronounce
  • Avoid misspelled words in names as you have to remember the misspelling
  • Avoid often misspelled words
  • Centralizing control over things that might change is good
  • Random accessing into arrays (ie not sequentially) is similar to random gotos
  • Put the normal case in the if not the else
  • Prefer for loops to while loops as all the loop control is at the top in one place
  • Make each loop perform only one function - Only combine loops if measured performance shows you should (and you need the extra performance)
  • Don't change the index of a for loop inside the loop
  • Simulate (in head) loop for 1st, last and random middle case to check it
  • Consider table based approaches instead of complicated ifs/switch statements
  • Prefer < to > as it orders arguments like a number line
  • Code reviews more effective than testing because they find cause and symptoms whereas tests only find symptoms
  • For data-flow testing, have a test case for each DEFINED-USED pair
  • When debugging, consider how long brute-force techniques such as rewriting the routine would take
  • "being wring about a change should leave you astonished"
  • Larger projects will have lower productivity and high error density
  • Write a core then code and integrate one class at a time
  • When doing incremental integration, then you need to plan construction earlier
  • Leave a dyadic operator on the end of a line to indicate the expression carries on
Overall, I would recommend Code Complete to anyone with an interest in programming and software development. Newcomers to the field will have the code improved invaluably by reading the book and experiences practitioners will still be able to learn something and also know that the good habits they have picked up are backed by evidence.
Link to but the book on Amazon.com