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?:o
Printable View
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?:o
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.
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.
Mushroom programming is the biggest flaw developers make when coding. some people call it serail programming... that means..
this is what OOP does not teach :) avoid this kind of work...Code:my function()
{
dothisaction
if(doseconaction)
dothirdaction
updatethis
updatethat
openfileorregistery
saveinformation
Thankyoujobfinished
}
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 :p
Things like ....Quote:
Originally Posted by TOMNKZ
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 :o
Removing references to objects which are needed again later in the code, so one creates the same object several times.
I hate finding this in (not necessarily) beginners code:
N.B. I'm not referring to languages where bool is not an actual type.Code:bool function()
{
if (<bool expression> == true)
{
return true;
}
else
{
return false;
}
}
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.
:wave:
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.Quote:
Originally Posted by cloureir
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).
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.Quote:
Originally Posted by TOMNKZ
For example:
- too large Cyclomatic complexity
- allocate something without freeing (memory, handles, etc)
For C/C++/Java you can use this analysis tool to detect bad style issues in source code.
Years ago I saw this:
"Delete From Table_XXX"
that's it.... no Where clause!!!!! :eek:
Fortunately the DBA restored the data.
These also can generate trouble in a program sooner or later:
Code:SELECT * FROM blahblah
Code:INSERT INTO blahblah VALUES(...)
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')
Returning to C/C++
This one makes me often feeling sorry I have not a machine gun:
Code:HRESULT hr = SomeFunction();
_ASSERTE(SUCCEEDED(hr));
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));