Forum: Ruby on Rails RoR Job Interview

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Yonatan G. (Guest)
on 2006-12-24 17:22
(Received via mailing list)
Hi ,
Got an upcoming job interview as a RoR programmer, just thought If
you have good ideas
for questions that might come up during such interview, post them here,
I will try  to send back one reply with what I would have answered
hopefully this will open some debate,
and might help (me) and future programmers before a Ruby job interview.

Regards,
Yonatan G..
Peter (Guest)
on 2006-12-24 19:17
If I was the interviewer, I would look for passion.
If I would sense that you live and breath Rails you are hired.
Maybe you would lack certain skills, but based on above you would be
eager to learn.

But hey, everybody has their own list.
The next guy thinks its important how you are dressed.
I wouldnt giva a sh*t.

In other words , be yourself, and see how it goes.

But good luck, and let us know how it went!!

Peter
Jan M. (Guest)
on 2006-12-24 20:05
Yonatan G. wrote:
> Hi ,
> Got an upcoming job interview as a RoR programmer, just thought If
> you have good ideas
> for questions that might come up during such interview, post them here,
> I will try  to send back one reply with what I would have answered
> hopefully this will open some debate,
> and might help (me) and future programmers before a Ruby job interview.
>
> Regards,
> Yonatan G..

Hi,

take this as a start.
I am sure you will be able to come up with some RoR specific questions.

Jan


Interview questions you may be asked
Before attending an interview you should think about your responses to
the following questions. Your answers may depend on the job or company
in question, so you should go through your responses just before each
interview.

Why do you want this job?
Think carefully about this question. Stress the positive aspects which
have attracted you to applying for this position. Do not mention the
negative aspects of your current job or the job in question.

What qualities do you think will be required for this job?
The job specification I sent you for the job may help you a little bit,
but you should also think of the other qualities that may be required.
These may include team player, leadership ability, communication skills,
interpersonal skills, problem solving, analytical skills, etc.

What can you contribute?
This is your chance to shine. Tell them about your achievements in your
previous position(s) which are relevant to the new position you are
applying for.

Why do you want to work for this company?
Emphasise the positive reasons why you want to join their company, but
avoid aspects such as more money or shorter hours. These would not
endear you to a prospective employer.

What do you know about this company?
This is your chance to impress the interviewer with your knowledge of
their company. Give them a run down of their products/services, sales
figures, news, company figures, customers, etc.

What interests you about our product (or service)?
Again, your research into the company should aid you in answering this
question.

You have not done this sort of job before. How will you cope/succeed?
Say that you are the sort of person who aims to succeed at everything
you do and that you are very determined and will do whatever it takes to
get the job done.

Why should we employ you?
The answer to this question will be based on your previous experience
and achievements which relate to the company. At the end you could add
that you think there is a good fit between you and the job, and do ask
the interviewer for their opinion.

What do you like and dislike about the job we are discussing?
Likes: stress things such as a new challenge or the opportunity to bring
fresh experience to the company. Dislikes: Imply there is nothing to
dislike about the job, which is why you are so interested.

Why did you choose a career in ...?
Be positive about your reasons. If you have changed careers make a
logical argument as to why you did so. Career should come from your
experience and achievements, stress the transferable skills you have,
such as leadership ability, etc.

How much does your last job resemble the one you are applying for? What
are the differences?
The interviewer is trying to see how well you would fit in to the
position you are applying for. So you should stress the similarities
rather than the differences. When it comes to discussing the differences
it will help your case if you can show that either you have done
something similar in the past or that you can quickly pick up the new
skills.

What do you think of the last company you worked for?
You should stress the positive aspects of your last company saying that
they were a good company to work for. Tell them about the training you
received or the work related experience you gained.

How long have you been looking for a new job?
If you have been unemployed for a long time this may be a rather tricky
question to answer. But be honest. If you have been away on holiday or
done some voluntary work you could mention this.

Do you prefer to work in a small, medium or large company?
Remember where you are! If the company interviewing you is a small to
medium sized company say that you enjoy a close atmosphere with a good
team spirit. At a large company say that you enjoy the stability of
working for a large and established company.

What are you looking for in a new job?
Make sure your answer fits in with the company who is interviewing you.
A suitable reply would be that you are looking for a new job where you
can apply your existing skills and learn new ones.

What would your ideal job be?
Again, remember where you are! Describe the job in terms of the criteria
they have used to describe their job. An ideal job might include things
like challenging work, a fair rate of pay for the job, nice colleagues,
good career prospects, good team atmosphere, opportunity to learn new
skills, apply old skills, etc.

