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. Strong Typing

Strong Typing

Scheduled Pinned Locked Moved The Weird and The Wonderful
42 Posts 17 Posters 12 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.
  • T Tristan Rhodes

    "Don't bother with it, waste of time." :wtf:

    ------------------------------- Carrier Bags - 21st Century Tumbleweed.

    J Offline
    J Offline
    John R Shaw
    wrote on last edited by
    #15

    What are you talking about? If you are talking about variable type checking in C++, then you are wrong. I wish C was as tight with its type checking. Then again I wish C would allow me to declare a variable where ever I wanted too, instead of forcing me to create a new scope. P.S. I liked C, but I love C++.

    INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

    P P T 3 Replies Last reply
    0
    • J John R Shaw

      What are you talking about? If you are talking about variable type checking in C++, then you are wrong. I wish C was as tight with its type checking. Then again I wish C would allow me to declare a variable where ever I wanted too, instead of forcing me to create a new scope. P.S. I liked C, but I love C++.

      INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #16

      John R. Shaw wrote:

      What are you talking about?

      I am not sure either...

      1 Reply Last reply
      0
      • J John R Shaw

        What are you talking about? If you are talking about variable type checking in C++, then you are wrong. I wish C was as tight with its type checking. Then again I wish C would allow me to declare a variable where ever I wanted too, instead of forcing me to create a new scope. P.S. I liked C, but I love C++.

        INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #17

        John R. Shaw wrote:

        Then again I wish C would allow me to declare a variable where ever I wanted

        I prefer to have all the declarations in one place (the top) so in C# I still do that by choice. But requiring such isn't very friendly, flexibility is good.

        P J S E C 5 Replies Last reply
        0
        • P PIEBALDconsult

          John R. Shaw wrote:

          Then again I wish C would allow me to declare a variable where ever I wanted

          I prefer to have all the declarations in one place (the top) so in C# I still do that by choice. But requiring such isn't very friendly, flexibility is good.

          P Offline
          P Offline
          Paul Conrad
          wrote on last edited by
          #18

          PIEBALDconsult wrote:

          I prefer to have all the declarations in one place (the top) so in C# I still do that by choice.

          Same here, sure beats having to browse through the code looking for the declarations...

          J 1 Reply Last reply
          0
          • P PIEBALDconsult

            John R. Shaw wrote:

            Then again I wish C would allow me to declare a variable where ever I wanted

            I prefer to have all the declarations in one place (the top) so in C# I still do that by choice. But requiring such isn't very friendly, flexibility is good.

            J Offline
            J Offline
            John R Shaw
            wrote on last edited by
            #19

            I agree requiring such is not varying friendly, and is a real pain int the <blank>. Here are some thoughts to consider when writing you code.: 1) In C you can wrap a variable declaration in a scope and if that scope is not entered then no space is allocated on the stack for it (saves cycles and memory). This applies to languages other than C, including C#. 2) In C++ you can wrap a class (variable) declaration in a scope and if that scope is not entered then the constructor and destructor are not called.

            INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

            1 Reply Last reply
            0
            • P PIEBALDconsult

              John R. Shaw wrote:

              Then again I wish C would allow me to declare a variable where ever I wanted

              I prefer to have all the declarations in one place (the top) so in C# I still do that by choice. But requiring such isn't very friendly, flexibility is good.

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

              PIEBALDconsult wrote:

              I prefer to have all the declarations in one place (the top) so in C# I still do that by choice.

              I hate that. Although it probably doesn't help that most of the functions i see doing it are hundreds of lines long, making it a real chore to track down declarations and ensure variables are being used correctly.

              ----

              It appears that everybody is under the impression that I approve of the documentation. You probably also blame Ken Burns for supporting slavery.

              --Raymond Chen on MSDN

              P 1 Reply Last reply
              0
              • S Shog9 0

                PIEBALDconsult wrote:

                I prefer to have all the declarations in one place (the top) so in C# I still do that by choice.

                I hate that. Although it probably doesn't help that most of the functions i see doing it are hundreds of lines long, making it a real chore to track down declarations and ensure variables are being used correctly.

                ----

                It appears that everybody is under the impression that I approve of the documentation. You probably also blame Ken Burns for supporting slavery.

                --Raymond Chen on MSDN

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #21

                Yeah, if you can't the declaration then your method is too big (size matters). On the other hand, if they're all at the top, they're easy to find.

                1 Reply Last reply
                0
                • P PIEBALDconsult

                  John R. Shaw wrote:

                  Then again I wish C would allow me to declare a variable where ever I wanted

                  I prefer to have all the declarations in one place (the top) so in C# I still do that by choice. But requiring such isn't very friendly, flexibility is good.

                  E Offline
                  E Offline
                  eggsovereasy
                  wrote on last edited by
                  #22

                  Lol I think I was using C# for about 4 months before I realized I didn't have to do it. Its a tough choice though, all declarations at the top make it much easier for someone to come in and read your code, whereas its easier to code when I can make a variable whenever I need one. You can definitely look at my code and see the days on which I was lazy, because there is nothing in our coding guidelines about where to put variable declarations.

                  1 Reply Last reply
                  0
                  • P Paul Conrad

                    PIEBALDconsult wrote:

                    I prefer to have all the declarations in one place (the top) so in C# I still do that by choice.

                    Same here, sure beats having to browse through the code looking for the declarations...

                    J Offline
                    J Offline
                    jhwurmbach
                    wrote on last edited by
                    #23

                    Paul Conrad wrote:

                    browse through the code

                    But you did know about the existence of the CTRL-F feature of your editor? Or (with any modern IDE) even the context menus 'Go to Declaration' feature? :~


                    Failure is not an option - it's built right in.

                    D 1 Reply Last reply
                    0
                    • J jhwurmbach

                      Paul Conrad wrote:

                      browse through the code

                      But you did know about the existence of the CTRL-F feature of your editor? Or (with any modern IDE) even the context menus 'Go to Declaration' feature? :~


                      Failure is not an option - it's built right in.

                      D Offline
                      D Offline
                      dighn
                      wrote on last edited by
                      #24

                      But then you have to go back to where you were. Sure you could take note of the position but it would still be annoying.

                      J R 2 Replies Last reply
                      0
                      • T Tristan Rhodes

                        "Don't bother with it, waste of time." :wtf:

                        ------------------------------- Carrier Bags - 21st Century Tumbleweed.

                        U Offline
                        U Offline
                        urbane tiger
                        wrote on last edited by
                        #25

                        breaks keyboards too

                        1 Reply Last reply
                        0
                        • D dighn

                          But then you have to go back to where you were. Sure you could take note of the position but it would still be annoying.

                          J Offline
                          J Offline
                          jhwurmbach
                          wrote on last edited by
                          #26

                          Those points that are the hotspots of my current working are CTRL-F2-bookmarked anyway. And if I only want to know the type of a variable, Intellisense would open that little tooltip for me. I all boils down to being simply personal style, I guess.


                          Failure is not an option - it's built right in.

                          L 1 Reply Last reply
                          0
                          • J John R Shaw

                            Wrong! Unless you are talking about how hard you hit the keys on your keyboard.

                            INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

                            P Offline
                            P Offline
                            Pete OHanlon
                            wrote on last edited by
                            #27

                            Errm - I'm not sure if you are being subtly ironic here, or you missed the joke icon on my post. I'll give you the benefit of the doubt and go with subtly ironic.

                            Deja View - the feeling that you've seen this post before.

                            1 Reply Last reply
                            0
                            • J John R Shaw

                              What are you talking about? If you are talking about variable type checking in C++, then you are wrong. I wish C was as tight with its type checking. Then again I wish C would allow me to declare a variable where ever I wanted too, instead of forcing me to create a new scope. P.S. I liked C, but I love C++.

                              INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

                              T Offline
                              T Offline
                              Tristan Rhodes
                              wrote on last edited by
                              #28

                              Actualy it arose from some code i wrote in .Net. I wrapped a generic HttpSession collection in something that exposed typed properties for each of the items it contained, And was told it was a total waste of my time. T

                              ------------------------------- Carrier Bags - 21st Century Tumbleweed.

                              M 1 Reply Last reply
                              0
                              • T Tristan Rhodes

                                Actualy it arose from some code i wrote in .Net. I wrapped a generic HttpSession collection in something that exposed typed properties for each of the items it contained, And was told it was a total waste of my time. T

                                ------------------------------- Carrier Bags - 21st Century Tumbleweed.

                                M Offline
                                M Offline
                                Marcus J Smith
                                wrote on last edited by
                                #29

                                Tristan Rhodes wrote:

                                And was told it was a total waste of my time.

                                Why?


                                CleaKO

                                "I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that.'" - Tommy (Tommy Boy)
                                "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)

                                T 1 Reply Last reply
                                0
                                • M Marcus J Smith

                                  Tristan Rhodes wrote:

                                  And was told it was a total waste of my time.

                                  Why?


                                  CleaKO

                                  "I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that.'" - Tommy (Tommy Boy)
                                  "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)

                                  T Offline
                                  T Offline
                                  Tristan Rhodes
                                  wrote on last edited by
                                  #30

                                  Because the general concencus was that "It's the most pointless piece of code" they had ever seen. :S

                                  ------------------------------- Carrier Bags - 21st Century Tumbleweed.

                                  P M 2 Replies Last reply
                                  0
                                  • T Tristan Rhodes

                                    Because the general concencus was that "It's the most pointless piece of code" they had ever seen. :S

                                    ------------------------------- Carrier Bags - 21st Century Tumbleweed.

                                    P Offline
                                    P Offline
                                    PIEBALDconsult
                                    wrote on last edited by
                                    #31

                                    I'd have to see the code.

                                    T 1 Reply Last reply
                                    0
                                    • P PIEBALDconsult

                                      John R. Shaw wrote:

                                      Then again I wish C would allow me to declare a variable where ever I wanted

                                      I prefer to have all the declarations in one place (the top) so in C# I still do that by choice. But requiring such isn't very friendly, flexibility is good.

                                      C Offline
                                      C Offline
                                      Chris Maunder
                                      wrote on last edited by
                                      #32

                                      ewwww! Declare the variables as close to their first use as possible. I have spoken.

                                      cheers, Chris Maunder

                                      CodeProject.com : C++ MVP

                                      X 1 Reply Last reply
                                      0
                                      • T Tristan Rhodes

                                        Because the general concencus was that "It's the most pointless piece of code" they had ever seen. :S

                                        ------------------------------- Carrier Bags - 21st Century Tumbleweed.

                                        M Offline
                                        M Offline
                                        Marcus J Smith
                                        wrote on last edited by
                                        #33

                                        Maybe it was just the code. Strong typing is a good way to control up front what type of information you are looking for rather than waiting for it to hit the database or a flat file and finding out later it isnt what it should be.


                                        CleaKO

                                        "I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that.'" - Tommy (Tommy Boy)
                                        "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)

                                        1 Reply Last reply
                                        0
                                        • P PIEBALDconsult

                                          I'd have to see the code.

                                          T Offline
                                          T Offline
                                          Tristan Rhodes
                                          wrote on last edited by
                                          #34

                                          public class SessionWrapper { private HttpSessionState session; // Constants public SessionWrapper() { session = HttpContext.Current.Session; } public string UserName { get{return (string)session[SE_USER_NAME];} set{session[SE_USER_NAME] = value;} } public int? LastPurchase { get{return (int?)session[SE_LAST_PURCHASE];} set{session[SE_LAST_PURCHASE] = value;} } // Etc } I'm actualy working on a code generator to build stuff like that for me, but at the time it was written manualy. My argument was its a strongly typed wrapper that exposes other developers to exactly what they need, what type it is, and hides the constants. T

                                          ------------------------------- Carrier Bags - 21st Century Tumbleweed.

                                          P 2 Replies 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