Hi
I do have an Interface, which is implemented in lot of places, My
question is i observed that After quite some time if i need to add a
new method in the interface , i need to do a lot of rework in lot of
places , So i do see a flaw in my design, How best we can avoid this
situation
Thanks in Advance
thomson 6 1396
"thomson" <sa**********@y ahoo.com> wrote in message
news:11******** **************@ u72g2000cwu.goo glegroups.com.. . Hi I do have an Interface, which is implemented in lot of places, My question is i observed that After quite some time if i need to add a new method in the interface , i need to do a lot of rework in lot of places , So i do see a flaw in my design, How best we can avoid this situation
The basic idea with interfaces is not to change them but to define a new
interface.
This is why some people prefer to use base classes wherever possible - it is
easier to update. However there are drawbacks with that approach too.
"thomson" <sa**********@y ahoo.com> wrote: I do have an Interface, which is implemented in lot of places, My question is i observed that After quite some time if i need to add a new method in the interface , i need to do a lot of rework in lot of places , So i do see a flaw in my design, How best we can avoid this situation
The recommended approach is to use an abstract base class instead. They
version better. If you need to add a new method in the future, you can
implement it in terms of existing methods, or implement some kind of
default.
Interfaces work best for fine-grained behaviour that needs to be
supported by arbitrary classes, irrelevant of where they are in an
existing hierarchy.
Check out section 4.3 of the Framework Design Guidelines book by Cwalina
and Abrams, it has a good discussion of this.
-- Barry
Can you let me know how would be the implentation of abstract base
class in this scenario, and please let me know the flaws of abstract
class design
Hi,
"thomson" <sa**********@y ahoo.com> wrote in message
news:11******** **************@ u72g2000cwu.goo glegroups.com.. . Hi I do have an Interface, which is implemented in lot of places, My question is i observed that After quite some time if i need to add a new method in the interface , i need to do a lot of rework in lot of places , So i do see a flaw in my design, How best we can avoid this situation
You could say it's a flaw, you could also say it was an unforeseen
requirement. it does not matter now really.
You have two possible paths:
1- Modify the interface, this mean modify ALL the classes that implement it.
IF you have access to all these code and the implementation is similar in
all (or most) of the cases you could go out and modify all the classes.
2- Define an interface derived from the original one that define the new
member needed. then you can modify (or derive ) the classes that need to
implement it.
Unfortunately I do not see other way to solve your situation.
out of curiosity, does the new method needs extra member variables ?
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"thomson" <sa**********@y ahoo.com> wrote: Can you let me know how would be the implentation of abstract base class in this scenario
Stream, TextReader and TextWriter are all examples of these abstract
base classes. Compare their design and place in their hierarchies with
your own.
please let me know the flaws of abstract class design
The only problem with using an abstract class instead of an interface is
that you can't then bolt it onto an existing class hierarchy.
In the book I mentioned, Rico Mariani suggests this:
"Good interface candidates often have this 'mix-in' feel to them. All
sorts of objects can be IFormattable -- it isn't restricted to a certain
subtype. It's more like a type attribute."
-- Barry
"Barry Kelly" <ba***********@ gmail.com> wrote in message
news:1m******** *************** *********@4ax.c om... "thomson" <sa**********@y ahoo.com> wrote:
Can you let me know how would be the implentation of abstract base class in this scenario
Stream, TextReader and TextWriter are all examples of these abstract base classes. Compare their design and place in their hierarchies with your own.
please let me know the flaws of abstract class design
The only problem with using an abstract class instead of an interface is that you can't then bolt it onto an existing class hierarchy.
Somewhere in the MS library guidelines it explicitly mentions that they use
abstract base classes as a matter of policy because they don't have the
backward compatibility problems of interfaces.... but then they never have
to fit into someone else's hierarchy :( This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: grz02 |
last post by:
Hi,
Im an experienced database+software designer and developer,
but, unfortunately, anything to do with web-programming and
web-systems designs is still a pretty new area to me...
(been working mostly with "legacy" environments the last 10 years)
So I am writing this, hoping to get some useful advise and feedback...
I have done some pretty trivial, small websites with html/PHP,
|
by: Ash |
last post by:
Hello all,
I am hoping this is the appropriate newsgroup for a C++ interface
design question. I am trying to design an interface for a subscriber
to register/deregister handlers for various events. The callbacks
specified by the subscriber will be called when the events get
trigerred in a different thread. Each event has different kinds of
data associated with it. To achieve this I have the following:
// The following describes the...
|
by: Tony Johansson |
last post by:
Hello!
I'm reading about design pattern adaptor in the GOF book and
there is something that sounds strange.
When you use the adaptor design pattern you have these participants.
*Target
- defines the domain-specific interface that Client uses.
* Client
|
by: emma middlebrook |
last post by:
Hi
Straight to the point - I don't understand why System.Array derives
from IList (given the methods/properties actually on IList).
When designing an interface you specify a contract. Deriving from an
interface and only implementing some of it means something is wrong:
either the interface specification is wrong e.g. not minimal or the
derivation is wrong e.g. the type can't actually honour this contract.
|
by: zlst |
last post by:
Many technological innovations rely upon User Interface Design to elevate
their technical complexity to a usable product. Technology alone may not win
user acceptance and subsequent marketability. The User Experience, or how
the user experiences the end product, is the key to acceptance. And that is
where User Interface Design enters the design process. While product
engineers focus on the technology, usability specialists focus on the user...
| |
by: YellowFin Announcements |
last post by:
Introduction
Usability and relevance have been identified as the major factors
preventing mass adoption of
Business Intelligence applications. What we have today are traditional
BI tools that don't work
nearly as well as they should, even for analysts and power users. The
reason they haven't
reached the masses is because most of the tools are so difficult to use
and reveal so little
|
by: Grizlyk |
last post by:
Somebody have offered std colors to C++ in the msg here:
http://groups.google.com/group/comp.lang.c++/browse_frm/thread/2e5bb3d36ece543b/1acf6cd7e3ebdbcd#1acf6cd7e3ebdbcd
The main objection to the including "colors markup" is useless of the
marks, the marks is unneccessary extra information. The most used way
to make colored view of C++ programs is usage of classes of C++
language words (already included in C++): reserved words, user...
|
by: obrianpatrick |
last post by:
Hi,
I am relatively new to object oriented programming and design. I am
developing an application in VS 2005. I am having the following design
problem:
I have two interfaces X and Y. Y is derived from X as the following:
__interface X
{
|
by: weaknessforcats |
last post by:
Design Patterns: Visitor
Introduction
Polymorphism requires a class hierarchy where the interface to the hierarchy is in the base class. Virtual functions allow derived classes to override base class functions. Applications using polymorphism typically have functions with base class pointers or references as arguments. Then derived objects are created and used as arguments to these functions. Inside the function, only the base class methods...
|
by: =?Utf-8?B?QmVu?= |
last post by:
Hi,
I have a couple of questions about the proper design of classes.
I'll use a simple Customer class for my question.
1) Lets say that I have this Customer class like I said, and I want to
distinguish
between different types of customers, for example private, business,
other etc.
This will allow me to filter customers based on their type. Should I
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |