A.
Typecasting
issue in C++
C++
code of type casting, which is considered as an insecured code. The same
problem occurred in Ariane 5, which ended up in a crash.
According
to (Soulie, 2007),
Type casting is known as converting an
expression of a given type into another type. In C, type converstion can be
done using,
1. Implicit Convertion –
one type of data is automatically converted into compatible type of
data.
2. Explicit Convertion – Many conversions, specially thos that
imply a different interpreation of the value. It has 4 specific casting
operators (dynamic_cast, reinterpret_cast, static_cast and const_cast).
Here,
the conversion truncates, that is the fractional part is discared. There is a
data loss, since the out put is 13, expected output was 14.
Remedy – Use static_cast and add 0.5 before casting.
c = static_cast(b + 0.5) + a; //
output is 14
Because of above mentioned reasons, Eiffel
does not allow these type castings.
B.
Break statement in Java
Break statement is used
to terminate the loop program on a pre defined condition. One basic rule in
structured programming is, each control structure should contain only one entry
point and one exit point. But above code has 2 exit points.
In the above code snippet,
for loop is supposes to execute 10 times. It has if condition to check loop, if
it reach on 5 of value i, break point will be executed. Once break point is
executed, for loop will terminate.
Moreover, using break
statement is a bad practice, since that could possibly skip some code after the
break. Also it is difficult to go through the flow of the program break
statements. It would be more difficult with nested loops. So using break
statement might help in some situations, such as switch statements, but in the
other way program is not secured.
C.
Un-type
variables in PHP
PHP (Hypertext
Preprocessor) is a un-type programming language, which any variable can store
data of any type. Un-typed programming languages make programmers
responsibility to avoid run time errors.
It is not secured,
since variable does not have a type and programmers have to keep sure about
what is stored and where it is stored. Error may occur at run-time.
Typed languages, such
as Eiffel, Java and C++, identify errors at compile time, since they have
compilers. Therefore, programs ensure that program will not fail at run-time.
Therefore it is another vital feature of language security in typed languages.
References
Blankenhorn,
D., Lessons from Google Wave failure. CBS Interactive [Online] Available at: http://www.zdnet.com/blog/open-source/lessons-from-google-wave-failure/7025
[accessed: 31st
October 2010]
Douglas, N. A., (2000),
The explosion of Ariane 5. University
of Minnesota [online] Available at: http://www.ima.umn.edu/~arnold/disasters/ariane.html
[accessed: 29th October
2010]
Eiffel Software. Fortune
500 Technology Manufacturer Uses Eiffel Software to Dominate its Market.
Available
at: http://www.eiffel.com/executives/case_studies/storage/storage.pdf
[accessed: 29th October
2010]
Goldstein, H.,
Who Killed the Virtual
Case File?. North America: IEEE Spectrum,
[online] Available at: http://spectrum.ieee.org/computing/software/who-killed-the-virtual-case-file [accessed 30th October 2010]
Greenemeier, L.,
(2005), Tech vs. Terrorism, UBM
TechWeb [online] Available at: http://www.informationweek.com/news/global-cio/showArticle.jhtml?articleID=164300083 [accessed: 30th
October 2010]
National Research Council (2004), A Review of the FBI’s Trilogy Information Technology
Modernization Program. Computer Science and Telecommunication Board, National Academies
Press, Washington D.C, [online] Available at: http://www.nap.edu/openbook.php?record_id=10991&page=R1
[accessed: 30th
October 2010]
Neimat, T., Why IT Projects Fail, The PROJECT
PERFECT White Paper Collection [Online] Available at: http://www.projectperfect.com.au/downloads/Info/info_it_projects_fail.pdf [accessed:
30th October 2010]
Nell, D., Chip, W., (2008), Programming and problem solving with JAVA. Jones and Bartlet publishers,
Ontario, [online] Available at: http://www.nap.edu/openbook.php?record_id=10991&page=R1
[accessed: 30th
October 2010]
Soulie, J. (2007), Type Casting. cplusplus.com [Online]
Available at: http://www.cplusplus.com/doc/tutorial/typecasting/
[accessed:
30th October 2010]
Warren, C., Lessons Google Can Learn From Wave’s Failure,
Mashable [Online] Available at: http://mashable.com/2010/08/06/google-wave-lessons/ [accessed:
30th October 2010]
Comments
Post a Comment