Monthly Archives: April 2014

Concepts not syntax!!

If I could go back in time, and give myself any piece of advice, it would be this. “Don’t worry about the syntax of the language, concentrate on getting the concepts right!”

For example, here is a for-loop in C++:

for(int i = 0; i < max_limit; i++)
    // do something with i

Now here’s the Java equivalent,

for(int i = 0; i < max_limit; i++)
    // do something with i

Or how about Visual Basic?

For number As Double = 2 To 0 Step -0.25
    Debug.Write(number.ToString & " ")

Sadly I only learned this a few years back (I’ve only been coding professionally for five years, so am still playing catch-up) But when I learned this lesson, I found it was far easier to pick up stuff in other languages relatively quickly.

For example, I’m currently writing stuff in C# at home, which is VERY similar to Java (I know, old news…) So it means I don’t have so much of a curve to learn, as I already know how to declare an array, or a vector or a for loop or while loop.

And that’s what I’d encourage each new coder to do. While it’s tempting to dive in to your language and learn everything there is to know about it, and trust me, that IS a good thing. If you’re starting out, I’d suggest that you make sure you got the concepts solidly in your mind.

In five years, I have coded in: (in no particular order) C++, Java, Bash, Python, C, C#, Visual Basic (yup), and Perl. And I can tell you that learning the syntax is a doddle once you know the core concepts.

Now don’t misunderstand me at this point. Of course you should learn the syntax and the semantics of your chosen language, however the point I am making is don’t get so focused on the syntax, that the concepts pass you by! That’s the mistake I made!

Please note I’m specifically focussing on languages such as C, C++, Java and their ilk here. Of course there are markup languages like HTML, CSS, XML that have their own syntax, but they are beyond the scope of this blog post.

As ever, would welcome thoughts or comments!

Happy coding


Brother and sisters in arms…

From the 8th to the 12th of April, I and a few hundred people descended on the Marriot Hotel in Bristol to attend the ACCU Annual Conference.  So what is ACCU?  It stands for the Association of C and C++ Users, although don’t let the title fool you.  There we plenty of talks on all sorts of topics and other languages, for example, Uncle Bob spoke on Clojure, the excellent Jon Skeet spoke on how to abuse C# 5, Dan North spoke on why Agile Doesn’t Scale (well worth it!) and even your truly did a lightning talk on self-improvement as a programmer. 

So to the highlights…

Tuesday 8th April

So I was fortunate enough to be able to attend the pre-conference tutorial day which was on the Tuesday, and I elected to attend Nicolai Josuttis’ tutorial on C++11 and C++14 in a day, which was a whistlestop tour of the features that were in C++ 11, and what’s coming in 14 (Which is now out in the latest build of gcc, which is 4.9 at the time of writing.)  And I surprised myself with how much I’d learned by mucking about and watching the various video courses I’ve done at home. Nico is a very engaging speaker, and very easy to listen to and makes it easy for you to be able to absorb what he was saying.  I’m still absorbing if I’m honest.

Wednesday 9th April

The rest of the delegates rocked up today, and so the conference was packed out.  I had the age old problem of too many great talks to attend at one.  However Bill Liao kicked us off with a great keynote on the CoderDojo.

If you haven’t heard of the CoderDojo, it’s a self organised coding event designed to teach kids to program.  It was started by a young lad in Ireland called James Whelton, who started a computer club at his school but when it came time for him to graduate, so the club was in danger of being shut down.  So he approached Bill to help fund an organisation that taught kids to code.  And now it’s growing at quite a rate. 

Bill spoke about the impact of the CoderDojo in Cork, and encouraged the creation of CoderDojo’s all over, as programming is not really taught in schools any more.  I am currently analysing the state of teaching programming in our schools, and a more detailed blog post will follow.

The afternoon had a great talk by Jonathon Wakely on “There’s no such thing as a universal reference.”  This was in reference to something the legendary Scott Meyers said about the rhs (&&) operator in C++.  And the room was jammed as can be seen in the picture below.



It was an interesting talk, and Jonathon spoke of the circumstances where he thought that the use of the term “Universal Reference” was used incorrectly.  I’ll be honest, a lot of it went over my head, however it’s given me something to look up about and read on a bit more.  So that’s good. 

I also volunteered to do a lightning talk based on my experiences of seeking to becoming a better programmer over the last year.  The dangers of twitter…

Thursday 10th April

Thursday opened with Dan North speaking on why Agile doesn’t scale.  Which was quite good, and I wished my manager was there alongside me to hear the talk.  Dan went in to how Agile made projects that were slated to take years were done in months, however projects that should have taken days changed to taking months.  I found this talk quite engaging as the team I’m at work does Agile (I’ve since been corrected, we’ve moved away from that to Kanban now…)

Another great talk was the Art of Learning and Mentoring, which was more of a workshop than a talk, and it encouraged lively debate as to the best way to teach new team members on our teams, and discuss how we learned new techniques.

Although I freely admit that one of the highlights was been able to share a beer with the excellent Pete Goodliffe, and so got to discuss the talk he gave last year, and he kindly agreed to look over my lightning talk.  So beer time well earned methinks.

