HI, I have a simple question, I've asked 3-4 different people and have had different answers from each of them.
Which code layout is better and used more?
does it really matter as long as it's consistent?
Which is seen as better practice in the world of working as a programmer?
Eg
A)
for(int i=0;i<8;i++)
{
for(int p=0;p<8;p++)...
The following Java code is throwing a compiler error:
if ( checkGameTitle(currGame) )
ArrayList<String> items = parseColumns( tRows.get(rowOffset+1), currGame, time, method );
checkGameTitle is a public static function, returning a boolean. The errors are all of the type "cannot find symbol" with the symbols being variable ArrayL...
Many times I've seen a semicolon used after a function declaration, or after the anonymous "return" function of a Module Pattern script. When is it appropriate to use a semicolon after curly braces?
...
This kind of code structure makes, IMHO, code less readable:
int func() {
[...]
}
It's just a matter of taste, but I prefer this one:
int func()
{
[...]
}
So I've trying to make a regular expression to apply in my text editor in order to make code in the first example look like the second one.
I've come up with something lik...
i have this url, http://www.poer.com/oneup.htm?zip={zip}.
I need the {zip}, because in my code, when this page opens, I replace the {zip} with a zipcode say 10001.
But in aspx, when i put validation for that txtbox, it wont let the {} pass through.
This is the validation - ValidationExpression="http://([\w-]+.)+[\w-]+(/[\w- ./?%&=]*)?"
...
If you look at the following line of python code:
bpy.ops.object.particle_system_add({"object":bpy.data.objects[2]})
you see that in the parameters there is something enclosed in braces. Can anyone tell me what the braces are for (generically anyway)? I haven't really seen this type of syntax in python and I can't find any documenta...
I've found myself limiting scope fairly often. I find it makes code much clearer, and allows me to reuse variables much more easily. This is especially handy in C where variables must be declared at the start of a new scope.
Here is an example of what I mean.
{
int h = 0;
foreach (var item in photos)
{
...
So the loose tolerance of Ruby to use braces sometimes and not REQUIRE them has led to alot of confusion for me as I'm trying to learn Rails and when/where to use each and why?
Sometimes parameters or values are passed as (@user, @comment) and other times they seem to be [ :user => comment ] and still others it's just: :action => 'edit'...
Sometimes you run into code that has extra brace brackets, that have nothing to do with scope, only are for readability and avoiding mistakes.
For example:
GetMutexLock( handle ) ;
{
// brace brackets "scope" the lock,
// must close block / remember
// to release the handle.
// similar to C#'s lock construct
}
ReleaseMutexLock...
Hello All,
i have read this javascript article, where an exmaple is shown , Please explain why below codes return different output due to changes the place of curly braces {
curly brace { on new line
function test()
{
return
{ /* <----curly brace in new line*/
javascript : "fantastic"
};
}
var r = test();
try {
alert(r.ja...
I was surprised to see that the following doesn't work as expected.
define('CONST_TEST','Some string');
echo "What is the value of {CONST_TEST} going to be?";
outputs: What is the value of {CONST_TEST} going to be?
Is there a way to resolve constants within curly braces?
Yes, I am aware I could just do
echo "What is the value of "....
Has C# always permitted you to omit curly brackets inside a switch() statement between the case: statements?
What is the effect of omitting them, as javascript programmers often do?
Example:
switch(x)
{
case OneWay:
{ // <---- Omit this entire line
int y = 123;
FindYou(ref y);
break;
...
In Java the following is completely valid:
if (x == null)
Y();
else
Z();
I personally don't like it at all. I like all my IF statements to have braces:
if (x == null) {
Y();
} else {
Z();
}
The eclipse formatter is wonderful and can beautify my code in many other ways. Is there a way to have it add the braces to IF ...
I love short if statements without braces (PHP) like
if ($x === $y)
echo $z;
If I want to add a few lines (maybe just temporary for debugging) I have to manually add the braces. Is there a plugin for netbeans that does that via shortcut, something like "toggle (add/remove) previous statement braces"?
...
I've just started using emacs, and there's one feature I'd really like, and searching around a bit was fruitless. I hope someone else has done this because I don't want to learn elisp just yet.
void foo()<cursor>
I would like typing an "{" to cause this to happen
void foo(){
<cursor>
}
I would like this to only happen in cc-mod...
Bad style notwithstanding, is it legal C to have a for loop with braces inside the parens? Like this:
char *a = "a ";
char *b = "b ";
for ( { int aComesFirst = 1;
char *first = a;
char *second = b;
};
aComesFirst >= 0;
{ aComesFirst--;
swap(first, second);
} )
{
printf("%s%s\n", first,...
Possible Duplicate:
why results varies upon placement of curly braces in javascript code
We have company policies that dictate that in PHP opening curly braces should be on their own lines for readability and so that they can line-up with the closing brace; thus:
if (true)
{
...
}
but in JS they should be kept on the s...
In Visual Studio while designing MVC views (in .aspx or .ascx files) I often use if statements. When I auto-format (Ctrl-K,D), VS wraps the braces in this really ugly and hard to read way:
<% if (Model.UserIsAuthenticated)
{%>
(some HTML goes here...)
<%
}%>
Is there any way to make Visual Studio auto-format like this instead:...
PHP supports this:
$z = 5;
$str = "z is $z"; // result: "z is 5"
and it supports this:
$c = new StdClass();
$c->x = 9;
$str = "x is {$c->x}"; // result: "x is 9"
but it does NOT support this:
class abc
{
const n = 2;
}
$str = "x is {abc::n}"; // result: "x is {abc::n}"
Why does PHP not support insertion of consts via the c...