• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Object or No: Good Practices

Scheduled Pinned Locked Moved Developers' Forum
4 Posts 3 Posters 538 Views 3 Watching
Loading More Posts
  • 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.
  • H Offline
    hsmyers
    last edited by 21 May 2016, 17:05

    Given a simple extension should it be 'objectified'? By definition, it is already an object, so is there a preference to go further? Having started before C++ but after Simula, my habit is to only sparingly use objects and then usually to make the code more straight forward. If the language is missing something and I can best model it as an object then that's what I will do, otherwise I tend to see it as overhead. Please correct or enlighten me as needed.

    1 Reply Last reply Reply Quote 0
    • S Offline
      slbaumgartner
      last edited by 21 May 2016, 20:27

      Perhaps you really mean whether to use classes or not, as in Ruby everything is an object! This question is likely to get somewhat religious answers from OO fanatics!

      You should use at least modules to isolate namespaces. In Ruby the differences between modules and classes are more subtle than in many other OO languages, but it really comes down to whether the things you are coding need to have individual memory (state) hence be instances of a class, or just shared configuration in which case you could use either.

      1 Reply Last reply Reply Quote 0
      • H Offline
        hsmyers
        last edited by 21 May 2016, 20:47

        @slbaumgartner said:

        Perhaps you really mean whether to use classes or not, as in Ruby everything is an object! This question is likely to get somewhat religious answers from OO fanatics!

        Ah! You've detected my plan 😎 A lively discussion would be a good thing!

        @slbaumgartner said:

        You should use at least modules to isolate namespaces. In Ruby the differences between modules and classes are more subtle than in many other OO languages, but it really comes down to whether the things you are coding need to have individual memory (state) hence be instances of a class, or just shared configuration in which case you could use either.

        Good explanation, without frou-frou. I'm familiar with C++ (very), Smalltalk (less very) and most of the script languages currently around---I'm a bit of a language slut, seldom seen one I didn't find interesting enough to learn. Because of this I am aware of OO both integral as well as bolt on, say Python versus Perl. My preference is bolt on but that's not a statement of value just something based on experience and my programming origins (IBM-BAL was my first).

        Your rationale for using an object/s agrees with my preferences particularly with short succinct code like my extension, but the discussion is young yet!

        1 Reply Last reply Reply Quote 0
        • G Offline
          Garry K
          last edited by 21 May 2016, 21:35

          I've been coding all the way back to my assembler days (pre 1980). Various flavors of (Basic, Cobol, C, C++, Pascal, C#, Java), many database scripting languages such as (dBase, MSAcces, Paradox), other scripting languages such as javascript, jquery, PHP, Ruby, CSS, SQL. AWK, TCL ...

          I usually go with the flow. Borland built a very good library called the VCL (Visual Components Library), which makes use of an absolutely excellent object oriented set of classes. Easy to follow and very consistent stylisticly. This library is used by Delphi (object oriented pascal) and by C++ Builder.

          Microsoft built a terrible interface called MFC (Microsoft Foundation Classes). So when I had to use Microsoft for various early mobile devices I skipped it and used the Win API.


          With Sketchup I use a mix of both Classes (for tools) and simple reusable methods for helper functions. Even though I prefer using pointers with C, C++ etc. it just isn't possible with ruby (although under the hood most everything is passed as a reference).

          Having said all that - Ruby is quite good - although there are a few too many ways to do anything. This just means it is often a bit slower reading other code as the programmer often chooses a different way to do things.

          So I'm a bit more formal and like to use terse syntax where possible. ! instead of not, || instead of or, immediate if = ? :, parenthesis for all methods, lots of white space etc. For me it is all about readability so I can come back and speed read code I wrote months or years ago.

          But I do like some of Ruby's ways. "#{var}" the use of if after an assignment etc.

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          1 / 1
          • First post
            1/4
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement