We are moving. View our new website for Risk Engine development here

Engineering for the real world

Review of Numbers '09 for engineers

When Apple first released iWork '08 I immediately reviewed Numbers. I love the way that Excel and other spreadsheets have changed the way that engineering calculations are carried out, but over the last 10 years very little has changed to the humble spreadsheet. Apple finally decided to change the spreadsheet application with Numbers, but when I reviewed it the first time, there were a few problems. I couldn't use iWork for all my spreadsheets because of problems with the plotting and a lack of easy scripting support. So for iWork '09 have my wishes been answered?

The first thing I tried as importing a two existing spreadsheets. The import is now, near perfect. The problems last time included custom cell formats disappearing, problems with the graphs and missing spreadsheet functions. Now the only errors that pop up when importing a spreadsheet are only relatively minor issues such as defining plot areas. On top of all this, Numbers now seems to run at a similar speed to Excel when running the larger spreadsheets used in engineering.

One of my biggest requests was better graphing. Good plotting of x against y data was not possible in the previous version of iWork. The latest version allows x and y data as well as labels to be referenced to spreadsheet cells. This totally changes the form that graphs can take and allows the user to create most of the key types of graph. Log scales can now also be use on both axes.
pastedGraphic

Both data series for graphs and formulas use a new format with coloured labels with attached drop down toolbars. These drop down menus don't add much functionality but they really do aid the reading of an equation more than the simple colouring currently used in Excel. ultimately I'd like to see an improvement to the way brackets are used in the formulae to make them even more readable, but this is another good incremental improvement.
New formulae

The other new feature included is the formula list. The formula list is a complete list of all the formulas in a spreadsheet including a cell reference, a result and details of the formula. The list also includes a comprehensive find and replace feature. I'm not sure that I will use this feature much, but occasionally it might be useful to run through a spreadsheet to check for odd formulas in a series. It might also prove to be a useful to to review how spreadsheets work, allowing a viewer to quickly look through the types of formulae being used. What might be more useful in the future is this view to take on another form where the spreadsheet is set out in a graphical or flow chart way so that a review can easily see the flow of information through the chart. I know this type of view would have helped me in the past where previously I only had Excels formula auditing feature to help.
Formula list

There are many new functions that have been added to the latest version of Numbers. Whilst many of the new functions are fairly specific and of limited use to the general user, the new statistical distributions will be useful to many engineers. Statistics seems to becoming more and more important to engineers as time goes by so the inclusion of a comprehensive range of distributions , including Beta distributions, Binomial distributions, Gamma distributions, Lognormal distributions, and T distributions, is a really useful feature.

The other key feature request I originally made was the inclusion of an Applescript dictionary. This would allow other features to be included in the spreadsheet, such as Monte-Carlo analysis. Brilliantly Apple have also done this. All iWork applications now have an Applescript dictionary which makes then scriptable. Analyses such as a Monte-Carlo analysis can now be undertaken using Numbers. Numbers really is now the only spreadsheet an engineer will typically need.

I can heartily recommend a trial of the new version of Numbers in iWork '09 if you use spreadsheets regularly in your working life.


Reflections on the Quarterback problem

I never seem to read a piece by Malcom Gladwell without seeing reflections from all over my life. His latest article in the New Yorker is a fascinating piece about finding the right talent to do a job. One of the main thrusts of the piece is that, provided you can find the talent, the right people in the right positions can make a huge difference. This is probably best summed up in this section:

'Eric Hanushek, an economist at Stanford, estimates that the students of a very bad teacher will learn, on average, half a year’s worth of material in one school year. The students in the class of a very good teacher will learn a year and a half’s worth of material. That difference amounts to a year’s worth of learning in a single year. Teacher effects dwarf school effects: your child is actually better off in a “bad” school with an excellent teacher than in an excellent school with a bad teacher.'

