Month: November 2007

Rails Yet To Make Dent in the Enterprise?

Managed to post this twice becuase their system would’t let me log i … 

http://www.adtmag.com/article.aspx?id=21641

> Absence of sophisticated IDE/Debugging tools – Eclipse/IDEA/MS-Visual Studio excel in this realm. Rails IDE has a lot of catching up to do.

The NetBeans Rails tool (free) has all this, as does 3rd Rail (paid for and excellent) and there are at least 2 Rails plugins for Eclipse – wake up!

> 4. Due to its scripting nature and other things, it could not handle large volume of requests as gracefully as other frameworks. It allows developer to write working but incorrect code since there is no strong data types.

Have a look at what Bruce Eckel (author of classics “Thinking in C++” and “Thinking in Java”) has to say about strong types vs. proper testing – he now advocates Python and test frameworks. Strong typing is only half of what needs to be tested, and the least useful half. The Rails philosophy is BUILT on agile methods, constant testing etc. and it’s really easy to do. You must have forgotten this. One lone developer making a mistake is a ridiculous argument – we don’t work that way on big projects – no-one does – and strong typing gives you a false sense of security.

Java is an interpreted language too, you know, and people used to say exactly the same things about performance. Ruby 1.9 is significantly faster than 1.8, JRuby is also pretty quick. Rails 2.0 has lots of performance improvements, mostly based on getting HTTP efficencies that Java folks need to look at too.

Twitter and the Human Genome project are both built using Ruby on Rails – they are huge and don’t have a problem. “Rails does’t scale” – rubbish, do some research.

RSpec gotchas with exception handling

If your code throws exceptions then beware that RSpec uses exceptions to talk to itself, if you catch exceptions then beware that you could be masking the error RSpec is trying to report.

If you’re staring at something that you know should be working, comment out the rescue section and see if it tells you more.

Have fun.

Department of the obvious says …

Posted here on Sticky Minds:

The interfaces are part of the list of deliverables, surely? I can’t see why this is’t just a restatement of the obvious. It’s where all the effort used to go in the old days, e.g. if you were putting in Oracle or SAP.

Sounds like an old, old lesson needs to be relearned again. And, of course, if you are using the orthogonal UML models: Use Case/Interaction/Class you should have seen this coming if you were paying attention.

Of course, all of the old PM’s that knew this stuff have been fired because they were “too expensive”. Now we know why they were … they don’t make beginner’s mistakes like this.

SOAP idiocy – do not use it to send XML strings

I’m getting really tired of this:

SOAP – used to stand for Simple Object Access Protocol. Apparently it does’t any more but who cares?

In essence, create a complex object, marshal it into XML and send it down the wire.

This means you can do stuff like:

myObject = SoapObject.new
myObject.person = “James Smitt”
myObject.addresses[0] = “1313 Luck Street”
myObject.addresses[1] = “667 Beastie Neighbour”
myObject.employer = “Big Bang Burger Corp.”

(etc.)

Then, you can send it down the wire. The receiver of the object has everything nicely laid out for them and they can interrogate the object to get the fields back etc. All done for you by the SOAP framework. This is really easy. You just generate the object wrapper from the WSDL, and this is why there are version numbers in WSDL so you get the right object back.

Oh no, virtually every person I’ve had to deal with recently uses SOAP to send an XML string.

Why is this a bad idea?

First, the string has to be escaped so it won’t mess up the SOAP message.

Second, it has to be parsed at the remote end, which may not work because some dimwit put an ampersand somewhere (it’s data – they’re everywhere).

Third, you have to think about the XML object, maybe use stuff like XPath.

Fourth, while you can return an object (if you are the server) that has useful stuff like error messages or resultant ID’s in it, you probably won’t – just another XML document that again has to be parsed and so on.

This drives me nuts, it’s a lot more work to use, it is’t an API. If you want to send XML just use an HTTP post … why complicate it??

Look:

1. Create a complex object that wraps your data requirements, it can be hierachical, have arrays of things in, all sorts.

2. Fire your IDE of choice at this object and generate the WSDL

3. Use the technology like it was supposed to be used.

XML is witless and difficult to use on its own, as a means of marshalling complex objects it’s fine – but get the framework to do it; it’s been debugged and worked with by thousands of people.

Effectively, rolling your own XML description is reinventing the wheel every time. Let the framework do it.

Sigh.

