Most Popular

1500 questions
64
votes
23 answers

Is writing comments inside methods not a good practice?

A friend told me that writing comments inside methods is not good. He said that we should have comments only for the method definitions(javadocs) but not inside the method body. It seems he read in a book that having comments inside the code means…
Srini Kandula
64
votes
11 answers

How do you stay productive when dealing with extremely badly written code?

I don't have much experience in working in software industry, being self-taught and having participated in open source before deciding to take a job. Now that I work for money, I also have to deal with some unpleasant stuff, which is normal of…
Dan
  • 2,902
  • 1
  • 25
  • 30
64
votes
23 answers

Why can't there be an "universal" programming language that serves all purposes?

why not combine the best features of the all existent programming languages and fit it in a universal programming language?
killown
  • 1,466
  • 3
  • 15
  • 18
64
votes
19 answers

Which skills would you expect and appreciate in a Junior Software Engineer?

I recently finished my Master of Science in Software Engineering, and I am about to start my professional career in a few weeks. My role will be as a Junior Developer for a company which develops software using Java & related technologies (among…
Bartzilla
  • 361
  • 1
  • 4
  • 7
64
votes
5 answers

Is the usage of random values in unit testing a good practice?

Having worked in complex solutions that had Unit Tests and Integration Test in the CI/CD pipeline, I recall having a tough time with tests that failed randomly (either due to random values being injected or because of the async nature of the process…
64
votes
10 answers

How do I mitigate a scenario where a user goes to pay, but the price is changed mid-request?

This is kind of similar to the Two Generals' Problem, but not quite. I think there is a name for it, but I just can't remember it right now. I am working on my website's payment flow. Scenario Alice wants to pay Bob for a service. Bob has quoted…
turnip
  • 1,657
  • 2
  • 15
  • 21
64
votes
10 answers

When would you use a long, string ID instead of a simple integer?

I'd like to use Youtube as an example: they use IDs in the form of PEckzwggd78. Why don't they use simple integers? Or imgur.com - they also use IDs such as 9b6tMZS for images and galleries. Not sequential integers. Why don't they use integers…
Rakori
  • 787
  • 1
  • 5
  • 7
64
votes
10 answers

Do you generally send objects or their member variables into functions?

Which is generally accepted practice between these two cases: function insertIntoDatabase(Account account, Otherthing thing) { database.insertMethod(account.getId(), thing.getId(), thing.getSomeValue()); } or function insertIntoDatabase(long…
64
votes
12 answers

Does this class design violate the single responsibility principle?

Today I had an argument with someone. I was explaining the benefits of having a rich domain model as opposed to an anemic domain model. And I demoed my point with a simple class looking like that: public class Employee { public Employee(string…
tobiak777
  • 797
  • 1
  • 5
  • 11
64
votes
3 answers

Are header-only libraries more efficient?

Assumptions One of the advantages of header-only libraries for C++ is that they do not need to be compiled separately. In C and C++ inline makes sense only if the function is defined in a header file*. Traditionally, in C, .c/.h layout has been…
Vorac
  • 7,073
  • 7
  • 38
  • 58
64
votes
3 answers

Declaring multiple licences in a GitHub project

For years, I've been a great fan of putting licences on things shared online to make it easier for others to determine if and how they can reuse said things. Before GitHub began to gently 'push' its users to include LICENSE files with their repos, I…
Kay
  • 886
  • 1
  • 8
  • 11
64
votes
8 answers

When NOT to use virtual destructors?

I believed I searched many times about virtual destructors, most mention the purpose of virtual destructors, and why you need virtual destructors. Also I think in most cases destructors need to be virtual. Then the question is: Why doesn't c++ set…
ggrr
  • 5,725
  • 11
  • 35
  • 37
64
votes
12 answers

Reconciling the Boy Scout Rule and Opportunistic Refactoring with code reviews

I am a great believer in the Boy Scout Rule: Always check a module in cleaner than when you checked it out." No matter who the original author was, what if we always made some effort, no matter how small, to improve the module. What would be…
t0x1n
  • 945
  • 6
  • 7
64
votes
5 answers

What does HATEOAS offer for discoverability and decoupling besides ability to change your URL structure more or less freely?

Lately I've been reading about Hypermedia as the Engine of Application State (HATEOAS), the constraint that is claimed to make a web API "truly RESTful". It boils down to basically including links with every response to the possible transitions you…
Botond Balázs
  • 1,463
  • 2
  • 12
  • 13
64
votes
10 answers

Is better Show() + Hide() or SetVisible(bool visible)?

What is better and why? (From interface-design point of view) : a) To have two Show() and Hide() functions b) To have one SetVisible(bool visible) function EDIT: For example some object have visibility state and this functions is used to change…
user3123061
  • 1,609
  • 1
  • 15
  • 17