Skip to main content
added 39 characters in body
Source Link
McMannus
  • 851
  • 8
  • 20

Well, let's recall what it means to pass a variable as constructor parameter: You initialize an object in order to use its instance variables in methods of the object. The point is that you probably want to use it in more than one method since you want to have a high cohesionhigh cohesion in your class.

Passing a parameter directly to a method means in a way sending a message to an object and probably receive an answer. By that, the client wants the object to dodeliver a service for him.

So in conclusion, those are two very different means of passing parameters and you should choose whether your object should doeither deliver a service or providesprovide some functionality inherently and therefore manageswhile managing some datainformation internally.

Well, let's recall what it means to pass a variable as constructor parameter: You initialize an object in order to use its instance variables in methods of the object. The point is that you probably use it in more than one method since you want to have a high cohesion in your class.

Passing a parameter directly to a method means in a way sending a message to an object and probably receive an answer. By that, the client wants the object to do a service for him.

So in conclusion, those are two very different means of passing parameters and you should choose whether your object should do a service or provides some functionality inherently and therefore manages some data.

Well, let's recall what it means to pass a variable as constructor parameter: You initialize an object in order to use its instance variables in methods of the object. The point is that you probably want to use it in more than one method since you want to have a high cohesion in your class.

Passing a parameter directly to a method means in a way sending a message to an object and probably receive an answer. By that, the client wants the object to deliver a service for him.

So in conclusion, those are two very different means of passing parameters and you should choose whether your object should either deliver a service or provide some functionality inherently while managing some information internally.

Source Link
McMannus
  • 851
  • 8
  • 20

Well, let's recall what it means to pass a variable as constructor parameter: You initialize an object in order to use its instance variables in methods of the object. The point is that you probably use it in more than one method since you want to have a high cohesion in your class.

Passing a parameter directly to a method means in a way sending a message to an object and probably receive an answer. By that, the client wants the object to do a service for him.

So in conclusion, those are two very different means of passing parameters and you should choose whether your object should do a service or provides some functionality inherently and therefore manages some data.