Addition 27-Nov

It’s also easier to test your complex object and put validation in around values of fields, rather than trying to parse an incomplete XML document and just throwing some meaningless exception.

Goating

Goating 

Swap the M and N keys round …
Then turn co-worker’s drawer unit round so the back is facing them …

Then try not to laugh too hard when they realise what’s happened and go for their penknife in the drawer to lever the keys off …

Ghost mouse …

Tie a piece of string to their mouse and move it as they reach for it (don’t do this if co-worker has a weak heart).

And the universal yellow sticky on the bottom of the mouse so the laser can’t see any movement… removing ball from old-style mouse

Swap co-workers mice and keyboards around …

I don’t do this stuff any more because I upset someone too much and did’t want to do it again. But if you’re in the mood …

State of digital software distribution

 Comment here 

The problem is – if you start charging less than the recommended retail price the retailers are going to stiff you and stop stocking your product. They have to make a living too. So the only thing you can do is charge the RRP. Then the discounters are going to come in under that price. Very difficult to get around.

Can you imagine the howls of protest from the retailers with shelves and shelves of DVD’s and CD’s if Microsoft started charging, say, 50% less for the download? And quite rightly – very unfair and MS get to keep it all.

So, maybe drop the RRP and take less of a cut to get the price down for everyone? Hmm … pigs might fly.

Response to the vagueware blog

Comment left here:

I have a work laptop that has XP Pro SP 2 on it. Windows these days is’t bad. It very rarely freezes. My main problem is actually with Netbeans Nestor which I use for Rails development and is OS/Free and locks up at least twice a day, which I think is a problem with Java VM’s walking off the end of the pier. I stick with it because the only other choice is a poor Textmate clone called ‘E’, which, like Textmate, is a word processor pretending to be a proper development tool, but very Mac. Netbeans is miles ahead and runs on any platform with a Java VM.

Windows is’t that bad to develop on if you have plenty of memory and Cygwin and the Gnu tools installed. Free does’t mean good, necessarily. All I care about is whether things get in my way or not. That said, all our servers run Ubuntu or Redhat. So yeah, if I had a choice I’d run Ubuntu with the sexy 3d desktop, but I’m pretty effective with windows/cygwin/Gnu DOS window.

Apple, to me, are a bit like BMW – you drive one and say, yeah, nice car. But do you really want to pay the 20% premium?

Also, you have to do everything the Apple Way – with windows and Ubuntu there are lots of free/os bits you can add in to make it easier – if you want to. I’ve got my Windows machine looking very Apple-like with tools like Snarl popping up when I run autotest and so on. But I can choose what I want – Apple don’t decide for me. That, I like.

I’ve never played with free BSD – but worked a lot with Solaris 1, which was basically BSD, so I recon I’d get on well with it.

There’s a site that does reconditioned Thinkpads with Ubuntu preloaded. A similar spec to a tasty Macbook is about half the price. That’s where I’ll be looking if I need to buy a machine of my own.

Response to Coding Horror: Embracing Languages Inside Languages

Comment left for

Embracing Languages Inside Languages

The “sql is different across platforms” argument is pure nonsense. If you stick to the ANSI syntax it will work across MySQL/Oracle/DB2 and most of the others.

If you use something like Oracle avoid decode() and the (+) operator for outer joins – the standard syntax will work.

Stick to the standards and you’ll be fine.

I code in Ruby on Rails these days and use ActiveRecord for most of my database needs. Interestingly, the design goal for this was to make the simple stuff really easy (finding things, getting sets of child records etc.). But you can still put raw SQL in for more complex tasks that can’t be expressed in Object crud. This works really well.

Ruby’s metaprogramming makes it really easy to implement ActiveRecord, it has a method_missing method that allows it to intercept things like

Person.find_by_first_and_last_name “fred”, “smith”

and turn it into SQL (and also add this method into the class on the way so there is’t any runtime penalty after the first invocation). You can write really fluent-looking code that reads well, and also dive into SQL for grouping and so on (or proprietary hacks) if you must.

I can’t go back to Java and have never had to work with its child C#. I can just write code that reads like English. If I were going back I’d use Hibernate though – again it does the 95% really well and you don’t have to care about your database engine.

Regular expressions are part of the Ruby language and are first-class members of the object hierarchy. Working with them is really easy and they have the standard syntax. Again … Java … C# … shudder.