# Can I ask a "Comment my macro" question?

For someone like who is just starting out with TeX programming, it can be hard to produce quality code. I try to read as much as I can from various guides, but often my code may look dirty and ugly to the eye of an expert, even if it's completely doing its job.

Say I wrote some code, but then I wonder whether that's some good code or not. The best solution I can think of would be to ask a question like this:

I need some code to test if a letter is a Q, a T or something else. I wrote this:

 \def\awesomemacro#1 {% \let\ivebeenhere0 \if#1Q This letter was a {\bf Q}\let\ivebeenhere1 \fi \if#1T This letter was a {\bf T}\let\ivebeenhere1 \fi \ifx\ivebeenhere0 This letter is so weird\fi }

It works. Can I improve it?

After writing this, one may hope for answers like

or

You should use a boolean

or

Why don't you go fishing instead?

Of course, such a generic title would help no one: it would be extremely hard to find if you google it, and it's going to pop up with unrelated searches. But if the title were something like Is this the best way to write an else-if statement?, it would be easy to find and maybe even helpful. Then again, I actually needed what I was asking, i.e. a cnc on my work (including things like the use of \bf instead of \textbf), which the new seo-friendly title does not represent completely.

So, my question here is: what's a good way to ask "cnc this" questions?

EDIT: ff524 pointed out that this kind of question would be perfect for Code Review. I totally forgot about that site. Feel pretty dumb right now.

EDIT2: Ok removed the cnc part. It was just "comment and criticism", it's often used in graphic design forums to ask others what they think about your work without sugarcoating. Sorry.

• Sorry, but what does CNC stand for in this context?
– user31729
Jul 7 '14 at 6:44
• @ChristianHupfer There is a link in the question. Jul 7 '14 at 7:33
• With the example as-written, I'd imagine you'd get decent answers with a question focussed on the conditional part, with probably comments or 'by the way' sections to answers on the rest. (For example, \bf is deprecated in LaTeX but not in plain or ConTeXt, so with a low-level question of this type its not necessarily clear that \textbf would be 'right'.)
– Joseph Wright Mod
Jul 7 '14 at 8:23
• @JosephWright Yeah I realized it too late, that was probably the worst example I could put together... but you got the idea. Jul 7 '14 at 9:54
• Isn't this kind of thing exactly what Code Review is for? Jul 7 '14 at 14:03
• @ff524 OH! Right! Jul 7 '14 at 14:22
• @percusse -- before i found the link (had to search very hard; my monitor doesn't show these things clearly, and requests for help fixing it have come to naught), i tried looking at what google could offer. "comments 'n' criticism" doesn't seem to appear there in any of the more accessible acronym lists. (i did rather like the "chicken noodle coalition" offered by a list that ends with "Note: We have 250 other definitions for CNC in our Acronym Attic".) do have pity on us poor proto-luddites. Jul 7 '14 at 15:53
• @barbarabeeton Nevermind the hipsters :) As a mechie, CNC means one and only thing to me and that is manufacturing metal products. Jul 7 '14 at 17:03
• Anyway, isn't it CC to write your questions in a way which does not require PHs to follow links or search just in order to understand your question? (IMNSHO, of course.)
– cfr
Jul 8 '14 at 3:13
• @percusse: I am not sure, whether the link was already there when I posted my comment,but now I know ;-)
– user31729
Jul 8 '14 at 23:24
• Regarding CodeReview: Matter of fact is that so far there are only three questions with the [tex] tag; two of which I would not even consider as real TeX programming questions. So yes, while CodeReview should be the site for this kind of questions, it just won't help you unless people like egreg, David, Heiko, ... become regular users there. I would always try to ask here! Jul 15 '14 at 9:49

We've had a similar discussion about a year ago. Originally it seemed like it received good attention, but I had the impression that interest dwindled as it because obvious that the benefit to the community was diminishing. Well, it did in my opinion, since it seemed benefit the wider community less and less..

Tread lightly with these types of questions as

1. it may solicit primarily opinion-based answers - what I think as being "good code" may differ from what others think; and

2. there may be little benefit to the community as a whole - formerly these were classified as too localized, while now it may be considered off topic or maybe "unclear", even though it may not be off-topic nor unclear.

The first point is almost factual, and there's very little to argue about. The second is more subtle, and mostly visible to long-term users of the main site - people who've been around long enough to see what works and what doesn't.

1. Be specific about what you want - nothing general/generic;
2. Consider whether this is of benefit to this community, otherwise post it on CodeReview;
3. Tag it appropriately;
4. Accept that some people will not like it.

Yes, you can.

My evidence: When to use \edef, \noexpand, and \expandafter?

I'd recommend that you make your question easy to answer (as I tried to do in the above). Pick out one thing that you want to focus on and make your question about that. Make it clear what you're looking for in an answer. You can add the CNC (whatever that is) as motivation and so make it plain that any additional comments would be welcome, but focussing on one thing per question is the way that this site works best.

• That question is rather different (and a better fit to the site) as it is asking about the usage of a particular set of tex commands and the example is just an example. The question here though asking about code review of a particular block of code. Jul 7 '14 at 19:18
• @DavidCarlisle My argument is that a "CNC" question can be turned into such a question and that if so done then it fits the site (as mine did). Jul 7 '14 at 19:42