← Back to context

Comment by nh23423fefe

7 days ago

Any parameter list is permutation invariant. the first argument is special because methods are members of classes and thus get private access in the body of the method. If the implementation of the method is improved with private access then make a design decision.

You don't have to decide where to put the implementation if you dont want to, its just a type of inlining

    void foo(Type1 arg1, Type2 arg2) {
        // do something
    }

    class Type1 {
        void foo(Type2 arg) {
            foo(this, arg);
        }
    }


    class Type2 {
        void foo(Type1 arg) {
            foo(arg, this);
        }
    }

vs

    class Type1 {
        void foo(Type2 arg) {
            // do something
        }
    }

    class Type2 {
        void foo(Type1 arg) {
            arg.foo(this);
        }
    }