Solved

OO Design question, XDocument

Posted on 2010-09-24
2
466 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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

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…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
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…

739 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