Hull Minster Tower Tours
/I’ve decided that I really want to do this. If I take a camera or two I think that my desire to get a photograph might able to offset my fear of heights.
Rob Miles on the web. Also available in Real Life (tm)
I’ve decided that I really want to do this. If I take a camera or two I think that my desire to get a photograph might able to offset my fear of heights.
You know you’re getting old when your blog starts to fill up with recommendations for coffee shops.
Anyhoo, The Old Lamp Room in Cottingham is lovely. It is right by Cottingham station. In the building where they used to prepare lamps for steam trains. We had a drink and a scone and were able to sit outside and watch the trains go by. Great place. The food menu looks good too.
I've spent a lot of my time teaching C#. And the starting point for my students was always an empty console application. Something like this:
using System;
namespace OldSchoolConsole
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
This is what you used to get when you created an empty console application in Visual Studio. It brings in the System namespace so that you can interact with the user and then creates a namespace and a class containing the Main method that makes everything happen. (in this case print "Hello World!")
However, if you use Visual Studio 2022 and .NET 6.0 to create an empty console application you will get this:
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
The link in the code gets you to a description of what has been done and the C# features that make it possible. I can understand the reasons for the change. You can run a Python or JavaScript program from a single statement and so someone must have thought that C# needed that feature too. However, I'm not convinced that the change is a good one.
I really liked the way that the old arrangement forced the reader to consider the way C# programs are structured and managed. My C# Yellow Book makes a big feature of going through all the statements in a complete program right at the start, so readers appreciate how C# programs fit together. The new single line arrangement might give the impression that I'm doing stuff that is unnecessary and making things complicated when I'm really paving the way for understanding of how everything works. The new design doesn't really make it easier to construct programs. If you want to use classes in your simple one-line program it all falls apart with build errors that make little sense to the beginner.
The good news is that you can just delete the one line solution and go back to the old program if you want to. Which is what I plan to tell people to do.
I’ve just decided I’m wrong here. If I think about the issue properly (something that only ever seems to happen after I’ve posted an article) I reckon that the new console format is a good idea, especially from the point of view of teaching programming. When I wrote Begin to Code with C# I invented a framework (called Snaps) that makes it trivially easy to create a universal windows application with a minimum of surrounding code. This change is doing exactly the same thing for console apps.
My argument above doesn’t point up a flaw in the new design, it points up a desire on my part to keep my teaching sequence the same, rather than look at simplifying the learning process.
I’m now going to re-write the first part of the C# Yellow Book to make use of this new feature and make it easier to focus on what programs do before moving into the features that make solutions easier to manage. My apologies to the .NET 6 team, you’ve actually done something really nice.
Trinity Market in Hull is a wonderful place to visit. Lots of very interesting things to buy and great places to eat and drink. And all indoors and heated. Plus a nicely set up meeting space they use for all kinds of things. Including half-term crafting events for little people. Lovely. Count us in.
The event was organised by Hull Libraries who do some lovely stuff around the city. And in the library. They had coloured paper, feathers, stickers, glue, pipe cleaners and all the crafting stuff that kids (and me) like playing with. Thanks very much for organising it and making one little lady a very happy bunny. Whose happiness only increased when we swung by Dinsdales in Hepworth’s Arcade to buy a joke on the way home.
We also grabbed a coffee in the market from these folks which was excellent and extremely good value. They do very nice de-caffeinated too.
No wonder I look worried
The original Pokemon games kind of passed me by. Perhaps I was a bit too busy with other things when they first came out, or maybe I was anxious not to be seen to be taking over the games that my kids were playing at the time. Well, that ship has well and truly sailed now… So when Pokemon Legends Arceus came along I was tempted. The game seems to have a nice exploration angle and although the graphics didn’t look the best they looked good enough to build a solid atmosphere. So I stumped up the cash and downloaded a copy.
I’ve not done much yet. Just the training missions. But I am having fun, and it looks like there is a lot of depth to the whole thing.
The nights are getting brighter and there are things like this out. Could we be approaching the end of winter? Rather hope so.
We have a house guest for the next few days. Turns out her favourite TV show at the moment is “Boy Girl Dog Cat Mouse Cheese”. You can find it on BBC iPlayer and also on Netflix. Not the most relaxing watch, but fun. And it has cheese in it.
I’ve spent the day sharpening my pencils (no idea why) choosing font types, rearranging my desktop shortcuts, emptying my wastebasket, and tidying my desk very slightly. Then I finally got around to writing the agenda slide for my Red Nose Day presentation in rhyme. I hope you like it. It took a long time to write……
You can sponsor me here. And the best part is that if you sponsor me you don’t have to remember to watch the session at 7:00 pm on Friday 18th March (link here)
I was up town yesterday for the hardware meetup and the lighting was rather good. So I took a few pictures of the place. Above is City Hall, where I used to help with degree ceremonies back in the day.
This is part of Hull Maritime Museum, which is just undergoing a massive refurbishment.
This is an awesome mosaic which is now being preserved.
The design looks even more impressive close up.
We had our first in-person hardware meetup of the year tonight and it was a roaring success. The theme for the evening was “Thermal cameras” and Brian had brought along his thermal camera equipped Pi which has a really nifty screen. You can see it action above. Faces show up as bright red, with windows and other cold things dark blue.
Pretty much everyone had brought along some stuff to talk about. Ion had brought along some amazing creations, including a super accurate crystal controlled clock which he had built from scratch, including a custom designed four-layer printed circuit board.
Richard had brought his beautifully built “Completely Useless Machine”. To find out what it does you have to flick the switch.
I was going around making tiny printed portraits of people using the Kidizoom camera. You can just see one of Richard underneath his device above. It turns out that if you take a photo with the camera and then convert it in to a “colouring in” picture you get some nice looking line art printed out.
We’re going to try and meet up in person once a month from now on. If you’re in Hull and you fancy coming along it would be lovely to see you. I’ll be posting the details of the next meetup soon.
The flowers arrived on Valentine’s day. We’ve just finished building them and finding a vase to fit. This is just half of the set, we thought they’d work best as two bunches. Great fun and almost romantic.
I’ve just set up the JustGiving page for the Red Nose Day lecture in rhyme next month. For every donation I’ll add an extra cheese pun.
https://www.justgiving.com/fundraising/rhyming-rob-miles
And remember, if you sponsor me you don’t actually have to watch the presentation. In fact, you might prefer it that way.
Blimey. Twenty years eh? The .NET framework has been part of nearly a third of my life. Highlights for me:
Going to amazing sessions at Cambridge University and learning all about the new framework from the people that built it.
Launching the first ever .NET Masters Course at Hull University and delivering a couple of modules for it, including one where we modified the razor open source .NET compiler to make broken programs and then got the students to try and debug their code with it.
Switching to C# as our teaching language in the department and creating the world famous (in my world) C# Yellow Book.
Getting into mobile development with the .NET Compact Framework and revelling in being able to create C# code for a mobile platform.
Exploring the XNA Framework and making the immortal “Cheese Lander” game. Running it on a Zune (because I could).
Putting .NET programs into teeny, tiny devices using the .NET Micro Framework.
Running Sliverlight and XNA in a Windows Phone on what is still the most beautiful user interface there has ever been for a mobile platform.
Using .NET Gadgeteer to make amazing embedded devices, even down to their circuit diagrams. All in Visual Studio with in-device debugging.
Using ASP.NET to create a web controlled multi-player robot fighting game for Three Thing Game.
Writing the first Begin to Code book for C# and building an entire UWP environment called Snaps to make it easier to make useful applications quickly.
Here’s to the next 20 years.
A programming language is like any other language. It must evolve over time to reflect the ways that it is used. One of the things I love about C# is how it has grown over the years. One of the latest changes is the addition of a !! operator (otherwise known as the “bang bang” operator). This is causing a bit of debate, which is great because changes to a programming language should always be made on the basis of a proper discussion. But you might be wondering what all the debate is about. So here’s a quick explanation of what is going on.
C# has always had methods. A method is a thing you can ask an object to do. For example, you might have an object which you can ask to serve a drink:
barkeeper.serveBeer();
barkeeper.serveCoffee();
Then you might decide that rather than have a lot of different methods for different kinds of drink it would be easier to make a method that accepts an argument that tells it the kind of drink that is required:
barkeeper.serveDrink("Beer");
barkeeper.serveDrink("Coffee");
The serveDrink method can look at the value of the argument and decide what to do:
void serveDrink(string drinkName)
{
// test the name and make an appropriate drink
}
So far so sensible, although we have made things slightly easier in one respect (we can use serveDrink method to serve any drink rather than having to make lots of methods) by making things slightly more difficult in another (the serveDrink method has to decide what drink is to be made and what to do if a matching name is not found). For example, what should happen when the following code runs?:
barkeeper.serveDrink("BEER");
The above code is asking for a beer, but the name is all capital letters. Does the method deliver a "Beer", or does it fail with an error. If it fails with an error, how does the user of the program know that an error has occurred? At this point we have to invent a convention for our application. We might say that the serveDrink method will throw an exception if it is given a drink type it doesn't recognise. That's fine as long as the behaviour is documented so that users of the method now how to use it.
But what about bang bang? I hear you ask. The operator is intended to make life easier for programmers by automating the handing of null references. Consider what would happen if someone did this:
barkeeper.serveDrink(null);
This code will ask for a drink but provide a null reference as the drink description. A null reference is not the same as an empty string, it is a reference that points to nothing. This is like asking the barkeeper for a drink and then falling over on the floor before you tell them what you want. An attempt by the serveDrink method to use this null reference will result in the method failing in some way.
Naughty hackers love this kind of situation. They might discover that asking for a null drink causes the serveDrink function to crash just after it has opened a bar tab, so that they can then continue to order drinks for free. They might find it serves out the most expensive drink in the bar.
As the person who is writing the serveDrink method you don't want anything like this to happen. So in the method you add a test to make sure that the argument is not a null value:
void serveDrink(string drinkName)
{
if (drinkName is null) {
throw new ArgumentNullException(nameof(drinkName));
}
// test the name and make an appropriate drink
}
The first thing this serveDrink method does is check to see if the drinkName is null. If it is null an exception is thrown which exits the method instantly. This exception may or may not be handled by the caller, that is up to them. However, we have made sure that the serveDrink method won't do anything stupid if given a null reference. (of course we now have to worry about the issues that might be caused by this method throwing an exception thougth - welcome to the world of error handling).
What the bang bang operator does is make the above test for us automatically.
void serveDrink(string drinkName!!)
{
// test the name and make an appropriate drink
}
In this verson of the code an exception is thrown if drinkName is null. I don't have to remember to add the call. This might make my programs slightly safer. But it also means that readers of the code need to understand what !! means in this context. They might look at it and think that the drink is very important, or hot, or something else. They might not know what it does and add their own tests for null which don't do what they expect. Hence the debate.
My opinion? I split language features into two categories. Cake and icing. This is definitely icing. I'd never use it personally, as I like my error handling code to be very visible to someone reading my programs. Plus I don't like situations where readers need to know "special stuff" to make sense of what they see. However, it's not a thing I'd stress about too much either way. I just love the way that C# is still striving to move forwards.
You can find out more about this proposal and the debate here.
I’m playing with some ideas for the introduction to an update of the C# Yellow Book. I don’t want people to end up thinking that a developer writes programs. I think a good one does a lot more than that:
I like to think of a developer as having three heads. I think that to be a good developer you should be capable of wearing any of these heads, although you will probably be better with one head or another. If you are working in a team, you might find that team members gravitate towards one particular head, but everybody should know what the heads do. The heads are:
This head is friendly, approachable, and constructive, but not above asking hard questions about what should really happen or why something is being done the way it is. This head is good at writing things down and then showing them to people to make sure that everyone agrees what is being made. It has a twin - the "This is what I'm going to build" head which is used when you are making something for yourself.
When you first start programming you don’t use this head very much because the things that you do are set out as exercises for you to have a go it. However, if you can get good with this head it will vastly improve your usefulness as a developer.
This head is good with technology. It can take the problem definition from the first head and build a solution using software and hardware. Making it work might involve creating an overall design, breaking things into components and then making each component in turn. For a large development this head might have to assemble and manage a team of people. Testing will form a big part of the process; this head is very keen to be able to prove that it has made something that works. This is the head that most people think developers wear all the time. I think it is the hardest head to learn to use because when you are learning program it is very difficult to know where to start when confronted with a problem and asked to make something that provides a solution.
This head is a bit of a worrier. You might think it comes into play once the "Make something that works" head has finished but this is not quite how it works. This is a head that you pop on every now and then to look at how things are going. It's the one that asks the hard questions when finding out what is wanted. It's also the head that looks at a solution and worries about things like reliability (are there things that can go wrong), security (can the system be successfully attacked), scalability (what happens if we get lots of users) and business (can we be sure we are going to get paid for all this). This head really wants to make something good, but it also has a sense of perspective and is happy to negotiate what "good enough" means, as long is that is written down and everyone agrees about it.
In a team the heads can turn into different roles for team members. Whatever happens I think it is really useful if a developer stops every now and then and thinks “I wonder what my other heads would think of this?”.
We’re holding our first in-person meetup event of 2022 next week at the Makerspace in Hull. At this event we are going to take a look at what a thermal camera can do for you. Brian has got one running into a Raspberry Pi and has been doing some tests.
Of course we’ll be bringing along other bits of hardware to talk about and you are welcome to bring yours too.
If you’d told me thirty years ago that I would still be doing Red Nose Day lectures in Rhyme in 2022 I’d have said “Who are you?” and “Why can’t you tell me anything useful like ‘Buy Google Shares’?”
But that’s by the by. I’m doing it again, sooner than I expected. For now, just make a place holder in your diary and get ready to flex your wallet a bit. This time I’m going to tell you some Genuinely Useful stuff about how the web works. You don’t need to know how to program, or anything much about computers. But by the end you’ll know a bit about how the web works, have played a silly game and heard more cheese puns that you really want to.
Keep coming back to here and I’ll update you with progress, including the all-important link where you can donate your socks off.
Not bad for around twenty pounds
The thermal printer I ordered a while back has arrived. I’ve been playing around with it. What I want to do is control the printer over Bluetooth from an ESP-32 device. Then I can see about getting an ESP-32 with a camera and getting pictures off that and into the printer. First thing I did was fire up BLE Scanner for the iphone and take a look at the services provided by the device. I used this to send some ASCII codes to services I thought might work (you can do this with the program - it’s great fun) and managed to get the printer to print out “hello”. Which was nice.
Then I went to the source code for my Furby Bluetooth connection program and modified it to use the services that the printer supports and managed to make that print “hello” too.
Then, as I was rolling up my sleeves to start building the printer control software it dawned on me that someone else might have done this before. And someone has. He’s called Larry Bank and you can find his splendid library here. I had to make one tiny change to his code. My printer has the name “MPT-II”, which was not on the list of the printers supported by the driver. I fixed this (in a way that I’m not particularly proud of) by editing the file Thermal_Printer.cpp in the src folder for the library installation and changing the first printer name in the list to MP-II. It was on line 59 of the file in the version I was using.
const char *szBLENames[] = {(char *)"MPT-II",
It works a treat. The library is very comprehensive. It can do different sized text, barcodes and even print images. The next thing to for me do is to get an ESP-32 device with a camera and discover how to get images off it. However, if you have Arduino app which you just want to use with a printer this is a very self-contained, cheap and portable way to do it.
So, I’m loitering on this forum and Tamás was asking if anyone had any tips for first time technical writers. I sent an email response and then I decided that the whole world should have the chance to read my words of wisdom…..
I’ve written a few books over the years. I can confirm that it is not a way to get rich, but at least it is a hobby that doesn’t run at a loss. I’ve self published and used a publisher.
It is surprising how many typos get through when you self-publish. You have to work really hard (and show your text to loads of people) to get the same level of mistake detection as you get from a good copy editor.
A good technical editor adds a huge amount to a text. If you are self publishing see if you can persuade someone to take this role. Perhaps offer to pay them with a signed copy of the book. Or a nice piece of cheese.
Lots of pictures can make your book file large and unwieldly, but to the reader opening a book and seeing a pair of pages of dense text can be a bit demoralising. Settle for diagrams and cropped screenshots that might be less version sensitive.
Don’t be afraid to talk directly to the reader. When I started out I tried really hard to put things into the third person for no good reason. It’s painful and people don’t like to read it. Address the reader as “you”. Have a conversation with them. And for projects you can say “We are now.....”
Never say something is easy. It trivialises the point and makes the reader feel stupid if they don’t understand it. Instead tell folks how powerful the technique is and how useful it will be once they get it.
Context is key. Don’t tell the reader how a for loop works, tell them the situations in which a for loop would be useful, with a side order of when not to use them and how they can go wrong.
Readers love narrative. If you can make the text into a story or journey that will be a huge win.
Round things off at the end and provide a trajectory for the reader to take what you’ve told them and go further.
Use verbs in chapter titles – “Make a whatnot” is a quick way of setting a context. Just giving the name of a tool or technique as a heading won’t help the reader as they don’t know what it is. If you want to name the technique say “Make a whatnot with a whatsit”
Treat your first pass of the material as the “ore” that you you’ve mined. You then have to refine it into the finished content. Don’t be afraid of making huge changes at this point. You might have to rearrange or dump large sections until it feels right. I find that I have to “go and live” in a chapter for a week or so until I’m happy with the sequencing and content.
I went to a session about writing a long time ago and they talked about “Killing your favourite children”. By that they mean that you might have a chunk of text that you really like the look of, but it doesn’t really fit the context of the piece that you are writing. In that situation you need to dump the text that you love.
Never really throw anything away. I keep a folder called trash where I put stuff that didn’t fit (see above). Maybe it will come back as a blog post or in a different section.
Look at writing tools. I’m playing with something called Scrivener (https://www.literatureandlatte.com/scrivener/overview) which I quite like. It makes it very easy to organise and sequence elements (which can be given separate synopsis sections). It also has very advanced output options where the same text can be compiled to generate different output formats. I’m hoping that it will make it easy to make epubs, word documents and html pages. It’s looking promising so far...
Treat what you have written as collateral that you can always find an outlet for. This email is going to turn into a blog post 😊 - and it did
Rob Miles is technology author and educator who spent many years as a lecturer in Computer Science at the University of Hull. He is also a Microsoft Developer Technologies MVP. He is into technology, teaching and photography. He is the author of the World Famous C# Yellow Book and almost as handsome as he thinks he is.
Begin to Code with JavaScript is now available for purchase and download. You can find it here