Friday 11th April

I must confess that between commuting between home and Bristol each day (M5 eurgh), left me shattered at the end of each day, so I’m afraid I missed the keynote this morning, so I could focus on writing my lightning talk for tonight.  And it’s quite a daunting challenge to keep it down to 5 minutes, so I had to be merciless in what I was and wasn’t going to say.

But I’d been looking forward to Friday’s talks.  Mainly as Kevlin Henney was doing a talk on Immutability For The Win, and ironically he was changing his slides just before the talk.  But then the slides pack is a stack so it wasn’t really immutable….apparently.

Biggest highlight for me personally was entering a raffle run by Intel to win a Samsung Galaxy Tab 3.0, and on the Friday the draw was made.  And I won!!  So now that’s in full use at home.  I owe thanks to James Greening who I was sat with at the bar, and convinced me to head down to see the draw, so thanks James!  Beers on me next time I see you sir.

The other highlight was hearing Jon Skeet on Abusing C# 5, and it was quite funny and evil some of the stuff he’d done in the language.  It reminded me of a talk Phil Nash gave last year where he overloaded the –> operator in C++ so that it now pointed to the left (i.e. <- ). 

It just showed that if anyone was that way inclined, they could write vile and evil code that nobody had a hope of understanding. 

Then it came time for me to give my lightning talk, and I’d like to think it went well.  I kept a beady eye on the timer that Ewan was holding up, and finished a minute ahead of time.  However I think I may have rushed some elements of it.  It was a VERY full room, but what struck me was that nobody was glaring evilly at me, (won’t mentioned where I had that experience).  And I realised that what Malcolm said was right, that they were rooting for me.  So thank you all for listening.  The problem is no Phil Nash has challenged me to put in for a full talk next year.  So watch this space.

Saturday 12th April

By this point, my brain was pretty much mulch.  But still I bravely carried on.  Among the highlights was Arjan van Leeuwen’s talk on The Evolution of Good Code.  In which he discussed the discipline of writing good code, and compared what a number of text books had to say.

I also attended Anthony Williams’ talk on the continuing future of C++ Concurrency (multiple threading).  I’ll admit that this wasn’t the talk I was expecting, and as I’d done next nothing with threads in C++, I quietly slinked out (Sorry Anthony, nothing personal).  However as I’ve got Anthony’s book, it won’t happen again.  (Will post code to prove that I understand it ;-)  )

The conference was closed by Howard Hinnant on talking move semantics in C++, which was a very interesting.  I dutifully drew the chart he had in his slides, and will be revising that as often as I can.


I loved every second of this conference.  I’ll admit a lot went over my head, however I learned a lot as well.  I also made some great new contacts.  And I have some new challenges to take on this year.  Would I go again next year?  Yes, without hesitation.

And if you’re interested in being part of a large C++ community, then can I commend the ACCU to you.  While the acronym says C and C++ Users, it’s by no means exclusively the C++ language.  For instance, I also develop in Python, Java, C# and a few other languages as well, and I’m sure I’m not the only member either.  You get two publications, and great discounts on the conference. 

If you’re interested in joining then head on over to the ACCU Website for more details.

Compact SQL Databases….

I’m in the process of developing my first app for the Windows phone platform.  I won’t say more than that for now, but it requires the use of a database at the back end to hold user account details.

Now, sadly Windows Phone on it’s own, or Visual Studio (from what I could see so far) didn’t have a mechanism for me to check what’s going on in the database that’s sat on the Virtual Windows Phone. 

I’d recently made changes to my app so that the user could select the account type they wanted to store for the app as can be seen in the screenshot below:
 screenshot of app

And so I wanted to see that what I was doing was actually adding stuff to the data base, and therefore would allow me to start doing more clever things with my app such as firing off requests and the like.  But I digress.

So how did I do it? 

So Windows Phone stores the data base as an SQL Server Compact database, which stores everything in an sdf format.  So the first trick was to get that off the phone.  The tool I used for this was the Windows Phone Power Tools, which can be found here.

So I fired that up and you get the above screen initially.  So we need to select which Virtual Device (or actual device, I’ve not tested this with my actual Lumia yet) we want to connect to.

Once we’ve done that, we’re in, and can get about downloading the file.  The first thing I learned is that if I’m on the screen that’s interact with the database, it won’t download the file.  So do all the Database stuff you want to do, then close down the app, BUT NOT THE DEVICE! 

Once you’re ready to get the file, navigate to the .sdf you’re interested in.

You will need to click on it, and select GET and it will transfer the file from the device to the location of your choice.

The biggest problem I had then, was what to use to read the .sdf file.  There’s a load of great utilities out there I’m sure but most of them didn’t work for me.  What actually did work was CompactView.  Sure it looks a bit basic, but it opened the .sdf file for me, which allowed me to check that the data I’m looking at was accurate.  It also allows you to have a context menu option as well.

So to view the file, select CompactView, and you’ll then be faced with the following screen:


It may not look like much, but at least it told me that my code worked correctly.

So happy coding 🙂