• (nodebb)

    This isn't quite as bad as it looks at frist*. It's mostly just a single function that has too many parameters. Making it a macro might make it easier to read, since you could replace all of the repeated object properties (which is what makes the line so long) with a few variables. Changing the parameters to be a few objects and then using the properties inside the function would also help a lot.

    • Which may actually make it a bigger WTF
  • (nodebb)

    As sometimes happens, TRWTF is the way the article is written here.

    Frist of all, the author should have broken the lines on commas, not at convenient dots. Doing that, and discarding all the repeated jibberjabber, we end up with this:

    Losses = calcLossesInPart(
    	RatedFrequency, RadialPositionToMainDuct, IsTransposed, 
    	ParallelRadialCount, ParallelAxialCount, Type,
    	DimensionRadialElectric,
    	DimensionAxialElectric+InsulThickness,
    	getElectricConductivityAtTemperatureT1(
    		ElectricConductivityT0,
    		MaterialFactor,
    		ReferenceTemperatureT0,
    		ReferenceTemperature),
    	LayerNumberRatedVoltage,
    	InitechNeoDTActivePartPartLayerContainer(0),
    	RFactor)
    

    And that's much easier to follow.

  • (nodebb) in reply to Steve_The_Cynic

    It is, nonetheless, as noted by @Dragnslcr, a function with an uncomfortably large number of parameters.

    Aaaannnd, I was snecod...

  • Burner (unregistered)

    "I do not know exactly what this is doing" Paid by the character, and time it takes to complete.

  • (nodebb)

    Trying desperately to find a silver lining in this abomination, I will admit that the names are more meaningful than I expected.

  • (nodebb) in reply to Steve_The_Cynic

    Frist of all, the author should have broken the lines on commas

    The implication of the article is that there were no line breaks at all in the original.

    discarding all the repeated jibberjabber

    Yes, discarding the WTFery makes it not a WTF. That's pretty much true of any WTF.

  • (nodebb) in reply to Steve_The_Cynic

    It is, nonetheless, as noted by @Dragnslcr, a function with an uncomfortably large number of parameters.

    One of the 12 parameters is the sum of two values. Another parameter appears to be the value returned from a function that requires four parameters. That's a lot of parameters, but that's not exactly WTFery.

    TRWTF is having a function that takes 12 parameters, but you have to pass 16 values to make it work.

  • Loren Pechtel (unregistered)

    This is what happens when you don't have objects or intermediate values. For an Excel abomination it's not bad.

    16 values are needed to do the calculation (although four can be calculated to a single value), that calls out for structuring somehow--but Excel decidedly does not excel in doing that.

  • Paul Nickerson (github)

    As a fun activity, I tried writing a more readable drop-in replacement without addressing any underlying issues.

    Part = InitechNeoDTMachineDevice.InitechNeoDTActivePartContainer(0).InitechNeoDTActivePart(0)
    PartPart = Part.InitechNeoDTActivePartPartContainer(0).InitechNeoDTActivePartPart(iPart)
    PartPartConductorComposition = PartPart.InitechNeoDTActivePartPartSectionContainer(0).InitechNeoDTActivePartPartSection(0).InitechNeoDTActivePartPartConductorComposition(0)
    PartPartConductor = PartPartConductorComposition.InitechNeoDTActivePartPartConductor(0)
    PartPartConductorRawMaterial = PartPartConductor.InitechNeoDTActivePartPartConductorRawMaterial(0)
    
    DimensionAxialElectricPlusInsulThickness = PartPartConductor.DimensionAxialElectric + PartPartConductor.InsulThickness
    ElectricConductivityAtTemperatureT1 = getElectricConductivityAtTemperatureT1(
        PartPartConductorRawMaterial.ElectricConductivityT0,
        PartPartConductorRawMaterial.MaterialFactor,
        PartPartConductorRawMaterial.ReferenceTemperatureT0,
        InitechNeoDTMachineDevice.ReferenceTemperature),
    
    PartPart.Losses = calcLossesInPart(
        Part.RatedFrequency,
        PartPart.RadialPositionToMainDuct,
        PartPartConductorComposition.IsTransposed,
        PartPartConductorComposition.ParallelRadialCount,
        PartPartConductorComposition.ParallelAxialCount,
        PartPartConductor.Type,
        PartPartConductor.DimensionRadialElectric,
        DimensionAxialElectricPlusInsulThickness,
        ElectricConductivityAtTemperatureT1,
        LayerNumberRatedVoltage,
        PartPart.InitechNeoDTActivePartPartLayerContainer(0),
        Part.RFactor)
    
  • Steve (not that one) (unregistered) in reply to Paul Nickerson

    "As a fun activity," -- You have an interesting idea of "fun activity". :)

  • (nodebb)

    PartPart as a name (or fragment thereof) is a WTF all by itself

  • (nodebb) in reply to thosrtanner

    I propose using PartPart as the programming equivalent of the MoonMoon meme.

Leave a comment on “Formula Length”

Log In or post as a guest

Replying to comment #687928:

« Return to Article