[squeak-dev] How to really make portion of code optional

cdrick cdrick65 at gmail.com
Sun Aug 17 10:56:32 UTC 2008


Thanks James and Laurent,

Actually this question was more to learn is it was possible. I
remember a post about keeping or not comment in the source code...

To be more precise, it's for log output of the inference system
(http://nars.seasidehosting.st/). In each step, there can be something
like 10 lines processes depending on entities are infered. The thing
is this log output chunks are mixed in the code in several places. I
could maybe use a better trigger mechanism like sending a signal with
the entity in question, but still, there will be this message sent (or
the test). I used stream and it seems ok (regarding performance), just
wanted to know if we could deactivate some portion of code as
everything seems possible here ;). I'll remind the subclass tip
though.

Cheers,

Cédrick

2008/8/17 laurent laffont <laurent.laffont at gmail.com>:
>
>
> On Sat, Aug 16, 2008 at 10:57 PM, cdrick <cdrick65 at gmail.com> wrote:
>>
>> Hi,
>>
>> I'm looking for a way to hide/show portion of code depending on if it's in
>> development or production mode.
>>
>> First idea is to wrap the code in question around a global productionMode
>> var. But I was wondering if there is a better way. Somethink to really hide
>> these portions of code for efficiency. I know this is not a big deal (for my
>> project) but I'm quite sure something may exist maybe at the VM level, so
>> ...
>
> May be you can implement a sort of Strategy pattern
> (http://en.wikipedia.org/wiki/Strategy_pattern) in your classes, with
> XXXDevelopmentStrategy classes subclass/hook/wrap your XXXProductionStrategy
> classes to reuse code.
>
> Can you give more details ?
>
> --
> Laurent Laffont
>
>
>
>


More information about the Squeak-dev mailing list