LoginSignup
462

More than 5 years have passed since last update.

海外転職の面接の時に英語で聞かれるRubyとRailsの基礎質問を徹底マスターしておく方法

Posted at

海外転職の技術面談の形式に関してはこちらのブログに何度か書いたので、今回はその具体的な対策を書いた。ずばり「RubyとRailsに関する英語の基礎質問と解答例」

書類選考をみごとに通過したら次は電話面談かもしくはオフィスでの面談になる。いづれにしても採用側の会社からはエンジニアが2,3人ぐらい出てきて応募者の相手をすることになる。最初は本当に基礎的な技術質問から入る。それは誰にでも分かるような質問と答えで応募者に話してもらって緊張をほぐす意味と、あともうひとつは「箸にも棒にもかからない人に早々とご退場」願うためだ。あくまでメインは技術質問ではなくコーディングインタビューの方。

なんにしても技術質問の時点で詰まってはいけない。そんなに難しいことでもないし、技術分野に合わせて聞かれる内容はほぼ同じなので十分に対策が取れる。英語がネイティブじゃない応募者が詰まる原因とその対策は以下の3つの順になる。

  1. その技術質問の英語が分からない => 英語ヒアリング強化
  2. その技術質問の英語は分かるが答えが分からない => 技術力強化
  3. その技術質問も答えも分かるが英語が出てこない

3の「質問もその答えも分かってるのに、英語が出てこない!」辺りが案外あなどれない箇所。
「Rubyのクラス?そんなもんオレは毎日コード書いて3度の飯より馴染みあるわ。答えてやるぜ!(ここから英語)あー、くっくっく、クラス いず あー。。。(口開けたまま固まる)」となりがち。慣れない間は答えを丸暗記してしまうぐらいに、質問と答えを繰り返し暗唱して覚えてしまうこと。ということでよく出てくる質問とその答えを集めた。

RubyとRailsに関する英語の基礎質問と解答例

Q.
What is a class, what is an object and why we need modules?

クラスってなに?オブジェクトってなに?なんでモジュールが必要なの?

(以下の答えを読む前に声に出して英語で答えてみることをオススメします。頭の中で「分かっているぜ!オレ」と実際に「英語を声に出して説明すること」の差は自分の想像以上にあるものなので。)

A.
- Class: is the blueprint from which individual objects are created. Classes in Ruby are first-class objects---each is an instance of class Class.
- Instance: is an object which was instantiated from a Class
- Module: is a collection of methods and constants. You can't make an instance of a module; the way you access the constants and methods inside it depends on it's definition; module methods and variables can be accessed like this Module.method or Module.CONSTANT but if you want to access an instance method you should include the module to another class to use it.

  • クラスは入れるべきデータとメソッドを記載した設計図(青写真)
  • オブジェクトはクラスのインスタンス
  • モジュールはミックスインのためのツール。ネームスペースを提供する。

一応上記の回答はネットから引っ張ってきた回答なのだが、私の意見としてはこれでいいと思う。ただ文字にすると「?」という箇所がある。質問者はなぜモジュールが必要なのか?を聞いているのに解答者はそのなぜ?に答えていない。でも面接の場なんてそんなモンだし。面接官が「おい!オレはモジュールがなぜ必要なのかを聞いてるのであって、モジュールの概念は聞いてねーんだよ!!」とかこの段階で突っこんでくることはきっとない。あったとしても後から付け加えればいいだけ。
そんな重箱の隅をつつくようなことよりもここで重要なのはパッと聞かれてパッと答えるリズム。「クラスやモジュールのことなんて分かっているし、そんなレベルの質問で英語の会話が止まることなんてない」と思わせることの方が重要なのだ。そのためには自分の言葉でサラっと言えるようにしておくこと。上記の答えは100%素晴らしいレベルとは言えないので独自でも模範解答を作ることをオススメする。
 
 

Q.
What is the difference between include and extend?

includeとextendの違いってなに?

A.
Include is for adding methods to an instance of a class.
Extend is for adding class methods.

Includeはインスタンスとしてメソッドを追加する。
extendはクラスとしてメソッドを追加する。

上記が言えればほぼOk。後はホワイトボードか、スカイプ面談だったらチャットを使って以下のようなコード事例でも書いておけば完璧。

