28 Jun 2012

Annoying! I was getting an Access Denied error when sending through requests on the Amazon MWS Scratchpad. I checked and rechecked I was sending through the correct Access Key, Secret Key, Marketplace ID etc.

Turns out I was on the wrong site! My Marketplace was in the UK so I have to use

20 Jun 2012

In some cases, I would like to use the Omu ValueInjecter's InjectFrom() to only copy source properties which have been marked for inclusion by an MVC BindAttribute. So, I've developed the following Injection:

Using that technique, the end user can update the User object's Name property without being able to overwrite the IsSuperUser property.

NOTE

It's true that MVC's UpdateModel() method obeys BindAttribute inclusion/exclusions found on the target object, so you may ask why we need to use ValueInjecter at all. However, that would necessitate the target object type to contain the Bind attributes. In our case, we want the source and target to be of different types, so that the Source (ViewModel) type has the Bind exclusions, leaving the Target type (Source's super-type) undecorated. This approach allows us to declare thin ViewModels based on underlying domain classes without having to slavishly modify our VM definitions every time the superclass definition changes.

Incidentally, by default the BindAwareInjection uses the Bind attributes from the Source, but you can use the Target attributes instead like this:

Just a quick tip. If you want to use the Bind attribute to set the binding whitelist/blacklist (include/exclude) settings, you may have seen many examples where they set the attribute in the Controller Action signature i.e.

12 Jun 2012

Thought for the day - what's so great about the Raspberry Pi?
We've had one in the office for a week and we're already bored of it.

It's not the Pi's fault, either. For me, the problem is one of ridiculous expectations. The talk has all been of a computer that was going to reinvigorate the teaching of computer science and give modern kids an inroad into the subject.

To me, that suggested that the Pi was going to be simple, as in 'so boneheaded that even I can understand how it works'. But the Pi is far from simple. It's a very cleverly miniaturised PC on a single board. Everything on the board is tiny. I really don't think the fact that the guts are exposed will help kids learn what they do, why and how.

Then when you turn it on, it's a regular PC running Linux, only running it a bit slow because it's not very powerful. Again, I don't see how this helps kids out. Linux is a powerful and complicated operating system. A kid can't learn why we need an OS, or how it works under the hood, by just booting Linux.

I guess the thing that blew peoples minds about the Pi is the price. For 20 quid, it is excellent value, for a slightly dozy linux box. But I don't believe the problem that needs solving is one of expense.

Rather, what I was REALLY hoping for was something with the instant feedback that I used to enjoy in the 1980s with my 8-bit machines. I learned to program at an early age because when you turned the computer on (Apple II and ZX Spectrum 48k in my case) it would just sit there with a blinking cursor. You typed your basic program right in on the command line, and ran it.

10 PRINT "HELLO "
20 GOTO 10
RUN

To achieve the same effect on a modern machine requires booting up, logging in, loading a development IDE, building and running. Layers of abstraction and complication. The modern OS multitasks, runs your little program in a GUI window. In my opinion, it's too much. The good old days of the black screen and the flashing cursor put you right in control. You could build up your understanding slowly.

Regarding the hardware, I would have loved to have understood exactly how my computer worked at a deep level even back in the 80s. I don't know where kids are going to get that low-level experience now. Playing with Arduino-type hardware might be a way, but it still needs programming. I seem to remember playing with physical logic gate boards at school, which I enjoyed - physical programming. I think teaching electronics at school would be fantastic - capacitors, diodes, circuit boards.

6 Jun 2012

If you use EditorFor() in your MVC View code and pass it a nullable boolean (bool?), you'll see that MVC helpfully renders a tri-state dropdown list. However, the three choices in the dropdown are "Not Set", "True", and "False" which seem a bit unfriendly to some users.

Save the following template as Boolean.cshtml under Views / Shared / EditorTemplates in your project and you'll see a more friendly widget by default.