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. DRY, SoC, IoC, KISS... (NOT)

DRY, SoC, IoC, KISS... (NOT)

Scheduled Pinned Locked Moved The Weird and The Wonderful
performanceworkspace
20 Posts 11 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.
  • L Lost User

    Testing CP forum post limit may be.

    ...byte till it megahertz...

    P Offline
    P Offline
    Palladino
    wrote on last edited by
    #10

    Hey, bleedingfingers, had not thought of this ... but now that you said, I was testing. I was testing ... :thumbsup:

    Marcelo Palladino Brasil

    1 Reply Last reply
    0
    • P Palladino

      This code is based on true and real CRITICAL application. **In memory

      private void ProcessaNota(TextReader txt, string cDestino)
      {
      string baseDir = InfoApp.PastaSchemas() + "\\nfe_v1.10.xsd";

      if (!File.Exists(baseDir))
      {
          this.cMensagemErro += "Arquivo: " + baseDir +
                  " não encontrado" + Environment.NewLine;
          return;
      }
      DataSet dsNfe = new DataSet();
      dsNfe.ReadXmlSchema(baseDir);
      dsNfe.EnforceConstraints = false;
      
      DataRow dremit = dsNfe.Tables\["emit"\].NewRow();
      DataRow drdest = dsNfe.Tables\["dest"\].NewRow();
      DataRow drPISOutr = null;
      DataRow drPISST = null;
      DataRow drCOFINSOutr = null;
      DataRow drCOFINSST = null;
      DataRow drtransporta = null;
      DataRow drIPITrib = null;
      DataRow drVol = null;
      
      string idprod = "";
      int iControle = 1;
      int nElementos;
      int iLeitura;
      string\[\] dados;
      Int64 iTmp = 0;
      bool vNovaNota = false;
      bool vTiraxFant = false;
      bool transpAdd = false;
      
      this.nNF = 0;
      
      int DIid = 0;
      int prodID = 0;
      int idcomb = 0;
      int volid = 0;
      int indadicid = 0;
      
      while (cLinhaTXT != null)
      {
          cLinhaTXT = this.ConvertToOEM(this.cLinhaTXT);
      
          //cLinhaTXT += "!@#$%^&\*()\_+";
          bool reLe = false;
          for (int x = 0; x < cLinhaTXT.Length - 1; ++x)
              if (/\*char.IsSymbol(cLinhaTXT, x) ||\*/ char.IsControl(cLinhaTXT, x))
              {
                  this.cMensagemErro += "Linha \[" + this.iLinhaLida.ToString() +
                       "\] coluna \[" + (x + 1).ToString() + "\] contem o caracter \[" +
                       cLinhaTXT.Substring(x, 1) + "\] que não é permitido" +
                       Environment.NewLine;
                  //this.cMensagemErro += "\\t"+cLinhaTXT + Environment.NewLine;
      
                  cLinhaTXT = txt.ReadLine();
                  iLinhaLida++;
                  reLe = true;
                  break;
              }
      
          if (reLe)
              continue;
      
          dados = cLinhaTXT.Split('|');
          dados\[0\] = dados\[0\].ToUpper();
          nElementos = dados.GetLength(0) - 1;
          for (int n = 0; n < nElementos; ++n)
              dados\[n\] = dados\[n\].Trim();
      
          #region -- Segmentos
      
          switch (dados\[0\])
          {
              case "NOTAFISCAL":
              case "NOTA FISCAL":
                  break;
      
              case "A":
                  #region -- A
      
                  if (this.nNF > 0)
                  {**
      
      Y Offline
      Y Offline
      Yusuf
      wrote on last edited by
      #11

      Hey don't you have source control? No need to dump your code here ;P

      Yusuf May I help you?

      OriginalGriffO P 2 Replies Last reply
      0
      • Y Yusuf

        Hey don't you have source control? No need to dump your code here ;P

        Yusuf May I help you?

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

        Good idea! I hadn't thought of that... use CP as an offsite backup facility. Hmmm. I wonder if the hamsters will complain...

        Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

        "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
        • P PIEBALDconsult

          Do you have a point?

          P Offline
          P Offline
          peterchen
          wrote on last edited by
          #13

          That looks like at least a few dozens of function points to me.

          Agh! Reality! My Archnemesis![^]
          | FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy

          1 Reply Last reply
          0
          • Y Yusuf

            Hey don't you have source control? No need to dump your code here ;P

            Yusuf May I help you?

            P Offline
            P Offline
            Palladino
            wrote on last edited by
            #14

            hahaha, this is not my code, but you gave a good idea. Can I even do versioning of my sources here...

            Marcelo Palladino Brasil

            1 Reply Last reply
            0
            • P Palladino

              This code is based on true and real CRITICAL application. **In memory

              private void ProcessaNota(TextReader txt, string cDestino)
              {
              string baseDir = InfoApp.PastaSchemas() + "\\nfe_v1.10.xsd";

              if (!File.Exists(baseDir))
              {
                  this.cMensagemErro += "Arquivo: " + baseDir +
                          " não encontrado" + Environment.NewLine;
                  return;
              }
              DataSet dsNfe = new DataSet();
              dsNfe.ReadXmlSchema(baseDir);
              dsNfe.EnforceConstraints = false;
              
              DataRow dremit = dsNfe.Tables\["emit"\].NewRow();
              DataRow drdest = dsNfe.Tables\["dest"\].NewRow();
              DataRow drPISOutr = null;
              DataRow drPISST = null;
              DataRow drCOFINSOutr = null;
              DataRow drCOFINSST = null;
              DataRow drtransporta = null;
              DataRow drIPITrib = null;
              DataRow drVol = null;
              
              string idprod = "";
              int iControle = 1;
              int nElementos;
              int iLeitura;
              string\[\] dados;
              Int64 iTmp = 0;
              bool vNovaNota = false;
              bool vTiraxFant = false;
              bool transpAdd = false;
              
              this.nNF = 0;
              
              int DIid = 0;
              int prodID = 0;
              int idcomb = 0;
              int volid = 0;
              int indadicid = 0;
              
              while (cLinhaTXT != null)
              {
                  cLinhaTXT = this.ConvertToOEM(this.cLinhaTXT);
              
                  //cLinhaTXT += "!@#$%^&\*()\_+";
                  bool reLe = false;
                  for (int x = 0; x < cLinhaTXT.Length - 1; ++x)
                      if (/\*char.IsSymbol(cLinhaTXT, x) ||\*/ char.IsControl(cLinhaTXT, x))
                      {
                          this.cMensagemErro += "Linha \[" + this.iLinhaLida.ToString() +
                               "\] coluna \[" + (x + 1).ToString() + "\] contem o caracter \[" +
                               cLinhaTXT.Substring(x, 1) + "\] que não é permitido" +
                               Environment.NewLine;
                          //this.cMensagemErro += "\\t"+cLinhaTXT + Environment.NewLine;
              
                          cLinhaTXT = txt.ReadLine();
                          iLinhaLida++;
                          reLe = true;
                          break;
                      }
              
                  if (reLe)
                      continue;
              
                  dados = cLinhaTXT.Split('|');
                  dados\[0\] = dados\[0\].ToUpper();
                  nElementos = dados.GetLength(0) - 1;
                  for (int n = 0; n < nElementos; ++n)
                      dados\[n\] = dados\[n\].Trim();
              
                  #region -- Segmentos
              
                  switch (dados\[0\])
                  {
                      case "NOTAFISCAL":
                      case "NOTA FISCAL":
                          break;
              
                      case "A":
                          #region -- A
              
                          if (this.nNF > 0)
                          {**
              
              M Offline
              M Offline
              makumazan84
              wrote on last edited by
              #15

              I think that this piece of code is adorable (in a coding horror kind of way). Reminds me of a scene in Tarantino's Kill Bill pt.1, the one where Uma Thurman was slaughtering bad guys in Japan ))) I've really enjoyed all these cases in the code, but it is the size of this method that makes me dizzy. I still wonder how the PM or co-workers haven't done something before this method grow that big.

              P 1 Reply Last reply
              0
              • M makumazan84

                I think that this piece of code is adorable (in a coding horror kind of way). Reminds me of a scene in Tarantino's Kill Bill pt.1, the one where Uma Thurman was slaughtering bad guys in Japan ))) I've really enjoyed all these cases in the code, but it is the size of this method that makes me dizzy. I still wonder how the PM or co-workers haven't done something before this method grow that big.

                P Offline
                P Offline
                Palladino
                wrote on last edited by
                #16

                makumazan84, when PIEBALDconsult talked about blood, I thought that exact scene you described. Kill Bill is a masterpiece ... and the code, of a very particular way, it is also. As you get dizzy, I think in Visual Studio that could be solved with several sections #region. :cool:

                Marcelo Palladino Brasil

                C 1 Reply Last reply
                0
                • P Palladino

                  You got my points, Rob. :-D And Yes, it's a real life horror!

                  Marcelo Palladino Brasil

                  C Offline
                  C Offline
                  cpkilekofp
                  wrote on last edited by
                  #17

                  :sigh: This sort of horror is quite normal, but seldom are we given an example that we DON'T have to read...and thank you, those who did so! :laugh:

                  1 Reply Last reply
                  0
                  • P Palladino

                    makumazan84, when PIEBALDconsult talked about blood, I thought that exact scene you described. Kill Bill is a masterpiece ... and the code, of a very particular way, it is also. As you get dizzy, I think in Visual Studio that could be solved with several sections #region. :cool:

                    Marcelo Palladino Brasil

                    C Offline
                    C Offline
                    cpkilekofp
                    wrote on last edited by
                    #18

                    hmmm...in VS2003 and in VS2008SP1, you can't define #regions within a function body

                    P 1 Reply Last reply
                    0
                    • C cpkilekofp

                      hmmm...in VS2003 and in VS2008SP1, you can't define #regions within a function body

                      P Offline
                      P Offline
                      Palladino
                      wrote on last edited by
                      #19

                      Dammit! :-)

                      Marcelo Palladino Brasil Twitter: @ProgrammerHead Blog (pt-BR): http://programmerhead.wordpress.com

                      C 1 Reply Last reply
                      0
                      • P Palladino

                        Dammit! :-)

                        Marcelo Palladino Brasil Twitter: @ProgrammerHead Blog (pt-BR): http://programmerhead.wordpress.com

                        C Offline
                        C Offline
                        cpkilekofp
                        wrote on last edited by
                        #20

                        Palladino wrote:

                        Dammit!

                        Yeah, I had the same reaction the first time I wanted to use it, some time about two years ago. I dislike large function bodies, but realistically there are a number of situation-specific algorithms that depend on a long sequence of unrepeated operations. To reduce the size, one is left with the option of breaking them into smaller chunks as subroutines, then calling each subroutine in sequence. I've seen differences in how well that approach works when maintenance is being performed by novices to the software. I've seen genuinely intense frustration expressed by some developers when they have to nest down through two or more levels of subroutine that were simply put in to eliminate very lengthy code sequences, where the developer in question felt it would have been much easier to follow the sequence in its original lengthy form. Allowing collapsible regions within a subroutine brings the best of both techniques to bear on the problem.

                        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