module Momo
  def momo
    puts 'module!'
  end
end

class Caca
  include Momo
end

Caca.new.momo # module!
Caca.momo # NoMethodError

class Cacaca
  extend Momo
end

Cacaca.new.momo # NoMethodError
Cacaca.momo # module!

面談は「口頭だけで答えなければならない」なんてルールはない。英語がネイティブじゃなければ、その場にある書けるモノでも、ジェスチャーでも、なんでも使って言葉のハンディを埋めるようにしましょう。
 
 

Q.
What is the difference between a Proc and Lambda?

ProcとLambdaの違いってなに?

これは不思議なぐらいに面談で聞かれることがとっても多い質問。いまだになぜよく聞かれるのか訳が分からない。そんなにprocとlambdaの違いを把握することが実践で重要とは思えないんだけど。。。やけに頻出するから私も面接官をするときに聞いてしまう。で、ほとんどの候補者が同じ説明をして正解という質問。
 

A.
Lambdas check the number of arguments, while procs do not.
‘return’ inside of a lambda triggers the code right outside of the lambda code
‘return’ inside of a proc triggers the code outside of the method where the proc is being executed

違いとしてはまず引数のチェックが入るかどうかと、returnの処理の違い。
 
 

Q.
What's the difference between “includes” and “joins” in ActiveRecord query?

ActiveRecordのincludes とjoinsの違いってなに?
個人的にはこの質問の方がprocとlambdaよりもよほど実践的で意味のある質問ではないかと感じている。

A.
joins joins tables together in sql.
includes eager loads associations to avoid the n+1 problem (where one query is executed to retrieve the record and then one per association which is loaded).

joins はsqlでINNER JOIN する。
includesはデータの先読みをしてキャッシュする。N+1問題を解決してくれる。
 
 

Q.
What is ORM in Rails?

ORMってなに?

A.
ORM = Object Relationship Model in Rails indicate that your classes are mapped to the table in the database, and objects are directly mapped to the rows in the table.

Object Relationship Model クラスがデータベースのテーブルにマップされている便利なツール。

ぶっちゃけそれなりにRailsでコード書いてる人だったら、ORMなんて意識しててもしてなくても理解していると思う。でもこの面談ではそれが英語で説明できるかどうかが重要。「基本概念の定義の英語版」は覚えておいて損はない。
 
 

Q.
What is Gemfile and Gemfile.lock?

GemfileとGemfile.lockってなに?

A.
The Gemfile is where you specify which gems you want to use, and lets you specify which versions. The Gemfile.lock file is where Bundler records the exact versions that were installed. This way, when the same library/project is loaded on another machine, running bundle install will look at the Gemfile.lock and install the exact same versions, rather than just using the Gemfile and installing the most recent versions. (Running different versions on different machines could lead to broken tests, etc.) You shouldn’t ever have to directly edit the lock file.

一通り説明した後にGemfile.lockは直接編集しない方がいい、ってなんか実践分かってるぽいコメントを付け加えればいいかな、と。
 
 

Q.
What do you know about method accessibility, like what is the difference between private and protected.

メソッドのアクセス権でprivateとprotectedの違いってなに?

A.
Public - can be called from anywhere

Private - The method cannot be called outside class scope. The object send message to itself

Protected - You can call an object's protected methods as long as the default object self is an instance of the same clas as the object whose method you're calling

Public どこからでもアクセス可能
Private そのオブジェクトの外側からコールはできない
Protected 同じクラスのオブジェクトからならコールは可能

ややこしい時はいつでもコード事例を書くこと。これがいつでも最強。

class TestSuper
  protected
  def protected_method
  end

  private
  def private_method
  end
end

class Test < TestSuper
  def call
    t = Test.new
    t.protected_method
    t.private_method
  end
end

Test.new.call
 ========
t.protected_method > Ok 
t.private_method > Error

 
 

Q.
Why do you need a digest at the end of a compiled asset?

コンパイル済のアセットにはなぜダイジェストが必要なのか?

A.
non-digest versions of asset files are supported only for Rails 3 and older. From Rails 4 supports digested assets.

digest無しのアセットを受け付けてくれるのはRails3まででRails4からは全てdigest(fingerprint)がついているアセットしか扱わなくなったから。

