Like Tree1Likes

May 2013 coding style discussion thread

This is a discussion on May 2013 coding style discussion thread within the Tech Board forums, part of the Community Boards category; Originally Posted by rcgldr Currently I don't have an opinion on stuff like hungarian notation. This being the case, with ...

  1. #31
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,487
    Quote Originally Posted by rcgldr View Post
    Currently I don't have an opinion on stuff like hungarian notation.
    This being the case, with all due respect, I don't think you are qualified to discuss matters of coding style. You just don't have an opinion on one of the coding style tenets of C/C++ programming.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  2. #32
    Registered User
    Join Date
    Apr 2013
    Posts
    1,290
    Quote Originally Posted by rcgldr View Post
    Currently I don't have an opinion on stuff like hungarian notation. ... I don't consider coding styles like hungarian notation to have a signficant impact on being able to maintain or enhance code, so I don't worry about these things.
    Quote Originally Posted by Mario F. View Post
    You just don't have an opinion on one of the coding style tenets of C/C++ programming.
    Perhaps a poor choice of wording which was qualified in my later statement, that if some aspect of programming doesn't have a significant impact on being able to maintain, enhance, or reuse (I'm adding this now) code, it's not that important of an issue. What I meant was that my opinion on this is neutral. When I consider what are good or bad programming practices, coding style is way down on my list of issues, and the original thread asking for help for a specific program was not the place to start a debate about typedefs for pointers or all upper case typedefs, which how this thread got spawned.

    The statement that I was specifically disputing what that using typedefs for pointers or all upper case typedefs were bad programming practices. I'm not claiming they are good programming practices, just that they are not bad programming practices.

    Hungarian notation came up because I pointed out the fact that the windows API uses typedefs for poitners (so do other coding styles) and all upper case typedefs. Even linux / posix / unix uses the struct typedef FILE.
    Last edited by rcgldr; 05-13-2013 at 06:45 PM.

  3. #33
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,659
    Usually when a lot of people, especially knowledgeable people, all agree that specific code is not all that good, it starts to become bad practice. Some people on this board also believe in some of these so called bad practices. You are simply going to have to accept that people will complain about style issues that they consider bad practice (and some things which the community as a large consider bad practice).
    In case you don't want to start a discussion like this, don't disagree
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #34
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,714
    And when you lose an argument, to stop typing next, in my experience, is the most graceful exit.

  5. #35
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,487
    Quote Originally Posted by rcgldr View Post
    What I meant was that my opinion on this is neutral. When I consider what are good or bad programming practices, coding style is way down on my list of issues.

    Despite the best efforts of our lawmakers, code is meant to be shared. Even if only by the members of a small cult. Other times by large communities. So, can you imagine if the Bible read "Yeah, then the bigLORD bossGod created man out of dirt and coughed life up his nose" (King James Bible, Genesis 2-7)?

    Coding style matters, Hungarian notation sucks and all caps will meet their judgment on the last days.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  6. #36
    Registered User
    Join Date
    May 2010
    Posts
    2,778
    Hungarian notation came up because I pointed out the fact that the windows API uses typedefs for poitners (so do other coding styles) and all upper case typedefs.
    Just because Windows does something doesn't make it correct. They have made many mistakes, one of those "mistakes" was the adoption of Hungarian notation. Along with the adoption of Hungarian notation came pointer typedefs, to match.

    When converting Windows 16 bit code to 32 bit code came many of the same problems we are seeing today with the 32 to 64 bit migration, poor assumptions about the sizes of variables. This migration lead to the use of macros in the Windows 32bit API to replace C's integer types. The use of all upper case for macros is considered the norm by many programmers, so things like DWORD, a macro, being all upper case is "normal". Today this would probably be replaced with C's exact-width integer types (int8_t).

    Even linux / posix / unix uses the struct typedef FILE.
    FILE is a macro, hence is all upper case.
    From the April 12, 2011 draft standard, section 7.21
    1. The header <stdio.h> defines several macros, and declares three types and many
    functions for performing input and output.
    2. The types declared are size_t (described in 7.19);

    FILE
    which is an object type capable of recording all the information needed to control a
    stream, including its file position indicator, a pointer to its associated buffer (if any), an
    error indicator that records whether a read/write error has occurred, and an end-of-file
    indicator that records whether the end of the file has been reached; and

    Jim

  7. #37
    Registered User
    Join Date
    Jun 2005
    Posts
    6,337
    Quote Originally Posted by jimblumberg View Post
    FILE is a macro, hence is all upper case.
    That is not required anywhere - not even in that extract from the draft you quoted.

    That said, FILE being a macro is also not disallowed. Practically, FILE is effectively an opaque type - we know it represents a type capable of keeping track of all information need to control a stream, but the standard says nothing about how that information is organised.
    Right 98% of the time, and don't care about the other 3%.

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Is it bad style of coding ??
    By noobcpp in forum C++ Programming
    Replies: 15
    Last Post: 11-06-2008, 09:39 AM
  2. C++ Coding Standard Question/Discussion
    By Mastadex in forum C++ Programming
    Replies: 11
    Last Post: 08-13-2008, 10:54 AM
  3. Your Coding Style?
    By Krak in forum A Brief History of Cprogramming.com
    Replies: 45
    Last Post: 06-02-2005, 08:19 AM
  4. Coding style
    By Clyde in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 04-09-2002, 04:22 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21