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. Other Discussions
  3. The Weird and The Wonderful
  4. Don't they know what an array is?

Don't they know what an array is?

Scheduled Pinned Locked Moved The Weird and The Wonderful
cssdata-structureshelpquestioncareer
30 Posts 19 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.
  • N Nagy Vilmos

    OriginalGriff wrote:

    Unless they are VB developers, obviously

    Then they trump even Brad Pitt!!


    Panic, Chaos, Destruction. My work here is done.

    R Offline
    R Offline
    ragnaroknrol
    wrote on last edited by
    #21

    You are both horrible liars. Come on, we all know the standard programmer package involves a guy living in mom's basement at 20-something who plays World of Warcraft, goes to ren faires and hasn't touch a female pink part in 20 something years. The upgraded "I'll code for food" programmer has a wife, 2 kids, a mortgage and wishes he had gone into business school. For the premium package you get the choice of it being male or female, and the programmer is actually happy in the job. Most business do not opt for this upgrade.

    L OriginalGriffO B 3 Replies Last reply
    0
    • R ragnaroknrol

      You are both horrible liars. Come on, we all know the standard programmer package involves a guy living in mom's basement at 20-something who plays World of Warcraft, goes to ren faires and hasn't touch a female pink part in 20 something years. The upgraded "I'll code for food" programmer has a wife, 2 kids, a mortgage and wishes he had gone into business school. For the premium package you get the choice of it being male or female, and the programmer is actually happy in the job. Most business do not opt for this upgrade.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #22

      ragnaroknrol wrote:

      You are both horrible liars.

      I think they are quite good at it! :laugh:

      1 Reply Last reply
      0
      • R ragnaroknrol

        You are both horrible liars. Come on, we all know the standard programmer package involves a guy living in mom's basement at 20-something who plays World of Warcraft, goes to ren faires and hasn't touch a female pink part in 20 something years. The upgraded "I'll code for food" programmer has a wife, 2 kids, a mortgage and wishes he had gone into business school. For the premium package you get the choice of it being male or female, and the programmer is actually happy in the job. Most business do not opt for this upgrade.

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #23

        Obviously, you are not a european software developer! (Or you are a VB developer...) ;P

        No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones "Rumour has it that if you play Microsoft CDs backwards you will hear Satanic messages.Worse still, is that if you play them forwards they will install Windows"

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        1 Reply Last reply
        0
        • U User 4483848

          VickyC# wrote:

          Does the language support lists?

          It's C#.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #24

          OMG!!! all the way I have been thinking it is some good old FORTRAN or PASCAL !!!

          1 Reply Last reply
          0
          • U User 4483848

            I'm working with some really bad code at the moment. There is some code which joins a load of values (integers) with '~', and then it passes it to a function. So it would be something like 1~5~12~3 etc. In the function it then splits this values on the '~' to get each value. It would be so much more readable, efficient, and less frangile if they had used an array. It amazes me how these people do their job. The other code in the project isn't much better either, actually the other problems are more difficult to fix. I hate blaming other peoples code, but I think that's what I will need to do.

            D Offline
            D Offline
            dojohansen
            wrote on last edited by
            #25

            I feel your pain, and yet I suspect you feel only some of mine. In the project I am working on this would no doubt have been implemented as follows:

            string foobar(string xml)
            {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);

            // ... do something to doc

            // pick out some part of the doc that another function processes...
            string sXmlSelection = xml.SelectSingleNode("//xmlSelection").OuterXml;
            sXmlSelection = foo(sXmlSelection);
            string sXmlRestriction = xml.SelectSingleNode("//xmlRestriction").OuterXml;
            sXmlRestriction = foo(sXmlRestriction);

            ...

            return doc.OuterXml;
            }

            string foo(string xml)
            {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);
            // ... do something to doc
            // pick out some part of the doc that another function processes...
            string s = xml.SelectSingleNode(...).OuterXml;
            s = bar(s);

            ...

            return doc.OuterXml;
            }

            string bar(string xml)
            {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);

            // ... do something to doc

            return doc.OuterXml;
            }

            void main()
            {
            string xmlSelection = "";
            xmlSelection += "" + getElem() + ";
            xmlSelection += "" + getElem() + ";
            xmlSelection += "" + getElem() + ";
            xmlSelection += "" + getElem() + ";
            xmlSelection += "");

            string xmlRestriction = "";

            string xmlData = " + xmlSelection + "";
            xmlData += "" + xmlRestriction + "";

            foobar(xmlData);
            }

            I swear I've seen call stacks where eight methods are all calling one another with strings and returning strings, all of them working on xml, even though in most cases the only information used by the methods is the innertext of particular nodes. Every method parses the string to build an xml document, finds the real parameters to the method as text - never checking if nodes exist and thus ensuring a meaningless NullReferenceException in the event the poor person trying to use this "business logic" fails to pass the correct (and undocumented) xml to a method - then does some work such as selecting something from a database, stuffs the result into the xml document somewhere, and returns the OuterXml. Apart from this leading to code that spends virtually all it's time parsing xml strings and rendering documents back to such strings it is also incredibly wasteful of memory. A

            P S 2 Replies Last reply
            0
            • D dojohansen

              I feel your pain, and yet I suspect you feel only some of mine. In the project I am working on this would no doubt have been implemented as follows:

              string foobar(string xml)
              {
              XmlDocument doc = new XmlDocument();
              doc.LoadXml(xml);

              // ... do something to doc

              // pick out some part of the doc that another function processes...
              string sXmlSelection = xml.SelectSingleNode("//xmlSelection").OuterXml;
              sXmlSelection = foo(sXmlSelection);
              string sXmlRestriction = xml.SelectSingleNode("//xmlRestriction").OuterXml;
              sXmlRestriction = foo(sXmlRestriction);

              ...

              return doc.OuterXml;
              }

              string foo(string xml)
              {
              XmlDocument doc = new XmlDocument();
              doc.LoadXml(xml);
              // ... do something to doc
              // pick out some part of the doc that another function processes...
              string s = xml.SelectSingleNode(...).OuterXml;
              s = bar(s);

              ...

              return doc.OuterXml;
              }

              string bar(string xml)
              {
              XmlDocument doc = new XmlDocument();
              doc.LoadXml(xml);

              // ... do something to doc

              return doc.OuterXml;
              }

              void main()
              {
              string xmlSelection = "";
              xmlSelection += "" + getElem() + ";
              xmlSelection += "" + getElem() + ";
              xmlSelection += "" + getElem() + ";
              xmlSelection += "" + getElem() + ";
              xmlSelection += "");

              string xmlRestriction = "";

              string xmlData = " + xmlSelection + "";
              xmlData += "" + xmlRestriction + "";

              foobar(xmlData);
              }

              I swear I've seen call stacks where eight methods are all calling one another with strings and returning strings, all of them working on xml, even though in most cases the only information used by the methods is the innertext of particular nodes. Every method parses the string to build an xml document, finds the real parameters to the method as text - never checking if nodes exist and thus ensuring a meaningless NullReferenceException in the event the poor person trying to use this "business logic" fails to pass the correct (and undocumented) xml to a method - then does some work such as selecting something from a database, stuffs the result into the xml document somewhere, and returns the OuterXml. Apart from this leading to code that spends virtually all it's time parsing xml strings and rendering documents back to such strings it is also incredibly wasteful of memory. A

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #26

              dojohansen wrote:

              string is the perfect data structure

              Hellooo...! String theory! :-D

              1 Reply Last reply
              0
              • D dojohansen

                I feel your pain, and yet I suspect you feel only some of mine. In the project I am working on this would no doubt have been implemented as follows:

                string foobar(string xml)
                {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(xml);

                // ... do something to doc

                // pick out some part of the doc that another function processes...
                string sXmlSelection = xml.SelectSingleNode("//xmlSelection").OuterXml;
                sXmlSelection = foo(sXmlSelection);
                string sXmlRestriction = xml.SelectSingleNode("//xmlRestriction").OuterXml;
                sXmlRestriction = foo(sXmlRestriction);

                ...

                return doc.OuterXml;
                }

                string foo(string xml)
                {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(xml);
                // ... do something to doc
                // pick out some part of the doc that another function processes...
                string s = xml.SelectSingleNode(...).OuterXml;
                s = bar(s);

                ...

                return doc.OuterXml;
                }

                string bar(string xml)
                {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(xml);

                // ... do something to doc

                return doc.OuterXml;
                }

                void main()
                {
                string xmlSelection = "";
                xmlSelection += "" + getElem() + ";
                xmlSelection += "" + getElem() + ";
                xmlSelection += "" + getElem() + ";
                xmlSelection += "" + getElem() + ";
                xmlSelection += "");

                string xmlRestriction = "";

                string xmlData = " + xmlSelection + "";
                xmlData += "" + xmlRestriction + "";

                foobar(xmlData);
                }

                I swear I've seen call stacks where eight methods are all calling one another with strings and returning strings, all of them working on xml, even though in most cases the only information used by the methods is the innertext of particular nodes. Every method parses the string to build an xml document, finds the real parameters to the method as text - never checking if nodes exist and thus ensuring a meaningless NullReferenceException in the event the poor person trying to use this "business logic" fails to pass the correct (and undocumented) xml to a method - then does some work such as selecting something from a database, stuffs the result into the xml document somewhere, and returns the OuterXml. Apart from this leading to code that spends virtually all it's time parsing xml strings and rendering documents back to such strings it is also incredibly wasteful of memory. A

                S Offline
                S Offline
                supercat9
                wrote on last edited by
                #27

                If anyone has any idea where this idea that string is the perfect data structure for absolutely anything comes from, I would love to know. I have never been able to understand it. Strings are a reasonable data structure for information storage in many contexts. Many SQL-style databases, for example, have standard ways of reading and writing strings, but vary in how they handle binary data. It may be necessary to encode strings to ensure they don't contain any "funny" characters, but that's usually not too hard. The key is to avoid unnecessary packing and unpacking while data is being used internally.

                D 1 Reply Last reply
                0
                • S supercat9

                  If anyone has any idea where this idea that string is the perfect data structure for absolutely anything comes from, I would love to know. I have never been able to understand it. Strings are a reasonable data structure for information storage in many contexts. Many SQL-style databases, for example, have standard ways of reading and writing strings, but vary in how they handle binary data. It may be necessary to encode strings to ensure they don't contain any "funny" characters, but that's usually not too hard. The key is to avoid unnecessary packing and unpacking while data is being used internally.

                  D Offline
                  D Offline
                  dojohansen
                  wrote on last edited by
                  #28

                  supercat9 wrote:

                  Strings are a reasonable data structure for information storage in many contexts.

                  I don't really agree much with that, BUT... if you look at the original message you'll see that none of your stated reasons apply here anyway! There is no reason one should use strings and only strings within a C# business layer. If a method needs the caller to identify three entities, say a customer, a start date and an end date, and returns the set of orders placed by that customer between the two dates, it's rather better to have something like

                  public List GetOrders(Customer c, DateTime start, DateTime end)
                  public List GetOrders(int customerID, DateTime start, DateTime end)

                  than

                  public string GetOrders(string xmlData)

                  for reasons I hope are obvious. It may be acceptable to have both (for use with a particular AJAX implementation for example, like the one we've made and which is the reason why it's become this way), but the string version should then be in a separate class and not contain any actual business logic. It would pick out the bits of information the business logic needs from the string, use the appropriate business logic to obtain the result, and (probably using some third bit of logic) create an xml representation of it to be written to the response stream. The only nice thing about strings is that they are the most interoperable data type, certainly if sticking to the 7-bit ASCII set. That is an important benefit in many contexts, but it's no reason to go ahead and only use strings everywhere except the database!

                  1 Reply Last reply
                  0
                  • R ragnaroknrol

                    You are both horrible liars. Come on, we all know the standard programmer package involves a guy living in mom's basement at 20-something who plays World of Warcraft, goes to ren faires and hasn't touch a female pink part in 20 something years. The upgraded "I'll code for food" programmer has a wife, 2 kids, a mortgage and wishes he had gone into business school. For the premium package you get the choice of it being male or female, and the programmer is actually happy in the job. Most business do not opt for this upgrade.

                    B Offline
                    B Offline
                    Baeltazor
                    wrote on last edited by
                    #29

                    lol

                    Regards, Jason Pezzimenti.


                    If you liked the answer that I have provided, then please click the 'Good Answer' link on the bottom-right of this post. Thank you.

                    1 Reply Last reply
                    0
                    • U User 4483848

                      I'm working with some really bad code at the moment. There is some code which joins a load of values (integers) with '~', and then it passes it to a function. So it would be something like 1~5~12~3 etc. In the function it then splits this values on the '~' to get each value. It would be so much more readable, efficient, and less frangile if they had used an array. It amazes me how these people do their job. The other code in the project isn't much better either, actually the other problems are more difficult to fix. I hate blaming other peoples code, but I think that's what I will need to do.

                      T Offline
                      T Offline
                      Timothy Byrd
                      wrote on last edited by
                      #30

                      I hate to admit it, but I've found code like that here from a previous developer. It's also in C#, but the delimiter is a newline. Maybe you have our old developer?

                      public string FormatBarContent(string foo1,
                      string foo2, string f003,
                      // ...
                      string foo14,
                      )
                      {
                      StringBuilder sb=new StringBuilder();
                      sb.Append(foo1);
                      sb.Append("\n");
                      sb.Append(foo2);
                      sb.Append("\n");
                      // ...
                      sb.Append(foo14);
                      // sb.Append("\n");
                      return sb.ToString();
                      }

                      And some of the foo's have been converted from numbers to strings. The routine that gets this string immediately Split()'s it and parses the numbers back into numbers. None of the data ever needs to leave the current thread. Don't they know what a struct is? -- T

                      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