Menu
Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Java
example of a logic bug using pseudocode
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Arved Sandstrom, post: 3594916"] [ SNIP ] They're good examples, judging by the discussion so far. :-) Since the question asks for pseudocode some of the classic logic errors involving int/boolean conversions (= instead of == in if statement etc) or pointers get ruled out, since these will be language-specific. However, there are plenty of other well-known ones that can be pseudocoded. Off-by-one errors ([URL]http://en.wikipedia.org/wiki/Off-by-one_error[/URL]) will bite everyone sooner rather than later. Integer overflows are logic errors *if* your code assumes that they cannot happen (like thinking that your signed integer value will always be positive if you only add to it). Also see "Unnamed numerical constant" in [URL]http://en.wikipedia.org/wiki/Magic_number_(programming)[/URL] Using an unnamed numerical constant is not a logic error in and of itself (it's just usually bad programming), but there is a good chance that doing so will create a logic error somewhere...especially when the magic number needs to be changed. You might be able to pseudocode variable declarations that have no explicit initialization. In some languages (say C) this may (read probably will) lead to an arbitrary initial value for the variable; in others (like Java) you'll have a known value but it may not be what the programmer intended. Often enough (even in languages like Java) a variable declaration without an explicit initialization does suggest a logic error. And, of course, what is more fundamental than simply supplying the wrong values to a function? If a function expects two int parameters, each having a completely different meaning, it's easy enough to provide it with two ints in the wrong order, especially if not using an IDE. The function won't care - it got 2 ints. This is not an easy logic error to track down... AHS [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Java
example of a logic bug using pseudocode
Top