Getting started with Git


Git: Decentralising version control I've been a user of Subversion for a number of years, I was a little apprehensive about moving to a completely different versioning system but now I'm seriously glad I made the move. To recap, Subversion is a centralised version

Angry Monkeys


From my experience having programming standards and standard environments can be extremely beneficial to a development team. Not only can it improve the chances that you can find problems quickly but it also ensures problems are reproduceable. Having coding standards also

Review: Pragmatic Thinking & Learning


At Autotrader we have a book library for all developers to borrow from. First book I decided to read was Pragmatic Thinking & Learning by Andy Hunt which is from the Pragmatic Programmers series. I have to say I was very impressed. Many believe and have believed

Getting started with Git

Posted on by James Posted in Personal | Leave a comment

Git: Decentralising version control

I’ve been a user of Subversion for a number of years, I was a little apprehensive about moving to a completely different versioning system but now I’m seriously glad I made the move. To recap, Subversion is a centralised version control system. What this means is that you have a centralised code repository, developers use clients to checkout code which they can work on until they’re ready to commit their work back to the main repository.

So what is Git and why move to it at all? Why reinvent the wheel?

What is Git

Git is a decentralised version control system. Clients can clone the repository from any other copy of the repository. In general you all still have a main repository you use as a focal point of committing but you can create your own branches and therefore have more control of your own repository structure (until you need to commit and merge of course). So instead of checking out and committing you clone the repository, commit your changes to your own local repository then push the changes back to the focal repository when you’re ready, merging if and when necessary.

Advantages

  • No internet connectivity required – each client has a full copy of it’s own repository
  • Distributed development – as mentioned every client has it’s own repository copy
  • Strong support for branching / merging – distributed versioning systems lend themselves heavily to branching and merging often because every repository can at some point be considered a branch of others
  • Handles large projects efficiently – Git is an order of magnitude faster than other versioning systems
  • Ideal for feature development – users can branch themselves and work privately on their own feature independently of others
  • Allows for very flexible development – developers can choose who’s repository they want to merge with at any point in time

Disadvantages

  • Working in the same code area on similar features is trickier because merging may result in lots of conflicts
  • Distributed development tends to encourage private work which is bad for development practices
  • Maintenance work tends to be sloppier on distributed systems

Which should I choose

Ultimately it’s a personal decision. Many claim that a centralised versioning systems cannot work with distributed development, however, this is wrong. In a centralised versioning system if all developers worked on their own personal branch effectively you would have something similar to a distributed environment. In both systems you will still have eventually merge with someone responsible for releases, otherwise you have chaos and unpredictable builds, timelines and feature progress becomes difficult to track.

The nice thing I like about Git is just how easy it is to setup and get started in comparison with Subversion. No messing about plus hosting like Github makes things even easier.

Using Git on Github

Here’s just a few useful tips to get you started:

  1. Initialise Git repository in current folder
  2. git init

  3. Configure local Git to point to Github account
  4. git config --global user.name "Firstname Lastname"
    git config --global user.email "your_email@youremail.com"
    git config --global github.user username
    git config --global github.token 0123456789yourf0123456789token

  5. Add link to the remote github repository as origin i.e. main repo
  6. git remote add origin http://username@github.com/username/myrepo.git

  7. Set the default branch to merge to as the origin – this allows a simple git pull without branch
  8. [branch "master"]
    remote = origin
    merge = refs/heads/master

  9. Pull the code from the remote repository i.e. origin
  10. git pull

  11. Add a new file using the client
  12. git add myfile.ext

  13. Commit changes to your local repository
  14. git commit -am "Added myfile.ext to repository"

  15. Configure your buffer to 500mb so you don’t have issues with the size of commits
  16. git config http.postBuffer 524288000

  17. Push the code to the origin
  18. git push

    In Summary

    I hope this article has provided you with at least some insight into what Git is and in what way it varies from Subversion. Also, a precis on the advantages and disadvantages of each approach. If you agree or disagree feel free to leave me a comment below.

    Popularity: unranked [?]

Angry Monkeys

Posted on by James Posted in Java, Programming | Leave a comment

From my experience having programming standards and standard environments can be extremely beneficial to a development team. Not only can it improve the chances that you can find problems quickly but it also ensures problems are reproduceable. Having coding standards also means that code is easy to read and clean.

However, as is the same with anything, sometimes too many rules and too much bureaucracy can lead to a stifling of creativity. In chess for example, juniors are taught a number of rules so that they can safely navigate the first opening few moves, but if you play strictly according to those rules as a more advanced player against similarly more advanced players with no regard to the current situation then likely you’ll be crushed.

In the 1960s doctors were given the freedom to experiment with much less restraint than they do now. In order to study behaviour amongst primates the doctors would place some monkeys in a room with a a bunch of bananas hanging from the ceiling and a step ladder underneath. Naturally the monkeys would approach the stepladder in an attempt to eat the bananas however, whenever they got near the scientists would douse them in ice cold water – what do we get? Angry monkeys. Eventually none of the monkeys would go anywhere near the ladder.

