<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'll be more specific, how about this...<br>
<br>
UserRepository class>>forApp: anApp<br> ^ (Repository ifNil: [Repository := Dictionary new ])<br> at: anApp ifAbsentPut: [ GDRepository for: ANUser ]<br> <br>
<br>
ANComponent>>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'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>>repositoryForApp: anAppName<br> ^ (Repository ifNil: [Repository := Dictionary new ])<br> at: anAppName ifAbsentPut: [ GDRepository for: self ]<br> <br>
ANComponent>>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'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'll automatically be persisted.<br>
<br>Ramon Leon<br><a href="http://onsmalltalk.com">http://onsmalltalk.com</a><br>