I suspect this is no different in many other human endevours. Recently, my Mum had to go into hospital for a hip operation. I spent a few days in the hospital with her and we often chatted about doctors. She had been talking with some doctors whilst she was in hospital and one of the problems that some of the doctors have is that they are actually held back by other doctors. Some of the most talented surgeons can complete a number of operations a day by taking a factory approach and quickly moving from one to the next. Other surgeons claim this is not an appropriate way for work to be carried out and think that each surgeon should only carry out one operation per day. I have no doubt that the most talented surgeons could safely carry out multiple operations in day. But equaly, this is not an approach that will suit every surgeon, whatever the level of skill, and creating a more open and flexible system will inevitably lead to some surgeons causing more problems.

So we are left with a dilema. One approach is to create systems that enables the most talented and skilled individuals to do their work to the best of their ability. But how do we identify the most talented and how many problems would this cause because the system does not suit those who are less talented or not in a position that suits them? The other way is to create a tightly controlled system based on those individuals who are not the high fliers but which ensures that everyone can perform safely.

Arguabley a shining light of a company that enables talent is Apple. Although always an issue that provokes debate, few can argue that Apple is one of the leaders in software design, hardware design, in profitability, in marketing and in many other areas. One of the keys to their success must be having highly talented individuals do the right kind of work, Steve Jobs is a consumate figurehead for the organisation, Johnathon Ives is one of the most talented industrial designers in this generation and Tim Cook is widely praised as a COO. Apple enables the people with talent to deliver. Very infrequently does Johnathon Ive ever do anything but industrial design, and yet in other companies he might spend so much time as a figurehead so much that ultimately he might have little impact on the final design.

Enabling talent then clearly works, but where does that leave the rest of us? I'm not saying that only the elite few humans are talented, because it just is not true. Every person I have met has a unique combination of skils, experience and personaltiy that means that they have much to give the world. But so often people are not in positions where their talents can best serve. Sometimes it is timing, sometimes our personal situation intervenes, and sometimes we just need kick back and relax taking a back seat for a while. As human beings we don't want to be immediately replaced by someone else at the slightest indication that there is someone who might perform our job a little better. We need a little security in our lives. A world dominated by skill and talent, or at least percieved skill and talent, would probably be more like city banking with high rewards but equally high risks. I personally would prefer a world not so 'red in tooth a claw' as this.

It might not be the right thing to have a world dominated by talent alone, but surely the world could do with more people having their talents enabled. All to easily we can take a walk down the street and see poor design, poor management and poor delivery, things that have clearly come out of a system based on the lowest common denominator. The world could be so much better if those with talent, in the right position at the right time were not held back as they can be today. Today our risk and reward system is dominated by industry and hard work. Everyone can choose to work harder, and so by having a reward system related to our efforts, everyone gets an equal shot at the reward. But this does not reward ultimate delivery. Gladwell's teaching example clearly shows that some people can deliver a product 3 times better than others in the same job, and I suspect this is a cautious estimate.

We need to change our view of human industry and start rewarding people more for working in the right way rather than doing more work. We need to give people more and more opportunities to find and use their talents so that the fear from more flexible working is outweighed by the potential for people to find the right work for them. We need to find better ways of meaasuring talent so that the most talented can be picked out. The world has much to learn from the most talented individuals. Why are they so good at what they do and what can we do to enable them and the others that follow to do their work better.

Whilst the 20th centruy might have been the centruy of industry, I hope that the next century is the one where human being, as a social entity really does start to work smarter rather than harder.


Example Cocoa code

It always seems odd how it is difficult to find examples of the application you are working on. For me, just starting to learn Cocoa, tutorials and example applications have been the key to my learning. But for some reason you can never find the right tutorial to sort out the problem you are working on.
With this post I'm releasing some of my code into the wild for those new to Cocoa development. I'm not going to claim that the quality of the code is great and it doesn't really do anything very special, but it is out there and might help a few people solve some of the more basic problems that I had to initially deal with.
For the record, the application is designed to do some basic analysis for a tunnel, estimating the Fenner-Pacher curve. Some of the key Cocoa concepts in the application are:
  • Use of Core Data
  • Use of triggerChangeNotificationsForDependentKey for automatically updating data
  • Creating a graph which automatically updates using tableViewSelectionDidChange
  • Performing mathematical and engineering calculations
