This project was inspired by Elegant Objects by Yegor Bugayenko
PureOOFizzBuzz is a true object-oriented and immutable Java8 demo. Its key benefits, comparing to all others, include these seven fundamental principles:
- not a single
null
(why NULL is bad?) - not a single
public
static
method (why they are bad?) - not a single mutable class (why they are bad?)
- not a single
instanceof
keyword, type casting, or reflection (why?) - not a single
getter
orsetter
(why?) - not a single
new
outside of secondary constructors - not a single Java primitive
FizzBuzz values cannot be accessed directly. Instead they can be printed to any Media
.
You can implement Media
however you like.
####Print to Collection Usage
TextCollection media = new TextCollection();
new FizzBuzz(100).print(media);
Collection<String> stringValues = media.strings();
####Print Range to Collection Usage
TextCollection media = new TextCollection();
new FizzBuzz(15, 50).print(media);
Collection<String> stringValues = media.strings();
####Print to Console Usage
new FizzBuzz(100).print(new SystemConsole());
Silas Reinagel
You may use this code in part or in full however you wish.
No credit or attachments are required.