Are you considering any other positions at the moment?
If you are say so, but do not give too many details away - it will
weaken your negotiating position later. If you do not have any other job
offers at the moment just say that you have a few irons in the fire.

What did you think of your manager/supervisor?
Say that he/she was the sort of person you could learn from and you
communicated well, which meant that the task in hand was completed on
time.

How would you describe yourself? / How would others describe you?
Pick your best attributes and achievements from your career.

How could you improve yourself?
Do not mention anything negative about yourself - the interviewer is
looking for a chink in your armour.

Did you feel you progressed satisfactorily in your last job?
If you progressed faster than normal you should say so. If growth was
not as good as expected then be careful how you phrase this.

How do you handle criticism?
Your answer should be along the following lines: "I always think that it
is important to get feedback on how I am performing so that I can
improve any areas which my manager/supervisor highlights. Do you have
regular staff appraisals and a staff development plan?"

Are you accepted into a team quickly?
Hopefully you can answer a resounding "Yes" to this question.

Can you act on your own initiative?
You should say that you can. You could ask how much responsibility you
would have.

What motivates you?
Our suggestions are career growth, opportunity to learn new skills, good
co-workers, etc.

Can you work under pressure?
You need to say that you can. You could ask how much pressure the job
involves.

How many hours are you prepared to work?
You would be prepared to work the necessary hours to get the job done on
time.

What are your career goals?
Link in your goals with the company who is interviewing you.

What interests do you have outside work?
Your hobbies and interests can tell an employer a lot about you,
including whether you are sociable or solitary, and whether you can take
on 'leadership' roles. So you should think about which interests will
paint the right picture of you given the position you are discussing.

Are you prepared to relocate?
If you are, say so. If you do not want to move then you do not have to
accept the job - try and come across as someone who is positive.

How often are you off sick?
This can be a difficult question to answer if you are frequently off
sick or you have just recovered from a prolonged period of illness. If
you have generally enjoyed good health and this period of illness is not
typical then you should say so.

What did you earn in your last job?
You have to be very careful when answering this question because once an
interviewer knows your current salary they will try and fix your next
remuneration based on this figure. This may be satisfactory if you only
wanted a modest rise in salary and your current salary is in line with
their salary range, but, what if your current salary is substantially
lower than the rate for the job, or if you want a substantial salary
rise? In these cases you would be best advised to say that you do not
really want to prejudice yourself by being too high or too low. Ask if
you can discuss this later after the responsibilities for the job have
been discussed; you may also want to ask them what the range for the job
is (if you do not already know).

What level of salary are you looking for now?
Be very careful when you answer this question - you do not want to
appear to be greedy. If you are applying for a specific vacancy you
could ask them what the salary range is. Once they have answered you
could say "I think my experience would place me at the top end of your
range, don't you?" If they ask you this question fairly early on in the
interview you could delay answering by saying "It is hard to discuss
salary without first knowing a little bit more about the job and the
responsibilities."

What will your referees say about you?
Say that you expect excellent references.

Difficult questions
If you cannot answer a question you might reply with "That's an
interesting question - how would you tackle it?"

Questions you may want to ask an interviewer
The interview is a two-way process. The company interviewing you will
want to find out whether you are suitable for the position and you will
want to find out if the company and position are right for you. You
should therefore ensure that you have enough information to make up your
mind whether you want the job. For example:

    * What will be my responsibilities?
    * Who will I report to?
    * Who are your customers?
    * What training do you provide?
    * What is the next step?

From a website:
    * Why is this position available?
    * Is this a new position? How long has this position existed?
    * What happened to the person that held this position before?
    * How many people have held this position in the last four years?
    * What do you like about working here?
    * With whom will I be working most closely?
    * What kind of staff turnover rate does the company have?
    * What projects and assignments will I be working on?
    * How would you describe the company's culture?
    * What do you consider to be the company's strengths and weaknesses
as an employer?
    * What are the most challenging aspects of the position?
    * What are the opportunities for training and professional
development?
    * Will I receive any formal training?
    * What is the company's promotional policy?
    * Are there opportunities for advancement within the organisation?
    * When can I expect to hear from you?
Phlip (Guest)
on 2006-12-24 20:16
(Received via mailing list)
Yonatan G. wrote:

> Got an upcoming job interview as a RoR programmer...

If your interviewer has previous experience with ASP.NET, PHP, or
Tomcat, you can get them ranting about them and score some points.

Just don't abuse the trick... ;-)

--
  Phlip
  http://c2.com/cgi/wiki?ZeekLand  <-- NOT a blog!!
Mohit S. (Guest)
on 2006-12-24 21:16
(Received via mailing list)
Phlip wrote:
>
> Yonatan G. wrote:
>
>> Got an upcoming job interview as a RoR programmer...
>
> If your interviewer has previous experience with ASP.NET, PHP, or
> Tomcat, you can get them ranting about them and score some points.
>
> Just don't abuse the trick... ;-)
>
By the way, I wouldn't be surprised if your recruiter is on this list :P
Cheers
..mohit.
Yonatan G. (Guest)
on 2006-12-24 22:10
(Received via mailing list)
first , thanks for your replies.

mohit,
I guess he is on this list... still started to think about it today,
and thought it would trigger
a nice discussion.

I read Jan Martin's post , and it's definitely handy to have a list
of question to sit down with yourself
before a job interview. However, I was thinking more in the direction
of the technical aspects of the
interview. I guess there are many ways to approach this, one
interviewer would like to check,
If I get the overall picture of the whole framework, another could
just focus on the Ruby syntax,
and so forth, I would have put the emphasis on the personal experience.

I guess I revise the question to -
what you would look for in a rails developer ?,
what questions you would  have asked, if you were conducting the
interview ?

(i'll go first)
what was the most interesting code you wrote with rails ?
with this question I would like to see that a potential candidate has
some non-trivial experience,
that he has it's own creative approach.

thanks again for your time,
Yonatan G..
Phlip (Guest)
on 2006-12-24 22:20
(Received via mailing list)
Yonatan G. wrote:

> mohit, I guess he is on this list... still started to think about it today,
> and thought it would trigger
> a nice discussion.

Here's a good interview question: "Do you know how to work 'net forums?"

The kind of boss worth working for knows that's an important skill...

--
  Phlip
  http://c2.com/cgi/wiki?ZeekLand  <-- NOT a blog!!
Jeff C. (Guest)
on 2006-12-24 23:48
(Received via mailing list)
Yonatan G. wrote:
> I guess I revise the question to -
> what you would look for in a rails developer ?,
> what questions you would  have asked, if you were conducting the
> interview ?

It depends on what I'm looking for, but these come to mind as
conversation starters:

Rails background:
1. What are migrations and why are the useful?
2. What is AJAX all about?
3. How does Rails apply the MVC pattern?
4. How do you know when to write unit tests, functional tests, or
integration tests?
5. What are the different ways of storing sessions with Rails?
6. In Rails, how does a given url result in a controller method being
called?
7. What is REST all about?  Why is it an important design pattern?

Hopefully the answers will lead to more useful follow-up questions with
the candidate.

Ruby specific:
1. What are common methods used from the Enumerable module?
2. How do you subclass and override methods?
3. Describe a problem you solved by using missing_method appropriately.
4. What are singleton methods all about?

Again, these are not be all and all, but often provide good
conversation starters to find out how much the candidate knows.

Does this help?
Jeff
softiesonrails.com
matt (Guest)
on 2006-12-25 00:08
(Received via mailing list)
Just remember that when you are interviewing for a job, they are going
to ask questions on how you can benefit them, so they are going to pick
apart both your best and worst qualities.  Most of the interviews I've
gone on, only 25% of the interview is technical (ie. Ruby/Rails Related)
the rest of the questions are usually trying to find out how you were
able to help your last team, and what it is that you are capable of
doing for the job being interview for.

It's all about them, not you.

Matt
Simon C. (Guest)
on 2006-12-25 00:28
(Received via mailing list)
> Got an upcoming job interview as a RoR programmer, just thought If
> you have good ideas
> for questions that might come up during such interview, post them here,
> I will try  to send back one reply with what I would have answered
> hopefully this will open some debate,
> and might help (me) and future programmers before a Ruby job interview.

Jan's response is a good list of what interviewers should ask in an
interview.

Of  course, they'll make a decision based on whatever attributes they
feel an emotional connection to. Ideally, you'll find out that during
the interview.

Me, when I'm interviewing people I'm looking for raw talent (how fast
can you learn?), attitude (are you going to act in the company's
interest?) and personality (are you going to drive us all nuts, or be
happy you're around?).

Everything else is just window dressing.

The "How fast can you learn" is important in techies but particularly
important for Rails because the technology is evolving quickly - which
is part of the reason we're using it. But that means we need techies
who can pick it up as they go along, not wait for the next training
course. (I have a personal bias that anyone who needs to be taught
isn't worth employing, and any technology with a training course
delivered by generic IT trainers is probably obselete).

The attitude issue is just a reflection of the fact that a techie
position is one that carries a lot of responsibility. Sure, we can
mentor you, but we can't micro-manage you. If you're the kind of
techie who can't see beyond their immediate horizons then there's
probably not a lot we can do to get you with the program.

The
--
Simon J. Coles
CTO, Amphora Research Systems
http://www.amphora-research.com/
EMail: removed_email_address@domain.invalid
Phone: (513) 697-4764
Phlip (Guest)
on 2006-12-25 00:32
(Received via mailing list)
Jeff wrote:

> Rails background:

Ooh thanks I love these.

> 1. What are migrations and why are the useful?

Refactoring Databases is bloody hard. There's a book about them, which
I haven't read yet. If I wrote it, it would say for each new DB
version you must write a script that migrates live customer data
forward and backwards. So Rails provides that out of the box (and, as
usual, with only 75 lines of code, not the 75,000 that Brand X
requires).

> 2. What is AJAX all about?

Decoupling parts of your web page from each other so the server can
update them indepentantly, without forcing a page refresh and loss of
context.

> 3. How does Rails apply the MVC pattern?

Rails encourages MVC by enabling a 3-layer architecture, with
different available facilities in each one. True MVC is up to the
programmer, just as you can still write non-OO code in Smalltalk by
cramming everything into one long method.

> 4. How do you know when to write unit tests, functional tests, or
> integration tests?

Uh, you write them and see.

Better, you prefer unit unless you need the extra test capabilities in
the functional library; again you only move up to integration if you
need its capabilities.

This matches the rationale for placing code. Put it in its nearest
model unless it needs a controller's abilities, etc.

And if you invent a new system of your own, it should have test suites
that match its architecture.

> 5. What are the different ways of storing sessions with Rails?

Cookies, the Session variable, or as IDs that go round-trip thru the
view and into the database, as hidden fields.

> 6. In Rails, how does a given url result in a controller method being
> called?

The dispatcher calls routes.rb, which deconstructs the URI (not "URL")
and generally matches controllers and actions by name.

> 7. What is REST all about?  Why is it an important design pattern?

That's on my "see how long I can successfully ignore" list. ;-)

> Ruby specific:
> 1. What are common methods used from the Enumerable module?

Ruby is so easy to use that I have successfully placed that one on my
"ignore" list. Uh, something to do with overloading the spaceship <=>
operator so you can sort automatically.

> 2. How do you subclass and override methods?

You subclass classes and override methods. The keyword def is a
command, not a delimiter, so a class responds to messages with the
last-declared method with its name.

> 3. Describe a problem you solved by using missing_method appropriately.

I used Builder::XmlMarkup, and it just seems to read my mind. Its
verbosity is directly comperable to the XML or HTML that it replaces.
But it's easier to refactor!

> 4. What are singleton methods all about?

Sometimes when you put the barrel in your mouth you just can't reach
the trigger, huh? They are about making your code a pain in the balls
to unit-test. Resist the temptation of their syntactic sugar!

--
  Phlip
  http://c2.com/cgi/wiki?ZeekLand  <-- NOT a blog!!
Simon C. (Guest)
on 2006-12-25 00:36
(Received via mailing list)
Gmail send this on a keypress outside the edit window... before I
finished... so I'll reply with the rest... (sorry)

On 12/24/06, Simon C. <removed_email_address@domain.invalid> wrote:
> feel an emotional connection to. Ideally, you'll find out that during
> important for Rails because the technology is evolving quickly - which
> probably not a lot we can do to get you with the program.
>

The personality issue is just a reflection of the fact that we've got
to run a business and part of that is getting on with everyone else.
So this will depend on where you're going - in our case, we don't
isolate techies from the rest of the company (in fact, we encourage
mixing) so we really do expect you to sit next to sales or support and
be good co-workers in every sense. So we're looking for a well-rounded
personality, tolerance, etc.

In addition, we look for potential - ideally you'll be with us for a
while, and realistically you'd want to upgrade your contribution....
so we'd look to where you can grow. Can you get into marketing, sales,
management etc. So anything that shows you're more than just a geek
who sits in his room coding is all good.

Hope that helps,



Simon

--
Simon J. Coles
CTO, Amphora Research Systems
http://www.amphora-research.com/
EMail: removed_email_address@domain.invalid
Phone: (513) 697-4764
Pat M. (Guest)
on 2006-12-25 01:24
(Received via mailing list)
On 12/24/06, Phlip <removed_email_address@domain.invalid> wrote:
> > 3. How does Rails apply the MVC pattern?
>
> Rails encourages MVC by enabling a 3-layer architecture, with
> different available facilities in each one. True MVC is up to the
> programmer, just as you can still write non-OO code in Smalltalk by
> cramming everything into one long method.

When I think of 3-layer architecture, I think of the separation
between database, application, and web server.  So yeah, Rails does
enable a 3-layer architecture in that regard.  As far as MVC goes,
it's a lot simpler - it cleanly separates the model, view, and
controller.



> model unless it needs a controller's abilities, etc.
I don't really agree with this.  Integration tests are good for
writing acceptance tests, and you definitely need to have those.  They
don't just apply "if you need its capabilities."

Functional tests (at least in Rails parlance) are for testing
controllers.  Unit tests are for testing your model.  Pretty simple,
and there's no reason you should try to push EVERYTHING into the
model.  Just what belongs there - business logic.  Coordinating logic
should definitely go in the controller, thus be tested in functional
tests.


> > 5. What are the different ways of storing sessions with Rails?
>
> Cookies, the Session variable, or as IDs that go round-trip thru the
> view and into the database, as hidden fields.

I think the interviewer is probably looking for temp files, AR session
store, and SQL session store.


> > 7. What is REST all about?  Why is it an important design pattern?
>
> That's on my "see how long I can successfully ignore" list. ;-)

Well that's short-sighted and will bite you in the butt :)


> > Ruby specific:
> > 1. What are common methods used from the Enumerable module?
>
> Ruby is so easy to use that I have successfully placed that one on my
> "ignore" list. Uh, something to do with overloading the spaceship <=>
> operator so you can sort automatically.

You've got it confused with Comparable...implementing Enumerable
requires that you implement the each method, which gives you a bunch
of other stuff for free.


> > 4. What are singleton methods all about?
>
> Sometimes when you put the barrel in your mouth you just can't reach
> the trigger, huh? They are about making your code a pain in the balls
> to unit-test. Resist the temptation of their syntactic sugar!

I'm going to assume this is a joke.

Pat
Pat M. (Guest)
on 2006-12-25 01:26
(Received via mailing list)
On 12/24/06, Peter <removed_email_address@domain.invalid> wrote:
> In other words , be yourself, and see how it goes.

This is key.  If you have to lie to yourself or just aren't
comfortable in order to get the job, how much are you actually going
to like the job itself?

Though to tell you the truth I bet the interview will be cake...I mean
hell you're gonna get to code Rails!  Surely your enthusiasm will
shine.

Pat
Warner O. (Guest)
on 2006-12-25 01:54
(Received via mailing list)
Wow, that's funny I just wrote up a blog post on that very subject:
http://warneronstine.com/blog/articles/2006/12/21/...

We are currently hiring developers for the Kuali project at the UofA
(in Tucson, AZ) and that was one of the deciding factors between two
candidates.

-warner
Phlip (Guest)
on 2006-12-25 02:00
(Received via mailing list)
Pat M. wrote:

> When I think of 3-layer architecture, I think of the separation
> between database, application, and web server.  So yeah, Rails does
> enable a 3-layer architecture in that regard.  As far as MVC goes,
> it's a lot simpler - it cleanly separates the model, view, and
> controller.

MVC means elements in each layer can observe (via messages of some
type) elements in other layers.

When I change a field in a database table, its image in the view
doesn't automatically update. I have to do just a little bit more than
patch-cord fields to images.

> I don't really agree with this.  Integration tests are good for
> writing acceptance tests, and you definitely need to have those.  They
> don't just apply "if you need its capabilities."

"acceptance" means matching a customer specification. "integration",
in Rails, means the test can access more than one browser context. The
kinds of tests overlap. A Rails "integration" test could be a "unit"
test if its failure implicates only one unit.

The distinction is between the syntax of the test case and the
semantics we need it for.

(BTW this is the kind of conversation I generally shouldn't have
during interviews;)

> Functional tests (at least in Rails parlance) are for testing
> controllers.  Unit tests are for testing your model.  Pretty simple,
> and there's no reason you should try to push EVERYTHING into the
> model.  Just what belongs there - business logic.  Coordinating logic
> should definitely go in the controller, thus be tested in functional
> tests.

If a function doesn't need a controller, then it only needs one model,
so it goes into that model. This follows from simple refactoring -
finding the leanest solution for a problem.

Models don't exist in isolation from our application, unless they do,
in which case they should only contain their shared methods, and their
application-specific methods should just get mixed-in.

> > > 4. What are singleton methods all about?
> >
> > Sometimes when you put the barrel in your mouth you just can't reach
> > the trigger, huh? They are about making your code a pain in the balls
> > to unit-test. Resist the temptation of their syntactic sugar!
>
> I'm going to assume this is a joke.

Singletons are not an excuse for a global variable.

--
  Phlip
  http://c2.com/cgi/wiki?ZeekLand  <-- NOT a blog!!
Pat M. (Guest)
on 2006-12-25 02:24
(Received via mailing list)
On 12/24/06, Phlip <removed_email_address@domain.invalid> wrote:
> type) elements in other layers.
>
> When I change a field in a database table, its image in the view
> doesn't automatically update. I have to do just a little bit more than
> patch-cord fields to images.

I know what MVC is.  I was just saying that, to me anyway, a 3-tiered
architecture is something completely different.


> semantics we need it for.
I said integration tests are "good for writing acceptance tests."  Not
that they are acceptance tests.  They are for me, because that's how I
choose to use them.  You should use acceptance tests though, and using
the Rails integration tests for that is great because it's built right
in.


> > > > 4. What are singleton methods all about?
> > >
> > > Sometimes when you put the barrel in your mouth you just can't reach
> > > the trigger, huh? They are about making your code a pain in the balls
> > > to unit-test. Resist the temptation of their syntactic sugar!
> >
> > I'm going to assume this is a joke.
>
> Singletons are not an excuse for a global variable.

You're confusing the singleton pattern [1] with a singleton method
[2].  DA Black's book, "Ruby for Rails," is very good for gaining a
deep understanding of Ruby.

Pat

[1] http://en.wikipedia.org/wiki/Singleton_pattern
[2] http://www.rubycentral.com/faq/rubyfaq-8.html
http://www.rubyist.net/~slagell/ruby/singletonmethods.html
Pratik N. (Guest)
on 2006-12-25 06:45
(Received via mailing list)
I don't like the idea of preparing specific set of questions for an
interview. Just be yourself and you'll pass your interview if you
deserve to!

On 12/24/06, Yonatan G. <removed_email_address@domain.invalid> wrote:
> Yonatan G..
>
> >
>


--
rm -rf / 2>/dev/null - http://null.in

Dont judge those who try and fail, judge those who fail to try..
unknown (Guest)
on 2006-12-26 01:20
(Received via mailing list)
On Sun, 24 Dec 2006, Jeff wrote:

> Yonatan G. wrote:
>> I guess I revise the question to -
>> what you would look for in a rails developer ?,
>> what questions you would  have asked, if you were conducting the
>> interview ?
>
> It depends on what I'm looking for, but these come to mind as
> conversation starters:

[...]

> 3. Describe a problem you solved by using missing_method appropriately.

I wouldn't close the door to Ruby programmers who have never used
method_missing.  It's a pretty specialized technique -- not
specialized in the sense of advanced, but in the sense of not likely
to be of much genuine use except in writing frameworks and programming
tools and such "meta" things.


David

--
Q. What's a good holiday present for the serious Rails developer?
A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black)
    aka The Ruby book for Rails developers!
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
A. Ruby Power and Light, LLC (http://www.rubypal.com)
Elad (Guest)
on 2006-12-26 06:34
Mohit S. wrote:
> Phlip wrote:
>>
>> Yonatan G. wrote:
>>
>>> Got an upcoming job interview as a RoR programmer...
>>
>> If your interviewer has previous experience with ASP.NET, PHP, or
>> Tomcat, you can get them ranting about them and score some points.
>>
>> Just don't abuse the trick... ;-)
>>
> By the way, I wouldn't be surprised if your recruiter is on this list :P
> Cheers
> ..mohit.

Me neither :)
Jeff C. (Guest)
on 2006-12-27 22:45
(Received via mailing list)
removed_email_address@domain.invalid wrote:
> I wouldn't close the door to Ruby programmers who have never used
> method_missing.  It's a pretty specialized technique -- not
> specialized in the sense of advanced, but in the sense of not likely
> to be of much genuine use except in writing frameworks and programming
> tools and such "meta" things.

