Is there any rule for the placement of space after and before parentheses?
I often get stuck when forming or formatting a sentence with one or more parentheses. For example, I wrote an answer on another Stack Exchange site, in which I wrote:
...whereas, my phone(xperia x10 mini) comes with several widgets...
which, afterwards, I thought should be:
...whereas, my phone (xperia x10 mini) comes with several widgets...
But in some cases I feel the former way is correct, like:
... phones which have a camera include IPhone(5MP), Nokia N8(12MP), Nokia X6(3MP)....
Is there any rule for the placement of space after and before parentheses?
The one rule remains readability.
No space before a parenthesis is usually used with functions:
f(x)
Since your technical description of camera isn't a "function", I would still go with:
...phones which have camera include IPhone (5MP), Nokia N8 (12MP), Nokia X6 (3MP)
That being said, if you have a consistent convention throughout your document with no space before parenthesis, you could go with it.
But as you illustrate in your question, there are instances where a space is needed.
Ordinarily a parenthesis (pl: parentheses) introduces a term or clause that modifies whatever precedes it. It would be preceded by a space and followed by whatever would otherwise follow that term in the absence of the parenthetical remark (e.g., a space, comma, or period).
In mathematics, science, marketing (there's a strange set of bedfellows!), and in certain abbreviations, a parenthesis may be part of a term. As such it serves purely as a character rather than having the functional role of introducing a modifier. It would be as incorrect to insert anything before the parenthesis-qua-character as it would be to put arbitrary spaces within any word.
Thus, preceding a parenthesis (or opening bracket of any kind, such as "[" or "{") by a space provides a clear and well-understood mechanism to distinguish these two uses. For example, we would read "IPhone(5MP)" as being the full name of a particular kind of IPhone, whereas "IPhone (5MP)" would refer to something whose name is "IPhone" which happened to have the "5MP" property. That is a subtle distinction in this case, but perhaps it's strong enough to permit a reasoned choice concerning the usage that best conveys the intended thought.