Are there demerits of type casting ? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 2

Are there demerits of type casting ?

3rd Oct 2017, 3:15 PM
Harsh Tirkey
Harsh Tirkey - avatar
2 Antworten
+ 14
Typecasting turns off your complier’s ability to check for type mismatches and therefore creates a hole in your defensive -programming armor. A program that requires many type casts probably has some architectural gaps that need to be revisited. Redesign if that’s possible; otherwise, try to avoid type casts as much as you can. (Source: Code complete 2)
3rd Oct 2017, 4:20 PM
Babak
Babak - avatar
+ 4
Typecasting can not only get the program to overlook type errors, but can also result in loss of data and significant figures. Hence, it's best to avoid it if possible. Hope this helps! :)
3rd Oct 2017, 4:28 PM
Shinjini Ghosh