Skip to main content

All Questions

2votes
2answers
436views

When to prefer print over logging?

Generally print statements are frowned upon in favor to logging. But are there any situations where I should prefer using print statements? In a interactive command line application, if I ask for user ...
9votes
2answers
1kviews

Should function names describe their parameter types?

If you wish to perform the same action using different parameters, you can either make differently named functions: public Apple findAppleById(long id){ return repo.findById(id); } public Apple ...
6votes
5answers
5kviews

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 ...
3votes
0answers
162views

Forgetting about the utils [closed]

Let's say my language's standard library does not include TrickyFunction(). Since implementation seems quite trivial for me, I decide to create utils in the project and add such function, for others ...
50votes
8answers
17kviews

When is it appropriate to make a separate function when there will only ever be a single call to said function? [duplicate]

We are designing coding standards, and are having disagreements as to if it is ever appropriate to break code out into separate functions within a class, when those functions will only ever be called ...
18votes
2answers
8kviews

Is there a standardized practice for ordering attributes in HTML tags?

I am working on an AngularJS project and the attributes are numerous in many of my HTML elements: <button type="submit" ng-click="Page.UI.DetailView.ExecuteFunction()" ng-...
2votes
1answer
469views

How to balance 'efficient' vs 'clean' code? [closed]

I have been coding in python for a little over a year, and I have learned a lot and developed quite a few applications, in the process. I do not program for my profession, I simply program ...
14votes
2answers
3kviews

Is it bad practice to create blocks of code?

In C++, is it bad practice create blocks of code inside some function, such as the following: bool f() { { double test = 0; test = // some other variable ...
2votes
2answers
213views

Should one create shareable private class member or keep variable in method scope to pass it as a second method argument?

Recently I had to refactor some legacy code. As in most cases, I had to split big parts of code into smaller, cleaner and readable functions. I ended with many functions, that had multiple, weird ...
2votes
5answers
1kviews

What should a constructor contain?

What should a constructor contain? In both cases, all three arguments are needed for the class to work. Which approach is better and why? 1) class Language { LanguageRepository ...
1vote
1answer
206views

counting identifiers and operators as code size metric

I'm looking for a code metric for monitor and track over time the size of several projects and their components. Also, I would like to use it for: evaluate size reduction after refactoring compare ...
3votes
4answers
3kviews

How to use Macros in Programming to make code faster, efficient and compact

Recently I was going through some of the source-codes of the best competitive programmers in the world. I found out that those people use a template while writing programs, preferably in C++. I have ...
-2votes
1answer
276views

Property file, annotations or database tables for storing configurations

Which one is better property file, annotations or database tables for storing configurations related to a program? What are the advantages/disadvantages and what use cases are best suited for each ...
0votes
2answers
110views

Negation of sameness is confirmation of difference [closed]

De Morgan's laws: the negation of a disjunction is the conjunction of the negations; and the negation of a conjunction is the disjunction of the negations; or, the same: not (A or B) = not A and not B;...
2votes
1answer
293views

Guard block moved to the bottom [closed]

Sometimes it is a good idea to have a guard block: https://softwareengineering.stackexchange.com/a/157413 https://en.wikipedia.org/wiki/Guard_(computer_science) Guard block guards against special ...

153050per page
close