Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

Ok, so I read Appropriate level of contextual information in Stack Overflow questions on this very site, and I really think it is a little bit more general and different from what I'm wondering.

The basic situation

User "A" asks a question for a specific part of some framework for a programming language, e.g. jQuery question, which is in fact always related to JavaScript: syntax, variables, etc. The user is a novice to the programming framework (this is assumed from the level of difficulty of the question), but has knowledge in the programming language (he knows Javascript, but he is new to jQuery).

Demonstrative Question

How can I place optional (to be called only if set as parameter) callback in my $.ajax function?

Demonstrative Answer v.1

var ajax = function(url, callback) {
       url: url, 
       success: typeof(callback) === 'function' ? callback : undefined });

Here I'm using basic JavaScript language method, but in fact in the framework exists specific functions for exactly the same manipulation (as in my answer v.2). By this answer the user perhaps will understand better that the callback of every event has to be just a regular function (because he knows JavaScript, and doesn't know jQuery as much, this answer will be clearer for him).

Demonstrative Answer v.2

var ajax = function(url, callback) {
       url: url, 
       success: $.isFunction(callback) ? callback : undefined });

Here I'm using the native $.isFunction() which is part of the framework he is learning and it might ( or not ? ) be better to learn the other utils that the framework gives along with the general question that has been asked.

The general meta-question, regarding my answer

  1. What is the best way (in level of deepness and context) to answer such a question, regarding the connection between the framework and the language?

  2. Is it better to place your examples with as much native language code or more framework-oriented code (talking about questions from novice of the framework users)?

This question came up to me while answering this How to call model's method from collection in backbone.js? and it came up as a discussion with another answerer in the comments.

share|improve this question
My procedure: answer in jQuery, leave a note on pure JS solution – Manishearth May 2 '12 at 17:06

Is it better to place your examples with as much native language code or more framework-oriented code (talking about questions from novice of the framework users)?

I would say it is better to use example that use as much as possible of that framework. The reason the user is a novice about the framework is a reason more for using the functions/methods available in the framework, rather than the functions available from the language.
Differently, in a question about jQuery, you would be showing the usage of the DOM manipulation functions, rather than the usage of $(), and other functions/methods available in jQuery.

This is not different from what you would do in a question about Drupal, which is written in PHP: Between a function available in PHP, and a function made available from Drupal, you should show code using the Drupal function. Otherwise, the beginner will not use the correct function, but will keep using the PHP function, as if he was writing code in plain PHP.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .