'Library' etc. methods ?

Home Forums General Programming 'Library' etc. methods ?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #83095
    human fly
    Participant
      • Topics: 124
      • Replies: 1070
      • Total: 1194
      • ★★★★

      having seen examples of methods that are a collection
      of functions that can be either called at startup, or
      from any method, i’ve started using this, and it works
      well to simplify a long method.

      however: i’ve also found, conversely, that it can make it
      quite complicated to keep track if you overuse this practice:
      ie: keeping track of variable names, or just ending up with
      situations where functions are run more than once, and become
      inter-dependent.

      any thoughts and tips on using and handling these external
      functions? (i quite like being able to summarise a piece of
      code by simply invoking it, and, wherever possible, keeping
      my method to something quite short and easily ‘scannable’)

      does this constitute ‘spaghetti’, and make it unreadable?
      or is it in fact good practice?

      #83098
      dasfaker
      Keymaster
        • Topics: 80
        • Replies: 793
        • Total: 873
        • ★★★

        While I’m not a programmer, it’s very useful to have functions independent of methods, so you can call them at any time form anywhere.

        Remember that you can use local variables to avoid problems with their names

        filter = panel:getModualtorByName(“Filter) — global variable
        local filter = panel:getModualtorByName(“Filter) — local variable

        #83140
        goodweather
        Participant
          • Topics: 45
          • Replies: 550
          • Total: 595
          • ★★★

          Exactly!
          I’m using one method as container for several functions. This method is then not connected to any modulator or panel element.
          When connected to a modulator or panel element thenh it is better to have one to one.
          And the same method can be used for several modulators performing the same stuff (for example OscShape_OnChange working for Osc1, Osc2, Osc3…). Just a matter to identify the modulator that triggered the method…

          #83150
          human fly
          Participant
            • Topics: 124
            • Replies: 1070
            • Total: 1194
            • ★★★★

            yes yes it’s great, and i got the idea from goodweather – probably
            both of you in fact. except i’m a bit of a novice at it, and tried
            to be too clever probably, and had one function that was so useful
            it ended up called by other functions, and the whole thing was getting
            a bit circuitous lol
            ie: i checked, enabling a console print, and saw that appear 3x each
            time i clicked a button.
            so maybe i just need to cool my heels a little and organise a bit better.

            #83151
            human fly
            Participant
              • Topics: 124
              • Replies: 1070
              • Total: 1194
              • ★★★★

              but it did occur to me that i could go quite a long way
              with these function calls – ie: each time i want the
              display refreshed, even something very simple, sending
              text to a label, insert the function. in fact just keeping
              this simple, and not depending on too much other stuff,
              could be best (with what i’m doing).

            Viewing 5 posts - 1 through 5 (of 5 total)
            • The forum ‘Programming’ is closed to new topics and replies.
            There is currently 0 users and 62 guests online
            No users are currently active
            Forum Statistics
            Threads: 2,495, Posts: 17,374, Members: 77,605
            Most users ever online was 12 on January 22, 2019 3:47 pm
            Ctrlr