Magma with style
Facundo Vozzi
facundov79 at gmail.com
Wed Dec 8 19:13:20 UTC 2010
Hi all,
I'm refactoring my code and I found that I have two ways to do the same in
distint parts of my system.
1) Entity class >> atCode: aCode
"Answer the receiver instance with code equal to aCode or evaluate aBlock if
it doesn't exists."
^(self all detect: [:one | one code = aCode]) copy
or
2) Entity class>> atCode: aCode inSession: anUserSession
"Answer the receiver instance with code equal to aCode or evaluate aBlock if
it doesn't exists."
^(self allInSession: anUserSession) detect: [:one | one code = aCode]
The difference is that 1 is using the shared session so I need copy the
object to be used (referenced by other object) on anUserSession. The uggly
of 2 is that I have to pass anUserSession as argument.
Either way works well, is really the same?
Thanks in advance,
Facu
(*) I eliminate aBlock for absent elements for this example
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/magma/attachments/20101208/9fc6b4c0/attachment.htm
More information about the Magma
mailing list