Like Tree4Likes
  • 2 Post By phantomotap
  • 1 Post By Salem
  • 1 Post By CommonTater

Advice...

This is a discussion on Advice... within the C Programming forums, part of the General Programming Boards category; A philosophical question for C programmers... (just C... please) What's the best advice you ever got regarding programming in C?...

  1. #1
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547

    Advice...

    A philosophical question for C programmers... (just C... please)

    What's the best advice you ever got regarding programming in C?

  2. #2
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,173
    What's the best advice you ever got regarding programming in C?
    "Compile often; test often."

    Soma
    quzah and Bayint Naung like this.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Probably how to compile with warning levels turned up. That, or to make it clean and readable. (But I don't think anyone ever actually told me the latter, it's just something I do.)


    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Epy
    Epy is offline
    Fortran lover Epy's Avatar
    Join Date
    Sep 2009
    Location
    California, USA
    Posts
    949
    To add more comments (as I didn't comment at all at the time)

  5. #5
    Registered User
    Join Date
    Jul 2010
    Location
    Oklahoma
    Posts
    107
    CommonTater,

    The best advice that I received about programming in C came from a professor who would call a program "wrong" if it were poorly formatted or difficult to read, in conjunction with Paul S. Wang's text: An Introduction to ANSI C on UNIX (isbn: 0-534-14232-X). On page 90, Wang summarized his advice...

    ...
    Advice on thinking in C was given. A recommended program-formatting style was also described. These principles form the foundation on which all the elaborate constructs of later chapters will be built. No time spent in their mastery should be considered wasted.
    ...
    The actual advice was given on pages 87-9, but it amounts to what we end up talking about quite frequently with regard to formatting, declarations, naming conventions and comments. Knowing the standards made later discussions easier and most importantly meaningful.

    I've found that a flowchart has been invaluable, but I'm not completely confident that is exclusively a C issue.

    The next most important thing, being familiar with the compiler one has chosen to employ. It is imperative for proper use of any language. Primarily because, messages vary from one to the next and getting settings fine tuned is usually system specific. For example, telling the linker which library to use, or where to find it and such "road blocks" would sometimes make for very long sessions in the laboratory. The professor was very clear about that as well....

    Later during the engineering courses, the various sorts of documentation styles were emphasized because it was essential to appreciate the body of work during the maintenance/testing phase. In fact, it would be very difficult, if not impossible, to perform maintenance/testing on large projects with out it. This leads me to a completely separate topic...revision control.

    On a side note, I don't mean to continuously quote Wang. His text is a favorite and it easy to get to. I did intentionally omitted his specific advice because there are all sorts of standards out there...not to mention something about copyright lawyers that makes me break out in a sweat.

    Best Regards,
    Kept the text books....
    Went interdisciplinary after college....
    Still looking for a real job since 2005....

    During the interim, I may be reached at ELance, vWorker, FreeLancer, oDesk and WyzAnt.

  6. #6
    Registered User
    Join Date
    Apr 2011
    Posts
    10
    Make sure you don't overcomplicate your applications, if there is an automated way of doing something, use it, don't try to make your own way up.

  7. #7
    Registered User
    Join Date
    Sep 2008
    Posts
    200
    1. Do the simplest thing that could possibly work - only consider more complicated routes if the simplest way isn't good enough. (A corollary of this is not to optimize early.)
    2. Always compile everything with as many warnings and errors as you can turned on (with gcc, at the very least use -Wall and -Wextra) and make sure it compiles without any warnings (with gcc you can use -Werror to turn warnings into errors).

  8. #8
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    There is a lot of stuff which is just good programming practice, regardless of the language.

    But one thing which is rather more C specific is KISS. C has so much flexibility that you can all too easily create monsters that cannot be debugged or changed. Yes, occasionally, you need to get creative for some reason or another, but for the most part, keep it obvious.

    A modern compiler with maximum warnings is the minimum.

    Anyone working professionally should be using additional tools like these:
    Gimpel Software PC-lint Overview
    Software Quality and Security Analysis | Coverity
    Bayint Naung likes this.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  9. #9
    Registered User
    Join Date
    Apr 2011
    Posts
    33
    c can do anything...
    from hacking to kernel design.....
    (but i never succeded.)

  10. #10
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    For me it was "Think first, type later"...

    It came from a programmer sitting in his cubical, staring at the ceiling. I asked if there was a problem and he answered: "Nope. Just thinking it through before I commit to it."
    Last edited by CommonTater; 05-01-2011 at 07:29 AM.
    new_ink2001 likes this.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Advice
    By zacs7 in forum Game Programming
    Replies: 3
    Last Post: 10-06-2007, 03:48 AM
  2. Advice?
    By cgsarebeast in forum C++ Programming
    Replies: 1
    Last Post: 06-05-2007, 12:22 PM
  3. Need Advice
    By jamez05 in forum C++ Programming
    Replies: 2
    Last Post: 10-19-2006, 11:21 AM
  4. advice
    By daman in forum C Programming
    Replies: 2
    Last Post: 04-19-2004, 10:30 AM
  5. Need your help, advice
    By Coconut in forum Tech Board
    Replies: 2
    Last Post: 10-09-2002, 08:23 PM

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