EdH
  • Member for 8 years, 10 months
  • Last seen more than a month ago
Reasoning to wait until third time in the Rule of Three?
19 votes

I think this rule of thumb exists because it is easy to get caught into playing "What if..." when designing the code for the first time or after the first duplication. I've encountered severe ...

View answer
How to unit test a class which is just an adapter that logs input and output to a third-party library?
4 votes

If I were writing a test for this in Java, I would use a mocking library (like Mockito) and create a mock instance of ThirdPartyClass (and possibly the ILog instance). Then I would create an instance ...

View answer
What made BASIC profitable?
3 votes

Also think how programs are compiled/distributed has changed. Remember, before DOS, most computing was on mainframe-esque systems. Compilers were delivered as part of the hardware because you rarely ...

View answer
How to make my code decide which class to instantiate based on a parameter?
Accepted answer
2 votes

As Steve Evers states, using an enumeration as a key and either a Class to instantiate (or an instance of Query pre-built) to return. If you don't like the if/else pattern, I know Java has Map ...

View answer
Is there a certain way that I have to include a library and its license?
Accepted answer
2 votes

I don't know if there's a standard way to include licenses. Libraries are easy, in that if it's not included the correct way the application won't work. Licenses are fuzzier, because each license ...

View answer
How to create a Web app that "interacts" with email?
1 votes

Java has JavaMail, which is a complete API for email servers and services. You could run a small java application which listens for the messages, processes them and acts accordingly (writing to a ...

View answer
Proper OAuth2 Grant
0 votes

Can you use a client_credentials grant for the first type? It only requires the clientId & clientSecret in order to get a token. I believe it is meant to support application access, opposed to ...

View answer
Calling blocking functions and execute code when result is ready, but without callbacks
0 votes

Java has something called a CountDownLatch, which should do what you're after. From the JavaDoc for it class Driver { // ... void main() throws InterruptedException { CountDownLatch ...

View answer