hackergotchi
Tales from a phasmatodean man

Peter Miller is a senior software developer with over 30 years on embedded systems. He has experience on a variety of platforms and is renowned for his focus on effective software testing practises. He was one of the the original authors of the now universally used gettext internationalization infrastructure. Lately he has been writing a library to better “explain” error messages coming from the Linux kernel's various system calls.

Contact...

Twitter @PeterMillerAus

Google Plus +Peter Miller

Email 0x70405E10

RSS Feed /pmiller

Phasmatodea: Ripe Cages

I reared phasmids for 14 years. Along the way I noticed a few things that came along.  My first phasmids were, adult females of Extatosoma tiaratum tiaratum and Eurycnema goliath; well doesn’t everyone? This was 1997.

I kept a journal and notes, and I was able to pull some populations studies from the data.  I just wish the Leukaemia had left me alone for long enough to get some published papers from it.

Eurycnema goliath

When I first started rearing stick insects, I kept the two species in the same cage.  Most weeks I would sort the frass to obtain the eggs, and put them into new take-away food boxes sorted by month of laying (by the way re-using actual take-away food by washing them isn’t nearly clean enough).  The eggs started hatching, and my statistics told me that it took a properly hydrated E.goliath hatchling 9 days to starve to death. Now what was I supposed to do?

Why would they starve to death?  I watched them.  They ate the leaves, and still starved to death.  By the way having an adult or slightly more mature  nymphs, the early instar nymphs can smell where to eat in the fresh bite marks.  Maybe the problem was that they were getting none of the gut flora required to eat Eucalypt leaves.  Where could it be from?  A clue: cockroach nymphs get their gut flora from eating their parent’s turds.   Could phasmids do it via a similar route?  Maybe the environment supplies it all, maybe they get their gut flora directly from the leaves they eat.  Hang on, I had already tried that one.

The entomologist’s term for the old skin when they moult to the next instar is  “Exuviae” and it is a plural (and “exuvium” is the singular and it rarely happens in nature).  Why plural? They moult both their exoskeleton, and also their complete gut lining. When a nymph turns around to eat its own exuviae it is re-swallowing the gut flora, and also recovering some of the energy and protein. It’s a pretty neat trick making proteins just using only Eucalyptus leaves.

How to make it hard for gut-flora-less hatchlings to miss their parent’s turds.  To each box of eggs I put two parent turds, crushed into a powder, and one  fresh eucalyptus leaf.  And I stopped cleaning the cages so thoroughly, I let them “age” naturally.  Nymphs have a trick where they let go with all 6 legs and float down to the ground.  And head straight in the nearest vertical thing, usually a tree.  My success rate  with E.goliath became one of my most reliable breeding lines, for over 10 years.

This is my concept of a “ripe cage”.

E.tiaratum

At this time I had ripe “nymph” cages, and I would look for hatchlings each morning.   And I made a second adult cage, so I could separate turds and put known-correct adult turds into each egg box.  And into the nymph cages.  Once they reach about 3rd or 4th instar, I would transfer them into the adult cage.  Plenty of species-correct frass for the nymphs to fall on.

And is far easier to sort eggs from frass when you only need to look for a single shape at a time.

Other species

  • I reared Acrophylla titan for many years, they are native to my suburb.  My initial problems with this species were because, they got too much to drink and it needed to be about once a month, not once a week.
  • I was never especially successful with E. wuelfingi, no idea why, anecdotally many people I knew said you got a few generations, and then stopped hatching.  The plural of “anecdote” is not “data”.
  • I reared E.tiaratum.bufonium, they are native to my suburb. People wanted to know if they are dangerous.
  • Ctenomorpha marginnipennis, also native to my suburb, and most of the Sydney Basin. This species needs to drink more often than once a week in the egg boxes
  • Didymuria violescens. Native to my suburb. These require little help from the keeper, they are one of 3 species that can explode into plague proportions, mine didn’t much, one January I wound up with 4,000 eggs.  Sorting that lot was torture.
  • P.wilkinsonii  Native to my suburb.  There are 8 red tubercles in the prothorax of nymphs, aal mostly gone by adul except on Another potential “plague” species, but mine never did.
  • T.childrenii, native to my locality.  Originally I thought I has seeing two species, with wild caught male and separately wild caught female.  Rearing eggs throught to adult, I knew it was the one species.
  • and a few more, I’d have to dig up my old notes.

 

assignment operator swap idiom

I’ve been writing C++ since about 1986.  This post is more of a reminder than a tutorial.  One of the things I get junior C++ programmers to show me at interview, is writing a C++ assignment operator.

Problem

The C++ assignment operator is subtle, and very easy to get wrong.  If you are writing a “smart pointer” (which is neither) to manage reference counted objects, when the code explodes and blows your foot off the cause is actually several mountains away.

Note that this blog post is a restatement of the work of other brilliant people.

