473,385 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to add functionality to an existing Interface Class and Implementations

210 Expert 100+
Please help me understand the concept of how I can add functionality to an existing Interface class and its implementations with out breaking any previously released codes.

Here is the Interface Class
Expand|Select|Wrap|Line Numbers
  1. Public Interface IShipmentProvider
  2.     ReadOnly Property ProviderName As String
  3.     ReadOnly Property ShipmentItems As ICollection(Of Package)
  4.     Function GetRates() As ICollection(Of Rate)
  5.     Function VerifyAddress(ByVal address As Address) As ICollection(Of Address)
  6. End Interface
  7.  
Here are the implementations
Expand|Select|Wrap|Line Numbers
  1. Public Class FedExShipmentProvider
  2.     Implements IShipmentProvider
  3.  
  4.     Public Function GetRates() As ICollection(Of Rate) Implements IShipmentProvider.GetRates
  5.         Throw New NotImplementedException
  6.     End Function
  7.  
  8.     Public ReadOnly Property ProviderName As String Implements IShipmentProvider.ProviderName
  9.         Get
  10.             Return "FedEx"
  11.         End Get
  12.     End Property
  13.  
  14.     Public ReadOnly Property ShipmentItems As ICollection(Of Package) Implements IShipmentProvider.ShipmentItems
  15.         Get
  16.             Return _lstofItems
  17.         End Get
  18.     End Property
  19.  
  20.     Public Function VerifyAddress(address As Address) As ICollection(Of Address) Implements IShipmentProvider.VerifyAddress
  21.         Throw New NotImplementedException
  22.     End Function
  23. End Class
  24.  
  25.  
  26. Public Class USPSShipmentProvider
  27.     Implements IShipmentProvider
  28.  
  29.     Public Function GetRates() As ICollection(Of Rate) Implements IShipmentProvider.GetRates
  30.         Throw New NotImplementedException
  31.     End Function
  32.  
  33.     Public ReadOnly Property ProviderName As String Implements IShipmentProvider.ProviderName
  34.         Get
  35.             Return "USPS"
  36.         End Get
  37.     End Property
  38.  
  39.     Public ReadOnly Property ShipmentItems As ICollection(Of Package) Implements IShipmentProvider.ShipmentItems
  40.         Get
  41.             Return _lstofItems
  42.         End Get
  43.     End Property
  44.  
  45.     Public Function VerifyAddress(address As Address) As ICollection(Of Address) Implements IShipmentProvider.VerifyAddress
  46.         Throw New NotImplementedException
  47.     End Function
  48. End Class
  49.  
  50. Public Class UPSShipmentProvider
  51.     Implements IShipmentProvider
  52.  
  53.     Public Function GetRates() As ICollection(Of Rate) Implements IShipmentProvider.GetRates
  54.         Throw New NotImplementedException
  55.     End Function
  56.  
  57.     Public ReadOnly Property ProviderName As String Implements IShipmentProvider.ProviderName
  58.         Get
  59.             Return "UPS"
  60.         End Get
  61.     End Property
  62.  
  63.     Public ReadOnly Property ShipmentItems As ICollection(Of Package) Implements IShipmentProvider.ShipmentItems
  64.         Get
  65.             Return _lstofItems
  66.         End Get
  67.     End Property
  68.  
  69.     Public Function VerifyAddress(address As Address) As ICollection(Of Address) Implements IShipmentProvider.VerifyAddress
  70.         Throw New NotImplementedException
  71.     End Function
  72.  
  73. End Class
  74.  
  75.  
Here I have provided three implementations of the IShipmentProvider but there may be more.

Now let just say I am supposed to add additional functionality of generating shipping label. How do I add the function of creating label to the interface class and implementations without breaking any other implementations. If I add the function directly to the interface then I will run into issue of breaking all the existing implementations unless I update all of them. Is there a way we can add the functionality with out breaking or updating existing implementations.

Please direct me to the right directions.

Thank you in advance.
Apr 16 '14 #1
1 1303
semomaniz
210 Expert 100+
Any help would be really appreciated.
Apr 17 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Kyo Guan | last post by:
How to Adding Functionality to a Class by metaclass(not by inherit) #example: import inspect class Foo(object): def f(self): pass
3
by: Richard | last post by:
Hi, I'm new to C# and are having difficultly implementing an interface class. Basically I want to define an interface class, then inherit it. I want some of the methods to be public, and...
1
by: guhar1 | last post by:
A few design issues: 1. If I decide to implement an interface between my "business object layer" and my "data access layer", so as to protect the BOL from changes in DAL, do I provide ONE...
3
by: Salman | last post by:
One one please tell me whats the difference between ABSTRACT Class and INTERFACE Class in c++. If you can explain me using examples, that would be more good for me.
5
by: The Cool Giraffe | last post by:
I'm designing an ABC and in connection to that i have run into some "huh!" and "oh...". Let me put it as a list. 1. Since the class will only contain bodies of the methods, only the header file...
0
by: Ken | last post by:
Hi I have a little application that does datavalidation. It supports dynamically loaded plugins (you drop a dll with a class implementing IValidator<Tin the same dir as the main application)....
6
by: StevenECBrown | last post by:
I'm somewhat of a newbie. This question has come up for me a couple of times, and it came up again today: I have an interface IProviderFileVersionNumber that has this method called GetOrderable....
5
by: ewpatton | last post by:
I'm working on a modular application that handles working with different file types. Each file type is defined in a separate DLL so that new types can be defined and then imported. Here's the code...
0
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i have a user interface class that builds my controls on the fly (like my textboxes, dropdownlists,etc) and places them in a div and then passes it back up to the web-form code-behind (is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.