ARLM-Keller / aforge

Automatically exported from code.google.com/p/aforge
0 stars 0 forks source link

GetMostIntensiveLines(count) returns null #110

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
<b>What is the actual output?</b>

HoughLinesTransformaion.GetMostIntensiveLines(int count) returns null by design 
when 
count = 0.

<b>What is the expected output?</b>

Expected output is an empty array. Although null behaviour is described in 
documentation :)

<b>What version of the product are you using?</b>

2.0.0

<b>Please provide any additional information below.</b>

According «Framework Design Guidelines» by K.Cwalina, 8.3 Collections:
«DO NOT return null values from collection properties or from methods 
returning 
collections. Return an empty collection or an empty array instead.
Users of collection properties often assume that the following code will always 
work:
<pre>IEnumerable&lt;string&gt; list = GetList();
foreach (string name in list) {
  ...
}</pre>
The general rule is that null and empty (0 item) collections or arrays should 
be 
treated the same.»

Also, look at «Design Guidelines for Developing Class Libraries» from 
Microsoft 
(actually, author is same person): <a href="http://msdn.microsoft.com/en-
us/library/k2604h5s.aspx">http://msdn.microsoft.com/en-us/library/k2604h5s.aspx<
/a>

I see, that changes to this method can break existing code. Maybe, it would be 
reasonable to add another, checked version of this method? While obsoleting the 
previous one?

Original issue reported on code.google.com by Qbi...@gmail.com on 5 Sep 2009 at 2:43

GoogleCodeExporter commented 8 years ago

Original comment by andrew.k...@gmail.com on 12 Sep 2009 at 4:44

GoogleCodeExporter commented 8 years ago
Both GetMostIntensiveLines() and GetLinesByRelativeIntensity() methods were 
updated 
to return array of zero length instead of null in the case when there are no 
lines 
to return.

Committed in revision 1064. Will be released in 2.0.1 version.

Original comment by andrew.k...@gmail.com on 15 Sep 2009 at 8:31

GoogleCodeExporter commented 8 years ago

Original comment by andrew.k...@gmail.com on 19 Sep 2009 at 7:11