Absolutely - sorry if I implied otherwise... I just thought it might be
one way to find if they are familiar with it, or if they've at least
seen it used somewhere (like by reading some of the Rails source, or
something).  I didn't mean that it should be used to weed someone in or
out.

I remember when I first "got" the idea of method_missing, and how it
got me to start thinking in terms of messages being received instead of
methods being called.  (Coming from C++ and later C#, I always thought
of a method as just a pointer to some function that must already exist,
so the method_missing concept was weird for me at first).

Jeff
Phlip (Guest)
on 2006-12-28 07:03
(Received via mailing list)
Pat M. wrote:

> I know what MVC is.  I was just saying that, to me anyway, a 3-tiered
> architecture is something completely different.

And all Rails is, out of the box, is 3-layered. Not true MVC, and not
3-tiered.

> You're confusing the singleton pattern [1] with a singleton method
> [2].  DA Black's book, "Ruby for Rails," is very good for gaining a
> deep understanding of Ruby.

I suspect /Working Effectively with Legacy Code/, by Mike Feathers, has
a
good discussion about singleton abuse. I should know, because I'm cited
as a
reviewer in it.

But I have simply never seen a situation improved by a Singleton. Not a
joke, not a citation, just an observation.

--
  Phlip
  http://www.greencheese.us/ZeekLand <-- NOT a blog!!!
