I agree with you, but I'add for the sake of completeness that, sometimes,
relaxing the rules a bit becomes a necessary evil, like for instance, when
doing a cast.

When you do this:

// bar is typed as ISomeInterface somewhere else
var foo:SomeConcreteClass = bar as SomeConcreteClass;  // or
SomeConcreteClass(bar)
foo.methodOnlyPresentInConcreteClass();

You are basically bypassing the rules of type system. You're telling the
compiler that an object declared as ISomeInterface at compile time will be
an instance of SomeConcreteClass at runtime. You're asking the compiler to
trust you and not blow up when compiling your code. Some times this is
avoidable with some refactoring (and or a better design). Sometimes it's not
possible or impractical (this also depends on how purist you are, I guess).
Nevertheless, having too many casts is usually considered a code smell for
this very reason.

Cheers
Juan Pablo Califano




2010/6/7 Merrill, Jason <[email protected]>

> >> Or, you can simply turn strict mode off. I tend to agree with Steven
> Sacks, though.
> >>There's a really good reason for strong typing--mainly, it's easier to
> find bugs at compile time than at
>
> Yep. IMO, there should never be a reason to turn strict typing off, it's
> like saying, "Don't tell me about my bugs, I don't want to hear it.",
> which is like saying, "doctor, only tell me I'm healthy, because I don't
> want to hear I have cancer." But that's just me. :)
>
>
> Jason Merrill
>
> Instructional Technology Architect
> Bank of  America  Global Learning
>
> Join the Bank of America Flash Platform Community  and visit our
> Instructional Technology Design Blog
> (note: these are for Bank of America employees only)
>
>
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to