<div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I agree with James but I&#39;ll be more specific, how about this...<br>
<br>
UserRepository class&gt;&gt;forApp: anApp<br>    ^ (Repository ifNil: [Repository := Dictionary new ])<br>        at: anApp ifAbsentPut: [ GDRepository for: ANUser ]<br>            <br>
<br>
ANComponent&gt;&gt;initialize<br>    super initialize.<br>    userRepository := UserRespository forApp: self session baseUrl printString.<br><br>No need to stick the repository on a component class, create a unique class just for it, you get an automatic singleton because classes *are* singletons and why shouldn&#39;t a user repository be its own abstraction?<br>
<font color="#888888">
<br>Ramon Leon<br><a href="http://onsmalltalk.com" target="_blank">http://onsmalltalk.com</a><br>
</font></blockquote></div><br>Or even better...<br><br>
ANUser class&gt;&gt;repositoryForApp: anAppName<br>    ^ (Repository ifNil: [Repository := Dictionary new ])<br>        at: anAppName ifAbsentPut: [ GDRepository for: self ]<br>            <br>

ANComponent&gt;&gt;initialize<br>    super initialize.<br>    userRepository := ANUser repositoryForApp: self session baseUrl printString.<br><br>Let the ANUser class itself hold the repository for all its instances for all entry points.  Then you don&#39;t have to think as much, you just establish the pattern that a repository for any class is on that class.  This works for prototyping in Squeak/Pharo and in Gemstone works as an actual production solution because it&#39;ll automatically be persisted.<br>
<br>Ramon Leon<br><a href="http://onsmalltalk.com">http://onsmalltalk.com</a><br>