Closed Plootie closed 1 month ago
Generally, I prefer keeping lists to the owning class exclusively and - if required - exposing them as IEnumerable or alike. This is to prevent other classes from manipulating its state.
I admit in this case I guess it would be better to expose the list as such. It's a library that helps to chat after all. If someone wants to change the messages ... why not?
Would you like to submit a pull request? I guess we could remove the SetMessages()
, too.
Understandable. Sure! I'll submit one when I'm back from holiday on Monday ^^
Awesome, looking forward! I am back on Monday too 😄
I'm curious about the design choice to have a chat's message list private and only exposed via the
IReadOnlyCollection Messages
property. For someone wishing to, for example, limit the chat messages ton
would need to do something similar to:which can be a little clunky. Are there any particular reasons why we couldn't have this field exposed directly?