Are there demerits of type casting ? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 2

Are there demerits of type casting ?

3rd Oct 2017, 3:15 PM
Harsh Tirkey
Harsh Tirkey - avatar
2 ответов
+ 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