C# Dependency Injection via /r/csharp

via Trying to understand something about Dependency Injection : csharp

User badlife says this:

DI is a lot deeper than you’re thinking. It’s an entirely different way of doing architecture. Here’s a simple example:

Without DI:

  • I’m a component. I need X to do some work. So I’ll create an instance of X and use it. I don’t want Y, or something that looks like X but behaves differently– I want an instance of X and only X.

With DI:

  • I’m a component. I need an instance of X to do some work
    • I’m not going to create an instance of X– I’ll let you give me one when you create me
    • I don’t care if X is really X, as long as it looks like X.
    • I don’t want Y, but if Y pretends to be X, I’ll never know. This is because I only want something that lookslike X.

Here’s an example in concrete terms:

  • The ‘component’ is something that does a calculation. As part of the calculation, it needs to call a web service to get a value (let’s say an interest rate)
  • X is usually a component that calls a web service to get the interest rate
  • Y is a testing component that just returns ‘1.0’ for the interest rate

Without DI, the component is very hard to test because it needs to call a ‘live’ web service to get an interest rate. What if that web service isn’t live? What if it isn’t accessible from the testing environment? The test could be running as part of a build, and the build server might not be able to see the web service.

With DI, both X and Y can implement a common interface. The component doesn’t actually create an instance of X– it just asks for a reference to the interface. So in a real world scenario, the system gives the component a ‘real’ instance of X by passing a reference to its interface. In a testing scenario, the system gives the component a ‘fake’ version of X (it’s actually Y!) also by passing a reference to its interface. The component doesn’t know or care about the internal implementation of what it thinks is X, and can do its work without the web service being available.

Advertisements

Samsung 850 Pro NVMe Driver

UPDATE 5/31/2018: I believe there are version 3.0 drivers now on Samsung’s website.

Here are the latest 64 bit drivers I could find on Samsung’s website for an 850 Pro NVMe. They (the .inf and .sys files) are from the version 2.3 installer. It may install for other SSDs as well, though I have not tested them yet. Instructions below..

The password is “nvme“. If you can’t find the download link, it is purring at you.

kittycatkitten45201

Hint: Past Post.

Instructions:

  1. Install 7zip, if you haven’t already.
  2. Make sure you have a backup of your important files.
  3. Download the cute cat picture to a temp folder.
  4. Open the image with 7zip.
  5. Save the 7z contents to the temp folder, all 3 files.
  6. Open your device manager and navigate down to “Storage controllers”.
  7. Override Microsoft’s default NVMe driver with these from Samsung.

Reboot and you should be good to go.
Benchmark before and after if you’re into that sort of stuff. 😛

[Free] Online Link Expander & Decrypter

@ Link Expander & Decrypter

Quote from their site (with the Grammar fixed!):

“This tool is an Ajax based link expander. It works by taking into account the API & shortening algorithm used by the shortener. After you submit your link, it checks the API used by the shortener. Within seconds the tool unshortens the URL according to the API detected. But that’s not all this tool does, it also tells if the uncovered site is safe to browse and displays a screenshot of the website along with the result. Now you can decrypt any URL with our link unshortener. We have tested our tool with all the services & it works perfectly!”
“Now expand URL from Bitly, Goog.l, AdFly & many more in just a click!”

Performance Boost with VeraCrypt?!

VeraCrypt – Free Open Source Storage Device Encryption
(with strong security for the paranoid!) – Their words, not mine lol.

Has anyone else noticed a performance boost in reading from and writing to a VeraCrypt encrypted storage device?

Let’s run some tests and see if there really is any difference..

Continue reading “Performance Boost with VeraCrypt?!”

Recommended free storage device benchmarking software for Windows 10

For free storage device benchmarking software, I highly recommend CrystalDiskMark. The interface is nice, clean, and simple to use. And the results are easy to understand!

You can even record the test results by pressing Alt-PrintScreen (after the benchmarks have completed, of course) to post to your website or blog for sharing and historical comparisons.

I’ll be using this program in my next blog post to test VeraCrypt’s (a free storage device encryption program) performance vs the same plain hard drive.

estimation

Recommended drive diagnostic software for Windows 10 (with S.M.A.R.T. data!)

For free hard, flash, USB, SSD, and NVMe drive diagnostic software, I highly recommend CrystalDiskInfo. It sits in your Windows system tray and report all drive’s temperatures and S.M.A.R.T data.

It can also set off an audible alarm if any drive’s temperature gets too high (the temperature limit is adjustable). Very useful when testing new computer case configurations or new drives!