Skip to main content

All Questions

13 votes
6 answers
5k views

Is it bad practice create "alias" variables to not use globals or arguments with long names in a method?

Is it OK to create a variable which only purpose is to increase readability? Example: public class Example { private final HowLongCanARepositoryNameReallyBeRepository ...
Adilson Cabral's user avatar
4 votes
3 answers
1k views

Passing object or using the field

I would like to know what is a more appropriate way to code in Java. Is it generally better to pass entire objects in the method's parameters or just using the fields from the class? Using the field: ...
max's user avatar
  • 163
1 vote
1 answer
206 views

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 ...
Guish's user avatar
  • 23
1 vote
2 answers
1k views

Calling methods on objects VS. passing objects as parameters

Which is considered a generally accepted practice? class Image { public void decode(); }; //main Image image; image.decode(); vs class ImageDecoder { public Image run(Image image); }; //main Image ...
Sfraley's user avatar
  • 21
4 votes
7 answers
1k views

How do you know where you stopped in your codes after a 2-week break? [closed]

I just had a more than 2-week long vacation/business trip and I couldn't remember actually what was I working in my coding and where I stopped. Could someone recommend a best practice to solve this?
vyap56's user avatar
  • 175
94 votes
14 answers
9k views

How can I avoid always feeling like if I completely rebuilt my program from scratch I'd do it much better? [closed]

I have learned a significant amount of coding, however, it's always been in a scientific environment (not computer science), completely self-taught without anyone to guide me in the right direction. ...
Ashish's user avatar
  • 359
3 votes
1 answer
108 views

What security practices do I employ when building a library that requires low level root access to certain devices and files?

Backstory I am writing a library that accesses the kernel module, uinput which allows you to create or take control of devices in /dev/input/event#, and insert events into them. A simple usecase would ...
Anon's user avatar
  • 3,633
2 votes
2 answers
213 views

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 ...
helvy91's user avatar
  • 29
14 votes
2 answers
3k views

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 ...
Inertial Ignorance's user avatar
0 votes
1 answer
267 views

Which is better in terms of performance (bool01==bool02) vs (bool01 && bool02) [duplicate]

Which of these two is the better way of doing the same thing - public void someMethod(String s, boolean bool02){ boolean bool01 = s!=null; if(bool01==bool02){ doSomething(); } } OR public void ...
user3344591's user avatar
1 vote
1 answer
132 views

Should a loop be nested inside an unchanging conditional?

I was reviewing some old code and stumbled upon a loop nested inside a conditional like this: std::cin >> number; //number is used elsewhere, so should be preserved if (number <= 10) for (...
BrainFRZ's user avatar
  • 113
1 vote
3 answers
1k views

How to handle custom metadata in XML?

Backstory I have an XML type document (SSML, which is used forText-To-Speech), which will be used to generate audio files when ssh transferred to a remote server. As such, I will need to include ...
Anon's user avatar
  • 3,633
42 votes
9 answers
7k views

Is a JS Boolean having custom properties a bad practice?

In JS you can return a Boolean having custom properties. Eg. when Modernizr tests for video support it returns true or false but the returned Boolean (Bool is first class object in JS) has properties ...
konrad's user avatar
  • 551
10 votes
5 answers
819 views

Is placing text markers inside of strings bad style? Is there an alternative?

I work with massive strings which need a lot of manipulation. For example, I might generate a string like this: Part 1 Boat Section A Programming Part 2 Partitioning boats for ...
Anon's user avatar
  • 3,633
12 votes
5 answers
6k views

Should I be using const more in C++?

There are some things I am pretty strict about, but const has not been one of them. For example, I might make a local variable that I use three times in a function, that does not get changed, and yet ...
Anon's user avatar
  • 3,633

15 30 50 per page