chuck icon indicating copy to clipboard operation
chuck copied to clipboard

Add abstract and final class and method modifiers

Open heuermh opened this issue 7 years ago • 0 comments

When composing object hierarchies, it is often useful to create abstract classes, those meant for extension not instantiation and final classes, those meant for instantiation not extension. The same modifiers are also useful at the method level.

For example, LiCK contains a class AbstractBounce which as the comment says is not meant to be instantiated, it only provides functionality shared among concrete subclasses. Ideally this class would be marked with an abstract class modifier so that it cannot be instantiated and its easeIn(float) and easeOut(float) methods marked with a final method modifier so that they cannot be overridden. Then the concrete subclasses BounceIn, BounceOut, and BounceInOut could be marked with a final class modifier so that they cannot be extended.

https://github.com/heuermh/lick/blob/master/AbstractBounce.ck

For reference, here are the definitions per the Java Language Specification

abstract class modifier http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.1.1.1

final class modifier http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.1.1.2

abstract method modifier http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.4.3.1

final method modifier http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.4.3.3

Migrated from https://github.com/spencersalazar/chuck/issues/29

heuermh avatar Jan 16 '18 17:01 heuermh