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. The Lounge
  3. C++ Coding Style

C++ Coding Style

Scheduled Pinned Locked Moved The Lounge
c++learningjsonquestion
27 Posts 19 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.
  • J jpg 0

    I am learning C++ and I have several questions regarding the C++ coding style. 1.) Why most functions are named in lower case? 2.) Why the extensive use of shorts such as printf(),instead of PrintFormat()? 3.) Why do we need something like HWND, HINSTANCE, instead of a simple int? 4.) How could someone possiblily learn and use MFC without learning the win32 api? I see someone who considered themselve as experienced C++ programmer, and they can create a working MFC app, but they can't create a menu without a resource editor. I mean, creating menu is probably the first thing I learn in Windows programming. Is that normal? Thanks in advance.:)

    C Offline
    C Offline
    Christian Graus
    wrote on last edited by
    #7

    1 - they aren't 2 - because if you want needlessly verbose, VB.NET is waiting for you 3 - Because it differentiates between an int and, well, an int, by making clear what that number represents. If a function takes HWND or if it takes an int, you'd expect to use them very differently 4 - Do you understand exactly how your PC works ? If not, how can you possibly use it ? Seriously, this is a bizarre question from a beginner. By all means, jump in at the deep end if you want to, I'm an advocate of learning MFC first tho, because it is a means of taking byte sized ( har har ) pieces and learning a bit at a time. Only a moron would use Win32 over MFC by default as far as I can see. If you want to take longer to deliver your products for no good reason, just use assembler and be done with it, or at least use C, which is really what Win32 is for. That's why it uses HWNDs instead of just wrapping it's handles in classes.

    Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

    J Richard Andrew x64R 2 Replies Last reply
    0
    • A AbhishekBK

      No programing questions in the lounge!

      Abhishek The worst loneliness is not to be comfortable with yourself. --Mark Twain

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

      This isn't technically a programming question. If he had posted this in the C++ forum, nobody would have answered it.

      "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
      -----
      "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

      1 Reply Last reply
      0
      • W Weiye Chen

        Steve_Harris wrote:

        People learn what they need to learn to get the job done.

        Reminds me of a question that has been bothering me. Is it important to just get the job done? In terms of coding, isn't it more important to do it in a more efficient way? :confused: Aw... no need to reply. I am just frustrated right now.. X|

        Weiye Chen Time may have changed my life, but my heart remains the same to you... Time may have changed my heart, but my love for you never change...

        R Offline
        R Offline
        realJSOP
        wrote on last edited by
        #9

        If you're in an extreme time crunch to get if done, you normally don't have time for "efficiency", but you should NEVER sacrifice quality in deference to "the schedule". Most managers will (grudgingly) give you the time to do it right if you make enough noise about it. Of course, the more experience you have, and the more ability you've demonstrated in the past goes a long way towards your credibility when whining about "the schedule".

        "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
        -----
        "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

        1 Reply Last reply
        0
        • C Christian Graus

          1 - they aren't 2 - because if you want needlessly verbose, VB.NET is waiting for you 3 - Because it differentiates between an int and, well, an int, by making clear what that number represents. If a function takes HWND or if it takes an int, you'd expect to use them very differently 4 - Do you understand exactly how your PC works ? If not, how can you possibly use it ? Seriously, this is a bizarre question from a beginner. By all means, jump in at the deep end if you want to, I'm an advocate of learning MFC first tho, because it is a means of taking byte sized ( har har ) pieces and learning a bit at a time. Only a moron would use Win32 over MFC by default as far as I can see. If you want to take longer to deliver your products for no good reason, just use assembler and be done with it, or at least use C, which is really what Win32 is for. That's why it uses HWNDs instead of just wrapping it's handles in classes.

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

          J Offline
          J Offline
          jpg 0
          wrote on last edited by
          #10

          >> Only a moron would use Win32 over MFC by default as far as I can see. Are you sure? I think using a high level framework is good in general, but it depends on the technology your are using. If you use VB, you expected it to be a high level language and the lack of understanding on the underlying logics are also expected. VB was designed for simple in mind. The VB runtime act as a very thick layer between VB code and the underlying win32 api. I think the VB runtime was designed to wrap the VB world into a sphere. In contrast, I think the MFC is a relatively thin layer between the win32 api. The MFC doesn't wrap and close the win32 api but instead, more like a thin layer of utilities and wrappers for win32 programmer to shorten their coding time. This layer is so thin that you will sooner or later have to use win32 api to solve or work-around a problem. Therefore, I think understanding, or at least, knowing, the win32 api is still essential for working with MFC. I am a beginner and please correct me if I am wrong.:)

          L C L 3 Replies Last reply
          0
          • J jpg 0

            I am learning C++ and I have several questions regarding the C++ coding style. 1.) Why most functions are named in lower case? 2.) Why the extensive use of shorts such as printf(),instead of PrintFormat()? 3.) Why do we need something like HWND, HINSTANCE, instead of a simple int? 4.) How could someone possiblily learn and use MFC without learning the win32 api? I see someone who considered themselve as experienced C++ programmer, and they can create a working MFC app, but they can't create a menu without a resource editor. I mean, creating menu is probably the first thing I learn in Windows programming. Is that normal? Thanks in advance.:)

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #11
            1. they_are_only_written_like_this_in_K&R_C InC++TheyAreWrittenMoreLikeThis. 2) Dont you hate typing too? 3) Why not give all your variables the same name too, it'll make it so easy to read. 4) C++ has nothing to do with MFC and the WIn32 api. After all, if you cant paint bitmaps on the screen and capture mouse coordinates to make your menus function then you arent much of a C++ coder either. (ever written a mouse, button and menu app in DOS?)

            Truth is the subjection of reality to an individuals perception

            J M D 3 Replies Last reply
            0
            • J jpg 0

              >> Only a moron would use Win32 over MFC by default as far as I can see. Are you sure? I think using a high level framework is good in general, but it depends on the technology your are using. If you use VB, you expected it to be a high level language and the lack of understanding on the underlying logics are also expected. VB was designed for simple in mind. The VB runtime act as a very thick layer between VB code and the underlying win32 api. I think the VB runtime was designed to wrap the VB world into a sphere. In contrast, I think the MFC is a relatively thin layer between the win32 api. The MFC doesn't wrap and close the win32 api but instead, more like a thin layer of utilities and wrappers for win32 programmer to shorten their coding time. This layer is so thin that you will sooner or later have to use win32 api to solve or work-around a problem. Therefore, I think understanding, or at least, knowing, the win32 api is still essential for working with MFC. I am a beginner and please correct me if I am wrong.:)

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

              EscapeKey wrote:

              Are you sure?

              Yes. It is about 10 times quicker to throw an app together using MFC.

              EscapeKey wrote:

              or later have to use win32 api to solve or work-around a problem

              Very rerely. Some 90% of the win 32 api is wraped by MFC (setwindowshook being one usefull example of what isnt wrapped by MFC)

              EscapeKey wrote:

              Therefore, I think understanding, or at least, knowing, the win32 api is still essential for working with MFC.

              At some stage you will be presented with the 'if you dont know assembler you dont know real coding'. Choose your stopping off point and do it (which usually depends on who pays the bills)

              Truth is the subjection of reality to an individuals perception

              1 Reply Last reply
              0
              • C Christian Graus

                1 - they aren't 2 - because if you want needlessly verbose, VB.NET is waiting for you 3 - Because it differentiates between an int and, well, an int, by making clear what that number represents. If a function takes HWND or if it takes an int, you'd expect to use them very differently 4 - Do you understand exactly how your PC works ? If not, how can you possibly use it ? Seriously, this is a bizarre question from a beginner. By all means, jump in at the deep end if you want to, I'm an advocate of learning MFC first tho, because it is a means of taking byte sized ( har har ) pieces and learning a bit at a time. Only a moron would use Win32 over MFC by default as far as I can see. If you want to take longer to deliver your products for no good reason, just use assembler and be done with it, or at least use C, which is really what Win32 is for. That's why it uses HWNDs instead of just wrapping it's handles in classes.

                Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                Richard Andrew x64R Offline
                Richard Andrew x64R Offline
                Richard Andrew x64
                wrote on last edited by
                #13

                There is a reason that race cars use manual transmissions instead of automatics. There are times when it's beneficial to use the low-level stuff.

                -------------------------------- "All that is necessary for the forces of evil to win in the world is for enough good men to do nothing" -- Edmund Burke

                C 1 Reply Last reply
                0
                • J jpg 0

                  >> Only a moron would use Win32 over MFC by default as far as I can see. Are you sure? I think using a high level framework is good in general, but it depends on the technology your are using. If you use VB, you expected it to be a high level language and the lack of understanding on the underlying logics are also expected. VB was designed for simple in mind. The VB runtime act as a very thick layer between VB code and the underlying win32 api. I think the VB runtime was designed to wrap the VB world into a sphere. In contrast, I think the MFC is a relatively thin layer between the win32 api. The MFC doesn't wrap and close the win32 api but instead, more like a thin layer of utilities and wrappers for win32 programmer to shorten their coding time. This layer is so thin that you will sooner or later have to use win32 api to solve or work-around a problem. Therefore, I think understanding, or at least, knowing, the win32 api is still essential for working with MFC. I am a beginner and please correct me if I am wrong.:)

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #14

                  EscapeKey wrote:

                  Are you sure?

                  Absolutely. Why walk when you can take a car ? Why write assembler when you can write C++ ? Why use Win32 if you can get the job done in less than half the time with MFC ?

                  EscapeKey wrote:

                  but it depends on the technology your are using.

                  Sure - I said 'without good reason'. MFC should be the default, it's the easiest and best supported C++ approach. But sometimes Win32 is better. I wrote my own windowing framework, which interfaced to Python. I used Win32, why put another framework on top of Win32 when I was writing my own ? There are times when Win32 makes sense, but if you're going to make a general statement, the general truth is than MFC is a better choice.

                  EscapeKey wrote:

                  VB was designed for simple in mind

                  You TOTALLY rock.

                  EscapeKey wrote:

                  n contrast, I think the MFC is a relatively thin layer between the win32 api

                  It is incredibly thin at times. And you get the source code. That's what rocks, once you know MFC, it's easy to step in and see what it's wrapping and how, to learn Win32 after learning MFC ( which many people learn while learning C++ ). Along the way, MFC helps you learn how to do things in an OO way, which Win32 very much can't, as it's a C API.

                  EscapeKey wrote:

                  This layer is so thin that you will sooner or later have to use win32 api to solve or work-around a problem.

                  Absolutely. Again, that's why I advocate the approach I do. Win32 will rear it's head in lots of little ways that you won't even notice until you set out to learn Win32 and realise how often you were already using it.

                  EscapeKey wrote:

                  Therefore, I think understanding, or at least, knowing, the win32 api is still essential for working with MFC.

                  Well, that's not really what you said. If you had said this, I would have agreed, somewhat, in that learning MFC is a small step from learning Win32 at times, and you will learn parts of Win32 while using MFC, by default.

                  Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                  H 1 Reply Last reply
                  0
                  • Richard Andrew x64R Richard Andrew x64

                    There is a reason that race cars use manual transmissions instead of automatics. There are times when it's beneficial to use the low-level stuff.

                    -------------------------------- "All that is necessary for the forces of evil to win in the world is for enough good men to do nothing" -- Edmund Burke

                    C Offline
                    C Offline
                    Christian Graus
                    wrote on last edited by
                    #15

                    Gee - who didn't see this coming ? I said : Only a moron would use Win32 over MFC by default as far as I can see. In other words, yes, sometimes you need a racecar, but some times a push bike does the job just fine at a much lower cost. For most people, an average car is what they need, and for most apps, MFC is the best way to go. That doesn't mean that a race car driver should be compelled to use a Datsun 180B, nor does it mean that MFC is always the best choice. It just is *most* of the time. The OP made a comment to imply that the default should be Win32, and that is not the case. You didn't say it was, but you did seem to miss my point.

                    Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                    Richard Andrew x64R 1 Reply Last reply
                    0
                    • C Christian Graus

                      Gee - who didn't see this coming ? I said : Only a moron would use Win32 over MFC by default as far as I can see. In other words, yes, sometimes you need a racecar, but some times a push bike does the job just fine at a much lower cost. For most people, an average car is what they need, and for most apps, MFC is the best way to go. That doesn't mean that a race car driver should be compelled to use a Datsun 180B, nor does it mean that MFC is always the best choice. It just is *most* of the time. The OP made a comment to imply that the default should be Win32, and that is not the case. You didn't say it was, but you did seem to miss my point.

                      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                      Richard Andrew x64R Offline
                      Richard Andrew x64R Offline
                      Richard Andrew x64
                      wrote on last edited by
                      #16

                      Christian Graus wrote:

                      but you did seem to miss my point.

                      OK, I agree that I misinterpreted your point. I just wanted to get in a plug for my preference of using the low-level stuff. :-O

                      -------------------------------- "All that is necessary for the forces of evil to win in the world is for enough good men to do nothing" -- Edmund Burke

                      1 Reply Last reply
                      0
                      • L Lost User
                        1. they_are_only_written_like_this_in_K&R_C InC++TheyAreWrittenMoreLikeThis. 2) Dont you hate typing too? 3) Why not give all your variables the same name too, it'll make it so easy to read. 4) C++ has nothing to do with MFC and the WIn32 api. After all, if you cant paint bitmaps on the screen and capture mouse coordinates to make your menus function then you arent much of a C++ coder either. (ever written a mouse, button and menu app in DOS?)

                        Truth is the subjection of reality to an individuals perception

                        J Offline
                        J Offline
                        Jorgen Sigvardsson
                        wrote on last edited by
                        #17

                        fat_boy wrote:

                        ever written a mouse, button and menu app in DOS?

                        I have! It was fun too...

                        -- Torn from tomorrow's headlines

                        1 Reply Last reply
                        0
                        • L Lost User
                          1. they_are_only_written_like_this_in_K&R_C InC++TheyAreWrittenMoreLikeThis. 2) Dont you hate typing too? 3) Why not give all your variables the same name too, it'll make it so easy to read. 4) C++ has nothing to do with MFC and the WIn32 api. After all, if you cant paint bitmaps on the screen and capture mouse coordinates to make your menus function then you arent much of a C++ coder either. (ever written a mouse, button and menu app in DOS?)

                          Truth is the subjection of reality to an individuals perception

                          M Offline
                          M Offline
                          Michael P Butler
                          wrote on last edited by
                          #18

                          fat_boy wrote:

                          (ever written a mouse, button and menu app in DOS?)

                          Oh yes. And it was fun to write but didn't leave much time for writing the rest of the app.

                          Michael CP Blog [^] Development Blog [^]

                          1 Reply Last reply
                          0
                          • L Lost User
                            1. they_are_only_written_like_this_in_K&R_C InC++TheyAreWrittenMoreLikeThis. 2) Dont you hate typing too? 3) Why not give all your variables the same name too, it'll make it so easy to read. 4) C++ has nothing to do with MFC and the WIn32 api. After all, if you cant paint bitmaps on the screen and capture mouse coordinates to make your menus function then you arent much of a C++ coder either. (ever written a mouse, button and menu app in DOS?)

                            Truth is the subjection of reality to an individuals perception

                            D Offline
                            D Offline
                            Dan Neely
                            wrote on last edited by
                            #19

                            fat_boy wrote:

                            (ever written a mouse, button and menu app in DOS?)

                            No menus, but I did do the other two parts once. In turbopascal. :doh:

                            1 Reply Last reply
                            0
                            • C Christian Graus

                              EscapeKey wrote:

                              Are you sure?

                              Absolutely. Why walk when you can take a car ? Why write assembler when you can write C++ ? Why use Win32 if you can get the job done in less than half the time with MFC ?

                              EscapeKey wrote:

                              but it depends on the technology your are using.

                              Sure - I said 'without good reason'. MFC should be the default, it's the easiest and best supported C++ approach. But sometimes Win32 is better. I wrote my own windowing framework, which interfaced to Python. I used Win32, why put another framework on top of Win32 when I was writing my own ? There are times when Win32 makes sense, but if you're going to make a general statement, the general truth is than MFC is a better choice.

                              EscapeKey wrote:

                              VB was designed for simple in mind

                              You TOTALLY rock.

                              EscapeKey wrote:

                              n contrast, I think the MFC is a relatively thin layer between the win32 api

                              It is incredibly thin at times. And you get the source code. That's what rocks, once you know MFC, it's easy to step in and see what it's wrapping and how, to learn Win32 after learning MFC ( which many people learn while learning C++ ). Along the way, MFC helps you learn how to do things in an OO way, which Win32 very much can't, as it's a C API.

                              EscapeKey wrote:

                              This layer is so thin that you will sooner or later have to use win32 api to solve or work-around a problem.

                              Absolutely. Again, that's why I advocate the approach I do. Win32 will rear it's head in lots of little ways that you won't even notice until you set out to learn Win32 and realise how often you were already using it.

                              EscapeKey wrote:

                              Therefore, I think understanding, or at least, knowing, the win32 api is still essential for working with MFC.

                              Well, that's not really what you said. If you had said this, I would have agreed, somewhat, in that learning MFC is a small step from learning Win32 at times, and you will learn parts of Win32 while using MFC, by default.

                              Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                              H Offline
                              H Offline
                              hairy_hats
                              wrote on last edited by
                              #20

                              Christian Graus wrote:

                              EscapeKey wrote: VB was designed for simple in mind You TOTALLY rock.

                              :laugh:

                              "He's got a lot on his mind, and it's not a load-bearing structure." - John Weak

                              1 Reply Last reply
                              0
                              • J jpg 0

                                I am learning C++ and I have several questions regarding the C++ coding style. 1.) Why most functions are named in lower case? 2.) Why the extensive use of shorts such as printf(),instead of PrintFormat()? 3.) Why do we need something like HWND, HINSTANCE, instead of a simple int? 4.) How could someone possiblily learn and use MFC without learning the win32 api? I see someone who considered themselve as experienced C++ programmer, and they can create a working MFC app, but they can't create a menu without a resource editor. I mean, creating menu is probably the first thing I learn in Windows programming. Is that normal? Thanks in advance.:)

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

                                Adding to what others have answered for "Why do we need something like HWND, HINSTANCE, instead of a simple int?": Because it may be a simple int on one platform, but it may very well be a long, a long long, an unsigned long or any of a dozen other data types on another platform. Just ask anyone who has ported code to 64bit.

                                cheers, Chris Maunder

                                CodeProject.com : C++ MVP

                                1 Reply Last reply
                                0
                                • J jpg 0

                                  I am learning C++ and I have several questions regarding the C++ coding style. 1.) Why most functions are named in lower case? 2.) Why the extensive use of shorts such as printf(),instead of PrintFormat()? 3.) Why do we need something like HWND, HINSTANCE, instead of a simple int? 4.) How could someone possiblily learn and use MFC without learning the win32 api? I see someone who considered themselve as experienced C++ programmer, and they can create a working MFC app, but they can't create a menu without a resource editor. I mean, creating menu is probably the first thing I learn in Windows programming. Is that normal? Thanks in advance.:)

                                  E Offline
                                  E Offline
                                  El Gato
                                  wrote on last edited by
                                  #22

                                  I am learning C++ and I have several questions regarding the C++ coding style. 1.) Why most functions are named in lower case? this is preference ... C and C++ came around way before we really developed formal coding standards. Also, no intellisense back then ... making everything lower case or all uppercase was easier to remember. Uppercase was used for constants. 2.) Why the extensive use of shorts such as printf(),instead of PrintFormat()? Sharthand is always easier ... less typing .. but also less storage. C and C++ were created during times where a mere 20 MB drive was very expensive. You noobs are used to seeing large storage drive capacity for very little $$$. 3.) Why do we need something like HWND, HINSTANCE, instead of a simple int? As members have already mentioned. You create a a type HWND to denote its function and use. Comments only go so far. Try declaring everything as int ... sooner or later, you'll realize you have extremely hard to trace memory leaks (at best). 4.) How could someone possiblily learn and use MFC without learning the win32 api? I see someone who considered themselve as experienced C++ programmer, and they can create a working MFC app, but they can't create a menu without a resource editor. I mean, creating menu is probably the first thing I learn in Windows programming. Is that normal? Win32 came around before MFC ... naturally everything you can do in MFC can be done in Win32. MFC is an extension of Win32 (not a 100% as noted by other members). MFC does simplify creating applications, much in the same way that printf accomplishes a task in 1 line where as in Assembly requires 8-20 lines. After writing a couple applications, you will greatly appreciate MFC over Win32 Api. Good luck!

                                  1 Reply Last reply
                                  0
                                  • J jpg 0

                                    I am learning C++ and I have several questions regarding the C++ coding style. 1.) Why most functions are named in lower case? 2.) Why the extensive use of shorts such as printf(),instead of PrintFormat()? 3.) Why do we need something like HWND, HINSTANCE, instead of a simple int? 4.) How could someone possiblily learn and use MFC without learning the win32 api? I see someone who considered themselve as experienced C++ programmer, and they can create a working MFC app, but they can't create a menu without a resource editor. I mean, creating menu is probably the first thing I learn in Windows programming. Is that normal? Thanks in advance.:)

                                    J Offline
                                    J Offline
                                    James Curran
                                    wrote on last edited by
                                    #23

                                    1.) Why most functions are named in lower case? Basically, because the keywords in C are in lower case, and it made the standard function look like part of the language. 2.) Why the extensive use of shorts such as printf(),instead of PrintFormat()? I assume you mean "short names". Because when C was from designed, only the first 7 or 8 characters of a name were significant (limitation of the linkers of the day). Also because early C & Unix programmer were incredibly lazy typists. 3.) Why do we need something like HWND, HINSTANCE, instead of a simple int? In case you wanted to change the type of HWND but not HINSTANCE. You'd only have to change it once, in the typedef, instead of everywhere. Also it helps self-document the program. If a function returns a HWND you know it returns a "Handle to a Window". If it returns an int, you don't know what that means. Note that if you define STRICT in MFC (which you always should do), HWND & HINSTANCE *are* defined differently, and if you use one where the other is intended, you'll get an error. 4.) How could someone ..... Why would anyone in their right mind want to create a menu without the resource editor? I've have to do that maybe twice in my career. That's much like saying, how could anyone dress themselves without knowing how to operate a spinning wheel.

                                    Truth, James

                                    1 Reply Last reply
                                    0
                                    • J jpg 0

                                      I am learning C++ and I have several questions regarding the C++ coding style. 1.) Why most functions are named in lower case? 2.) Why the extensive use of shorts such as printf(),instead of PrintFormat()? 3.) Why do we need something like HWND, HINSTANCE, instead of a simple int? 4.) How could someone possiblily learn and use MFC without learning the win32 api? I see someone who considered themselve as experienced C++ programmer, and they can create a working MFC app, but they can't create a menu without a resource editor. I mean, creating menu is probably the first thing I learn in Windows programming. Is that normal? Thanks in advance.:)

                                      T Offline
                                      T Offline
                                      tamas m
                                      wrote on last edited by
                                      #24

                                      1.) Why most functions are named in lower case? Convention of the last 20 years (about). Functions are lower case, DEFINE macros are upper case. Changing case within words make typing slower. Nowadays, some of the programming editors can help You with auomatic completion, but not all. 2.) Why the extensive use of shorts such as printf(),instead of PrintFormat()? PrintFormat looks like a PASCAL or BASIC (I apologise for these rude words in a c++ forum) procedure to configure Your printer. printf is a standard C library function, maybe its older than some programmers. BTW, do You like typing? 3.) Why do we need something like HWND, HINSTANCE, instead of a simple int? Of course, You're right. But please tell this to Microsoft. Because Microsoft prefers their own "programming language", Visual Basic, so they would like to make programmers to hate C++. 4.) How could someone possiblily learn ... See the answer above. You can make your own decision. You can use Microsoft preferred technology, or You can use some open source/commercial libraries to make c++ programming easier. BTW, Microsoft technology to separate resource editing and coding, makes modifying and team working a bit easier. 4,5.) ... without win32 api? If You write a program to run on Windows, You always use win32 api, even if You don't know about it. Sometimes api is simpler or more efficient than using MFC, but only if You know it. I hope, my answers will help You in the way of becoming a C++ master.

                                      1 Reply Last reply
                                      0
                                      • J jpg 0

                                        I am learning C++ and I have several questions regarding the C++ coding style. 1.) Why most functions are named in lower case? 2.) Why the extensive use of shorts such as printf(),instead of PrintFormat()? 3.) Why do we need something like HWND, HINSTANCE, instead of a simple int? 4.) How could someone possiblily learn and use MFC without learning the win32 api? I see someone who considered themselve as experienced C++ programmer, and they can create a working MFC app, but they can't create a menu without a resource editor. I mean, creating menu is probably the first thing I learn in Windows programming. Is that normal? Thanks in advance.:)

                                        M Offline
                                        M Offline
                                        mcintyrg
                                        wrote on last edited by
                                        #25

                                        C++ Coding Standards : Rules, Guidelines, and Best Practices by Herb Sutter and Andrei Alexandrescu Is a very good book on the subject

                                        1 Reply Last reply
                                        0
                                        • J jpg 0

                                          I am learning C++ and I have several questions regarding the C++ coding style. 1.) Why most functions are named in lower case? 2.) Why the extensive use of shorts such as printf(),instead of PrintFormat()? 3.) Why do we need something like HWND, HINSTANCE, instead of a simple int? 4.) How could someone possiblily learn and use MFC without learning the win32 api? I see someone who considered themselve as experienced C++ programmer, and they can create a working MFC app, but they can't create a menu without a resource editor. I mean, creating menu is probably the first thing I learn in Windows programming. Is that normal? Thanks in advance.:)

                                          K Offline
                                          K Offline
                                          kevin daly onetel net
                                          wrote on last edited by
                                          #26

                                          C and C++ standards started before Microsoft and a lot of conventions where created UNIX system such as Solaris used strStringName as a standard to define type and name Microsoft used m_MemberName to define members of an object Some other used Camel notation, Hungarian notation (Microsoft mainly) and loads of other conventions. Why so many? Show 2 people the same object and they think different things, well whatever notation you use is less important than site consistency. Most software is developed by teams of analysts and programmer working together, over time the team sheet changes and to allow for change a site convention is used. Of course any new member will learn the site conventions quicker, if the site uses a generally accepted convention such as that employed by Microsoft or Sun. In team development consistency of approach is paramount otherwise it very quickly becomes a Wild West show. NOTATION In object orientated programming we often have objects containing other objects, so to tell if the programmer is using an object or a method of an object we use notation to clarify the situation (make the code more readable). Separation of Logic Best practice for coding suggests that the presentation, business logic layer and storage layer should be separate. What that should give is independent presentation so changes to a screen should not affect the business layer and changes to storage layer should not affect the business logic. Many programmers do not take the time to separate out their design, for small applications this is sometimes can be good approach with regard to time and maintenance, however in lager applications not clearly defining boundaries can be a disaster. Creating your own wrapper class around presentation, business and storage layers can improve maintance of code and scalability of an application. In small scale application this is rarely a problem, however good practice is always good practice no matter what programming language or methodogly is used. Basically make your system changeable and separate out the logical components of your system. No C++ application should be made as non portable. If you use wrapper around you presentation class then if MFC changes or you are asked to port the code to another platform, the task becomes easier and the same applies to business logic (process behavior) plus persistence logic (storage). Factory Patterns Or how to make a program unreadable! Factory pattern is a very useful pattern when used correctly, however overuse

                                          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