More about methods, it’s inspired/spurred by a comment on methods, public_methods, and private_methods by Pit Captain. It also corrects some misconceptions I had (and may have (wrongly) given others).
I’ve added a new category, “eating crow” for this and any other postings where I step back and re-evaluate my posts. This is [...]
Ruby’s Object has a method, methods. You can use it to see the methods which an object has. Sort of. In this post I’m examining methods, public_methods, and private_methods as well as some of their implications.
I have a neglectful relationship with inject. That is, I neglect to remember that it exists, having worked for so long with other languages which are “unfamiliar with the concept”. Amos King’s blog entry on Inject & Me - BFFs got me to thinking that ucat (see cat on steroids (or cat on [...]
I got to thinking about SuperIO and how it could be used as a swiss army chainsaw to open files, whereever they might be on the net. From there, my fevered mind got to thinking about cat and how the two could be used together. That said, I present ucat — a universal cat, if [...]
The Pragmatic Programmers have proposed that developers learn a language a year. I agree that it’s very important to keep abreast of changes in IT and that by learning new languages we can keep our minds sharp and bring new ways of doing things into old languages. However, I have to wonder if this learning [...]
Today’s thought for the day from A Word A Day is:
Not being able to govern events, I govern myself.
-Michel de Montaigne, essayist (1533-1592)
This struck me as being very much the idea behind defensive programming. Because we don’t know what sort of events life will throw at a programme, we need for it to be robust [...]
In the quest for simplicity and maintainability, sometimes we need to add components. It seems counter intuitive, perhaps, but sometimes it’s true.
As an example, I once came across a project which had multiple queries, each of which contained over 40 lines of SQL code. I don’t know about you, but 40 lines of code for [...]
Yesterday, I posted an article entitled Break my code, please, wherein I posted a very fragile piece of code, with the challenge to find ways in which to break it.
What follows is a discussion of the code and why it is bad/fragile/easily broken…..
There’s a number of things we can should take into account when writing code — boundary cases, etc., that can make or break a programme. Yes, testing is important, but I think that developing good defensive programming practices is even more important. That said; I present the following, fragile, code. Just about every line has [...]
22 Aug, 2008
Posted by: Matt Williams In: ruby
One of the (imho) lesser used pieces of the Ruby language is ObjectSpace. In this article I’ll show one of the things you can do with it — get all the subclasses of a class.