?
Solved

OO Design question, XDocument

Posted on 2010-09-24
2
Medium Priority
?
475 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 2000 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

Setting up LaraDock for Laravel

Learn how to set up LaraDock in a Laravel project - LaraDock gives us an easy way to run a Laravel application using Docker in a single command.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

777 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