Questions tagged [conventions]

A generic tag covering any accepted method of doing things, which could include naming, spacing, coding, commenting, etc.

A generic tag covering any accepted method of doing things, which could include naming, spacing, coding, commenting, etc.

1143 questions
105
votes
1 answer

Python "private" function coding convention

When writing a python module and functions in it, I have some "public" functions that are supposed to be exposed to outsiders, but some other "private" functions that are only supposed to be seen and used locally and internally. I understand in…
Kaifei
  • 1,568
  • 2
  • 13
  • 16
102
votes
10 answers

Where to place private methods in Ruby?

Most of the blogs or tutorials or books have private methods at the bottom of any class/module. Is this the best practice? I find having private methods as and when necessary more convenient. For example: public def my_method # do something …
ZX12R
  • 4,760
  • 8
  • 38
  • 53
98
votes
11 answers

Should arrays be used in C++?

Since std::list and std::vector exist, is there a reason to use traditional C arrays in C++, or should they be avoided, just like malloc?
Andreas
  • 7,470
  • 10
  • 51
  • 73
94
votes
15 answers

Is it a good idea to typedef pointers?

I looked through some code and noticed that the convention was to turn pointer types like SomeStruct* into typedef SomeStruct* pSomeStruct; Is there any merit to this?
Unknown
  • 45,913
  • 27
  • 138
  • 182
90
votes
13 answers

Python: using 4 spaces for indentation. Why?

While coding python I'm using only 2 spaces to indent, sure PEP-8 really recommend to have 4 spaces, but historically for me it's unusual. So, can anyone convince me to use 4 spaces instead of 2? What pros and cons? P.S. And finally, what's easy way…
HardQuestions
  • 4,075
  • 7
  • 34
  • 39
81
votes
5 answers

Netbeans 7.4 introduces "10 lines max" per method rule. Where does this rule come from?

NetBeans 7.4 beta is currently available for public download, and it introduces a weird warning rule by default: Method length is 16 lines (10 allowed) My question is: Is this an accepted code convention rule, that can be proven somehow, somewhere…
Sliq
  • 15,937
  • 27
  • 110
  • 143
79
votes
4 answers

Objective-C: Assertion vs. Exception vs. Error

In Cocoa, when should I use NSAssert, NSException, NSError? Here's what I've been thinking: NSAssert - When creating any client program used for the programmers own benefit to double check rules, conventions, assumptions, or pre-conditions and…
Tobias
  • 4,397
  • 3
  • 26
  • 33
79
votes
14 answers

Should programmers use boolean variables to "document" their code?

I'm reading McConell's Code Complete, and he discusses using boolean variables to document your code. For example, instead of: if((elementIndex < 0) || (MAX_ELEMENTS < elementIndex) || (elementIndex == lastElementIndex)){ ... } He…
froadie
  • 79,995
  • 75
  • 166
  • 235
77
votes
5 answers

Why would font names need quotes?

As far as I know, one needs to use double or single quotes for fonts if they contain spaces, like: font-family: "Times New Roman", Times; font-family: 'Times New Roman', Times; But on Google Fonts (http://www.google.com/webfont), I also see…
Benn
  • 4,840
  • 8
  • 65
  • 106
76
votes
5 answers

Lisp commenting convention

What is the Lisp convention about how many semicolons to use for different kinds of comments (and what the level of indentation for various numbers of semicolons should be)? Also, is there any convention about when to use semicolon comments and…
compman
  • 2,174
  • 2
  • 18
  • 26
75
votes
5 answers

Good Haskell coding standards

Could someone provide a link to a good coding standard for Haskell? I've found this and this, but they are far from comprehensive. Not to mention that the HaskellWiki one includes such "gems" as "use classes with care" and "defining symbolic infix…
Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487
71
votes
3 answers

Do C++ private functions really need to be in the header file?

I have always thought of header files as a sort of 'public interface' describing a class, in which case it would be better to keep private fields and functions in the .cpp file. I understand that private fields need to be in the header so that other…
Ghost314
  • 791
  • 1
  • 6
  • 10
68
votes
6 answers

How can I build/concatenate strings in JavaScript?

Does JavaScript support substitution/interpolation? Overview I'm working on a JavaScript project, and as it's getting bigger, keeping strings in good shape is getting a lot harder. I'm wondering what's the easiest and most conventional way to…
MrHaze
  • 3,786
  • 3
  • 26
  • 47
67
votes
3 answers

Folder naming convention for python projects

What is the naming convention in python community to set names for project folders and subfolders? my-great-python-project my_great_python_project myGreatPythonProject MyGreatPythonProject I find mixed up in the github. Appreciate your expert…
CognitiveRobot
  • 1,337
  • 1
  • 9
  • 26
64
votes
6 answers

Is there a standard for inclusive/exclusive ends of time intervals?

I'm wondering if there is a standard or "normal" means of interpreting time interval data end points with respect to inclusiveness/exclusiveness of the value defining the end point. Note however that I am asking what the standard (or most common)…
Gus
  • 6,719
  • 6
  • 37
  • 58
1
2
3
76 77