From: Juergen Strobel Date: 2006-06-21T18:40:41+09:00 Subject: Re: Achieve pure object oriented design in Ruby --8t9RHnE3ZwKMSgU+ Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jun 21, 2006 at 08:48:38AM +0900, Jacob Fugal wrote: > On 6/20/06, Robert Dober wrote: > >On 6/21/06, Jacob Fugal wrote: > >> One way would be to make B.new protected/private (similar to the way > >> it's done in the Singleton mixin). But once you've done that, I'm not > >> sure if there's a clean way to allow A to use that method -- Ruby > >> doesn't have "friends" ala C++ (and I'm glad for it). Of course, once > >> it's protected you *could* have A use send explicitly: > > > >as can anyone else :( >=20 > >=20 > >If that pleases the OP I do not think the anonymous class is easily > >accessible, of course one can always create an accessor to the anonymous > >class inside A, :( >=20 > Exactly. With a language like Ruby, it's *really* hard to not let > someone do something. I simply went for removing the obvious path, but > not making it impossible. >=20 > Jacob Fugal In no language private/protected (or final) is a fool proof security measure. It is there to provide some safety nets against errors, and to help design, not for security. It is quite easy in C++ to get at any function in memory via pointers. In Java people can use AOP to accomplish this. Your most economical bet is to just document the class (or whatever) to be "private, not to be used directly" in Ruby. Sometimes the low-tech effort is simply the best, especially if any high-tech effort is going to put *you* to much more troubles than the attacker, who will circumvent it fast any way. J=FCrgen --=20 The box said it requires Windows 95 or better so I installed Linux --8t9RHnE3ZwKMSgU+ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) iQEVAwUBRJkUEvy64gyiEfXtAQJVyggAzUIlE6uw8LQ7FwWRH2wKucx3qcdi0I5P KjEJK4a+i01w6ZxUFanxPvCIdlFmwIqz4OLEyV7pRYeKkTOxsaBhc8eS0BWtgNhG tlrbkG0eXroEYvJnfNGkHAk4UEP11CA/gy6cSzioHRxHtQo8Gt5ktf+uThhHn7+Z ybSJoMNRltsK/UXc4nxQgw9g8YkNVWooo6QWYf+oqyuNenpE8NoHz5u52CrUUzx0 AoKjR9EVjZeucV5HgmF2Mgfe039A68esCSZ4Xi/3DU1rTfqlIKOaxhDrreBvgoZv ETANSNrWAX1TBe1Q/jua11nA/3tS2E/8O6oho7NJIeiAiThb20+aOQ== =G/Vr -----END PGP SIGNATURE----- --8t9RHnE3ZwKMSgU+--