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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. The Lounge
  3. Objective-C

Objective-C

Scheduled Pinned Locked Moved The Lounge
csharplearningc++javadelphi
9 Posts 6 Posters 1 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.
  • R Offline
    R Offline
    Rohde
    wrote on last edited by
    #1

    So, in my spare time I'm learning some Cocoa on the Mac - you know just to widen my horizon (I do C#/ASP.NET at my day-job) and I absolutely love the Objective-C message sending syntax even though it's kind of verbose. I'll use the example from Hillegass' book (Cocoa Programming for Mac OS X, Second Edition) to contrast C++ (and Java and C# for that matter) with Objective-C:

    if (x.intersectsArc(35.0, 19.0, 23.0, 90.0, 120.0))

    vs.

    if ([x intersectsArcWithRadius:35.0
    centeredAtX:19.0
    Y:23.0
    fromAngle:90.0
    toAngle:120.0])

    Yes, it's more wordy (and I normally hate wordy languages like Pascal and VB), but rest of the language is just as terse as the other curly-brace languages (although I could do without the brackets [ ...and... ]). So, any of you have any experience with Objective-C and Cocoa, and if so whada you think?


    "When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
    -Atlas Shrugged, Ayn Rand

    M P D G 4 Replies Last reply
    0
    • R Rohde

      So, in my spare time I'm learning some Cocoa on the Mac - you know just to widen my horizon (I do C#/ASP.NET at my day-job) and I absolutely love the Objective-C message sending syntax even though it's kind of verbose. I'll use the example from Hillegass' book (Cocoa Programming for Mac OS X, Second Edition) to contrast C++ (and Java and C# for that matter) with Objective-C:

      if (x.intersectsArc(35.0, 19.0, 23.0, 90.0, 120.0))

      vs.

      if ([x intersectsArcWithRadius:35.0
      centeredAtX:19.0
      Y:23.0
      fromAngle:90.0
      toAngle:120.0])

      Yes, it's more wordy (and I normally hate wordy languages like Pascal and VB), but rest of the language is just as terse as the other curly-brace languages (although I could do without the brackets [ ...and... ]). So, any of you have any experience with Objective-C and Cocoa, and if so whada you think?


      "When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
      -Atlas Shrugged, Ayn Rand

      M Offline
      M Offline
      Michael Sadlon
      wrote on last edited by
      #2

      I don't see the large improvement. If the argument names matter so much, then do this:

      if (x.intersectsArc(
      35.0, //intersects Arc With Radius
      19.0, //centered At X
      23.0, //Y
      90.0, //from Angle
      120.0 //to Angle
      ))

      Otherwise, it looks like normal C to me. Am I missing something ingenius?

      S 1 Reply Last reply
      0
      • R Rohde

        So, in my spare time I'm learning some Cocoa on the Mac - you know just to widen my horizon (I do C#/ASP.NET at my day-job) and I absolutely love the Objective-C message sending syntax even though it's kind of verbose. I'll use the example from Hillegass' book (Cocoa Programming for Mac OS X, Second Edition) to contrast C++ (and Java and C# for that matter) with Objective-C:

        if (x.intersectsArc(35.0, 19.0, 23.0, 90.0, 120.0))

        vs.

        if ([x intersectsArcWithRadius:35.0
        centeredAtX:19.0
        Y:23.0
        fromAngle:90.0
        toAngle:120.0])

        Yes, it's more wordy (and I normally hate wordy languages like Pascal and VB), but rest of the language is just as terse as the other curly-brace languages (although I could do without the brackets [ ...and... ]). So, any of you have any experience with Objective-C and Cocoa, and if so whada you think?


        "When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
        -Atlas Shrugged, Ayn Rand

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

        No idea at all, but the named arguments would be a big helper for many-param-functions. It helps readability of the code a lot - esp. if it is optional (is it?) so I can be as terse or verbose as the context requires.


        To many words
        - me, during, while and after reading Atlas Shrugged.

        1 Reply Last reply
        0
        • M Michael Sadlon

          I don't see the large improvement. If the argument names matter so much, then do this:

          if (x.intersectsArc(
          35.0, //intersects Arc With Radius
          19.0, //centered At X
          23.0, //Y
          90.0, //from Angle
          120.0 //to Angle
          ))

          Otherwise, it looks like normal C to me. Am I missing something ingenius?

          S Offline
          S Offline
          Shog9 0
          wrote on last edited by
          #4

          ...Now you have another place for bugs to hide... Think about how many Win32 functions take a structure as a parameter. With named parameters, this is less necessary, as functions with many arguments become less troublesome.

          ----

          Yes, but can you blame them for doing so if that's the only legal way they can hire programmers they want at the rate they can afford?

          -- Nish on sketchy hiring practices

          1 Reply Last reply
          0
          • R Rohde

            So, in my spare time I'm learning some Cocoa on the Mac - you know just to widen my horizon (I do C#/ASP.NET at my day-job) and I absolutely love the Objective-C message sending syntax even though it's kind of verbose. I'll use the example from Hillegass' book (Cocoa Programming for Mac OS X, Second Edition) to contrast C++ (and Java and C# for that matter) with Objective-C:

            if (x.intersectsArc(35.0, 19.0, 23.0, 90.0, 120.0))

            vs.

            if ([x intersectsArcWithRadius:35.0
            centeredAtX:19.0
            Y:23.0
            fromAngle:90.0
            toAngle:120.0])

            Yes, it's more wordy (and I normally hate wordy languages like Pascal and VB), but rest of the language is just as terse as the other curly-brace languages (although I could do without the brackets [ ...and... ]). So, any of you have any experience with Objective-C and Cocoa, and if so whada you think?


            "When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
            -Atlas Shrugged, Ayn Rand

            D Offline
            D Offline
            Daniel Grunwald
            wrote on last edited by
            #5

            Why not make an arc an object instead of having huge parameter lists everywhere you expect an arc? Add C# 3.0 object initializer syntax and you get:

            Arc arc = new Arc { Radius = 35, Center = { 19, 23 }, FromAngle = 90, ToAngle = 120 };
            if (x.IntersectsArc(arc)) {
            ...
            }
            class Arc {
            public double Radius, FromAngle, ToAngle;
            public Point Center;
            }

            R 1 Reply Last reply
            0
            • D Daniel Grunwald

              Why not make an arc an object instead of having huge parameter lists everywhere you expect an arc? Add C# 3.0 object initializer syntax and you get:

              Arc arc = new Arc { Radius = 35, Center = { 19, 23 }, FromAngle = 90, ToAngle = 120 };
              if (x.IntersectsArc(arc)) {
              ...
              }
              class Arc {
              public double Radius, FromAngle, ToAngle;
              public Point Center;
              }

              R Offline
              R Offline
              Rohde
              wrote on last edited by
              #6

              Yes, that is also a good way to do it. I really like some of the C# 3.0 features.


              "When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
              -Atlas Shrugged, Ayn Rand

              1 Reply Last reply
              0
              • R Rohde

                So, in my spare time I'm learning some Cocoa on the Mac - you know just to widen my horizon (I do C#/ASP.NET at my day-job) and I absolutely love the Objective-C message sending syntax even though it's kind of verbose. I'll use the example from Hillegass' book (Cocoa Programming for Mac OS X, Second Edition) to contrast C++ (and Java and C# for that matter) with Objective-C:

                if (x.intersectsArc(35.0, 19.0, 23.0, 90.0, 120.0))

                vs.

                if ([x intersectsArcWithRadius:35.0
                centeredAtX:19.0
                Y:23.0
                fromAngle:90.0
                toAngle:120.0])

                Yes, it's more wordy (and I normally hate wordy languages like Pascal and VB), but rest of the language is just as terse as the other curly-brace languages (although I could do without the brackets [ ...and... ]). So, any of you have any experience with Objective-C and Cocoa, and if so whada you think?


                "When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
                -Atlas Shrugged, Ayn Rand

                G Offline
                G Offline
                Gary R Wheeler
                wrote on last edited by
                #7

                This seems similar to the named arguments feature available in Ada, one of the few features in that programming language I actively miss in C++.


                Software Zen: delete this;

                Fold With Us![^]

                R 1 Reply Last reply
                0
                • G Gary R Wheeler

                  This seems similar to the named arguments feature available in Ada, one of the few features in that programming language I actively miss in C++.


                  Software Zen: delete this;

                  Fold With Us![^]

                  R Offline
                  R Offline
                  Rohde
                  wrote on last edited by
                  #8

                  Ada, now there's a language I've looked at many times, but never really tried. Some of the features seems quite nice, but it seems pretty useless for what I do because of lack of toolkits etc, but I guess it's pretty big in Dod.


                  "When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
                  -Atlas Shrugged, Ayn Rand

                  G 1 Reply Last reply
                  0
                  • R Rohde

                    Ada, now there's a language I've looked at many times, but never really tried. Some of the features seems quite nice, but it seems pretty useless for what I do because of lack of toolkits etc, but I guess it's pretty big in Dod.


                    "When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
                    -Atlas Shrugged, Ayn Rand

                    G Offline
                    G Offline
                    Gary R Wheeler
                    wrote on last edited by
                    #9

                    I have no idea how prominent Ada is even in the defense community any longer. When it was originally developed, the idea was to make Ada the one programming language used throughout the DoD. I don't think that ever materialized.


                    Software Zen: delete this;

                    Fold With Us![^]

                    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