I’m reading this page
I am confused as to what is wrong with the first example. Why cannot he just add readonly to the declaration of the private fields?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The keyword
readonly(or its equivalent) is provided in some languages (for example, C# and VB.NET) but not others.C++ is an example of an object-oriented language that does not have a keyword stipulating “This can be set at any part of a constructor function, but nowhere else”.
Object oriented design patterns are meant to be language neutral: applying to all object-oriented languages.
It follows from this that some languages might have extra features which make a particular pattern obsolete.
In this instance, the presentation of the pattern appears extra silly because the pattern is introduced, then the example is provided in C# which doesn’t need it.