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. Can you top that?

Can you top that?

Scheduled Pinned Locked Moved The Weird and The Wonderful
c++csscomhelpquestion
8 Posts 5 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.
  • P Offline
    P Offline
    peterchen
    wrote on last edited by
    #1

    My rule of thumb is "4 method parameters are fine, 6 is questionable, 8 are a problem". Here I present you what I have to deal with:

    long BunnyInitSub( BunnyType eBunnyType,
    long lBunnyIndex,
    CString sBunnyLabel1,
    long lBunnyColor1,
    bool bBunnyAutoScale1,
    bool bBunnyAutoMin1,
    bool bBunnyAutoMax1,
    double dBunnyMin1,
    double dBunnyMax1,
    bool bBunnyLogScale1,
    bool bOverlap,
    long lBunnyPlotFirst,
    bool bEnableSecondPlot,
    long lBunnyPlotSecond = EASTER_LINE,
    bool bEnableSubBunny = false,
    CString sBunnyLabel2 = _T(""),
    long lBunnyColor2 = black,
    bool bBunnyAutoScale2 = true,
    bool bBunnyAutoMin2 = true,
    bool bBunnyAutoMax2 = true,
    double dBunnyMin2 = 0,
    double dBunnyMax2 = 0,
    bool bBunnyLogScale2 = false );

    Thank you, Visual Assist, for coping with this horror! (No it's not Bunny in the original code. Changed to protect the nocent.) Yes, this is more or less two times the same information. Which are, internally, stored in a struct with similar layout as the method. Serialized raw, requiring two-way-compatibility. Which, due to some mishap with "storage size optimizations" don't even have identical alignment, so can't be replaced with two instances of half the struct. Gaaaaaaah!

    FILETIME to time_t
    | FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy

    V S M L 5 Replies Last reply
    0
    • P peterchen

      My rule of thumb is "4 method parameters are fine, 6 is questionable, 8 are a problem". Here I present you what I have to deal with:

      long BunnyInitSub( BunnyType eBunnyType,
      long lBunnyIndex,
      CString sBunnyLabel1,
      long lBunnyColor1,
      bool bBunnyAutoScale1,
      bool bBunnyAutoMin1,
      bool bBunnyAutoMax1,
      double dBunnyMin1,
      double dBunnyMax1,
      bool bBunnyLogScale1,
      bool bOverlap,
      long lBunnyPlotFirst,
      bool bEnableSecondPlot,
      long lBunnyPlotSecond = EASTER_LINE,
      bool bEnableSubBunny = false,
      CString sBunnyLabel2 = _T(""),
      long lBunnyColor2 = black,
      bool bBunnyAutoScale2 = true,
      bool bBunnyAutoMin2 = true,
      bool bBunnyAutoMax2 = true,
      double dBunnyMin2 = 0,
      double dBunnyMax2 = 0,
      bool bBunnyLogScale2 = false );

      Thank you, Visual Assist, for coping with this horror! (No it's not Bunny in the original code. Changed to protect the nocent.) Yes, this is more or less two times the same information. Which are, internally, stored in a struct with similar layout as the method. Serialized raw, requiring two-way-compatibility. Which, due to some mishap with "storage size optimizations" don't even have identical alignment, so can't be replaced with two instances of half the struct. Gaaaaaaah!

      FILETIME to time_t
      | FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy

      V Offline
      V Offline
      Vladimir Svyatski
      wrote on last edited by
      #2

      Didn't you happen to work with Excel COM API? For example Microsoft.Office.Interop.Excel.Dialog.Show has 30 parameters. Cool, isn't it? They are optional of course, but in languages like C# before 4.0 you've got to specify them all:mad:

      1 Reply Last reply
      0
      • P peterchen

        My rule of thumb is "4 method parameters are fine, 6 is questionable, 8 are a problem". Here I present you what I have to deal with:

        long BunnyInitSub( BunnyType eBunnyType,
        long lBunnyIndex,
        CString sBunnyLabel1,
        long lBunnyColor1,
        bool bBunnyAutoScale1,
        bool bBunnyAutoMin1,
        bool bBunnyAutoMax1,
        double dBunnyMin1,
        double dBunnyMax1,
        bool bBunnyLogScale1,
        bool bOverlap,
        long lBunnyPlotFirst,
        bool bEnableSecondPlot,
        long lBunnyPlotSecond = EASTER_LINE,
        bool bEnableSubBunny = false,
        CString sBunnyLabel2 = _T(""),
        long lBunnyColor2 = black,
        bool bBunnyAutoScale2 = true,
        bool bBunnyAutoMin2 = true,
        bool bBunnyAutoMax2 = true,
        double dBunnyMin2 = 0,
        double dBunnyMax2 = 0,
        bool bBunnyLogScale2 = false );

        Thank you, Visual Assist, for coping with this horror! (No it's not Bunny in the original code. Changed to protect the nocent.) Yes, this is more or less two times the same information. Which are, internally, stored in a struct with similar layout as the method. Serialized raw, requiring two-way-compatibility. Which, due to some mishap with "storage size optimizations" don't even have identical alignment, so can't be replaced with two instances of half the struct. Gaaaaaaah!

        FILETIME to time_t
        | FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy

        S Offline
        S Offline
        Single Step Debugger
        wrote on last edited by
        #3

        Someone there has no fucking idea how to pass object, object reference or pointer to object as a function parameter.

        There is only one Ashley Judd and Salma Hayek is her prophet! Advertise here – minimum three posts per day are guaranteed.

        P 1 Reply Last reply
        0
        • S Single Step Debugger

          Someone there has no fucking idea how to pass object, object reference or pointer to object as a function parameter.

          There is only one Ashley Judd and Salma Hayek is her prophet! Advertise here – minimum three posts per day are guaranteed.

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

          That's what I wished for: one struct per "bunny" with good initializers, and an Init method taking one or two of them. The guy would have done better with some guidance. It's a rarely used part of the API - I've already fixed the more common parts. What hurts most is that even without those objects, he could have folded three of the bools into the two doubles. Twice.

          FILETIME to time_t
          | FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy

          1 Reply Last reply
          0
          • P peterchen

            My rule of thumb is "4 method parameters are fine, 6 is questionable, 8 are a problem". Here I present you what I have to deal with:

            long BunnyInitSub( BunnyType eBunnyType,
            long lBunnyIndex,
            CString sBunnyLabel1,
            long lBunnyColor1,
            bool bBunnyAutoScale1,
            bool bBunnyAutoMin1,
            bool bBunnyAutoMax1,
            double dBunnyMin1,
            double dBunnyMax1,
            bool bBunnyLogScale1,
            bool bOverlap,
            long lBunnyPlotFirst,
            bool bEnableSecondPlot,
            long lBunnyPlotSecond = EASTER_LINE,
            bool bEnableSubBunny = false,
            CString sBunnyLabel2 = _T(""),
            long lBunnyColor2 = black,
            bool bBunnyAutoScale2 = true,
            bool bBunnyAutoMin2 = true,
            bool bBunnyAutoMax2 = true,
            double dBunnyMin2 = 0,
            double dBunnyMax2 = 0,
            bool bBunnyLogScale2 = false );

            Thank you, Visual Assist, for coping with this horror! (No it's not Bunny in the original code. Changed to protect the nocent.) Yes, this is more or less two times the same information. Which are, internally, stored in a struct with similar layout as the method. Serialized raw, requiring two-way-compatibility. Which, due to some mishap with "storage size optimizations" don't even have identical alignment, so can't be replaced with two instances of half the struct. Gaaaaaaah!

            FILETIME to time_t
            | FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy

            M Offline
            M Offline
            musefan
            wrote on last edited by
            #5

            I think you should send your rule over to Microsoft. some of their developers are still using the classic rule of... 40 method parameters are fine, 20 is questionable, 10 is a problem

            Illogical thoughts make me ill

            1 Reply Last reply
            0
            • P peterchen

              My rule of thumb is "4 method parameters are fine, 6 is questionable, 8 are a problem". Here I present you what I have to deal with:

              long BunnyInitSub( BunnyType eBunnyType,
              long lBunnyIndex,
              CString sBunnyLabel1,
              long lBunnyColor1,
              bool bBunnyAutoScale1,
              bool bBunnyAutoMin1,
              bool bBunnyAutoMax1,
              double dBunnyMin1,
              double dBunnyMax1,
              bool bBunnyLogScale1,
              bool bOverlap,
              long lBunnyPlotFirst,
              bool bEnableSecondPlot,
              long lBunnyPlotSecond = EASTER_LINE,
              bool bEnableSubBunny = false,
              CString sBunnyLabel2 = _T(""),
              long lBunnyColor2 = black,
              bool bBunnyAutoScale2 = true,
              bool bBunnyAutoMin2 = true,
              bool bBunnyAutoMax2 = true,
              double dBunnyMin2 = 0,
              double dBunnyMax2 = 0,
              bool bBunnyLogScale2 = false );

              Thank you, Visual Assist, for coping with this horror! (No it's not Bunny in the original code. Changed to protect the nocent.) Yes, this is more or less two times the same information. Which are, internally, stored in a struct with similar layout as the method. Serialized raw, requiring two-way-compatibility. Which, due to some mishap with "storage size optimizations" don't even have identical alignment, so can't be replaced with two instances of half the struct. Gaaaaaaah!

              FILETIME to time_t
              | FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              You never worked in the kernel then... NTSTATUS ZwCreateFile( __out PHANDLE FileHandle, __in ACCESS_MASK DesiredAccess, __in POBJECT_ATTRIBUTES ObjectAttributes, __out PIO_STATUS_BLOCK IoStatusBlock, __in_opt PLARGE_INTEGER AllocationSize, __in ULONG FileAttributes, __in ULONG ShareAccess, __in ULONG CreateDisposition, __in ULONG CreateOptions, __in_opt PVOID EaBuffer, __in ULONG EaLength );

              "It is a remarkable fact that despite the worldwide expenditure of perhaps US$50 billion since 1990, and the efforts of tens of thousands of scientists worldwide, no human climate signal has yet been detected that is distinct from natural variation." Bob Carter, Research Professor of Geology, James Cook University, Townsville

              P 1 Reply Last reply
              0
              • L Lost User

                You never worked in the kernel then... NTSTATUS ZwCreateFile( __out PHANDLE FileHandle, __in ACCESS_MASK DesiredAccess, __in POBJECT_ATTRIBUTES ObjectAttributes, __out PIO_STATUS_BLOCK IoStatusBlock, __in_opt PLARGE_INTEGER AllocationSize, __in ULONG FileAttributes, __in ULONG ShareAccess, __in ULONG CreateDisposition, __in ULONG CreateOptions, __in_opt PVOID EaBuffer, __in ULONG EaLength );

                "It is a remarkable fact that despite the worldwide expenditure of perhaps US$50 billion since 1990, and the efforts of tens of thousands of scientists worldwide, no human climate signal has yet been detected that is distinct from natural variation." Bob Carter, Research Professor of Geology, James Cook University, Townsville

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

                Still 11 < 23 ;) Not much worse than Win32 CreateFile. My rules of thumb would get some leeway (say a +2..+4 modifier) for a C-StyleAPI, so the scratch by. Also, it's a rule for orientation - if one in 100 methods violates that, it's fine, if one in ten does, it's a problem.

                FILETIME to time_t
                | FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy

                1 Reply Last reply
                0
                • P peterchen

                  My rule of thumb is "4 method parameters are fine, 6 is questionable, 8 are a problem". Here I present you what I have to deal with:

                  long BunnyInitSub( BunnyType eBunnyType,
                  long lBunnyIndex,
                  CString sBunnyLabel1,
                  long lBunnyColor1,
                  bool bBunnyAutoScale1,
                  bool bBunnyAutoMin1,
                  bool bBunnyAutoMax1,
                  double dBunnyMin1,
                  double dBunnyMax1,
                  bool bBunnyLogScale1,
                  bool bOverlap,
                  long lBunnyPlotFirst,
                  bool bEnableSecondPlot,
                  long lBunnyPlotSecond = EASTER_LINE,
                  bool bEnableSubBunny = false,
                  CString sBunnyLabel2 = _T(""),
                  long lBunnyColor2 = black,
                  bool bBunnyAutoScale2 = true,
                  bool bBunnyAutoMin2 = true,
                  bool bBunnyAutoMax2 = true,
                  double dBunnyMin2 = 0,
                  double dBunnyMax2 = 0,
                  bool bBunnyLogScale2 = false );

                  Thank you, Visual Assist, for coping with this horror! (No it's not Bunny in the original code. Changed to protect the nocent.) Yes, this is more or less two times the same information. Which are, internally, stored in a struct with similar layout as the method. Serialized raw, requiring two-way-compatibility. Which, due to some mishap with "storage size optimizations" don't even have identical alignment, so can't be replaced with two instances of half the struct. Gaaaaaaah!

                  FILETIME to time_t
                  | FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  Top that? Easily. Here is just one of endlessly many similar static methods in an application I just replaced (including comments and documentation):

                  public static int DoSomethingWithBunnies(int auswahl, string artnr, string artbez, string lnam,
                  string lnr, string lartnr, string wg, string mkenz, string ean,
                  string gab, bool ges, bool bug, bool bau, bool eks, int stanort,
                  string uid)
                  {
                  // You don't want to see what comes here
                  }

                  Edit: It's not the number of parameters that's the problem here. Much worse that all methods are static, usually at least 1000 lines of the worst spaghetti code long and often redundant. There are at least two more versions of this particular method here with '2' and '3' added to the name with little to no apparent differences in the copied code. All without any comments except for those I added or any documentation.

                  "I have what could be described as the most wide-open sense of humor on the site, and if I don't think something is funny, then it really isn't." - JSOC, 2011 -----
                  "Friar Modest never was a prior" - Italian proverb

                  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