Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>I cannot stress enough how bad an idea this design is.</strong> </p> <p><code>ToString()</code> is part of the object contract in .Net. If you don't want to implement it then don't override it, and just let it return the type info. What harm could that possible cause?</p> <p>I don't mean to be so negative, but I am absolutely floored that someone would want to get rid of <code>ToString()</code>.</p> <p><strong>Some additional points:</strong></p> <ol> <li><p>Why do the programmers using this class assume that <code>ToString()</code> will return an ID? Are other classes in your ecosystem doing this? One can argue that <code>ToString()</code> should return some meaningful data. But you really shouldn't be programming against the results of a <code>ToString()</code> call. <code>ToString()</code> is for a string representations of the class, period. This sounds like an education or communication issue between programmers or departments.</p></li> <li><p>Crippling <code>ToString()</code> in any way, whether you can figure out how to at compile time or by throwing an exception at run time, will have ripples. I have <em>never</em> seen this done, and would not expect any class I am using to exhibit this behavior. I think most programmers would have the same expectations. Will future programmers that use your class expect this? What bugs and maintenance nightmares are you causing down the road?</p></li> <li><p>What impact does this have in the IDE or debugger, which rely on <code>ToString()</code>?</p></li> <li><p>What impact will this have when using databinding technologies that don't bind against a specific type, but use reflection at run-time to pull out values? Most databinding will fall back to calling <code>ToString()</code> on an object if a member is not specified to use.</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload