My colleagues tell me that table based formatting of code is bad and it is no readable and I should follow conventions. What's that bad about table based formatting? Why is it banned?
I'm asking because for me it's much more readable.
Examples (not real code):
if (res == ResultType.Failure)
something = ProcessFailure(...
To make my code more concise, can I do something like
int f(int const x, y, z), g(int const x, y, z);
to declare functions f and g which each take three int const arguments?
Edit:
Perhaps here is a better example:
int f(int const a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z);
How would that not be m...
This is probably a dumb question, but...
I found this snippet of code in my travels in researching JSON:
var array = typeof objArray != 'object' ? JSON.parse(objArray) : objArray;
I'm seeing more and more of the ? and : notation. I don't even know what it is called to look it up! Can anyone point me to a good resource for this? (btw...
Would you put the annotation in implementation class methods? Does it serve any purpose? If you mistype or don't have it, it is a compile error anyway.
...
I know that this is more of a coding style, instead of a one right way of doing things. But, I'm a bit frustrated if I came across different indenting formats.
But, I would like to hear the reasons by various people on these issues:
Do you use spaces or tabs? Tabs with spaces? Any difference with "Tab insert space", instead of using ...
Consider languages like Python or JavaScript that allow functions to be nested like this:
print(vector(a * b),(a * c),(b * c)))
or flat like this:
i = (a * b)
j = (a * c)
k = (b * c)
V = vector(i,j,k)
print(V)
How much does the different format affect performance? Can valid generalizations be made, or does it vary a lot by language...
Ignoring version, what are the best practices for formatting SQL code?
I prefer this way (method A):
select col from a inner join b on a.id = b.id inner join c on b.id = c.id
a colleague prefers another (method B):
select col from a inner join (b inner join c on b.id=c.id) on a.id = b.id
I'd like to know if there is any difference...
Hello,
I have a coding style question which probably should be asked of a senior mac programmer at work - but since I'm the only mac programmer, well, SO it is. I have a pop-up GUI for my software (3D models, data visualization) and the pop-up is Mainly a Tabbed control with a ton of stuff in each tab (sliders, radio buttons, checkboxe...
Is there a way to enforce a code style programatically in eclipse e.g. using eclipse plugins.
I have created a code template. I want to enforce it so that everytime a user selects save or saveas,the code template is checked against the one I created. If it matches the file is saved otherwise the user gets an error message.
The problem ...
Which coding style do you prefer, and why?
if case1:
return res1
if case2:
return res2
return res3
or:
if case1:
return res1
elif case2:
return res2
else:
return res3
or:
res = None
if case1:
res = res1
elif case2:
res = res2
else:
res = res3
return res
Reason: I have code that looks like this, an...
Possible Duplicate:
Which Coding convention to follow for PHP?
After coding for a while similar in terms to the coding style offered by zend, im constantly finding myself getting told to change my code at work. They prefer a different coding style. For example a huge annoyance for them is using:
funtction testFunction
{
}...
I guess that most factory like methods start with create. But why are they called "create"? Why not "make", "produce", "build", "generate" or something else? Is it only a matter of taste? A convention? Or is there a special meaning in "create"?
createURI(...)
makeURI(...)
produceURI(...)
buildURI(...)
generateURI(...)
Which one would...
Should I use getters and setters in C++ or is it better to access class data directly?
...
I have some C source files that are slowly expanding. I tend to keep the prototypes with documentation in the .h file in good order, grouped into relevant functions and types with #pragma mark. The code is written and documented in a way that requires reading the .h file alongside the .c file. I'd like the files to be ordered in a way th...
What are the bad things present in flowing code:
print "<ul>"
$conn = mysql_connect( "localhost:8080", "root", "admin" );
mysql_select_db( "testdb", $conn ); #selects a database
$q = " SELECT * FROM table1 WHERE id > " . $_GET["id"]. ";";
$res = mysql_query( $q, $conn);
while( $row = mysql_fetch_assoc($res) )
{
print "<li>".$row['descri...
What should be more appropriate to use when you want to initialize class properties from datatable.
i.e.
name=dt.Rows[0][0] or name=dt.Rows[0]["Name"]
Which approach is more scalable any easy to handle.
Currently I uses 2nd approach but feels like if I use indexes rather than name that i only need to change stored procedures rather ...
What is the best practice when nesting method calls or using one-shot variables?
Should you never use one-shot variables?
example:
[persistentStoreCoordinator addPersistentStoreWithType:NSXMLStoreType
configuration:nil
URL:[NSURL fileURLWithP...
First of all, I don't want to start a coding styles war, so please only reply if you are answering the question.
I've encountered a couple of people who put their fields at the top of the class. Could anyone who does this explain the rationale behind it?
Many thanks
...
I program with eclipse and sometimes use GUI text editors like SciTE or vim. However, I'm at a point in a project that requires me to edit files over a ssh connection in a 80 column SSH window.
Since I have to (* shiver*) sudo vim before I can open the file I'm not sure how to open the file in an editor outside the terminal (that would ...
I quite often see the following naming convention used in java code.
class SomeClass {
private final String name;
public SomeClass(final String name) {
this.name = name;
}
}
This seems a little odd to me. First off if you happen to misspell the variable in the method signature it will still compile...
class SomeC...