The tag has no wiki summary.

learn more… | top users | synonyms

-2
votes
0answers
29 views

Why dose PSR-1 avoid any recommendation about property names? [on hold]

Why dose PSR-1 avoid any recommendation about property names? Could not they reach any agreement? I think suggesting a style was much more useful: $StudlyCaps, $camelCase, or $under_score.
1
vote
3answers
602 views

Should we enforce code style in our large codebase? [duplicate]

By "code style" I mean 2 things: Style, eg. // bad if(foo){ ... } // good if (foo) { ... } Conventions and idiomaticity, where two ways of writing the same thing are functionally equivalent, but ...
1
vote
1answer
138 views

The purpose of using a constants pool for immutable constants

Originally posted at stackoverflow.com/q/23961260 I come across the following code with a lot of frequency: if (myArray.length == Constants.ZERO_INT) or if (myString != null && ...
2
votes
5answers
271 views

Simplicity-efficiency tradeoff

The CTO called to inform me of a new project and in the process told me that my code is weird. He explained that my colleagues find it difficult to understand due to the overly complex, often new ...
2
votes
1answer
233 views

Why does Java support brackets behind variables and even behind method signatures? [closed]

Java allows this: class X{ int i,j[]; // j is an array, i is not } and even worse, it allows this: class X{ int foo(String bar)[][][] // foo actually returns int[][][] { return null; } ...
3
votes
0answers
256 views

Why are so many Python files really big (5k+ lines)? [closed]

Is there any specific reason driving Python files to often be so large? Python files may contain several classes within one file, and some files go up over 10k lines in length. This seems to go ...
15
votes
7answers
1k views

Does this justify goto statements?

I came across this question a second ago, and I'm pulling some of the material off of there: Is there a name for the 'break n' construct? This appears to be a needlessly complex way for ...
0
votes
2answers
751 views

Summary of C# naming conventions (official Microsoft conventions) [duplicate]

I am struggling with naming convetions in C# I do not know when to use PascalCase or camelCase. I have read Microsoft's naming convention, but I got lost ther ...
8
votes
2answers
837 views

Dealing with the node.js callback pyramid

I've just started using node, and one thing I've quickly noticed is how quickly callbacks can build up to a silly level of indentation: doStuff(arg1, arg2, function(err, result) { ...
14
votes
3answers
381 views

Does usage of advanced language features decrease maintainability? [duplicate]

On a code review, I've stumbled on an interesting idea, which I can't properly judge alone. Is it OK to improve readability of code by means of not widely known language syntax? When the original ...
-1
votes
1answer
277 views

Which style to use for repetitive code (in java)

I have a project written in Java that required some repetitive code. Basically the gist of it is that I'm taking one object and copying it into two different objects -- Which I would just use clone() ...
77
votes
23answers
7k views

Is fewer lines of code always better? [closed]

Which of these programming styles is better? var result = methodOne(methodTwo(a, methodThree(b)), c, d); or var result3 = methodThree(b); var result2 = methodTwo(a, result3); var result = ...
0
votes
3answers
612 views

Java: How to make local fields & parameters final without having a 'final' keyword on each declaration

By default, I want all my local variables and method parameters to be final. Unfortunately, the Java language designers chose a different default: variables&parameters are by default non-final, ...
6
votes
1answer
219 views

Is deep nesting of control flow in code a studied problem?

I made the case to coworkers that deep levels of control flow was harmful to the readability of code. Example, taken from the relevant stack overflow question If you need more than 3 levels of ...
1
vote
1answer
132 views

Less code or less operation

Sometimes I hesitate between "More code to avoid unnecessary operations" and "less code but with redundant operations". Let me just take an example (Win32 API): I try to paint some controls manually ...
1
vote
2answers
280 views

Python code style - blank lines in long list

I'm curious, is there a standard approach to dealing with long lists in the Python community, and in particular, is there any antipathy toward doing blank lines followed by comments to break up a ...
43
votes
8answers
3k views

What's the right balance between code consistency and code improvement?

Recently I had a discussion with a colleague regarding code style. He was arguing that your usage of APIs and the general patterns you are using should be as similar as possible with the surrounding ...
1
vote
4answers
943 views

Legitimate reasons for circular references in C++

I have project written in C++ that I am working on which has a parent-child relationship where each child has only one parent. I had previously decided after looking at this post that I would make the ...
0
votes
1answer
200 views

Formatting Dynamic Web Pages

A page built so that is has server side scripts implemented on the page. Should indentation of the code be according to the server side logic (making it easier to read while coding) or according to ...
3
votes
1answer
207 views

Should methods always return from one place? [duplicate]

Possible Duplicate: Where did the notion of “one return only” come from? I got into a little argument with a coworker about whether a method should be written like this: public Thing ...
7
votes
3answers
218 views

“static” as a semantic clue about statelessness?

this might be a little philosophical but I hope someone can help me find a good way to think about this. I've recently undertaken a refactoring of a medium sized project in Java to go back and add ...
0
votes
2answers
248 views

Question on refactoring and code design

Suppose, I have a class with a constant static final field. Then I want in certain situations that field to be different. It still can be final, because it should be initialized in constructor. My ...
3
votes
1answer
154 views

Using T[1] instead of T for functions overloaded for T(&)[N]

The asio::buffer function has (void*, size_t) and (PodType(&)[N]) overloads. I didn't want to write ugly C-style (&x, sizeof(x)) code, so I wrote this: SomePacket packet[1]; // SomePacket is ...
16
votes
9answers
1k views

Hiding away complexity with sub functions

I am having a discussion on code style, and it's starting to sound like a "matter of taste". I strongly believe otherwise, so I'm writing this to get your opinion and learn from your arguments for and ...
8
votes
3answers
1k views

“how bad” is unrelated code in try-catch-finally block?

This is a related Q: Is use of finally clause for doing work after return bad style/dangerous? In the referenced Q, the finally code is related to the structure used and the necessity of ...
6
votes
3answers
385 views

What is your approach to multi-paradigm programming?

I have been learning some Ruby recently and I had the following experience. I had written a small tool of about 200 lines of code and, as an inexperienced Ruby programmer, I had used several loops to ...
16
votes
3answers
932 views

How to camel-case where consecutive words have numbers?

Just wondering if anybody has a good convention to follow in this corner-corner-corner case. I really use Java but figured the C# folks might have some good insight too. Say I am trying to name a ...
10
votes
6answers
861 views

Struggling with the Single Responsibility Principle

Consider this example: I have a website. It allows users to make posts (can be anything) and add tags that describe the post. In the code, I have two classes that represent the post and tags. Lets ...
4
votes
5answers
431 views

What happened to the this type of naming convention?

I have read so many docs about naming conventions, most recommending both Pascal and Camel naming conventions. Well, I agree to this, it's ok. This might not be pleasing to some, but I am just trying ...
12
votes
4answers
687 views

Is there justification for leaving conflict markers in checked-in code?

Consider conflict markers. i.e.: <<<<<<< branch blah blah this ======= blah blah that >>>>>>> HEAD In the particular case which has motivated me to post ...
5
votes
5answers
301 views

Static functions question

Something came to my mind today. I have been doing a lot of the following new Object().doSomething(); I create an object and call on of its functions, then forget about the object. I don't need it ...
25
votes
16answers
2k views

Are short identifiers bad? [closed]

Are short identifiers bad? How does identifier length correlate with code comprehension? What other factors (besides code comprehension) might be of consideration when it comes to naming identifiers? ...