CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2011
    Location
    .NET4.0 / VS 2010
    Posts
    70

    Suggestions about programming approach

    I've been trying to make a program that reads a file and then it lists all objects like weapons, armor, clothing and such in a list. When the item is selected all of its properties are then displayed in the window. The files range from 1mb to 8mb so I decided to break down this file into smaller files. By the end of the program the user ends up with a folder where all items are placed individually in their own text file.

    Once extracted the program looks through the folder and adds all the items into a combo box. The user clicks the item in the combo box and the item's properties are displayed in a text box.

    My questions are about the method I am using.
    1)Is this a bad practice or is it fine since no secure data is stored in these files?
    2)Would there be a better approach to doing this instead of extracting these items? I know how to use array's and list but I'm worried that too many resources will be used up creating the list.

    Thanks in advance and sorry for my lack of knowledge and understanding.

  2. #2
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    Re: Suggestions about programming approach

    Hello (again)!

    (1) If you don't think the data needs to be secured, I see no security issues with the way you are doing it. It doesn't seem like a bad practice to me from a security standpoint.

    (2) Yes, why not just parse the large text file into memory instead of looking at smaller text files? Unless you're using ... ridiculously old (15+ years?)... hardware, there is absolutely no problem with loading 8 MB into memory (I wouldn't even worry about it unless either (a) the files are over 500 MB or (b) you are having serious performance problems). Access to data in memory is faster than access to disk and there will be no need to handle errors arising from file system accesses. Thus, just go for the more simple read-it-into-an-array strategy.

    The tradeoff is that if you had huge files, the read-it-into-an-array strategy won't work so well (what if you had an 8GB file instead of 8MB?). For a truly scalable solution, you could look into using a database. The one I typically use is MySQL, but there may be other alternatively that might be better (e.g. PostgreSQL) [the choice of which is a discussion beyond my expertise]. However, for 8 MB of data just using a text file ("flat file") is the best choice. Don't use a database until you absolutely need one ("probably not for this project").

    Thanks in advance and sorry for my lack of knowledge and understanding.
    You don't need to apologize! The answer to these types of questions are hard to Google for. I don't think anyone will get mad at you for trying to improve your skills. :-)
    Best Regards,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured