What is dependency injection?

Dependency Injection is passing dependency to other objects or framework( dependency injector). Dependency injection makes testing easier. The injection can be done through constructor. SomeClass() has its constructor as following: Problem: If myObject involves complex tasks such as disk access or network access, it is hard to do unit test on SomeClass(). Programmers have to … Read more

:wq! command in vim

If you don’t have permission to the file (e.g. you don’t own the file), then it will not force the write. If you do have permission to the file, but it is a read-only file, then you can force-write it. It’s as if you first change the file mode to writable, write your changes, and … Read more

Why prefer two’s complement over sign-and-magnitude for signed numbers?

It’s done so that addition doesn’t need to have any special logic for dealing with negative numbers. Check out the article on Wikipedia. Say you have two numbers, 2 and -1. In your “intuitive” way of representing numbers, they would be 0010 and 1001, respectively (I’m sticking to 4 bits for size). In the two’s … Read more