Solved

OO Design question, XDocument

Posted on 2010-09-24
2
472 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
VincentSG earned 500 total points
ID: 33759040
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
ID: 33760096
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

696 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