Pat M. (Guest)
on 2006-12-28 17:08
(Received via mailing list)
On 12/27/06, Phlip <removed_email_address@domain.invalid> wrote:
> > You're confusing the singleton pattern [1] with a singleton method
> > [2].  DA Black's book, "Ruby for Rails," is very good for gaining a
> > deep understanding of Ruby.
>
> I suspect /Working Effectively with Legacy Code/, by Mike Feathers, has a
> good discussion about singleton abuse. I should know, because I'm cited as a
> reviewer in it.
>
> But I have simply never seen a situation improved by a Singleton. Not a
> joke, not a citation, just an observation.

I'm not doubting that you know what the singleton pattern is.  I'm
just saying you clearly don't know what a singleton METHOD is.  Either
that or you didn't read the question.

Here's the simplest case of a singleton method:
class Foo
  def self.foo
    "This is a singleton method on Foo"
  end
end

foo is a singleton method on the class Foo.  You might also know it as
a class method.  I generally find them helpful, and not in the context
of trying to shoot myself.

Here we define a singleton method on an object.
o = Object.new
def o.foo
  "foo"
end

which could also be
class << o
  def foo
end

Singleton methods are, quite simply, methods defined on the singleton
class of an object.  They have nothing to do with the Singleton
pattern.

I have a feeling that since Java, C++, and C# don't even have
singleton methods, your review and Feathers' discussion probably
didn't cover them.

