locked
What could be changed in the code? RRS feed

  • Question

  • public void WriteFile(string DrrsFilePath)
            {
                if (DrrsnData != null)
                {
                    System.Xml.XmlDataDocument DrrsXmlDocument = new System.Xml.XmlDataDocument(DrrsnData);
                    DrrsXmlDocument.Save(DrrsFilePath);
                }  
            }

    Garry Dawkins

    Wednesday, September 19, 2012 5:44 PM

Answers

  • In what way does it not behave as you would like.  There are lots of ways to change the code without changing what it does:

    • You could change the variable names to be something different.  
    • You could add comments
    • You could add code that doesn't do anything, for example computing a value and then disregarding the result.
    • You could refactor lines that do more than one thing into additional lines, or refactor several lines into a single line.  (Not much opportunity in this code sample though),
    • Proposed as answer by Jason Dot Wang Friday, September 21, 2012 6:16 AM
    • Marked as answer by Jason Dot Wang Thursday, September 27, 2012 8:30 AM
    Wednesday, September 19, 2012 6:21 PM

All replies

  • Can you be more specific about your question, or elaborate a little more what you want?

    • Could be changed and which situation?
    • What is DrrsnData? When it will be null or not ?
    • When you said that you want change something in this code, you mean, any tip, hint etc? When you call this code?
    Wednesday, September 19, 2012 5:52 PM
  • In what way does it not behave as you would like.  There are lots of ways to change the code without changing what it does:

    • You could change the variable names to be something different.  
    • You could add comments
    • You could add code that doesn't do anything, for example computing a value and then disregarding the result.
    • You could refactor lines that do more than one thing into additional lines, or refactor several lines into a single line.  (Not much opportunity in this code sample though),
    • Proposed as answer by Jason Dot Wang Friday, September 21, 2012 6:16 AM
    • Marked as answer by Jason Dot Wang Thursday, September 27, 2012 8:30 AM
    Wednesday, September 19, 2012 6:21 PM
  • A lot can be done with this code.

    For example I can use using statements and try and catch block.

    Use other xml methods to read and write file. 

    So in what way you want this code to be changed(performance wise or more structured)?


    Mark it as helpful if so!!! thanks, Mithilesh

    Wednesday, September 19, 2012 7:53 PM