2

My boss regards himself as a OOP Guru where as I consider him as a hobbyist programmer. He handles our Sage development, adding custom requirements to our clients Sage installations. He recently has got very excited by reflection, he is reflecting on Sage's assemblies in code and changing private members and event handlers. I thought this was not a good idea but he shot me down stating that Sage thought he was amazing that he could do it. I believed that this was bad practice because it was inefficient and because if they change their implementation at any point our code could collapse. I mean usually a developer has made something private for a reason right?

What's the general rule regarding this?

Many Thanks and apologies if this seems like a stupid question.

Paul

Paulie Waulie
  • 1,690
  • 13
  • 23
  • 1
    Well that depends all on how crappy (or good) the Sage API is. Sometimes you are forced to do silly stuff. – leppie Sep 01 '10 at 10:35
  • 6
    his abuse of reflection *slightly* contradicts with OOP Guru title. – Andrey Sep 01 '10 at 10:36
  • @Andrey: +100 for that comment! – Steven Sep 01 '10 at 10:38
  • The better way would be for him to make support requests to Sage to implement the changes that he's doing via Reflection. And talking about support, tell him to ask Sage for written confirmation if they'll support his usage and see what they say :) – Hans Olsson Sep 01 '10 at 10:38
  • Thanks for the comments, thought I wasn't being an idiot but nice to make sure and ask some experts. The guy is hilarious to be honest, the other week he had to sit an online Sage exam and was doing pretty badly, half way through he rang the examiner and told him the exam was wrong :0) for about half an hour. – Paulie Waulie Sep 01 '10 at 10:47
  • 1
    For most developers, allowing reflection usage is like giving a loaded machine gun to a monkey :) You should suggest writing directly to the memory of the graphics card instead to alter the application behavior! – Guillaume Sep 01 '10 at 11:13
  • 1
    Your Boss sounds like a complete and utter t*@t. Leave the company as soon as possible before you do something equally crazy like develop a renderer over a 2 year period which looks exactly the same and does less than the previous version. HTH – brumScouse Oct 26 '10 at 21:46
  • [Here's a good link to send your boss](http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming)) –  Apr 04 '12 at 16:49
  • @Will Thanks for the link ;). Thankfully I left that company about three weeks after posting this question for obvious reasons and have never looked back. – Paulie Waulie Apr 05 '12 at 09:15
  • @PaulieWaulie: Ah! Sorry about that. I usually check the age of a question before commenting. Good for ya! –  Apr 05 '12 at 14:23

3 Answers3

4

You are right. If you depend on implementation details of 3rd party library, you better be ready to rewrite everything when 3rd party library is updated and for the unexpected side effects when you change some private variable with some "innocent" value.

The answer is do it only if you 100% sure in what you are doing and you a ready to face the consequences.

Alex Reitbort
  • 13,504
  • 1
  • 40
  • 61
2

You shouldn't modify existing assemblies - the results are likely to be unknown and definately not supported by the assembly vendor. Also, such changes will lose the assembly signing that guarentees the assembly is the version shipped by the vendor.

Basically, anything could happen, so unless you're willing to do very rigorous testing, with no vendor support to fall back on, stay well away!

thecoop
  • 45,220
  • 19
  • 132
  • 189
1

Each new version of an assembly can have a completely different implementation. A software update from Sage could completely invalidate your Boss's code, and would require completely redevelopment to re-establish the same functionality.

For a real example: StringBuilder in .NET 3.5 used a string internally, in .NET 4 it uses a char[] see this recent question.)

Community
  • 1
  • 1
Richard
  • 106,783
  • 21
  • 203
  • 265