• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Really Terrible Programmers!

Cogman

Lifer
Gah, I think I've seen the devil, and he is OpenFOAM! (not to parody ModelWorks thread too much 🙂)

Code:
00038 int [URL="http://foam.sourceforge.net/doc/Doxygen/html/postCalc_8C.html#0ddf1224851353fc92bfbff6f499fa97"]main[/URL](int argc, char *argv[])
00039 {
00040 
00041 #   include "[URL="http://foam.sourceforge.net/doc/Doxygen/html/setRootCase_8H.html"]setRootCase.H[/URL]"
00042 
00043 #   include "[URL="http://foam.sourceforge.net/doc/Doxygen/html/createTime_8H.html"]createTime.H[/URL]"
00044 #   include "[URL="http://foam.sourceforge.net/doc/Doxygen/html/createMesh_8H.html"]createMesh.H[/URL]"
00045 #   include "createFields.H"
00046 
00047 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00048 
00049     [URL="http://foam.sourceforge.net/doc/Doxygen/html/namespaceFoam.html#501e80d1e14c94973e82f1555e7eb711"]Info[/URL]<< "\nCalculating temperature distribution\n" << [URL="http://foam.sourceforge.net/doc/Doxygen/html/namespaceFoam.html#2db8fe02a0d3909e9351bb4275b23ce4"]endl[/URL];
00050 
00051     while (runTime.loop())
00052     {
00053         [URL="http://foam.sourceforge.net/doc/Doxygen/html/namespaceFoam.html#501e80d1e14c94973e82f1555e7eb711"]Info[/URL]<< "Time = " << runTime.timeName() << [URL="http://foam.sourceforge.net/doc/Doxygen/html/namespaceFoam.html#e53117a9770efe95d2d01bb5cc2c99ef"]nl[/URL] << endl;
00054 
00055 #       include "[URL="http://foam.sourceforge.net/doc/Doxygen/html/readSIMPLEControls_8H.html"]readSIMPLEControls.H[/URL]"
00056 
00057         for (int nonOrth=0; nonOrth<=[URL="http://foam.sourceforge.net/doc/Doxygen/html/src_2finiteVolume_2cfdTools_2general_2include_2readPIMPLEControls_8H.html#060124ee45213b6f2aa5ef8f167ddfcd"]nNonOrthCorr[/URL]; nonOrth++)
00058         {
00059             [URL="http://foam.sourceforge.net/doc/Doxygen/html/compressible_2sonicFoam_2UEqn_8H.html#93f31b5949948976c8eafb225ca3e504"]solve[/URL]
00060             (
00061                 [URL="http://foam.sourceforge.net/doc/Doxygen/html/namespaceFoam_1_1fvc.html#3d0f12fefe9662a52356f0c0aff94efc"]fvm::ddt[/URL]([URL="http://foam.sourceforge.net/doc/Doxygen/html/solvers_2combustion_2coldEngineFoam_2createFields_8H.html#bb80dfe0d55ec4a3a97b2dc1353d66dc"]T[/URL]) - [URL="http://foam.sourceforge.net/doc/Doxygen/html/namespaceFoam_1_1resError.html#4a0c3022439539bbef0dad2906b90d9e"]fvm::laplacian[/URL](DT, [URL="http://foam.sourceforge.net/doc/Doxygen/html/solvers_2combustion_2coldEngineFoam_2createFields_8H.html#bb80dfe0d55ec4a3a97b2dc1353d66dc"]T[/URL])
00062             );
00063         }
00064 
00065 #       include "write.H"
00066 
00067         [URL="http://foam.sourceforge.net/doc/Doxygen/html/namespaceFoam.html#501e80d1e14c94973e82f1555e7eb711"]Info[/URL]<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
00068             << "  ClockTime = " << runTime.elapsedClockTime() << " s"
00069             << [URL="http://foam.sourceforge.net/doc/Doxygen/html/namespaceFoam.html#e53117a9770efe95d2d01bb5cc2c99ef"]nl[/URL] << endl;
00070     }
00071 
00072     [URL="http://foam.sourceforge.net/doc/Doxygen/html/namespaceFoam.html#501e80d1e14c94973e82f1555e7eb711"]Info[/URL]<< "End\n" << endl;
00073 
00074     return 0;
00075 }
Sorry, you're going to have to live with the numbers, I'm too lazy to remove them.

