Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Class/Application design question

Class/Application design question

Scheduled Pinned Locked Moved C#
questioncomdesigndiscussion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    therealmccoy
    wrote on last edited by
    #1

    Background: I need to read in 3 text files. Each file has it's own format. I decided to code a class for each type. Each class impliments some common methods: getItem() getDescription(item) getCount() In addition each class contains some items that are more specific to the data in that file. I originally had specified the name of the file to be read in the constructor. The constructor would then load the file (and it's associated data) into arrays then close the file. The instance would look like this... fileReader1 fr1 = new fileReader1(sFileName); It was then requested that I validate my input files. This is where my question lies.. What is the best approach for this functionality? Bear in mind I need to not process anything if the file is not valid. I am currently working on a 3 tier design (GUI, Logic, Data). The readers are called from the Logic layer. I have mulled the following: #1 Move the ability to read the file from the constructor to a public method. Code a new method called 'validated()' that would return TRUE if the file was valid and then call the read method (this would be done from the Logic layer) if validated returns TRUE #2 Continute to read in the file via the constructor, but only read the file if it is valid (via private validate method). If the file is not valid fire a 'not valid event' and catch it in my GUI. #3 Create a seperate class called 'Validator' that I pass in the file to validate and the type. If this returns TRUE then continue, otherwise dont' #4 Let the constructor validate the file. Set a bool variable in my reader class and expose it as a public property. If file is valid set variable to TRUE and call public read method. I am interested in the best way, the 'professional' way to impliment this. Thanks in advance for your thoughts/comments. www.lovethosetrains.com

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups