Most Popular

1500 questions
69
votes
4 answers

Why were Java collections implemented with "optional methods" in the interface?

During my first implementation extending the Java collection framework, I was quite surprised to see that the collection interface contains methods declared as optional. The implementer is expected to throw UnsupportedOperationExceptions if…
glenviewjeff
  • 1,405
69
votes
8 answers

In code review, should I ask to do a refactor outside of the scope in a pull request?

I have been studying the best practices for a code review, and I was wondering what to do in the following scenario: During a code review, I see potential improvements, but decide that they are outside of the scope of the pull request (PR). Should I…
Tisp
  • 817
69
votes
9 answers

Why prefer a package manager over a library folder?

When I think about the pros and cons of a static library folder and a package manager I feel like the library folder is a better approach. Pros I see with a library folder: No need for an external tool to manage packages. No internet connection…
Ignacio Soler Garcia
  • 1,574
  • 2
  • 11
  • 17
69
votes
12 answers

Does a constructor that validates its arguments violate SRP?

I am trying to adhere to the Single Responsibility Principle (SRP) as much as possible and got used to a certain pattern (for the SRP on methods) heavily relying on delegates. I'd like to know if this approach is sound or if there are any severe…
69
votes
8 answers

Should I record a bug that I discovered and patched?

I suppose that this is a common situation: I test some code, discover a bug, fix it and commit the bug-fix to the repository. Assuming that many people work on this project, should I first create a bug report, assign it to myself, and refer to it in…
David D
  • 759
  • 5
  • 6
69
votes
4 answers

Is functional programming faster in multithreading because I write things differently or because things are compiled differently?

I'm diving into the world of functional programming and I keep reading everywhere that functional languages are better for multithreading/multicore programs. I understand how functional languages do a lot of things differently, such as recursion,…
Aventinus
  • 801
69
votes
4 answers

Uncle Bob's clean architecture - An entity/model class for each layer?

BACKGROUND : I'm trying to use Uncle Bob's clean architecture in my android app. I studied many open source projects that are trying to show the right way to do it, and I found an interesting implementation based on RxAndroid. WHAT I NOTICIED : In…
Rami Jemli
  • 791
  • 1
  • 6
  • 6
69
votes
3 answers

Which programming language is used to write a BIOS program?

As I understand, the BIOS code/bitstream that is held in the ROM should be generic (work alongside with multiple CPU types or ISAs). In addition, I saw mentioned on the web that it is possible to dump its code (and to "disassemble" it). So, in which…
69
votes
6 answers

Should Latin-1 be used over UTF-8 when it comes to database configuration?

We are using MySQL at the company I work for, and we build both client-facing and internal applications using Ruby on Rails. When I started working here, I ran into a problem what I had never encountered before; the database on the production server…
Ten Bitcomb
  • 1,164
69
votes
3 answers

Why are the Java 8 java.time classes missing a getMillis() method?

Java 8 has a whole new library for dates and times in the package java.time which is very welcome thing to anyone who has had to use JodaTime before or hassle with making it's own date processing helper methods. Many classes in this package…
Tarmo
  • 793
  • 1
  • 5
  • 8
69
votes
7 answers

Is it sufficient to use acceptance and integration tests instead of unit test?

Short introduction to this question. I have used now TDD and lately BDD for over one year now. I use techniques like mocking to make writing my tests more efficiently. Lately I have started a personal project to write a little money management…
twilker
  • 908
69
votes
4 answers

Most human-friendly way to order class method definitions?

In any given class definition, I've seen the method definitions ordered in various ways: alphabetical, chronological based on most common usage, alphabetical grouped by visibility, alphabetical with getters and setters grouped together, etc. When I…
Johntron
  • 1,008
69
votes
6 answers

Testing multi-threaded race conditions

Reading the comments to this answer, specifically: Just because you can't write a test doesn't mean it's not broken. Undefined behaviour which usually happens to work as expected (C and C++ are full of that), race conditions, potential reordering…
69
votes
12 answers

Is catching general exceptions really a bad thing?

I typically agree with most code analysis warnings, and I try to adhere to them. However, I'm having a harder time with this one: CA1031: Do not catch general exception types I understand the rationale for this rule. But, in practice, if I want to…
Bob Horn
  • 2,327
  • 3
  • 21
  • 26
69
votes
8 answers

Asking for a code sample of the company at an interview

Asking a job seeker to show some code is a fairly common practice for a software company. However, would it be acceptable for the candidate to ask the interviewer to show him a small piece of code that he thinks is well written?
Simon Bergot
  • 7,970
  • 4
  • 35
  • 55