monterail / guidelines

[DEPRECATED] We are Ruby on Rails experts from Poland. Think hussars. Solid & winged. These are our guidelines.
71 stars 17 forks source link

How to indent private and protected #232

Closed jcieslar closed 9 years ago

jcieslar commented 9 years ago
module Api::V1
  class PostsController < ApplicationController

    def create
      @post = Post.create!(post_params)
      render json: PostRepresenter.new(@post)
    end

    private

    def post_params
      params.require(:post).permit( :excerpt, :content, :title, user_ids: [], tags: [] )
    end
  end
end

2.

module Api::V1
  class PostsController < ApplicationController

    def create
      @post = Post.create!(post_params)
      render json: PostRepresenter.new(@post)
    end

  private

    def post_params
      params.require(:post).permit( :excerpt, :content, :title, user_ids: [], tags: [] )
    end
  end
end

3.

module Api::V1
  class PostsController < ApplicationController

    def create
      @post = Post.create!(post_params)
      render json: PostRepresenter.new(@post)
    end

    private

      def post_params
        params.require(:post).permit( :excerpt, :content, :title, user_ids: [], tags: [] )
      end
  end
end
jcieslar commented 9 years ago

I prefer 2.

RadoMark commented 9 years ago

Vote for 3.

szajbus commented 9 years ago

:+1: for 1.

metrox commented 9 years ago

1/2

Ostrzy commented 9 years ago

Number 3 is the only truth! Rest are mere false gods!

My argumentation is that 3 help you work with larger classes - you clearly see where public interface ends.

jandudulski commented 9 years ago

I'm always using no. 1.

Why? Because private and public are just class methods. And leaving them alone, with empty line before and after, expose it enough.

My argumentation is that 3 help you work with larger classes

I would rather say that large class is a smell and it should be splitted into smaller ones :tongue:

chytreg commented 9 years ago

Agree with @jandudulski, but I don't like 2. I would accept 3. Should be same across whole project.

tallica commented 9 years ago

1 / 2

Ostrzy commented 9 years ago

I would rather say that large class is a smell and it should be splitted into smaller ones :tongue:

Yeah, but they happen and then you have to deal with them. Also smaller classes means ~100 lines of code which is enough for 3 to help you interact with it.

teamon commented 9 years ago

Zapraszam do głosowania.

Każdy może oddać dowolną ilość głosów! Głosujemy na zasadzie "I'm OK with Option X" dla każdej z opcji. Czyli nie na ulubioną, a na wszystkie te, które są dla mnie okej.

Ankieta: http://doodle.com/farkkdi7fy2qsynb.

Dlaczego tak głosujemy

teamon commented 9 years ago

@monterail/dev Deadline na oddanie głosu - 22.07.2015 23:59

hodak commented 9 years ago

Closing without pull request as solution that won is unchanged in guidelines.