0
votes
4answers
289 views

How can if (sscanf(buf, “%i”, &mode) != 1 || TRUE) be rewritten to if (TRUE)?

I got lost in the opening of this post on reddit. How can if (sscanf(buf, "%i", &mode) != 1 || TRUE) be rewritten to if (TRUE)? Does this assume that the sscanf never fails?
1
vote
0answers
58 views

MVC Controller - keeping methods small

I'm reading uncle Bob's Clean Code and it completely revolutionizes my programming style. In this book author claims that best methods are small methods. What about controller's action methods in ...
5
votes
4answers
2k views

Should you ever use private on fields and methods in C#?

I am somewhat new to C# and just found out that: in C# all of the fields and methods in a class are default private. Meaning that this: class MyClass { string myString } is the same as: class ...
40
votes
6answers
3k views

Is making a small change, testing it, then “rinse and repeat”, a bad habit?

I am a programmer with a number of years of experience. I realized I got a certain habit. I'm not sure whether it's really a bad habit or not. I get a list of tasks to perform for a solution, even ...
3
votes
3answers
416 views

Refactoring previous intern's noodle code with future interns in mind [duplicate]

Background I've run across this problem as I am currently an intern at a large company's local software division. I have been given the task of extending a project that several previous interns have ...
2
votes
1answer
143 views

Is serialization better done in instance methods or static methods

Say I have a class workStockItem, that I wish to serialize. Which is the better style? using a static method or using a non-static method (maybe even implemented as a property as seen below) ...
2
votes
1answer
93 views

equivalence in callback and non-callback javascript

I'm pretty sure that the following two snippets are equivalent but I wanted to double check: CALLBACK STYLE function foo(input, callback) { // do stuff with input callback(); } function ...
0
votes
1answer
95 views

Which is preferred coding style to validate and return from a method [duplicate]

Which of the below is a preferred coding style (in c# .net) public void DoWork(Employee employee) { if(employee == null) return; if(!string.IsNullOrEmpty(employee.Name)) return; // Do ...
3
votes
3answers
1k views

articles in variable names and hard-coding strings

re-edited by author: no this is not 2 questions. This is one question about code review questions containing two separate points. Please do not edit my question. For naming variables, the two sides ...
1
vote
2answers
150 views

Is repeating links to the same class in a single javadoc comment a bad practice?

I'm currently writing an API and its documentation. For example I have something like this: public interface Event { } public interface Process { } public interface EventProcessor { /** * ...
1
vote
5answers
248 views

Is it a good practice to write a method that gets something and checks the value? [duplicate]

Occassinally I have to write methods like this: string GetReportOutputDirectoryAndMakeSureExist() { string path = Path.Combine ( ... ) //whatever logic if(!Directory.Exists(path)) ...
2
votes
2answers
303 views

Choosing between words with different spellings for function names

A question has been bothering me for a while: when developing international projects, it is common sense to use English as the reference language since it is the language that the most people ...
5
votes
4answers
349 views

In which order should I do comparisons? [duplicate]

I'm a strong proponent of writing if statements like this: variable == constant Because to me it just makes sense, it is more readable than the inverted: constant == variable Which seems to be ...
1
vote
4answers
2k views

Switching from ActionScript to JavaScript, tips for writing code?

I am quite comfortable with using actionscript3 and flash. I also have some experience with Java. But recently, I started learning JavaScript and node.js. I ultimately want to make a 3d game in ...
0
votes
2answers
262 views

Need some advice and feedback on my code's design

I am looking for feedback on the design of my program. I have a shell script call function.sh that defines a lot of helper functions. My intent is to use those bash functions defined in functions.sh ...
6
votes
3answers
447 views

Does studying other people's programs help in self growth?

Should I be studying big softwares written by other people in our company? My work may be a small sub module on the top of that software, and I may not be required to know what goes beneath the hood, ...
1
vote
4answers
392 views

Is extensive documentation a code smell? [closed]

Every library, open-source project, and SDK/API I've ever come across has come packaged with a (usually large) documentation file, and this seems contradictory to the wide-spread belief that good code ...
6
votes
3answers
257 views

Style bits vs. Separate bool's

My main platform (WinAPI) still heavily uses bits for control styles etc. (example). When introducing custom controls, I'm permanently wondering whether to follow that style or rather use individual ...
26
votes
9answers
2k views

Simple vs Complex (but performance efficient) solution - which one to choose and when?

I have been programming for a couple of years and have often found myself at a dilemma. There are two solutions - one is simple one i.e. simple approach, easier to understand and maintain. It ...
11
votes
9answers
926 views

Should a programmer take writing lessons to enhance code expressiveness?

Given that programmers are authors and write code to express abstract thoughts and concepts, and good code should be read by other programmers without difficulties and misunderstandings, should a ...
2
votes
4answers
304 views

Linking in code comments (to other unique anchors/comments)

How would you recommend creating "anchors" in code comments, so that during maintenance, developers can easily cross-reference other code comments. I realise that software should be intelligently ...
11
votes
6answers
1k views

A defense for boilerplate?

To me, boilerplate code is obviously bad. However I've met a developer who displays resistance in any attempt to reduce boilerplate. I realized I didn't have a readily formed, well thought out ...
5
votes
8answers
1k views

What are the benefits of using comments

I just accepted a new job. Our application is in the 50,000 lines of code area. None of which is commented. I am finding it difficult to understand how the application works. Id like to prevent this ...
71
votes
10answers
14k views

Why do most of us use 'i' as a loop counter variable?

Has anyone thought about why so many of us repeat this same pattern using the same variable names? for (int i = 0; i < foo; i++) { // ... } It seems most code I've ever looked at uses i, j, ...
37
votes
11answers
3k views

Is it bad habit not using interfaces? [closed]

I use interfaces rarely and find them common in others code. Also I create sub and super classes (while creating my own classes) rarely in my code. Is it a bad thing? Would you suggest changing ...
-2
votes
7answers
338 views

Vector operations: vec1.dot(vec2) vs vec1 * vec2 vs dot(vec1, vec2) [closed]

What's your preferred way to implement/use vector operations? vec1.dot(vec2) allows to reuse vec1 but is hard to read for longer equations dot(vec1, vec2) A friend of mine prefers this as "dot" ...
5
votes
8answers
1k views

Top bad practices in MySQL [closed]

There was another post allowing people to post their top bad practices in PHP, I had a gripe about MySQL practices and thought it'd be an interesting topic to hear the top bad practices in MySQL. Up ...