Solved

OO Design question, XDocument

Posted on 2010-09-24
2
440 Views
Last Modified: 2012-05-10
Please help me to understand the newer and possibly more modern programmers I am working with.  I come from a SmallTalk / C++ background but I would like to think I know something about inheritance and c#.

We will be doing a lot of work with .Nets XDocument on a series of XML sources with very- very similar schemas.

So it is reasonable from my background to create a new name space and extend the XDocument class with functionality we will need.  I think it is reasonable to create a more refined XDocument from the point of view of our needs.  I favor a ‘Is-A’ design where the new class is integrated with our logging and other proprietary behaviors.  Furthermore containing methods that we need over and over again.

The true .NET recently college trained programmers strongly object.  They advocate a ‘Has-A’ design with other classes that accept enumerators of type XDocument to do the type of refinements necessary.


I value your opinion.  Thank you for your time and consideration.  

Example code.
namespace MyCompany.MyProduct.XDocument
{

public class XDocumentFR : XDocument , IDisposable

static XElement CloneElement(XElement element)
public string ValueAsTextFromElement(XElement rootElement, string xPath)
public void Load(xmlSourceType eXmlSource, string xmlSourceValue)


0
Comment
Question by:wilfordrocks
2 Comments
 
LVL 5

Accepted Solution

by:
VincentSG earned 500 total points
Comment Utility
Hi!

I think this is an interesting question.

The benefits of a "Is-A" approach is that all functionalities are already built-in into the class. If you are sure that in your project and future projects you will keep using this same class without much modification, then it could be easier to manage your code in the future.

However, having a "Has-A" approach allows you to build functionality classes such as Logging etc that can be reused in other projects which could have totally different nature.

Therefore I would suggest that if you are planning to build a library that be reused for other projects OR you already have other classes such as Logging etc from other projects, use a "Has-A" approach. If you do not need or want to support other projects or want to keep it simple and within this project, then use a "Is-A" approach.

Personally I would prefer a "Has-A" approach in general cases however I believe whether to follow which approach should be on a case-by-case basis.
0
 

Author Closing Comment

by:wilfordrocks
Comment Utility
Thank you for your insight.  
Personally, I find the .Net strangely lacking in project wizards and frameworks like the document / view architecture.  The development framework provided is more like VB 6.0 than VC 6.0.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Article by: Nadia
Linear search (searching each index in an array one by one) works almost everywhere but it is not optimal in many cases. Let's assume, we have a book which has 42949672960 pages. We also have a table of contents. Now we want to read the content on p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now