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. The Lounge
  3. There's tightly coupling and then there's this...

There's tightly coupling and then there's this...

Scheduled Pinned Locked Moved The Lounge
javascriptdatabasecloudcsharplinq
4 Posts 4 Posters 301 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.
  • Sander RosselS Offline
    Sander RosselS Offline
    Sander Rossel
    wrote on last edited by
    #1

    So I need to replace an old file import. The file is simple, it looks like:

    40241018Some comment 123...

    Where the first two characters is some ID, the next two is the year, next two month, next two day, next 16 a comment, next three a price, etc... That's not the exact file, but you get the idea, fixed width fields. Nothing fancy and usually very easy to read. Now the database has the following columns. ID BIGINT DATE CHAR(8) STATUS CHAR(1) FIELD01 CHAR(2) FIELD02 CHAR(2) FIELD03 CHAR(2) FIELD04 CHAR(2) FIELD05 CHAR(16) FIELD06 CHAR(3) ... Now let's just ignore all the uppercases, CHAR data types and the CHAR(8) for date... Naming the fields FIELDXX is a pain because now you'll never know what the data represents, but this may have been done for "flexibility"??? :confused: The real horror is the code. It gets the table structure of the database, skips the first three fields (because they're not part of the import), reads the length of the next field, takes that many chars and places it in the table :wtf: That means if you change the field length or even field order in the database your import will fail. Also, if the file changes in even the slightest way you'll have to change your database schema. This was probably the hardest way to make this work and for sure the most tightly coupled :doh: Why do people do this? :((

    Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript

    H 0 J 3 Replies Last reply
    0
    • Sander RosselS Sander Rossel

      So I need to replace an old file import. The file is simple, it looks like:

      40241018Some comment 123...

      Where the first two characters is some ID, the next two is the year, next two month, next two day, next 16 a comment, next three a price, etc... That's not the exact file, but you get the idea, fixed width fields. Nothing fancy and usually very easy to read. Now the database has the following columns. ID BIGINT DATE CHAR(8) STATUS CHAR(1) FIELD01 CHAR(2) FIELD02 CHAR(2) FIELD03 CHAR(2) FIELD04 CHAR(2) FIELD05 CHAR(16) FIELD06 CHAR(3) ... Now let's just ignore all the uppercases, CHAR data types and the CHAR(8) for date... Naming the fields FIELDXX is a pain because now you'll never know what the data represents, but this may have been done for "flexibility"??? :confused: The real horror is the code. It gets the table structure of the database, skips the first three fields (because they're not part of the import), reads the length of the next field, takes that many chars and places it in the table :wtf: That means if you change the field length or even field order in the database your import will fail. Also, if the file changes in even the slightest way you'll have to change your database schema. This was probably the hardest way to make this work and for sure the most tightly coupled :doh: Why do people do this? :((

      Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript

      H Offline
      H Offline
      honey the codewitch
      wrote on last edited by
      #2

      They do it because if work were easy it wouldn't be work, would it? *hides*

      Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

      1 Reply Last reply
      0
      • Sander RosselS Sander Rossel

        So I need to replace an old file import. The file is simple, it looks like:

        40241018Some comment 123...

        Where the first two characters is some ID, the next two is the year, next two month, next two day, next 16 a comment, next three a price, etc... That's not the exact file, but you get the idea, fixed width fields. Nothing fancy and usually very easy to read. Now the database has the following columns. ID BIGINT DATE CHAR(8) STATUS CHAR(1) FIELD01 CHAR(2) FIELD02 CHAR(2) FIELD03 CHAR(2) FIELD04 CHAR(2) FIELD05 CHAR(16) FIELD06 CHAR(3) ... Now let's just ignore all the uppercases, CHAR data types and the CHAR(8) for date... Naming the fields FIELDXX is a pain because now you'll never know what the data represents, but this may have been done for "flexibility"??? :confused: The real horror is the code. It gets the table structure of the database, skips the first three fields (because they're not part of the import), reads the length of the next field, takes that many chars and places it in the table :wtf: That means if you change the field length or even field order in the database your import will fail. Also, if the file changes in even the slightest way you'll have to change your database schema. This was probably the hardest way to make this work and for sure the most tightly coupled :doh: Why do people do this? :((

        Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript

        0 Offline
        0 Offline
        0x01AA
        wrote on last edited by
        #3

        I would also obfuscate my data import like this to prevent from illegal use ;P :laugh:

        1 Reply Last reply
        0
        • Sander RosselS Sander Rossel

          So I need to replace an old file import. The file is simple, it looks like:

          40241018Some comment 123...

          Where the first two characters is some ID, the next two is the year, next two month, next two day, next 16 a comment, next three a price, etc... That's not the exact file, but you get the idea, fixed width fields. Nothing fancy and usually very easy to read. Now the database has the following columns. ID BIGINT DATE CHAR(8) STATUS CHAR(1) FIELD01 CHAR(2) FIELD02 CHAR(2) FIELD03 CHAR(2) FIELD04 CHAR(2) FIELD05 CHAR(16) FIELD06 CHAR(3) ... Now let's just ignore all the uppercases, CHAR data types and the CHAR(8) for date... Naming the fields FIELDXX is a pain because now you'll never know what the data represents, but this may have been done for "flexibility"??? :confused: The real horror is the code. It gets the table structure of the database, skips the first three fields (because they're not part of the import), reads the length of the next field, takes that many chars and places it in the table :wtf: That means if you change the field length or even field order in the database your import will fail. Also, if the file changes in even the slightest way you'll have to change your database schema. This was probably the hardest way to make this work and for sure the most tightly coupled :doh: Why do people do this? :((

          Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript

          J Offline
          J Offline
          Jeremy Falcon
          wrote on last edited by
          #4

          I mean, at least they didn't call the db fields f1, f2, etc. See, they tried... :laugh: :laugh: :laugh:

          Jeremy Falcon

          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