The method for creating the graph is based on the delegate method which is used in Step into XCode Mac OSX Development (for OS 10.4) and XCode 3 unleashed (for OS 10.5) by Fritz Anderson. A tutorial by Tim Isted gives another method, using bindings, to create automatically updating graphs.

You can download my source code here.


Learning Cocoa

Over the last few months I've been trying to learn programming using Cocoa, one of the native programming languages for a Mac. It's been a tough learning curve. Until trying to learn Cocoa I've only really developed rather basic scripts with languages such as Visual Basic, Applescript and FISH. I've never had any formal training in programming so it's all been a bit of a struggle. I decide not to learn through books, even though there are few very highly rated books out there. The internet is such a great resource it seemed obvious that there must be some great tutorials out there.

Well I have to say that it is true, there really are some great resources out there. The trouble is there is no structure to it. There is no way to find out which tutorial you should start with and where you should go from there. It took me a bit of stumbling around in the dark to try and find my way around it all. I must admit that there are a few tutorials that I have done more than once and still don't understand, and that is despite the tutorials being describe as 'for beginners'. The penny has finally dropped though, I have suddenly started to understand Cocoa and that is because I happened to find a sequence of tutorials that seems to have worked. If you want to have a go at learning Cocoa, try this sequence. I hope it will as well for you as it did for me.

- The first stage is to go through an excellent short PDF manual called Become an Xcoder. This really does require no prior knowledge of C, C++ or any other language that most manuals assume the reader has. It gives the reader sufficient knowledge to understand what is happening in all the different sections of a project as well as working with basic classes such as arrays or strings.

- The next stage I would recommend is to do Apple's tutorial. To understand fully what is going on in this tutorial you do need some knowledge of the code structures used by Cocoa, but having been through 'Become and Xcoder' you should be ready for this. The one problem with Apples tutorial is that the latest version is based on Leopard and Objective C 2.0. If you don't have leopard, you aren't out of luck, there are still some examples using older versions of Xcode on the internet. This tutorial is useful because it gives you an understanding of some of the non code related issues associated with creating an application.
The latest Cocoa tutorial on the Apple Developer site
An older version of the Apple currency converter tutorial


- The next stage I would suggest is to go to CocoaDevCentral.com and go through the tutorials on the front page. These are some excellent tutorials dealing with some of the other features of Cocoa such as core data and working with graphics. Doing this will give you a fair understanding of how easily accessible some of the features of Cocoa are.
CocoaDevCentral

- Finally I would recommend looking at a larger project and taking it appart to understand how it works. An excellent example of this is a simple calculator app prepared by Apple. Being such a simple application we all understand what it needs to do, making the methods within the application much more accessible. Having been through all of these tutorials you should be able to understand what almost every line of code in the project does. You can then start adding your own buttons and code to the calculator to try out your own skills.

- Now, the world is you oyster. It is now time to start branching out to develop the type of application that you want to do. Once source I would suggest that you have a look at is MacDevNet. It includes two excellent podcasts, CocoaCast for those wanting to do more work on the basics and LateNightCocoa, a well produced series of interviews with Cocoa developers. MacDevNet

I hope this might help out a few people who are starting out or struggling with Cocoa. For a beginner it is a very steep learning curve but it will be well worth it in the end.


Version 5 of Sketchup for a Mac

Google Sketchup is a stunning application, a true example of the power of simplicity. It may not have the power of some other 3D design applications, but the simplicity does allow for the rapid development of design models.

One problem for Mac users is that version 6 only works with versions of OSX after 10.4.1. Unfortunately Google have not posted Sketchup version 5 for download. If you are using Mac OS 10.3.9 or earlier here is a version of Sketchup 5 that you can download.

Download it here


Applescript in iWork

