SOLID and unit testing. Using language provided methods/classes -


so i've read thing called solid (mixed with) writing testable code. , d part. how 1 follow these guidelines when using primitive types or methods/classes provided language library.

does 1 need use dependency injection arrays (java (new int[64]) or class members of say, filewriter?. these need injected using di or can class still instantiate them?

how far should go following above guidelines?

i not looking language-specific answer (if possible). imho answer should apply to, ex, php, python java, heck, c

you don't inject primitives or dto/pojo-like objects. reason are:

  1. simple value holders without business/domain logic associated
  2. easily stubbed without tools (creating array of fake data test not problematic)

filewriter different it's in exact opposition points above. can't stub in test , make work without few strong assumptions - like, assume every future developer running code have file on machine. no-go unit tests , 1 of reasons why di applied in cases.

those problems come fact filewriter serves communication point between 2 unrelated components - application , file system. class doing kind of integration (between app , db/network/file/rest etc.) in cases should abstracted , injected.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -