Re: [IMP-users] A remark concerning software design and the get_leaves() function
To: Help and discussion for users of IMP <>
Subject: Re: [IMP-users] A remark concerning software design and the get_leaves() function
From: Benjamin schwarz <>
Date: Sat, 31 Jul 2010 10:16:44 +0200
Reply-to: Help and discussion for users of IMP <>
It perfectly makes sense to me now, thanks for your answer.
--Ben
> The motivation is the "principle of least privilege". Basically, since the get_leaves() method doesn't need to do anything other than call a bunch of public methods on Hierarchy (eg get_children() until we reach the leaves), it doesn't need to be a member. And since it doesn't need to be a member, we don't make it one. The benefit is that doing this reduces the amount of code that is tied to the implementation of the Hierarchy class (that is, if we change how Hierarchy is implemented internally, we know we don't have to change get_leaves()).
>
> The other advantage is that people who don't have access to Hierarchy code can add methods that act similarly (eg, get_leaves() and get_my_special_nodes() are both used the same way).
>
> But yes, it does add a bit more to remember over having everything being a member method, and so isn't strictly better than having it as a method.