Skip to main content

Posts

Creating star ratings in HTML and Javascript

I'd searched around a little for some shortcuts to help in doing this but I couldn't find anything satisfactory that included the ability to pull the rating off again for saving. I'd ended up coming up with this rather cheeky solution. Hopefully it helps you too! This is my first post in a while (I stopped blogging properly about 8 years ago!) It's strange coming back to it. Blogger feels very crusty and old by todays standards too.
Recent posts

Make your objects immutable by default

More about the Good Dojo In my post last week , I discussed creating objects that are instantiated safely. Please go back and read if you are interested. At the end of the post, I mentioned that I'd also written the class so it was immutable when instantiated. This is important!!! I feel like a broken record in repeating this but I am sure at the time of writing your code, you aren't modifying your object all over the place and so are safe in the belief that protecting against mutability is overkill. Please remember though, your code could be around for a hell of a long time. You aren't writing your code for now... you are writing for the next fool that comes along (including you) . Nothing is more upsetting that coming back to fix a bug on some wonderfully crafted code to say "Who has butchered my code?!", but often you were involved at the start of the process. You made the code easy to modify, allowing objects to be used / reused / modified without thi

An instantiated object should be "ok"

I've been QA'ing quite a bit of work recently and one common theme I've noticed across both Java and C# projects I have been looking at is that we occasionally open ourselves up unessacarily to Exceptions by the way objects are being created. My general rule of thumb (which I have seen mentioned in a Pluralsight video recently but also always re-iterate in various Robust Software talks I have done) is that you shouldn't be able to create an object and then call a method or access a property that then throws an exception. At worst, it should return null (I'm not going to moan about that now). I've created an example below. We have two Dojos, one is good and one is bad. The bad dojo looks very familiar though. It's a little class written in the style that seems often encouraged. In fact, many classes start life as something like this. Then as years go on, you and other colleagues add more features to the class and it's instantiation becomes a second

Derbyshire Dot Net Talk - Writing Robust Systems

I talked at the end of the month at Derbyshire Dot Net . It was a first for me in the sense that I have never delivered someone elses talk. The talk was originally scheduled to be Andrew Bullock but I had agreed to cover it. It was an interesting experience but I think the topic was general enough for anyone au fiat with the main points to deliver. Especially as I am a keen proponent on many of the points made in the talk. Anyway, the crowd was either pleased or very understanding (I'll take the former thanks) and the evening was hosted in an excellent pub called the Brewer Tap  which definitely help take the edge off any nerves I had. The slides for the talk are here: http://slides.com/trullock/writing-robust-systems-4#/   (I can't take any credit for them but I thought they were excellent slides by Andrew).

Dealing with DataTables

The nice thing about having someone join in a junior position at work is that it gives you a lot to blog (or repeat yourself) about. We've discussed a lot of subjects this week. One; was them being burned by some terrible old code that involved DataTables. There were a series of enormous (and broken) methods that accessed DataRows directly using the integer column index. There was a large amount of calculations directly on these items but the reason behind any of it was meaningless. The underlying Stored Procedure had changed causing an invalid cast exception. In light of this, I thought it might be nice to go through a bit of a process of some different options of still using ado.net and why you might choose the options what the pitfalls were. Staying on topic, we didn't opt to use an SqlDataReader which would probably be the next option to go for considering how much faster that it. We talked about speed over maintainability, but I think even when we were programming on t

Making your domain less mutable

This happens regularly to me (and from my anecdotal investigation everyone involved in large / old projects). We need a new piece of functionality. I write it, it's beautiful and I win the internet. I have estimated 8 days (or 22.23 lol-points depending on how you live) and it's only taken 4 days. Ah, but then a very small; mostly ignored and very unimportant detail rears it's cruel head. You need to make it work with the code that exists already. This is normally in the form of saving to some pre-existing entities. Oh dear. You save everything through the various management / service classes that exist already and nothing works. So begins the next couple of days of horror. You find that you didn't set the work = true . Most of my woes in this area are caused by modifications at layer further down (or the stored procedure it finally ends up in) changing the object that I was trying to save or not saving part of the object because of some rule. So many errors

My home office upgrade wish list.

My home office is almost due an upgrade. I have been holding off until my youngest daughter is out of her cot as then we can finally dispatch the enormous monstrosity of a cot out from the kids bedroom and the drawers that are in my office can be banished giving me better access to my wonderful whiteboard. My other improvements will be purchasing a new, larger monitor. I currently work from a single 22ich Samsung which just doesn't cut it anymore, I did have two at some point but I can't recall what I did with it. I really enjoy using a touch screen so I think I will go for one of these 27inch Hannspree models that I have used before. I put a lot of hours in at home and whilst I have a reasonable chair I still tend to suffer with some back problems, so my next port of call will be to get a Varidesk for home. It works an absolute treat at work and just lets me switch stuff up when I feel like it. they take a reasonable amount of desk space up but I tend to leave my desk fairly