No comments, This isn't the worst example of bad naming schemes, but they do have pretty bad. And I don't know if you noticed it, but they put #includes in the BODY of the code! Yikes, talk about your maintenance nightmares "Oh, whats in this header, humm, source code?"

Other gems include completely inconsistent standards (Lots of mixing between C/C++), I haven't seen a comment yet beyond the GNU license, And variable names get worse, much worse, like this gem

Code:
00043     [URL="http://foam.sourceforge.net/doc/Doxygen/html/UList_8H.html#1a02bffef961ee015f0e9b03d336c6a9"]forAll[/URL](TCells, celli)
00044     {
00045         const typename MixtureType::thermoType& mixture_ =
00046             this->cellMixture(celli);
00047 
00048         TCells[celli] = mixture_.TH(hCells[celli], TCells[celli]);
00049         psiCells[celli] = mixture_.psi(pCells[celli], TCells[celli]);
00050         rhoCells[celli] = mixture_.rho(pCells[celli], TCells[celli]);
00051 
00052         muCells[celli] = mixture_.mu(TCells[celli]);
00053         alphaCells[celli] = mixture_.alpha(TCells[celli]);
00054     }
Yay Open Source, were we can see all your crappy code!

I especially love the definition of the "ForAll" macro. It isn't what you think, I was hoping it would be a threading macro, it isn't. It really does just shorten out the for statement...
 
Last edited:
Good god, this is really bad, I've never seen someone put #includes inside functions.
And what do they put in .h files, single functions??
 
The links provide more, if you can stomach it. Here's what I got out of readSIMPLEControls.H (with the numbers removed with GVim. 🙂)

Code:
     dictionary simple = mesh.solutionDict().subDict("SIMPLE");
 
     int nNonOrthCorr =
         simple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);
 
     bool momentumPredictor =
         simple.lookupOrDefault<Switch>("momentumPredictor", true);
 
     bool fluxGradp =
         simple.lookupOrDefault<Switch>("fluxGradp", false);
 
     bool transonic =
         simple.lookupOrDefault<Switch>("transonic", false);
Looks like somebody who likes Perl tried to interface with C++. The initial method returns a result as a Dictionary; then the rest of the file extracts all the values into individual C++ variables. And I'm not sure they all even get used! D: D: D:

Edit: And I notice that the one variable I'm sure gets used is the one variable that does not match its Dictionary name! Ugh!
 
Last edited:
The links provide more, if you can stomach it. Here's what I got out of readSIMPLEControls.H (with the numbers removed with GVim. 🙂)

Code:
     dictionary simple = mesh.solutionDict().subDict("SIMPLE");
 
     int nNonOrthCorr =
         simple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);
 
     bool momentumPredictor =
         simple.lookupOrDefault<Switch>("momentumPredictor", true);
 
     bool fluxGradp =
         simple.lookupOrDefault<Switch>("fluxGradp", false);
 
     bool transonic =
         simple.lookupOrDefault<Switch>("transonic", false);
Looks like somebody who likes Perl tried to interface with C++. The initial method returns a result as a Dictionary; then the rest of the file extracts all the values into individual C++ variables. And I'm not sure they all even get used! D: D: D:

Edit: And I notice that the one variable I'm sure gets used is the one variable that does not match its Dictionary name! Ugh!

If you look up Openfoam, it is a huge project, and all barfed up into one directory. I wonder if the fact that it dates back to 1991 has anything to do with it.

Ok, looking through the code, Outside of the solver is "OK" and not strictly terrible, but whoever wrote the solver code must have been on crack. I do laugh at some of the ridiculous names they have like
pressureNormalInletOutletVelocityFvPatchVectorField.C
 
Last edited:
There's some code I had to work on where some of the variable names were 3 full lines and still managed to not be particularly descriptive. There was also constants named _3. This is code that's in use by a pretty large organization...
 
There's some code I had to work on where some of the variable names were 3 full lines and still managed to not be particularly descriptive. There was also constants named _3. This is code that's in use by a pretty large organization...

Wow. The following came to mind when I saw your post Talk about evil constants:
const int _3 = 18;
 
Back
Top