PROGRAMANDO EN .NET
Otro test de agudeza visual: ¿qué código es peor?
Febrero 26th, 2010 - [Enlace local]
Opción 1: Dim intVariable as Integer Try intVariable = LlamadaaMetodoQuePuedeDevolverNothing() Catch ex as Exception intVariable = 0 End TryOpción 2: Dim intVariable as Integer = 0 Try intVariable = LlamadaaMetodoQuePuedeDevolverNothing() Catch ex as Exception End TryRespuesta: la opción 2, que provoca un precioso "agujero negro de excepciones".PD: los 2 ejemplos están basados en hechos