This project is read-only.

Questions about project organization

Mar 14, 2011 at 11:43 PM

etendren asked the following questions regarding the project organization:

1) why copypasting in sources instead of using templates? I mean cases
when we have two similar functions for <double> and <complex>
2) what about testing system in project?
3) How should I upload my code as patches or as commits in svn?
4) If I write for example ind2sub function, should I do it in the
ArrayHelper? May be it will be better if you will establish what
function must be implemented in what class?

my answers are as follows:

1.  I would really like to find a way to avoid this because it adds a significant maintenance overhead.  The reason for not using templates is that I couldn't find a way to do it.  If we use a template method with parameter T for the type then T is treated as type 'object' and so can't be operated on arithmetically without casting, and unless microsoft are doing some clever tricks, I expect that casting each member of an array inside an inner loop is bad for performance.  It looks like others have solved this problem by using a preprocessor to generate the different overloads from a template.

2. There are no tests at the moment and this definitely needs rectifying.  I was thinking of nunit or something similar - do you have any suggestions for this?

3. I'm happy for you to commit directly.  If you want to change existing code (beyond a relatively simple fix) then it's worth posting your intention in the discussions first.

4.  The functions follow the matlab naming convention and so also were following the categorisation In the matlab function reference in terms of which class they go in.

etendren followed up with:

PS: hmm... " The functions follow the matlab naming convention and so

also were following the categorisation In the matlab function

reference in terms of which class they go in." - is not very good
answer) Because for example in matlab we see:
Arrays and Matrices > Elementary Matrices and Arrays > ind2sub
Arrays and Matrices > Array Manipulation > shiftdim

and in our sources shiftdim is in ArrayHelper. Furthermore in
ArrayHelper we have some helper functions not implemented in matlab..

my reply:

I agree - some reorganisation is required.  I'll raise a task in the issue tracker to put them in correctly named files.  There is another caveat with using the matlab categories, which is that some functions appear in more than one category - so in that case we need to pick the most appropriate one (which unfortunately is probably a subjective choice).

Mar 18, 2011 at 6:16 PM

I have now re-organised the code so that the functions are more closely matched with their categories.

The question is: what do we do about functions that exist in more than one category?  I see three potential options:

1) Put the function in the 'most suitable' category

2) Put the definitive function implementation in one of the categories and then put functions that call that function in the other categories

3) Switch to using partial classes of the same class and put the function in an arbitrary category.

I don't like (2) because it involves extra code to maintain and it will make the library more confusing to use.  The advantage of (3) is that the user doesn't need to work out which category the function is in before they can call it.  (1) is essentially what we are doing already.

Whatever we do. I think we should keep the separation into different files, otherwise it will become difficult to navigate the code.

Any thoughts?

Mar 18, 2011 at 7:43 PM

I dont undertand what do you mean in (3). What category? Do you suggest defining all functions in one class but separate this class for many files only for maintaining but not for user? Hmm. May be it is a good idea becouse if we appropriately follow matlab function naming we will never get two different functions with the same name.

Mar 18, 2011 at 8:09 PM

And what we are going to do with functions defined in ILNumerics? I think user of the library shuldn't deal with what function is defined in what library in mathlib or in ilnumerics.. mmm.. sorry for my english, I hope it is clear what I mean.

Mar 18, 2011 at 8:18 PM

(1) or (3) ... May be follow only one level of mathlib structure? Only classes Arrays, LinearAlgebra, ElementaryMath, etc.. ? as thought,,

Mar 19, 2011 at 9:02 AM

Yes - (3) would mean keeping the separate files so that we could maintain the code more easily and using a single class (e.g. Math) that would be spread across those files.  Normally I wouldn't recommend spreading a class across files like this but the number of class structure is so simple (essentially one main class with a few helper classes) that I think the benefits of breaking the code into managable parts outweigh the drawbacks of separating the class 'unit'.  As you say, the matlab function names are unique and so there won't be a problem with name clashes.

I suppose the most important thing is that the interface is simple to the user so my vote would be (3) as you don't need to work out which category a function is in to be able to use it (just like matlab).

I agree about ILNumerics and I think we need to wrap those functions so that all functions are called through our class and ILNumerics is not exposed (or at least does not need to be considered by the user).  It would be confusing to have to call ILNumerics for some functions and our math class for others.

Mar 20, 2011 at 6:51 AM

I also vote for (3), since it would make it easier for the user to access the necessary functions.