Tuesday, 5 January 2016

@Deprecated


 @Deprecated  

  • Used in managed packages
  • Any classes,methods, interfaces, exceptions,variables or enums ,etc which can no longer be referenced in subsequent releases (of that Managed Package).
  • Mostly used when you are refactoring / making more changes/improvements in your Managed Package as the requirements evolve.
  • It restricts new subscribers to see "deprecated" elements while existing subscribers/API integrations  get proper functioning elements as they were.
  • All 'global' modifiers need to be 'deprecated' as who referred your 'decprecated' element.
  • Unmanaged packages cannot contain code that uses the deprecated keyword.
  • Can't use with WebSerivces
  • Enum, Interface, Abstract classes need to depcrecated totally - cant decpracate individual method or individual enum value.

 EXAMPLE : 

       
            // This method is deprecated. Use myOptimizedMethod(String a, String b) instead.
  @deprecated 
  global void myMethod(String a) { 
 }