I'm neither being payed for this nor trolling. I thought there might be somebody here with more experience who might be able to offer their opinion and their reasons for it.
If it is not physically possible for the name class to have a length greater than ten (I.E: it represents some specific, documented naming standard which specifies all names must be less than ten characters) then this would go inside class X. It would enforce strict requirements in the setter for the name, as well as in the constructor. In fact, in this case, you should probably be making a specific class for the name property and encapsulating the login in there (much like you would a phone number class, or a ISBN class).
If however, this is simply a requirement necessitated by external influence and not really chosen for a specific design purpose (Say, the GUI does not have space for names longer than ten characters, a legacy database stores names in VARCHAR(10) or similar) then you would not put the logic in X. The class X will still support names longer than ten characters, but the classes that need a ten character name will need to perform appropriate transformations. (i.e.: the GUI could truncate it, insert a dash and move the rest to a newline, the database could maintain a separate map from unique 10 character 'id' values to true names.
>>15
Sounds gay. If the name shouldn't be > 10 chars, then it should be in class X. The GUI shouldn't contain special cases for each input field; it should set the maximum length of all text fields as the maximum length of the variables to which they are bound.
>>19
I read it 5 times. Class X should be aware of this requirement, regardless of whether it's specified by documentation or a legacy database, as it is part of its internals. The GUI should have nothing to do with this logic, apart from enforcing a 10-character limit on input fields (having been told to do so by class X).
Name:
Anonymous2010-09-19 10:04
I would make it a char[10] and if it overruns the program crashes
Name:
Anonymous2010-09-19 10:17
>>20
What if the character requirement is GUI-specific, hmm?
>>1
Probably in class X. You want to make invalid program states unrepresentable, so don't create a data type that can hold one. That's assuming that for all uses of class X, a name greater than 10 characters is invalid.
>>20
I'm not even going to bother helping you because it's clear you are too retarded to help yourself. Rest assured however, that you are completely wrong.
>>23
Okay, given no reason aside from baseless personal attack, I have no choice but to believe you. Thank you; you have shown me how I am wrong and how I can better myself - not only as a GUI programmer, but also as a human in general.
If I were to tell you what is wrong I would basically just be quoting your entire post. If you can't see what is wrong with it, then not only do you not understand OOP, but you don't know what you don't understand about OOP and that I fear is your downfall.