Questions tagged [coding-style]

**DO NOT USE! This tag refers to an entirely opinionated subject and is therefore no longer on-topic.** Questions that follow coding style and conventions.

DO NOT USE! This tag refers to an entirely opinionated subject and is therefore no longer on-topic.

Questions that follow coding style and conventions.

Coding-style or Programming style is a set of rules or guidelines used when writing the source code for a computer program. It is often claimed that following a particular programming style will help programmers to read and understand source code conforming to the style, and help to avoid introducing errors.

Questions relating to coding style: stylistic issues like braces and indentation or larger issues like refactoring, size of functions, and so forth.

Where can I ask these questions?

  • Process-level questions about coding conventions or style guides may be on-topic for Software Engineering. That also covers design-level questions

  • If you want to improve your style, you can ask for a Code Review.

  • Questions that ask for the “best style” or for advice in a specific situation are too subjective and/or too broad.

7804 questions
7
votes
3 answers

Checkstyle rule to prevent invocation of some methods and constructors

Is it possible to use Checkstyle to forbid usage of some constructors or method that use system-dependent defaults (locale, charset, etc..). I prefer to enforce a policy where the programmer should be explicit about system-dependent values. So I…
gawi
  • 13,940
  • 7
  • 42
  • 78
7
votes
5 answers

Is there a Visual Studio 2010 extension to sort methods?

StyleCop mandates a particular sort order for the contents of C# files. For example, fields should be declared before methods and public declarations should come before private ones. It would be useful to have a Visual Studio extension to move these…
7
votes
4 answers

What's the best practice for function callback structure?

Which function callback structure is the best to use in Javascript and why? I have seen these two options use quite a lot. Are there any more? Option A: // DECLARATION function funcA(required, success, error, options){ // if there is an error in…
wilsonpage
  • 17,341
  • 23
  • 103
  • 147
7
votes
5 answers

Variable declaration placement guidelines in Java

There seems to be two accepted variable declaration placements for Java variables, each with different raison d'être. From the Sun's code conventions we can see: Put declarations only at the beginning of blocks. (A block is any code surrounded by…
DPM
  • 1,960
  • 3
  • 26
  • 49
7
votes
5 answers

How to draw on screen for Windows Metro Style Apps in C#?

I simply want the user to be able to draw on the screen with some sort of pointer. I already have the code working that captures the pointer's position, but I can't figure out how to place the pixels or shapes or whatever onto the screen. I found…
Crystal
  • 191
  • 5
  • 10
7
votes
4 answers

How do you name and organize your exceptions?

When introducing new exception types I am always a but unsure how to do this correctly. Is there a common convention? How do you do it? I am interested in the scope you organize them (Keep them in the unit they are used in? Have a unit on component…
Heinrich Ulbricht
  • 10,064
  • 4
  • 54
  • 85
7
votes
2 answers

TextView state_pressed/state_focused/state_selected style change

I'm trying to change a TextView style based on its state. My styles.xml contains: