Refactoring, braces, indentation, Hungarian notation, and other stylistic issues relating to code.

learn more… | top users | synonyms (8)

0
votes
4answers
46 views

Is it better to create a variable than have a huge line of code?

I'm not sure how to phrase this, so looking it up was quite difficult and showed up nothing. I'm currently learning to program at university and I have a question about what I guess is programming ...
0
votes
1answer
56 views

C++ programming conventions regarding class definitions

Learning how to program without any formal IT education, I am fairly oblivious to many common programming conventions. Though nonessential, these details have been bugging me for quite a long time, ...
2
votes
1answer
14 views

Style preference for binary operators with long lines

Most style guides, such as Google's, for C++ recommend a maximum line length of 80 characters as well as relevant guidelines for function calls such that the function call is formatted correctly. For ...
0
votes
1answer
25 views

RegEx: Switch from ANSI C++ style open braces (new line) to K&R style (same line as the statement)

How would you write a regular expression for match and replace in order to reformat C++ code from the ANSI C++ style: if (a > 5) { } to the K&R style: if (a > 5) { } ?
1
vote
4answers
69 views

Programming conventions in java

I have a simple question about one aspect about so called programming conventions in java. Simply - if I pass a local variable in one method to a another (helper) method - should I keep the name of ...
1
vote
4answers
60 views

String.Format extension method [on hold]

I have: public static string Format(this string text, params object[] args) { return string.Format(text, args); } So I can do: "blablabla {0}".Format(variable1); Is it a good/bad? Can it ...
1
vote
1answer
36 views

Pythonic use of class and module methods

I suppose this is a bit of a beginner's question, but I'm wondering about the more pythonic approach to use when you're presented with a situation where you're using class methods from a class defined ...
0
votes
0answers
51 views

Will my coding technique harm me in the future? [on hold]

I'm a first year CS student and I've noticed that my coding style is not very math oriented. Below is an example of a problem that I've solved, and here's the question: Write a program to convert a ...
2
votes
1answer
78 views

Can I return a vector to extend an existing vector with C++11?

What's the best way to extend a vector with the contents of a vector returned from a function? I can do: std::vector<int> base; { std::vector<int> tmp = getVec(); //RVO will make ...
2
votes
5answers
36 views

correct style for element-wise operations on lists without numpy (python)

I would like to operate on lists element by element without using numpy, for example, i want add([1,2,3], [2,3,4]) = [3,5,7] and mult([1,1,1],[9,9,9]) = [9,9,9], but i'm not sure which way of doing is ...
0
votes
1answer
15 views

Javascript convention when clashing a reserved word

In python, when a variable name clashes with a reserved word (like in class, in, default, etcetera), the PEP8 convention states that a trailing underscore should be used (class_, in_, default_). What ...
-1
votes
1answer
21 views

Coding convention - use of underscore prefix and suffix [on hold]

There seems to be divided opinion on this subject, and I wanted to get people's insights on whether they've found using underscore prefixes and suffixes to be helpful with coding or not. You know, ...
3
votes
4answers
44 views

efficient alternative to if (a>b) in javascript for checking a variable range

I hope the title is not too generic nor misleading. var blah; if(a > 10) blah = 'large'; if(a <= 10 && a > 5) blah = 'medium'; if(a <= 5 && a >= 0) blah = 'small'; ...
0
votes
0answers
21 views

Best practice to keep method visibility with Spring @Controller stereotype

My project at current job use private access modifier for methods of MVC controllers: @Controller public class HelloWorldController { @RequestMapping("/helloWorld") private ModelAndView ...
0
votes
1answer
59 views

Proper selection of loops versus function versus object/class [on hold]

When writing a program, my understanding as a hobbyist programmer is, there are three ways to accomplish most of the things: create loops create and use function create and use object I am using ...

1 2 3 4 5 347
15 30 50 per page