Anti-Simplification
Our anonymous submitter relates a tale of simplification gone bad. As this nightmare unfolds, imagine the scenario of a new developer coming aboard at this company. Imagine being the one who has to explain this setup to said newcomer.
Imagine being the newcomer who inherits it.
David's job should have been an easy one. His company's sales data was stored in a database, and every day the reporting system would query a SQL view to get the numbers for the daily key performance indicators (KPIs). Until the company's CTO, who was proudly self-taught, decided that SQL views are hard to maintain, and the system should get the data from one of those new-fangled APIs instead.
But how does one call an API? The reporting system didn't have that option, so the logical choice was Azure Data Factory to call the API, then output the data to a file that the reporting system could read. The only issue was that nobody on the team spoke Azure Data Factory, or for that matter SQL. But no problem, one of David's colleagues assured, they could do all the work in the best and most multifunctional language ever: C#.
But you can't just write C# in a data factory directly, that would be silly. What you can do is have the data factory pipeline call an Azure function, which calls a DLL that contains the bytecode from C#. Oh, and a scheduler outside of the data factory to run the pipeline. To read multiple tables, the pipeline calls a separate function for each table. Each function would be based on a separate source project in C#, with 3 classes each for the HTTP header, content, and response; and a separate factory class for each of the actual classes.
After all, each table had a different set of columns, so you can't just re-use classes for that.
There was one little issue: the reporting system required an XML file, whereas the API would export data in JSON. It would be silly to expect a data factory, of all things, to convert this. So the CTO's solution was to have another C# program (in a DLL called by a function from a pipeline from an external scheduler) that reads the JSON document saved by the earlier program, uses foreach to go over each element, then saves the result as XML. A distinct program for each table, of course, requiring distinct classes for header, content, response, and factories thereof.
Now here's the genius part: to the C# class representing the output data, David's colleague decided to attach one different object for each input table required. The data class would use reflection to iterate over the attached objects, and for each object, use a big switch block to decide which source file to read. This allows the data class to perform joins and calculations before saving to XML.
To make testing easier, each calculation would be a separate function call. For example, calculating a customer's age was a function taking struct CustomerWithBirthDate as input, use a foreach loop to copy all the data except replacing one field, and return a CustomerWithAge struct to pass to the next function. The code performed a bit slowly, but that was an issue for a later year.
So basically, the scheduler calls the data factory, which calls a set of Azure functions, which call a C# function, which calls a set of factory classes to call the API and write the data to a text file. Then, the second scheduler calls a data factory, which calls Azure functions, which call C#, which calls reflection to check attachment classes, which read the text files, then call a series of functions for each join or calculation, then call another set of factory classes to write the data to an XML file, then call the reporting system to update.
Easy as pie, right? So where David's job could have been maintaining a couple hundred lines of SQL views, he instead inherited some 50,000 lines of heavily-duplicated C# code, where adding a new table to the process would easily take a month.
Or as the song goes, Somebody Told Me the User Provider should use an Adaptor to Proxy the Query Factory Builder ...
Essex railway station used by thousands that's technically built in the wrong place
I didn't believe three easy lifestyle changes could work as well as weight-loss jabs. Then I lost 35kg. My doctor was so stunned, she hugged me
'Hero' referee recounts saving life of under-15 footballer on pitch with parent
Child obesity 'doubled' in part of Essex in just one year
NASA’s asteroid defence mission slowed targets by 1.7 inches per hour
NASA has published new analysis of its 2022 planetary defense test that suggests the mission slowed down the target asteroids, albeit infinitesimally.…
Scientists Just Doubled Our Catalog of Black Hole and Neutron Star Collisions
Read more of this story at Slashdot.
Moment brazen knife-wielding thief grabs woman's £5,000 bike from London coffee shop before police show up - but only to buy a round of drinks
Ian Huntley told woman pen pal 'I've had a lot to deal with lately' in letter written eight days before double child killer was fatally struck by 3ft metal pole in jail
Unmasked: Cycling club president who knocked girl, 5, to the ground - as he breaks silence to blame HER for not moving out of his way and moan that her father made him 'look very bad' by posting video online
One in three of Whitehall blob moans about workload and barely half are 'proud' to be civil servant, survey finds, sparking accusations of 'rotten culture'
Calamity Lammy has lost his way on Cyprus now: ANDREW PIERCE
Fraudster conned elderly victims out of £11million by hosting hotel savings seminars
'Killjoy' Greens want to abolish zoos and force every dog owner to have a licence
Moment Green Party MP Hannah Spencer is forced into the back of a police car after violent brawl amid trans rights protest in Manchester
Queen Charlotte really was black, Bridgerton star insists
CHRISTOPHER STEVENS weekend TV review: A female 007? The Capture's Holliday Grainger would be my first choice...
Ewe must be joking! Council says 'no sir, no sir' to illuminated 'Baa Baa Black Sheep' roundabout sculpture after locals called the plans 'ridiculous'
Document Foundation urges EU to ditch Excel lock-in for cybersecurity law consultation
UPDATED The Document Foundation has taken a swipe at the European Commission over its consultation on guidance for the EU's Cyber Resilience Act – because the feedback template is only available as a Microsoft Excel spreadsheet.…