CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 4 1234 LastLast
Results 1 to 15 of 56
  1. #1
    Join Date
    Jun 2004
    Posts
    170

    Frequently encountered errors

    Hi
    I want to know what errors do you meet often in not yours code,in code of beginner. Especially, code which works, but still bad?

  2. #2
    Join Date
    Feb 2002
    Location
    Makati City, Philippines
    Posts
    1,054

    Re: Frequently encountered errors

    Code errors on codes that works?

    You probably mean general problems with a beginner's codes because if it works, it has no error.

    I have little experience evaluating other beginner's codes. I can only recall that when I compared my codes lately with my codes when I was a beginner, I often find something like:

    - There are variable assignments that can be placed strategically to make progam more efficient. Example, I sometimes assign values inside a loop when that value does not necessarily change on the duration of said loop.

    - Because I cannot memorize all functions, there are instances when I create one not knowing that it's already available.

    - I have tendencies to use variable type larger than necessary (in VB - Long instead of integer) because I felt then they're "much safer."

    - sometimes I defined dead variables or even dead functions.

    To sum it all, my common "error" (if you put it that way) is that my beginner's codes are often less efficient -- but they have worked.
    Last edited by aio; February 11th, 2005 at 08:28 AM.
    Marketing our skills - please participate in the survey and share your insights
    -

  3. #3
    Join Date
    Jun 2004
    Posts
    170

    Re: Frequently encountered errors

    I mean errors which reduce effectiveness of code
    or in future during redesign or some modifications cause errors
    or make something more complicated than it is.

  4. #4
    Andy Tacker is offline More than "Just Another Member"
    Join Date
    Jun 2001
    Location
    55°50' N 37°39' E
    Posts
    1,503

    Re: Frequently encountered errors

    Mushroom programming is the biggest flaw developers make when coding. some people call it serail programming... that means..
    Code:
    my function()
    {
        dothisaction
        if(doseconaction)
            dothirdaction
        updatethis
        updatethat
        openfileorregistery
        saveinformation
        Thankyoujobfinished
    }
    this is what OOP does not teach avoid this kind of work...

    be sure to minimize exception raisings... use try catch or check errors...

    never hardcode functionalities. try to be open. keep space for further enhancements of the code...

    what else? nothing much really... efficiency is not measured in LINES of code

    avoid my suggestions offcourse
    If you think you CAN, you can, If you think you CAN'T, you are probably right.

    Have some nice Idea to share? Write an Article Online or Email to us and You may WIN a Technical Book from CG.

  5. #5
    Join Date
    Feb 2005
    Location
    Denmark
    Posts
    742

    Re: Frequently encountered errors

    Quote Originally Posted by TOMNKZ
    I mean errors which reduce effectiveness of code
    or in future during redesign or some modifications cause errors
    or make something more complicated than it is.
    Things like ....

    Accidently keeping references to objects that are no longer needed
    Automatic garbage collection is nice .... if you remember to cut the references to the objects

    Removing references to objects which are needed again later in the code, so one creates the same object several times.

  6. #6
    Join Date
    Dec 2003
    Location
    http://map.search.ch/zuerich.en.html
    Posts
    1,074

    Re: Frequently encountered errors

    I hate finding this in (not necessarily) beginners code:
    Code:
    bool function()
    {
          if (<bool expression> == true) 
          {
                return true;
          }
          else
          {
                return false;
          } 
    }
    N.B. I'm not referring to languages where bool is not an actual type.
    Useful? Then click on (Rate This Post) at the top of this post.

  7. #7
    Join Date
    Jun 2004
    Posts
    17

    Re: Frequently encountered errors

    This is what I've found...
    these are not exactly errors in *code* :
    -forget to commit updates in DB.
    -forget to insert comments in code to make other coders' life easier.
    -do not follow coding standards
    -In GUI - forget about TAB ORDER of objects on sreens...as they (beginners) usually use mouse they forget about the users who prefer to use keyboards to enter data.
    -In GUI they type messages that are not understood by users.... like for example, Operation Commited, instead of, for example, Application Sumitted.

    That's all I can think for now.

  8. #8
    Join Date
    Feb 2002
    Location
    Makati City, Philippines
    Posts
    1,054

    Re: Frequently encountered errors

    Quote Originally Posted by cloureir
    This is what I've found...
    ...
    -In GUI - forget about TAB ORDER of objects on sreens...as they (beginners) usually use mouse they forget about the users who prefer to use keyboards to enter data.
    ...
    I totally agree with this one. Most beginner thinks that all users depended so much on mouse. I have encountered several of these on some of my newbie office mates before.

    And if I may add, there are lot's of tendencies newbies would overkill the design of the forms(like fonts too big, and multi-colored which in most instances are rather nuisance than helpful).
    Marketing our skills - please participate in the survey and share your insights
    -

  9. #9
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Frequently encountered errors

    Quote Originally Posted by TOMNKZ
    Hi
    I want to know what errors do you meet often in not yours code,in code of beginner. Especially, code which works, but still bad?
    I have to add here that can exist bad code which still works but not forever. And this is the most dangerous because usually it crashes after the testing phase at the customer.
    For example:
    Last edited by ovidiucucu; February 12th, 2005 at 07:29 AM.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  10. #10
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Frequently encountered errors

    For C/C++/Java you can use this analysis tool to detect bad style issues in source code.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  11. #11
    Join Date
    Jun 2004
    Posts
    17

    Re: Frequently encountered errors

    Years ago I saw this:
    "Delete From Table_XXX"
    that's it.... no Where clause!!!!!
    Fortunately the DBA restored the data.

  12. #12
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Frequently encountered errors

    These also can generate trouble in a program sooner or later:
    Code:
    SELECT * FROM blahblah
    Code:
    INSERT INTO blahblah VALUES(...)
    Last edited by ovidiucucu; February 16th, 2005 at 06:08 AM.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  13. #13
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Frequently encountered errors

    This stupid one made computer frozen (at the client of course ):
    Code:
    ..... WHERE ...<some good joins here>... AND a='A' OR a='B' OR a='C'
    instead of: 
    ..... WHERE ...<some good joins here>... AND a IN('A','B','C')
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  14. #14
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Frequently encountered errors

    Returning to C/C++
    This one makes me often feeling sorry I have not a machine gun:
    Code:
       HRESULT hr = SomeFunction();
       _ASSERTE(SUCCEEDED(hr));
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  15. #15
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Frequently encountered errors

    Here's one that makes me wish a had a gun:
    Code:
    byte _AnalogProperties[8]; // no initialization here
    
    if(<condition>) // this one can be false
    {
       // perhaps a loop here
       _AnalogProperties[some_index] = some_value;
    }
    
    SetTheseProperties(_AnalogProperties, sizeof(_AnalogProperties));
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

Page 1 of 4 1234 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured