'. '


From APIDesign

Jump to: navigation, search

Comments on Singletonizer <comments />

Rosinha said ...

The test should be deivred from some kind of use case. The funny thing is that first you introduced your class, then talked about writing a test, which is backwards to TDD.The use case informs the test, which informs the code. I highly doubt your use case is the user of my API can set a property called PartQty to any integer and always get back the integer they set . If that were the real use case, you'd write a unit test that checks int.MaxValue and int.MinValue. However, these are rarely real-world values.A real-world use case might look like: the user of my API news up a Bib injecting an IFlugleBinder, sets the PartQty to 4 and then calls the Execute method. This calls the Bind method on the IFlugleBinder instance 4 times. If that was the use case, your test would look very different.Honestly it looks like Bib is just a DTO of some kind. In my experience, most DTO's are just an artifact of some higher level use case. If the DTO is returned as some result of a function call that your API provides, then you should really be returning an interface, and the DTO class itself should be private, in which case it's not necessary to test it explicitly (just test the properties of the actual result you get from the method call). Likewise, if it's an internal DTO that's never exposed, then don't make it public. If your user has to provide some bundle of values, then your API should be accepting an interface. Let the user define their own class that implements the interface, or provide an immutable one, like this:public class Bib : IBib{ public Bib(int partQty) { PartQty = partQty; } public int PartQty { get; private set; }}Then you can write a test that checks if your constructor works if you want to be pedantic, but it's not that important.

--Rosinha 21:11, 25 June 2013 (CEST)

Galin said ...

Chong Minnehan 说道:Hey friend can i publsih some paragraph of your article on my little blog of university.I have to publsih a good articles out there and i really think your post Fits best into it.I will be grateful to give you an source link as well.I have two blogs one my own and the other which is my college blog.I will publsih some part in the university blog.Hope you do not mind.

--Galin 18:12, 21 October 2013 (CEST)

Aunty said ...

не переживай, мы за один день тебя не забыли, а если серьезно, то это очень злит (2640 comnmets) Reply:Март 14th, 2012 at 19:00Пасип! Злит, и ещё как злит (382 comnmets) Reply:Март 14th, 2012 at 20:43я тогда, когда у меня не работало, просто аж шипела (2640 comnmets) Reply:Март 14th, 2012 at 20:47Я тоже так делал только матерными словами )))

--Aunty 03:36, 22 October 2013 (CEST)

Personal tools