<div>Hi all,</div><div>I'm refactoring my code and I found that I have two ways to do the same in distint parts of my system.</div><div><br></div><div>1) Entity class >> atCode: aCode</div><div>"Answer the receiver instance with code equal to aCode or evaluate aBlock if it doesn't exists."</div>
<div><br></div><div> ^(self all detect: [:one | one code = aCode]) copy</div><div><br></div><div>or</div><div><br></div><div><div>2) Entity class>> atCode: aCode inSession: anUserSession</div><div>"Answer the receiver instance with code equal to aCode or evaluate aBlock if it doesn't exists."</div>
</div><div> </div><div> ^(self allInSession: anUserSession) detect: [:one | one code = aCode]</div><div><br></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif">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. </font></div>
<div><font class="Apple-style-span" face="arial, helvetica, sans-serif">Either way works well, is really the same?</font></div><div><br></div><div>Thanks in advance,</div><div>Facu</div><div><br></div><div>(*) I eliminate aBlock for absent elements for this example</div>