[fpc-devel] class abstract, class sealed implementation. please review.

Alexander Klenin klenin at gmail.com
Mon Oct 19 07:58:51 CEST 2009


On Mon, Oct 19, 2009 at 15:43, Paul Ishenin <ip at kmiac.ru> wrote:
> Except the security role sealed and abstract classes have their important
> oop meaning.

Security is only possible in the context of languages like Java, which can
actually enforce visibility rules at run-time. Compiled languages nave
no such ability.

> Look at the next "phones example":
>
> TBasicPhone = class abstract
> TCellularPhone = class(TBasicPhone)
> TSatelitePhone = class(TBasicPhone)
> TDialPhone = class(TBasicPhone)
> ...
> TNokiaPhone = class(TCellularPhone)
> TNokia37xxPhone = class(TNokiaPhone)
> TNokia3720Phone = class sealed(TNokia37xxPhone)
>
> TBasicPhone is ofcource an abstract class. It can have some basic fields
> like color, weight, dimensions, ...
> TNokia3720Phone is a final product which can't have any further derivations.
> It is logically to mark this class as sealed to prevent occasional errors.

Sure, and then company releases Nokia 3721, and some hapless developer in India
have to reimplement the entire TNokia3720Phone class.
This is classis example of why sealed is bad ;-)

-- 
Alexander S. Klenin



More information about the fpc-devel mailing list