Creating a base class for dbleCHOL, floatCHOL etc

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Creating a base class for dbleCHOL, floatCHOL etc

PrasannaKumar Muralidharan
When looking into dbleCHOL.cc, floatCHOL.cc files I could observe there was lot of common code. Is it possible to create a base class and implement common functions there? Is it possible to extend this to other operations (like dbleLU, floatLU etc)?

Before changing the code I wanted to know if there was any reason for doing things in the current way. I think there must be some reason.

Thanks,
PrasannaKumar
Reply | Threaded
Open this post in threaded view
|

Re: Creating a base class for dbleCHOL, floatCHOL etc

Jordi Gutiérrez Hermoso-2
On Sun, 2014-07-13 at 18:09 +0530, PrasannaKumar Muralidharan wrote:
> Before changing the code I wanted to know if there was any reason
> for doing things in the current way. I think there must be some
> reason.

The reason is that copy-pasting code is easier and faster than writing
abstractions that avoid code duplication. And "working" is better than
"perfect".

I'm all in favour of doing the extra work that removes code
duplication. If you're in the mood to do this, there are many, *many*
places in the Octave code where it can be done.

- Jordi G. H.



Reply | Threaded
Open this post in threaded view
|

Re: Creating a base class for dbleCHOL, floatCHOL etc

David Bateman-2


> Le 14 juil. 2014 à 00:43, Jordi Gutiérrez Hermoso <[hidden email]> a écrit :
>
>> On Sun, 2014-07-13 at 18:09 +0530, PrasannaKumar Muralidharan wrote:
>> Before changing the code I wanted to know if there was any reason
>> for doing things in the current way. I think there must be some
>> reason.
>
> The reason is that copy-pasting code is easier and faster than writing
> abstractions that avoid code duplication. And "working" is better than
> "perfect".
>
> I'm all in favour of doing the extra work that removes code
> duplication. If you're in the mood to do this, there are many, *many*
> places in the Octave code where it can be done.
>
> - Jordi G. H.
>
>
>

In fact for about 80% of the float code I used a cheap and nasty perl script to
write float versions from the double versions automatically. So there is a lottttttttt of duplication and this is probably just one small example

D.
Reply | Threaded
Open this post in threaded view
|

Re: Creating a base class for dbleCHOL, floatCHOL etc

PrasannaKumar Muralidharan
I will try to find out where code is duplicated and see if it can be reduced.

Thanks,
PrasannaKumar