How much logic is “right” to put in Callable?

I often use calls, and I was concerned about a question that annoys me:

Suppose that to run the foo () function, you first need to perform a couple of checks.

If you 1. Insert checks as part of the called:

class A implements Callable<Long> {
...
public Long call() {
    check1();
    check2();
    return (run()); 
}
  1. OR, paste all this logic into another class (ALOGIC) and use Callable for shell only for shell? class A implements Callable {
    ...
    public Long call() {
    ALogic aLogic = new ALogic();
    return (aLogic.run());
    }

What do you think pro and con are? What do you usually prefer?

+3
source share
3 answers

[Java keyword] , [-Java] . ( - ) , , .

, , , , . ( , , ).

+1

? .

+1

. "this", , .

0

Source: https://habr.com/ru/post/1702207/


All Articles