0

Inspired by my own question + a fragment of Robert Bräutigams answer there: Tell one, but ask the others?

i came up with this question here:

let's take us the write method of a chatroom or any other method of any object

public void doSomething();

i can add one parameter to that method

public void doSomething(Object a);

and a lot of more:

public void doSomething(Object a, Object b, Object c, ....);

i think the more parameter we add the more we give up the internal behaviour?

let's say the doSomething is the write method of a Chatroom. write(message) writes a message to the chatroom, and now we want to define how this is written to the chatroom, in bold-style, uperrcased-style, kursive-style, colored and so on, for that we need more parameters.

So we move more and more behaviour from the the class which contains the doSomething method to the outside to the client.

to bring the whole thing to the head, we also can do something like this

public void doSomething(Function f)

the Function f get as parameter all internals from the class of doSomething and now i can really do all i want with that class

ok one different we have there the code with many-parameters doesn't get direct access to all internals, but theoretically yes.

And as strict object-oriented programmer knows, don't manipulate the internals from outside^^

So my question is how you would do something like this, controlling the manner how is something written into a channel?

how you would classify my different code examples here: no parameter, many parameter till functional parameter? in which programming-style (oop, solid/procedural, ....) should i do when what?

Notice: Yeah i know of the technique capsulating many-parameter into a DTO, but that should change nothing^^

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.