[Prévia] [Próxima] [Prévia por assunto] [Próxima por assunto]
[Índice cronológico] [Índice de assunto]

consertando a confusão na definição de subtipos



Oi,

Eu havia me esquecido disso mas os ares da semana da pátria me lembraram. Logo na primeira aula da disciplina eu dei uma visão geral sobre conceitos básicos de OO e falei um pouco sobre subtipos e supertipos. Um pouco depois, um aluno me alertou que a definição que eu apresentei oralmente na aula estava meio ao contrário.

Então, vamos esclarecer isso. Peguei o seguinte trecho de http://computing-dictionary.thefreedictionary.com/subtype:


subtype - If S is a subtype of T then an expression of type S may be used anywhere that one of type T can and an implicit type conversion will be applied to convert it to type T.


In object oriented programming, this means that objects of type S must accept every message <http://computing-dictionary.thefreedictionary.com/message> that one of type T would.

Portanto, a interface do subtipo é um super-conjunto da interface do super-tipo. Foi aí que eu me confundi invertendo as coisas.

Feliz semana do saco cheio da pátria,
fabio.