Perhaps it's unfortunate that the names are the same.  Singleton
classes and methods in Ruby (which are completely different from the
Singleton pattern) are a very powerful and useful tool.

Pat
Phlip (Guest)
on 2006-12-28 17:14
(Received via mailing list)
Pat M. wrote:

> > >> > > > 4. What are singleton methods all about?

> I'm not doubting that you know what the singleton pattern is.  I'm
> just saying you clearly don't know what a singleton METHOD is.  Either
> that or you didn't read the question.

My bad. I was recovering from a nauseating refactoring session
regarding the Singleton Pattern, so I indeed forgot to read the word
"methods".

--
  Phlip
  http://c2.com/cgi/wiki?ZeekLand  <-- NOT a blog!!
Justin F. (Guest)
on 2006-12-28 18:28
(Received via mailing list)
Phlip wrote:
>
> Pat M. wrote:
>
>> I know what MVC is.  I was just saying that, to me anyway, a 3-tiered
>> architecture is something completely different.
>
> And all Rails is, out of the box, is 3-layered. Not true MVC, and not
> 3-tiered.

Hmm. Given the constraints of working with HTTP, is Rails any less MVC
than J2EE Model 2 MVC? That pattern is what is commonly referred to as
'MVC' in web application development.

   Justin F.
Long (Guest)
on 2006-12-28 19:14
(Received via mailing list)
Pat M. wrote:
>
[snip]
> end
>
> foo is a singleton method on the class Foo.  You might also know it as
> a class method.  I generally find them helpful, and not in the context
> of trying to shoot myself.
>
I was curious what singleton method is as well but found your
explanation
unclear. According to this link,

