6 Replies - 4123 Views - Last Post: 13 February 2011 - 03:56 PM Rate Topic: -----

#1 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,498
  • Joined: 29-May 08

C#'s Greatest Mistakes - a session at Øredev 2010

Posted 12 February 2011 - 02:32 PM

http://oredev.org/20...eatest-mistakes
Is This A Good Question/Topic? 2
  • +

Replies To: C#'s Greatest Mistakes - a session at Øredev 2010

#2 Martyr2  Icon User is online

  • Programming Theoretician
  • member icon

Reputation: 4421
  • View blog
  • Posts: 12,286
  • Joined: 18-April 07

Re: C#'s Greatest Mistakes - a session at Øredev 2010

Posted 13 February 2011 - 01:56 PM

Great video Adam for sure! Now I would be one of the ones to argue for keeping classes unsealed by default over forcing no default and having the programmer specifically say which they want. The reasons I have are...

1) I am lazy and don't want to have to make that decision for each class. Perhaps I am giving someone an example or perhaps I am "hacking" away on code seeing where it takes me. I don't want to have to keep putting it in.

2) While I agree we should really make programmers more responsible for their code, we should always try to keep programmers from guessing what their code might be used for in the future. We should always strive for making our code flexible enough that any future programmer can take it and run with it. Putting it as sealed is just going to force some other programmer to code their own, work around our sealed class, or unseal our class and then extend it. Why give them that much trouble? We would hope they unseal it and extend, but can you imagine if they coded some bad work around?

So by making it unsealed by default we stay out of their way while also making it easier later for programmers to modify and draw their own conclusions from our code. Am I saying get away from sealing classes? No, you intend it to be sealed so you seal it. I would see it and immediately think "Yes, they meant for this to be sealed and I wonder why". Otherwise I can always rely on the fact that any class can be twisted to my own bidding.

But anyways... too bad he was cut short on time. Again, great video. Thanks! :)
Was This Post Helpful? 0
  • +
  • -

#3 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,498
  • Joined: 29-May 08

Re: C#'s Greatest Mistakes - a session at Øredev 2010

Posted 13 February 2011 - 02:53 PM

He seem to me, not to understand that ToString() is overridable and overloadable. Using that a conditional compilation that you can have a ToString that is different during Debug to what it is during Running.
The default value of a that method is it's fully expanded class name.

To me, the language he is after is very close to Nemerle.
Was This Post Helpful? 0
  • +
  • -

#4 Martyr2  Icon User is online

  • Programming Theoretician
  • member icon

Reputation: 4421
  • View blog
  • Posts: 12,286
  • Joined: 18-April 07

Re: C#'s Greatest Mistakes - a session at Øredev 2010

Posted 13 February 2011 - 03:17 PM

No what he was suggesting is to keep the idea of a default toString from being defined in Object itself. Thus forcing people to create a toString for their objects since toString in Object really does nothing of value but to provide debug info. So he was suggesting renaming it or simply removing it. His overall argument was that Object itself is bloated with methods that 99% of the time are not used or overridden anyways... especially since now they have generics which was not available in C# 1.0.

I got what he was saying and it somewhat is bloated, but considering other classes in the framework, Object really doesn't have too much bloat. equals for sure could be kicked out because when does anyone ever use the default version of Object.equals when normally they create their own comparisons using a IComparable etc in a Generics setting.

But it is what it is, C# has done a lot of things right and most of what he was picking on was the beginning of a language that is simply aging. Languages age and with that comes baggage from earlier versions. Especially if you are like Microsoft and make backwards compatibility a priority. Nothing you could do right now without drastically breaking some code out in the wild.

:)
Was This Post Helpful? 0
  • +
  • -

#5 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,498
  • Joined: 29-May 08

Re: C#'s Greatest Mistakes - a session at Øredev 2010

Posted 13 February 2011 - 03:39 PM

If you're forcing to implement a .ToString() and they don't what would the debug value be?
Was This Post Helpful? 0
  • +
  • -

#6 MATTtheSEAHAWK  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 137
  • View blog
  • Posts: 782
  • Joined: 11-September 10

Re: C#'s Greatest Mistakes - a session at Øredev 2010

Posted 13 February 2011 - 03:49 PM

I a not sure maybe just the class name or type name?
Was This Post Helpful? 0
  • +
  • -

#7 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,498
  • Joined: 29-May 08

Re: C#'s Greatest Mistakes - a session at Øredev 2010

Posted 13 February 2011 - 03:56 PM

If that is so, then keep .ToString() in Object and then override.

This post has been edited by AdamSpeight2008: 13 February 2011 - 03:57 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1