They would then introduce a new monkey to the pack and he/she would then naturally try to climb the ladder but before reaching the ladder the monkey would be beaten by the others. Not knowing why they shouldn’t go near the ladder they would avoid it anyway for fear of being beaten. Eventually the scientists would replace the original group of monkeys with a completely new group. This group having never been doused with ice cold water, would still never go anywhere near the ladder.

The point of the story? Well, some developers often behave the same way. Never questioning why something is the way it is and why things are done in a particular way, they just do it.

Don’t be an angry monkey. Always question authority never believe what other people say until you’ve convinced yourself that there’s a good reason for it being that way.

This will make you a better developer… trust me.

Popularity: unranked [?]

Review: Pragmatic Thinking & Learning

Posted on by James Posted in Books, Personal | 2 Comments

Pragmatic Thinking & Learning

At Autotrader we have a book library for all developers to borrow from. First book I decided to read was Pragmatic Thinking & Learning by Andy Hunt which is from the Pragmatic Programmers series. I have to say I was very impressed.

Many believe and have believed that we have a natural limit to our intelligence and can be no more than that. The author tries to expel this belief. We all have a brain and it’s a well known fact that we only ever utilise a very small part of it.

The common belief is that our brain is split into a left and right side. Hunt refers to these as the L-mode and R-mode i.e. logical side and realisation (creative) side. The majority of us are either left or right brained and it’s this fact that limits our potential. We’ll often say to ourselves “I’m not really a very creative person” often though, that’s because our L-mode always seems to take over; it butts in takes control and doesn’t give the R-mode any time.

We can imagine our brain as a machine. Only one part of our brain can be doing anything at any one time (well unless you have multiple voices in your head; I’d see a doctor!) it’s either our logical side or the creative side that’s in control. However, to unlock this potential you need to stimulate those parts of your cortex you least use. As a programmer we have strong L-mode influences problem solving, critical thinking a general all round logical approach to everything there has to be a reason. We are in general though, weak on our R-mode functions. This part of the brain allows us to unlock creative ideas, blue-sky thinking and thinking out-of-the-box.

Hunt suggests a number of interesting techniques to open up this side of the brain. Normal suggestions include going out for a walk, not just going out for a walk and deliberately thinking about the problems you have but going out with a clear mind and letting thoughts just come to you. Have you ever been trying to think of the name of that actor in “that” age old film you talked about last week with a colleague. Ever found it bizarre how the name just pops into your head? Well that’s R-mode working in the background. It’s pretty slow at times but it gets there in the end, working all the time while your L-mode deals with all the day-to-day tasks.

Another interesting technique involves dumping every thought on a few sheets of A4 before you even have a shower or have breakfast in the morning. He calls it “morning pages”. Even if it’s a load of total rubbish that you write down eventually you’ll start to get your mind thinking overtime about the work you’re doing and you’ll also free it up to think about things that are more important to you.

There are a number of other things you can do such as increasing your focus (trying things like yoga or meditation for instance), using GTD methodologies, increasing productivity by limiting your distractions and change of contexts (using Quicksilver on the mac). The most important I thought though was to learn deliberately. Learning and putting the hours in just doesn’t cut it. You have to positive and really believe that what you’re doing is making a difference. If you believe that you’ll fail then you will.

Recently there’s been a book released called “Bounce: The Myth of Talent and the Power of Practice” which attempts to distill the myth that only those with supreme talent can make it to the top. I personally believe that with deliberate practise as Hunt describes you can truly reach your potential. Sure only a select few can ever be a world champion but many still have some ability to make it to the top echelon’s their field. Hunt tackles this in Pragmatic Thinking by talking about Learning through Teaching. In this teaching he describes not just telling a student what they’ve done wrong, but also subconsciously teaching the student how to do things right so they can see for themselves the result. More like feeling that they’ve done something right.

I suggest you have a read and tell me what you think. Remember it’s never too late to change the way you think for the better.

Popularity: unranked [?]

Beating the Orangutan

Posted on by James Posted in Chess, Openings | 2 Comments

No we’re not talking about the hairy variety! So you Animal activists are looking at the wrong blog unfortunately…

For those of you chess enthusiasts who’ve been caught unawares out of the opening only to be taught a lesson in just how “not” to play it – then read on. I’m going to hope to show you one of my own horrors where I make precisely all the mistakes that you should hope to avoid.

Sometimes a move made on just move 4 can decide the game so read on. This example is taken from my last club match – it’s not pretty and it’s one of the games in the year where I played just about as poorly as I could have done. That’s not to take anything away from my opponent, he played extremely well and had to be completely on the ball. What you’ve got to do is pick yourself up dust yourself off and learn from it.

Sheppard, Daniel vs Murphy, James

Orangutan / Sokolosky / Tartakower Opening

1. b4 e5 2. Bb2 d6??

Hard to believe but it’s only move 2 and already I’ve made a mistake. Black’s best move here is to capture on b4. So, besides not knowing the theory in the Sokolosky (Orangutan) why didn’t I just take it? Well to understand that I’m harping back to what I thought at the time: “If i capture on b4 he’ll be able to open up the a1-h8 diagonal for his Bishop and he’ll have an additional central pawn to me. Central pawns are better than flank pawns so I’d be giving up the advantage. Plus I can always mop up the b-pawn later or weaken it with a5 and open up the a-file exposing the a-pawn”.

Taking this on board it’s a pretty sound logically conclusion I came to and because I didn’t know the theory I stuck to my logic – unfortunately this was totally wrong. As I’ll show you later (after some background preparation) there’s some tricky tactics that develop on the e-file if White chooses to accept it (which he must).

Anyway on to the game…

3. e3 Be6 4. c4 d5?! 5. cxd5 Bxd5 6. Bxe5

At this point I’d gambitted a pawn. Now in hindsight my recommendation is don’t gambit a pawn in an opening that you don’t know the theory of unless you know there is something concrete that can come of it. As you’ll see it’s giving a pawn up for nothing unless you have some form of compensation.

6…Nc6 7. Bc3 Qd7 8. a3 h5 9. Bb2 a5 10. b5

To understand why this is all bad for black all we need to know is what white’s plan is now. Basically he wants to gain some space on the Queenside, ensure I can’t get the pawn back and cement some control on the centre, the pawn should then count. This is exactly what happened.

10…Na7 11. Nc3 Be6 12. Nf3 f6 13. Nd4 Bf7 14. Qf3!!

This for me is White’s key move for converting his advantage most efficiently. He hits b7 threatening to win another pawn and also threatens to exchange queens on f5. A good tip when trying to convert a pawn advantage – get Queens off as quickly as you can – simplify, simplify, simplify!

14…O-O-O?

I saw Qf5 and obliged but I didn’t like the alternatives which were putting it mildly – passive.

15. Qf5 Qxf5 16. Nxf5 g6

I wanted to get my bishop activated on g7 as quickly as possible.

17. Nd4 Kb8? 18. Be2 Nc8? 19. Na4 Nge7? 20. Nc5!

Three dubious moves in a row by me, after g6 I should have followed it up with Bg7 immediately getting the rooks connected and active. Piece activity is the only way I could get any compensation for that lost pawn and at the moment White is quickly mobilising his pieces.

20…Rd6 21. Ne4 Rd8 22. Nf3 Nd5 23. Nxf6 Bg7 24. Nd7+!

I saw this move a few moves earlier and realised it was the only way White could realise the advantage in full. After this White retains two full pawns to the good, not only that but he also wipes out my dark-squared bishop which could have been a big asset. White now has a big plus – only a blunder from my opponent will save me now.

24…Rxd7 25. Bxg7 Rh7 26. Be5 Bg8 27. O-O

With both rooks linked it’s now a matter of a technical win for White.

27…Ndb6 28. Rfc1 Nd6 29. Bxd6 Rxd6 30. d4 Bd5

I was hoping I would get an opportunity to set up a blockade in the middle but I realised without any pawns to support my pieces I was pretty much finished.

31. Ne5 Nc8 32. Bc4 Nb6 33. Bxd5

Eliminating one of the bishops blockading is a sure way to get rid of that troublesome blockade.

33…Nxd5 34. Rc5 b6??

This just quickens my demise. It’s probably best not to expose the weakness of c6 but then I was worried about the isolated pawn on a5.

35. Rc6 Rg7 36. Rac1 Rxc6 37. Nxc6+ Kc8 38. Kf1 g5 39. e4 Nf6
40. f3 g4 41. Ne5 gxf3 42. gxf3 Ne8 43. a4 Nf6 44. Kf2 Rg8 45. Rg1 Rf8 46. Ke3 Resigns 1-0

I decided to a call it a day – the cheapo Nxe4+ didn’t work but then I wasn’t going to offend my opponent by playing on and delaying the inevitable after all they’d deserved their victory this time.

Popularity: unranked [?]

Top 10 Chessplayers of all time

Posted on by James Posted in Chess, Masters | 3 Comments

For my first chess post since the blog relaunch I decided it’d be interesting to spark a debate on who you believe are the greatest chessplayers of all time and why. I’ve controversially included some faces from new and old. I’ve aimed to pick some of the greatest players from a number of different generations to give a bit of variety.

Unfortunately not everyone could make the cut. I felt compelled to include Vasily Smyslov following his death late last month but he didn’t quite make the grade.

Get in touch with me and let me know if you think I’m totally wrong and who you would include in your top 10 list!

Read more

Popularity: 100% [?]