Which is better (and why)?
Which feature should I attach this task to?
To which feature should I attach this task?
English Language & Usage Stack Exchange is a question and answer site for linguists, etymologists, and serious English language enthusiasts. It only takes a minute to sign up.Sign up to join this community
The first phrasing is what one would use in casual conversation; it does a good job of establishing the subject, object, and verb to a listener whereas the second phrasing takes some "decoding", in my opinion.
The "rule" that you can't end sentences with prepositions is a myth; it's generally agreed that ending sentences with prepositions is fine as long as the preposition is not extraneous (i.e. you wouldn't have the same meaning by removing it.) So, the first sentence is not ungrammatical.
However, the idea of this rule indeed exists because as TLP said, it is a bit of mouthful. It might make sense to go with an alternate phrasing.
Which feature is this task associated with?
Which feature involves this task?
I am not sure the first one is quite proper English, but I am sure it is passable. If you read it out loud, though, it is quite a mouthful.
The second one is, IMO, clearer, as it narrows the scope of the question straight away: "To which feature.."
An alternative to these two is:
To which feature should this task be attached?