yegor256 / takes

True Object-Oriented Java Web Framework without NULLs, Static Methods, Annotations, and Mutable Objects
https://www.takes.org/
MIT License
810 stars 201 forks source link

Eliminate all checked exceptions from the project. #920

Open skapral opened 5 years ago

skapral commented 5 years ago

First of all, to exclude any of future misunderstandings: I know about Elegant Objects and its principles and embrace most of them. Part about checked exceptions is a thing that I strongly propose to reconsider.

See this post for information on how checked exceptions pollute the project and everything which depend on it. Since Takes is a framework, and its components are designed to be heavily reused, the issue of checked exceptions becomes especially crucial here.

throws Exception tends to spread widely and uncontrollably across the code. Once we call unsafe method which throws checked exception, our method becomes unsafe either. Once our method becomes unsafe, throws Exception is propagated to the interface, where the method is declared. And once the interface has unsafe methods, all its implementors - both trivial and non-trivial ones - become unsafe. And all the interface callers become unsafe either. Checked exceptions are like a virus. For paradigm which relies on object composition, checked exceptions just doesn't work and make only harm.

I, as a user of a typical framework, expect it to solve its purpose without deep interference with my code. And I feel frustrated and discouraged when I realise that once I do some object composition with Takes artifacts (which are supposed to be maintainable, reusable and extendable as any Elegant Object), it impacts my declarations, once I instantiate, let's say, FtBasic there:

class WebApplication {
    ....
    // Won't compile until I add `throws Exception` to the constructor's declaration.
    // because FtBasic throws IOException.
    public WebApplication(int port) {
        this(
            new FtBasic(
                new TkFork(new FkRegex("/", "hello, world!")), port
            )
        );
    }
    ....
}

I propose to:

0crat commented 5 years ago

@paulodamaso/z please, pay attention to this issue

0crat commented 5 years ago

@skapral/z this project will fix the problem faster if you donate a few dollars to it; just click here and pay via Stripe, it's very fast, convenient and appreciated; thanks a lot!

victornoel commented 5 years ago

See also yegor256/cactoos#944