http://www.math.hokudai.ac.jp/~gotoken/ruby/ruby-u...

a singleton method is a method specialized on an instance of a Class,
not
the class itself.

> Here we define a singleton method on an object.
> o = Object.new
> def o.foo
>   "foo"
> end
>
Yes, this is how one would define a singleton method.

> which could also be
> class << o
>   def foo
> end
>
Hmmm, interesting...

> Singleton methods are, quite simply, methods defined on the singleton
> class of an object.
>
Again very confusing statement.

Long
http://edgesoft.ca/blog/read/2
Pat M. (Guest)
on 2006-12-28 19:16
(Received via mailing list)
On 12/28/06, Long <removed_email_address@domain.invalid> wrote:
>
> Pat M. wrote:
> > Singleton methods are, quite simply, methods defined on the singleton
> > class of an object.
> >
> Again very confusing statement.

I recommend picking up Ruby for Rails, it has a very good discussion
of singleton methods.  It's probably the most in-depth Ruby book
around.

Pat
unknown (Guest)
on 2006-12-28 19:31
(Received via mailing list)
Hi --

On Thu, 28 Dec 2006, Long wrote:

>> class Foo
> unclear. According to this link,
>
> http://www.math.hokudai.ac.jp/~gotoken/ruby/ruby-u...
>
> a singleton method is a method specialized on an instance of a Class, not
> the class itself.

