Reputation: 49
I have a class controller
class QueueMessagesController < SecureController
def create
create_queue_message(params) if params[:type] == 'cards'
delete_queue_message(params) if params[:type] == 'queue'
end
def create_queue_message(params)
end
def delete_queue_message(params)
end
private
def queue_params
params.require(:headers)
end
end
So my query is whether the create_queue_message
and delete_queue_message
should be private methods or not. what is good approach.
Upvotes: 0
Views: 44
Reputation: 106812
I would answer: Every method that is only used internally should be private
in object-oriented-programming.
If you do not make such methods as private then another developer might think that they belong to the public API of the class and might use them directly.
Therefore I think it is a good practice to make all methods private
as a default and only make a method public if there is a reason to add that method to the public API.
Upvotes: 2