Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

C# with XML data files

Options
  • 29-10-2010 4:25pm
    #1
    Registered Users Posts: 139 ✭✭


    Hi Folks,
    I wanted some thoughts or opinions on a project my group in collage has been assigned, as it's more of a real world thing (in that it will be used outside the collage) I thought it best to post here.

    Were developing an eLearning tool part of which requires data of the users be stored to track their progression through the course the lecturer overseeing the project has stated he does not want databases to be used ie SQL etc

    He also stated he wanted the data to be portable.. my view was that XML may work as the numbers of students using the tool would not be excessive and XML would be usable by other apps say if they wanted to make a mobile app etc.

    That said would anyone here have some thought or experience in using XML in this manner and if we should continue in this path or try and persuade them to let us use a more traditional database arrangement?


Comments

  • Registered Users Posts: 981 ✭✭✭fasty


    It depends on how people access the tool. If it's web based, then having multiple people potentially save to the same XML file concurrently, then you're going to run into problems. I suppose you could have an individual file per user or something to get around that but it'll still be a bit annoying compared to working with the database.

    There's no reason why the underlying data store could use SQL and you could provide an interface of some kind that would return the data in XML form.


  • Registered Users Posts: 3,287 ✭✭✭padraig_f


    yeah I think XML will be fine, it would be the easiest thing to set up. C#/.NET has good support for it and being able to open it in a text editor makes debugging easier. Your only concerns would be performance and synchronising access to the data (i.e. if it was accessible to many users at once, preventing access to the data while it's being written to).

    Performance shouldn't be a problem if your numbers aren't too great.
    Synchronising the reads/writes should be fairly easy as well with a simple lock.

    To cover yourself, you should also abstract the storage format from the application, put it behind an interface. e.g.
    interface IDatabase
    {
       StudentRecord Read( int studentID );
       void Write( StudentRecord record );
    }
    

    Your XML class would implement this interface.

    You pass the IDatabase pointer to your main app, i.e. your main app doesn't know anything about the XML class.

    Now in future if you need to use SQL or something for extra performance, you can write an SQL class implementing IDatabase. It would then slot in to your main app without having to make any changes.


  • Registered Users Posts: 139 ✭✭seithon


    Neat :)
    I'm still a student... so some of this is beyond me but that's some handy stuff that I can do some research on to find out how to use it properly.

    And yes, their should only be one user accessing one set of data at a time.

    Thanks very much for your help so far folks.


Advertisement