Applescript has the potential to significantly improve many work flows. Like all programming or scripting languages it does have a learning curve, but because of the simple structures and plain language the curve is one of the easiest languages to learn. The real power of the language is its ability to interface between different programmes allowing data to be transferred from one application to another. It is also a quick way of creating similar tools to Macros that are used in Microsoft Office.

It comes as a surprise that one of Apples flagship applications, iWork, does not fully support Applescript. Neither Pages nor Numbers have applescript dictionaries associated with them, although Keynote does have a dictionary. This means that Pages and Numbers do not have publicly documented specific Applescript abilities. The good news is that this doesn't mean that Applescript can't be used with this applications.

Using the 'application' System Events you can easily control keystrokes, and occasionally buttons within most applications. To demonstrate how this is done, the following simple script is used to insert a standard reference into the active Pages document. Applescript Studio can then be used to create an interface which allows different references to be inserted all at the click of a button.

set the_text to "Hoek-Brown failure criterion - 2002 edition, 2002, E.Hoek; C. Carranza Torres; B. Corkum, Proc. NARMS-TAC Conference, Toronto, 2002, 1, 267-273, www.rocscience.com/hoek/references/H2002.pdf"
set the clipboard to the_text
tell application "System Events"
tell application "Pages" to activate
tell process "Pages" to keystroke "v" using command down
end tell


I find this script a real timesaver because I don't have to look up references every time I need to insert them into a document. All it takes is a simple click of a button.


Review of iWork Numbers for engineers

I love Apple applications, they just seem to suit the way I work. Last months release of iWork '08 was a big step forward in the suite of applications, especially with the release of Numbers. I see this application as the start of one of the biggest changes that spreadsheet applications have ever had with the use of multiple tables on a single sheet. The effect of this will not be fully realised for a few generations of the software, but I wanted to find out how the current version of Numbers works for engineers.

To do this I recreated a standard spreadsheet I use on a regular basis for designing an unreinforced concrete section under axial load and bending. This spreadsheet allows me to check all of the basic features that I need in a spreadsheet for day to day use. It doesn't include some of the more advanced features that I use, but I know that Numbers is missing scripting and advanced plotting. As version 1.0, I don't expect these features and I know that Numbers will not be able to do everything I need it to do, but hopefully this will improve with time and newer versions.

First of all, here is the spreadsheet I created.

SectionR-BarSpacing

So how did I get on?

Well first of all the separate tables. It took me a few minutes to get used to them, but as soon as I did they are much more intuitive to use. You can concentrate totally on the table you are working on, forgetting about all the others. Once you've done the work setting up the spreadsheets you can then concentrate on how to lay them out. It really helps focus on what you are trying to achieve.

What is ultimately more significant is how the table can be modularised. To test this out I added another table to the spreadsheet which took into account reinforcement in the section. It was really easy, just add the table. What this means is that a library of standard tables can be created and just bolted together. Not only is this quick and easy, but if a standard library of verified tables is created, all you have to worry about when checking a new spreadsheet is how the table have been bolted together and not whether the contents of each and every cell is correct. The whole table concept, from the way they work to the potential ability to create a library of standard tables will make far more transparent and accurate spreadsheets.

The biggest problem I have with numbers is in the graph on my spreadsheet. The amount of control that you have over the type and format of the spreadsheet is an order of magnitude worse than it is with Excel. You can create beautiful looking graphs and charts, but the options are limited. I wanted to create a straight line between the points on my spreadsheet, but could only create a series of points. It is something that I will definitely be looking to Apple to improve in future versions.

My last gripe is a well known one, but there is a lack of support for either plugins or scripting. This is not surprising as most 1.0 applications released by Apple have limited support and things do improve with time. I hope that Applescript can be added for version 2.0, because the possibility of Applescript interfacing between Omnigraffle and Numbers is well worth waiting for. Once this happens the possibilities for quickly automatically generating standard plots and diagrams will mean there is a huge step forward in my productivity.

I think numbers is a big step forward for iWork, and a big step forward for spreadsheets. I will use it, but I have no doubt excel will be my tool of choice, but I look forward to seeing what can be achieved with version 2.0.