digestと言ったりfingerprintと言ったり妙に統一感がないので「?」となりがちだけど、digestを知らなかったからといって「分かりません」と降参してはいけない。
 
 

Q.
What's the difference between calling super and super() ?

super と super()の違いってなに?

A.
When you call super with no arguments, Ruby sends a message to the parent of the current object, asking it to invoke a method with the same arguments as where you called super from.

On the other hand, when called with super(), it sends no arguments to the parent.

super 呼び元と同じ引数でSuper クラスのメソッドをコールする。
super() 引数無しでSuper クラスのメソッドをコールする。
 
 

Q.
What is passanger

passangerってなに?

A.
Easy and robust deployment of ruby on rails app on appache and ngix webservers
passenger is an intermediate to run the ruby language in linux server

Railsアプリケーションを実行するためのApacheもしくはnginxモジュール
 
 

Q.
What is request.xhr?

request.xhrってなに?

A.
request.xhr tells the controller that the new Ajax request has come, It always return TRUE or FALSE

request.xhrはコントローラーにAjaxリクエストを知らせる働きをする
 
 

Q.
What is Session and Cookies?

セッションとクッキーってなに?

A.
Session: are used to store user information on the server side.
cookies: are used to store information on the browser side or we can say client side
Session : say session[:user] = “srikant” it remains when the browser is not closed

セッション サーバー側に保存するユーザー情報
クッキー クライアント側に保存するユーザー情報
面接官がさらに質問してきたりしたら、もっと説明してもいいとは思うけど1発目はこれで十分だと思う。
 
 

Q.
What is asset pipeline

アセットパイプラインってなに?

A.
asset pipeline which enables proper organization of CSS and JavaScript

JavaScriptやCSSのアセットを圧縮して連結するためのフレームワーク
 
 

Q.
Difference between render and redirect?

renderとredirectの違いってなに?

A:
render will render a particular view using the instance variables available in the action. Rails creates the html for that view and returns it back to the user’s browser. This is what you would consider a normal page load.

redirect_to will send a redirect to the user’s browser telling it to re-request a new URL. Then the browser will send a new request to that URL and it will go through the action for that URL, oblivious to the fact that it was redirected to. None of the variables created in the action that caused the redirect will be available to the redirected view.

-Redirect is used as:
redirect_to: controller => ‘users’, :action => ‘new’

-Render is used as:
render: partial
render: new -> this will call the template named as new.html without the need of redirecting it to the new action.

render viewのパートをレンダーする
redirect 新しいURLに新規のリクエストを投げて、再表示する
(だんだん日本語訳を書くのが面倒で雑になってきた)
 
 

Q.
What is eagerloading

eagerloading、なに?

A.
One way to improve performance is to reduce the number of database queries through eager loading.
-You can know where we need eager loading through “Bullet’ Gem

データベースクエリの数を減らしてパフォーマンスを改善する手段のひとつ。
bullet gemを使うことでeagerloadingが必要な箇所、N+1問題の発生している箇所を見つけることができる。
 
 

Q.
What is the diffence betweet symbol and string

symbolとstringの違いは?

A.
Symbols are immutable: Their value remains constant.
Multiple uses of the same symbol have the same object ID and are the same object compared to string which will be a different object with unique object ID, everytime.
You can't call any of the String methods like #upcase, #split on Symbols.

symbol => 値が変更できない。メモリーくわない、速い
string => 値を変更できる。メモリー食う、symbolに比べると遅い
(もうホントに日本語訳がダルい)
 
 

Q.
Explain how you define Instance Variable, Global Variable and Class Variable in Ruby?

A.
Instance variable begins with — @
Class variables begin with — @@
Global variables begin with — $

これはもう日本語訳要らないでしょう。
 
 
以上、「RubyとRailsに関する英語の基礎質問と解答例」でした。

他にもこちらのブログに英語圏へのエンジニア転職のこと、いろいろ書いてます。

エンジニアの皆様へ

ほとんどのエンジニアには解けるが、下位10%のダメなエンジニアにだけ解けないパズル?」なるものをシリーズ化してパズル1から8まで作成した。もしご興味あれば解いてみてください。
http://tango-ruby.hatenablog.com/entry/2015/11/30/122814

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
462