class example
{
private:
    int member;
public:
    ~example() { release(member)}
    example(const example &rhs) : member(copy(rhs.member)) { }
    example &operator=(const example &rhs)   
    {
         if (this != &rhs)
         {
             release(member);
             member = copy(rhs.member);
         }
         return *this;
    }
};

OK very small example, not actually a “smart pointer” but sufficient to demonstrate the solution.  This little example has some things to take note of:

  • The copy construtor’s code is duplicated in the assignment operator (bitrot: they will inevitably diverge over time).
  • The destructor’s code is duplicated in the assignment operator (bitrot: they will inevitabley diverge over time).

example::swap

The next step requires adding another method to the class, but one that is used extensively by the C++ standard library.

class example
{
private:
    // just the swap method for brevity
    void swap(example &rhs)
    {
        int temp = member;
        member = rhs.member;
        rhs.member = temp;
    }
};

Note that the swap is a shallow copy. If it were managing a reference counted object, there is no need to adjust the reference counts.

Code-Reuse

It is possible to the the swap method to have the compiler re-use the destructor code and re-use the copy constructor code.

class example
{
public:
    // just the assignment operator for brevity
    example &operator=(const example &rhs)    
    {
        example temp(rhs);
        temp.swap(*this);
        return *this;
    }
};

Things to note:

  • the copy constructor code is re-used,
  • the destructor code is re-used when destroying temp.
  • It works elegantly when faced with self assignment.

Just one more thing to note, if you are following the instance lifetimes carefully, it is possible to write this one line shorter, if the temporary is anonymous.

class example
{
    // just the assignment operator for brevity
    example &operator=(const example &rhs)    
    {
        example(rhs).swap(*this);
        return *this;
    }
};

But at the cost of possibly confusing later readers.

The Moral of Our Story

  1. Only destroy instance things in the destructor.  If you are destroying instance things in any other method, you are looking at a bug.
  2. If you find yourself writing your own “smart pointer” stop.  Use the ones from the Standard C++ library.  They are exception-proof and thread-proof.

Co-Maintainers Wanted

I am terminally ill, there exists a poorly defined window of time before my Open Source projects are involuntarily orphaned. It would be handy to use this window of time to transfer domain knowledge of my various Open Source projects to new maintainers.

The general issue is that sometimes people move on, and we often end up with Open Source projects without maintainers.  (If you know of an old answer to this old problem, that can be employed in this instance, I’d like to hear it.)

Here are the majority of my Open Source projects requiring a maintainer.

Git

The projects all use the Aegis DVCS.  The fact that the sources are not in Git may be a road-block for potential maintainers.  On the other hand, it may be enough to motivate a contributed refactoring that would allow Aegis to use a Git back-end.

I love geek humor:

You can move it to git over pmiller’s cold dead body? Might be a bit black.”

No, just a wee bit too soon.

I will have to a look at getting at least a copy of the trunk onto GitHub, for many of the projects.  If the code were already on GitHub then I am told that adoption would be repository transfer.

Tailor

Perhaps Tailor can help with this, if the necessary Aegis source-end were written. The  destination-end already exists.  If you know Tailor well, I would also like to hear from you.

From User to Maintainer

If you use a piece of Open Source software, it’s worth going further than just expecting someone else to keep maintaining it.  This how I have become a contributor to numerous projects (e.g. GNU Gettext). Many of my Open Source projects are aimed at software developers (e.g. SRecord).  Stepping up to maintainer should be relatively simple.

Seen from another perspective, only step up as maintainer for projects in a subject area you personally are interested in.  Don’t do it just because it’s a community-minded thing to do.  Projects that need them will get maintainers, eventually.

Feelings of Fraud

My transfusion schedule cuts across many of the other patients’ chemo schedules.  We get to talking, and a bit of a theme has emerged.

One of my friends has inoperable liver cancer, but most of the time she looks great, she’s still driving herself to chemo and oncologist appointments.  She lives with  the feeling that eventually some-one will jump up and yell to the world, “hey everyone, she’s’ a fraud”.

Often, when friends visit, they exclaim “wow, you look good”.  Every time someone says this, I feel like I should be out there getting a job.  I have managed to do some small and not so small, woodwork projects.  The logic goes like this, if I’m well enough to do woodwork, I can’t be so sick.  If you can make a big honking table, you can’t be terminally ill.  Eventually I worked out that this exclamation is relative to the speaker.  And usually translates to “wow, you look better than I prepared myself to see.”

Two short notes; I have to sleep or at least rest for two hours for each hour in the workshop.

Note two, without minimising the significance of the issue for my female IT colleagues, this bears a striking resemblance to Impostor Syndrome.


Material on this site copyright © 2002-2014 Operational Dynamics Consulting Pty Ltd, unless otherwise noted. All rights reserved. Not for redistribution or attribution without permission in writing. All times UTC

We make this service available to our staff and colleagues in order to promote the discourse of ideas especially as relates to the development of Open Source worldwide. Blog entries on this site, however, are the musings of the authors as individuals and do not represent the views of Operational Dynamics