Mockaroo is a great tool for creating test data, with lots of good options as well as extensive base data. Sometimes though, you need to build custom fields. Here are a few I have used recently.
The top items are lacking in sophistication, but they do get better I think. To do – replacing random with a better probability function, and adding some more as I progress through making up more test data.
|Decreasingly likely selection’||['A', 'B', 'C', 'D', 'E', 'F'].slice(0, random(1,6)).sample||Upper param for random is length of list to select from.|
|Slightly more realistic range of Title||if field('gender') == 'Male' then 'Mr.' else ['Ms.', 'Miss', 'Mrs.', 'Mrs', 'MRS', 'Dr', 'Dr.', ''].sample end||Assumes a gender field.|
|Male honorifics||['Mr', 'Mr.', '', 'MR', 'MR.', '', 'Dr.', 'DR.', ' ', 'Imam', 'Rabbi', 'Sir', 'Prof.', 'His Honour Judge', 'Lord' ].slice(0, random(1,15)).sample||No link to gender field. Note use of blanks to make values decreasingly common as you go to the right. Don’t infer anything from the ordering especially of religious titles. If ‘Rabnbi’ is too long, you can use ‘R.’ instead.|
|Female honorifics||['Mrs', 'Mrs.', '', 'MRS', 'MRS.', '', 'Dr.', 'DR.', ' ', 'Imam', 'Rabbi', 'Lady', 'Prof.', 'Her Honour Judge', 'Lady' ].slice(0, random(1,15)).sample||Follows same probability distribution as male list.|
|Gendered Honorifics based on the above.||if gender == 'Male' then _title_male else _title_female end|
|Month names||['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'][month(__dob)-1]||Used for Oracle import.|
|Oracle date format||format(day(__dob),0) + "-" + ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'][month(__dob)-1]+ "-" + format(year(__dob),0)||Use as a formula field.|
I’m doing a lot of code reviews at the moment and thought I’d write up some thoughts on simplifying c# code.
What is simple code?
simple code is code that amongst other things
* fits on a single screen
* can be understood pretty much at a glance.
* has simple logic
* has well-understood side effects – preferably none
* often make use of LINQ.
Why write simple code?
- Simple code can be understood quickly.
- Simple code can be checked for correctness.
- Simple code can be tested easily.
When are you done?
There are tools to measure how complex your code is (google Cyclomatic complexity for examples) but for my purposes, once you have met the requirements in the first list, you’re there!
An important part of my next project involves letting people indicate whereabouts they are, but without disclosing detailed location information until later. In the UK, we have Post codes which are alphanumeric codes between five and eight characters long which broadly identify roughly where a building is. They are composed of two parts, the outward code and the inward code separated by a single space.Examples: IV51 9XB or SE22 8BS.
There are about 3000 outward codes, and while many cover a fairly small area especially in cities, others like IV51 cover several hundred square miles. Generally they are good enough for my purpose, and where the outward code isn’t specific enough I will use the first part of the inward code as well.
My plan is to use the postcode information here http://www.freemaptools.com/download-uk-postcode-lat-lng.htm to identify the centre of each outward code and use that as a proxy for wherever the user is located. From that I can calculate a rough distance to other users. Where two users share an outward code, I can identify that fact and report it to the user doing the search.
Next time: Importing the data into MongoDB.
I guess writing a blog post about traffic or planning, (or traffic and planning even!), could mark the descent into middle-aged senescence, but the state of planning by North Yorkshire County Council’s roads department is deserving of a blog rant.
Here in Harrogate, they have been responsible for the design of a new road junction, here: https://goo.gl/maps/KrJqn.
The two lane turn right at Hookstone Rd onto the A61 Northbound is a prime example of a bad and probably dangerous junction. Turning south from Leadhall Lane feels scary even in large car as it is impossible to determine if it is safe to make the turn, so instead you hold back which results in all the traffic leaving Leadhall Lane being blocked. Why NYCC decided to deviate from the usual pattern of having a right-turn lane and a straight-on-or-left lane is not something I can determine. I suspect that the first serious accident at this junction will result in NYCC being on the receiving end of a court case when the defence argues that it is the junction at fault rather than a driver.
In the past couple of weeks I have twice seen people heading north on the A61 stopping because they are confused by the red light that controls the turn-right traffic. Most days there is one car stranded ahead of the stop line in the turn-right lane. Once, there were two, preventing east-west traffic.
The left turn into Leadhall Lane is difficult for the school buses going to Rossett and Asheville – I’ve seen one have to reverse back, blocking both lanes as it attempts the corner. This is lamentably bad and even a few brief consultation with bus companies would have shown how poorly laid out the entire thing is.
Update: Car drivers coming from Hookstone Road are starting to use the turn-left only lane as a straight-ahead lane. Illegal but predicable.
Yet again, I find myself resuming blogging at the temporal boundary between jobs. I’m happy and proud to say I’m now working for Financial Force as a Lead Developer. This means I will need to be conversant with the Force.com platform, rather than .Net and Sql Server which have been my main tools for the past decade. To that end, having absorbed the truism that the best way of learning about something is to write about it, I intend to write up my Force.com development experiences on this blog. This might cover some stuff that relates to some of the other tools I will be using – Eclipse, ExtJs and my transition from Windows to OSX, at work.
I might occasionally throw in some music.
In no particular order
* I’m not maintaining a web site on http://www.hyperoceanic.com at the moment.
* All the Groove related stuff should be considered to be of historical value only
* I got a new job at the British Library, leading an Agile team that builds the systems that import the digital media (eJournals, eBooks, web archives etc) into the Digital Library System. C#, SQL Server, MSMQ being the chief skills.