C++ Programming Tips

This is a discussion on C++ Programming Tips within the C++ Programming forums, part of the General Programming Boards category; Do you experienced programmers tend to have a common syntax or logic errors? Like Code: if (size = 3) instead ...

  1. #16
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    Do you experienced programmers tend to have a common syntax or logic errors? Like
    Code:
    if (size = 3)    instead of     if (size == 3)
    Stuff like that?
    I think everyone falls into that trap now and then when their brain is farting like coding late at night a simple trick to avoid this problem is this
    Code:
    size = 3 /* size gets 3 */
    size == 3 /*size equals three or size is three */
    I came across this a while ago and it seems to help me out.


    I don't see debugging in there. Is that under testing?
    That would be assumed under testing. Yes. perhaps I should have added.
    1.plan
    2.code
    3.test
    4.pull hair!! beat head against wall repeatedly
    4.repeat steps 2 - 4 ad nauseam.
    Last edited by caroundw5h; 09-14-2004 at 12:22 PM.
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

  2. #17
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >Do you guys write like pseudocode or do UML designs
    I use whatever design medium the project requires. For personal projects I'm not nearly as organized.

    >Do you experienced programmers tend to have a common syntax or logic errors?
    I have a nasty tendency to forget to dereference a pointer at the worst possible place. For example:
    Code:
    struct node *insert_node_r ( struct node *tree, int data, int *deeper )
    {
      ...
      if ( deeper ) {
        /* Rebalance */
      ...
    }
    deeper is never a null pointer, so the tree is always rebalanced even when it isn't needed (or wanted). I wrestled with this particular bug for too long this morning.

    >Is there much time spent debugging?
    It really depends on the programmer.
    My best code is written with the delete key.

  3. #18
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    >>I have a nasty tendency to forget to dereference a pointer at the worst possible place.
    At least you won't run into type punning problems

    >>It really depends on the programmer.
    And to a certain extent, I believe, the budget
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  4. #19
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    And ask a many questions as you need on this board. The people are really helpful and will not quit helping you until you get it. (You will most likely quit before them, if it takes weeks).

  5. #20
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    my own personal method for debugging, which you may want to try ,is to not ever make mistakes.
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  6. #21
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    Quote Originally Posted by The Brain
    my own personal method for debugging, which you may want to try ,is to not ever make mistakes.


    I really never debugged anything until I started making an emulator. Then you really learn how a debugger works, and in some cases make your own little GUI debugger for your program.
    What is C++?

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Programming Tips
    By webmaster in forum General Discussions
    Replies: 18
    Last Post: 12-20-2009, 02:14 PM
  2. Ballon Tips in C++ (Borland C++ Builder 6)
    By dfghjk in forum C++ Programming
    Replies: 4
    Last Post: 05-11-2008, 09:00 PM
  3. Tips on becoming a competent programmer
    By trickae2 in forum C Programming
    Replies: 16
    Last Post: 08-28-2006, 08:33 PM
  4. any useful tips to increase speed when parsing files
    By Shadow12345 in forum C++ Programming
    Replies: 2
    Last Post: 01-18-2003, 05:52 PM
  5. Tips
    By laughman in forum C++ Programming
    Replies: 5
    Last Post: 10-01-2002, 12:48 PM

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