However, a class is itself an instance of Class, and in that capacity,
it can have singleton methods.  As Pat says, the singleton methods of
a Class object are what we call "class methods".  Mostly that's
just a convenience term; singleton methods work the same way whether
their object is a Class, a String, or a Whatever.  However, there's
one special behavior: a subclass can call its superclass's singleton
methods:

    class C
      def self.talk
        puts "Hello"
      end
    end

    class D < C
    end

    D.hello

That's the only case where an object can access another object's
singleton methods.  It's a bit of an anomaly, but it's a worthwhile
anomaly because it adds a useful functionality.

>>   def foo
>> end
>>
> Hmmm, interesting...
>
>> Singleton methods are, quite simply, methods defined on the singleton
>> class of an object.
> Again very confusing statement.

All you need is some info on singleton classes, and then it will make
sense.  Here's a starting point:
http://www.wobblini.net/singletons.html


David

--
Q. What is THE Ruby book for Rails developers?
A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black)
    (See what readers are saying!  http://www.rubypal.com/r4rrevs.pdf)
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
A. Ruby Power and Light, LLC (http://www.rubypal.com)
Phlip (Guest)
on 2006-12-28 19:37
(Received via mailing list)
Justin F. wrote:

> Hmm. Given the constraints of working with HTTP, is Rails any less MVC
> than J2EE Model 2 MVC? That pattern is what is commonly referred to as
> 'MVC' in web application development.

That system is why I went to the ModelViewController page on a certain
Wiki and added 'When a system obeys the principle
DoTheMostComplexThingThatCouldPossiblyWork, marketects often respond
by clumping its rambling notions together into 3 groups. The
sub-SpaghettiCode group nearest the User becomes the "view", that
nearest the database becomes the "model", and the stuff in between
becomes the "controller".'

To answer your question, the browser layer ain't the View. The View is
"That which observes the Model", which is typically in our controller
layer.

--
  Phlip
  http://c2.com/cgi/wiki?ZeekLand  <-- NOT a blog!!
Long (Guest)
on 2006-12-28 23:23
(Received via mailing list)
David wrote:
>
> Hi --
>
[snip]
>
> All you need is some info on singleton classes, and then it will make
> sense.  Here's a starting point:
> http://www.wobblini.net/singletons.html
>
So this singleton method/class method is ruby-specific. Good starting
point nonetheless.

Thanks,

Long
Justin F. (Guest)
on 2006-12-28 23:57
(Received via mailing list)
Phlip wrote:
> by clumping its rambling notions together into 3 groups. The
> sub-SpaghettiCode group nearest the User becomes the "view", that
> nearest the database becomes the "model", and the stuff in between
> becomes the "controller".'
>
> To answer your question, the browser layer ain't the View. The View is
> "That which observes the Model", which is typically in our controller
> layer.

That does nothing to answer my question, and jumps to a wrong conclusion
about what I thought the View was, but at least it tells us what one of
your layers is.

The part of Rails that *presents* the Model is the View.

Model 2 MVC is a server-side MVC model constrained by the grain size of
the HTTP request/response, dividing responsibilities as follows:

- the controller interprets the HTTP request, makes any changes required
on the model, and decides what view should be presented next;

- the view renders the required parts of the model, together with user
controls, to provide the body of the HTTP response;

- the model is an appropriate OO model of the application domain.

This is a perfectly valid interpretation of MVC, given the constraints,
and has been the dominant OO web architecture over the past five years.
Competition from component-oriented MVC web architectures (JSF,
Tapestry, WebObjects...) is growing, and continuation-based approaches
are worth keeping an eye on.

You concentrated on the "observing" relationship between the view and
model which is an important part of classical MVC. That works well
Smalltalk (and in 'fat' applications in general), where the view can be
updated incrementally, but is less relevant when you are using HTTP with
a stateless server. Then you have to create the whole rendered result on
each request.

regards

   Justin F.
Justin F. (Guest)
on 2006-12-29 04:26
(Received via mailing list)
Justin F. wrote:
>> Wiki and added 'When a system obeys the principle
> That does nothing to answer my question, and jumps to a wrong conclusion
>
>
> You concentrated on the "observing" relationship between the view and
> model which is an important part of classical MVC. That works well
> Smalltalk (and in 'fat' applications in general), where the view can be
> updated incrementally, but is less relevant when you are using HTTP with
> a stateless server. Then you have to create the whole rendered result on
> each request.

oops - "works well Smalltalk" should be "works well in Smalltalk"

   Justin
This topic is locked and can not be replied to.