Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Refactoring 4 Matlab

Subject: Refactoring 4 Matlab

From: Sander Aerts

Date: 5 Feb, 2010 08:52:05

Message: 1 of 35

Hello,

I was wondering why there are no refactoring tools for matlab? When i look it up on the internet i see lot's of posts of people dying to get their hands on it. There is an elementry find-replace (ctrl+H) tool in the editor but this does not work across multiple files, thus making life harder on us all. The find files feature is usefull for finding more occurances of a name, but does not include a replace functionality, thus making it (yet again) not as usefull as could be.

I cannot imagine that simple features such as selecting code and extracting a new mfile, for example, can be so hard to implement. It's not that i expect miracles here, but a minor refactoring functionality would make my work much more pleasant and it would also speed it up big time.

Thanks

Sander

Subject: Refactoring 4 Matlab

From: Steven Lord

Date: 5 Feb, 2010 13:57:24

Message: 2 of 35


"Sander Aerts" <remove.this.sander.aerts@be.atlascopco.com> wrote in message
news:hkgm7l$ms7$1@fred.mathworks.com...
> Hello,
>
> I was wondering why there are no refactoring tools for matlab?

Can you share _your_ definition for "refactoring"? Many people have many
different definitions for what qualifies as a refactoring and what doesn't.

> When i look it up on the internet i see lot's of posts of people dying to
> get their hands on it. There is an elementry find-replace (ctrl+H) tool in
> the editor but this does not work across multiple files, thus making life
> harder on us all. The find files feature is usefull for finding more
> occurances of a name, but does not include a replace functionality, thus
> making it (yet again) not as usefull as could be.

Those sound like reasonable enhancement requests. You should contact
Technical Support and ask them to enter them into the enhancement database.
When you do that, if you can offer some examples of how specifically those
features would have helped you in your work that would serve as excellent
motivation to include in the enhancement requests.

> I cannot imagine that simple features such as selecting code and
> extracting a new mfile, for example, can be so hard to implement.

Are you asking for a single command that does the sequence:

Select a block of code
Cut that block of code to the clipboard
Open a new file in the Editor
Paste that block of code into the new file

or do you have something more elaborate in mind when you say "extracting a
new mfile"?

> It's not that i expect miracles here, but a minor refactoring
> functionality would make my work much more pleasant and it would also
> speed it up big time.

So tell us what you want it to do. I can't promise that we'll implement
what you suggest or that we'll implement it for the next release, but we
welcome feedback and requests for new functionality.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: Refactoring 4 Matlab

From: Mike

Date: 5 Mar, 2010 03:30:29

Message: 3 of 35

On Feb 5, 4:52 pm, "Sander Aerts"
<remove.this.sander.ae...@be.atlascopco.com> wrote:
> Hello,
>
> I was wondering why there are no refactoring tools for matlab? When i look it up on the internet i see lot's of posts of people dying to get their hands on it. There is an elementryfind-replace(ctrl+H) tool in the editor but this does not work across multiple files, thus making life harder on us all. Thefindfilesfeature is usefull for finding more occurances of a name, but does not include areplacefunctionality, thus making it (yet again) not as usefull as could be.

I agree. First I'll File Files. Then I would like to replace a
string like function name, which is referenced
by man M files. How to do this easily?

Mike

Subject: Refactoring 4 Matlab

From: Mike

Date: 5 Mar, 2010 03:34:00

Message: 4 of 35

On Feb 5, 9:57 pm, "Steven Lord" <sl...@mathworks.com> wrote:
> "Sander Aerts" <remove.this.sander.ae...@be.atlascopco.com> wrote in message
>
> news:hkgm7l$ms7$1@fred.mathworks.com...
>
> > Hello,
>
> > I was wondering why there are no refactoring tools for matlab?
>
> Can you share _your_ definition for "refactoring"?  Many people have many
> different definitions for what qualifies as a refactoring and what doesn't.
>
> > When i look it up on the internet i see lot's of posts of people dying to
> > get their hands on it. There is an elementryfind-replace(ctrl+H) tool in
> > the editor but this does not work across multiple files, thus making life
> > harder on us all. Thefindfilesfeature is usefull for finding more
> > occurances of a name, but does not include areplacefunctionality, thus
> > making it (yet again) not as usefull as could be.
>
> Those sound like reasonable enhancement requests.  You should contact
> Technical Support and ask them to enter them into the enhancement database.
> When you do that, if you can offer some examples of how specifically those
> features would have helped you in your work that would serve as excellent
> motivation to include in the enhancement requests.
>
> > I cannot imagine that simple features such as selecting code and
> > extracting a new mfile, for example, can be so hard to implement.
>
> Are you asking for a single command that does the sequence:
>
> Select a block of code

Find Files

> Cut that block of code to the clipboard

list all files containing string.

> Open a new file in the Editor
> Paste that block of code into the new file

some mechanism to Find & Replaces , which is capable to go to
multiple files in found files.
Then replace. Also function name should be renamed?

Mike
>
> or do you have something more elaborate in mind when you say "extracting a
> new mfile"?
>
> > It's not that i expect miracles here, but a minor refactoring
> > functionality would make my work much more pleasant and it would also
> > speed it up big time.
>
> So tell us what you want it to do.  I can't promise that we'll implement
> what you suggest or that we'll implement it for the next release, but we
> welcome feedback and requests for new functionality.
>
> --
> Steve Lord
> sl...@mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ:http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: Refactoring 4 Matlab

From: Michael Teo

Date: 14 Sep, 2010 05:41:05

Message: 5 of 35

yes, i will like to see refactoring features in matlab.

my definition of refactoring features are:
1. renaming of function will applies to all affected dependency.
2. change of function input / output parameters will list out all the affected dependency in a TODO list.
3. moving from one package to another will applies to all affected dependency.

refactoring features are quite common in most commercial IDE such Visual Studio and open source IDE as Eclipse, Netbeans. its really improved the programmer productivity.

hope mathlab will take this suggestion seriously.

Subject: Refactoring 4 Matlab

From: Sander Aerts

Date: 14 Sep, 2010 06:38:05

Message: 6 of 35

Before I elaborate more on the refactoring topic one has to understand this in an Object Oriented context because here it is possible to detect the type of the variable, which is not possible with standard Matlab code because most variables are all doubles, cells, structs, ints... but there isn't realy much custom action going on there.

When I'm talking about refactoring I think about Eclipse because it has a great builtin refactoring functionality.
Say we have a package with a class mfile:
somepath/+fooPackage/Foo.m

If one wants to move it to another location with another name:
somepath/+otherFooPackage/Foo2.m

then this becomes a very painfull job that can be very easily automated. First let's look at how one instantiates an object of the class Foo:
myFoo = fooPackage.Foo(arg1, arg2, ...);

For the moved and renamed this would become:
myFoo = otherFooPackage.Foo2(...);

Note how this already provides a lot of information about the type of the object and it's location within packages. The refactoring tool would have to lookup all instantiations across the current (or a selected) path and change those in accordance with the new name.

So far the move and rename functionality. Another great feature would be extra "pre compiler" alerts, that actually already exist but not for the functionality I'd like to see.

Say I have an abstract super class: AbstractFoo with a few abstract properties and methods. To properly implement a subclass that isn't abstract one has to inherit from AbstractFoo and implement the properties with the matching attributes (offcourse). But this is not done as a standard... instead Matlab defines an abstract class as being abstract as long as it does not itself implement the abstract properties or methods... making it difficult to keep track of what properties you still have to implement (I'm thinking about bigger inheritance trees here...). A simple solution to this would be to create an extra class attribute: Abstract = true/false. This would allow a "precompiler" to check (for Abstract=false + inheritance from an abstract class) if all abstract properties and methods are implemented... if not you could even introduce an extra "quick fix" alt+enter solution because you
know what to implement.

I really hope that those features will appear in future releases because there is (as I believe) great potential in the OO-features of Matlab, especially in subclassing the handle class because this (in general) can greatly improve performance.

Regards,
 -Sander

Subject: Refactoring 4 Matlab

From: Steven_Lord

Date: 14 Sep, 2010 13:49:35

Message: 7 of 35



"Sander Aerts" <remove.this.sander.aerts@be.atlascopco.com> wrote in message
news:i6n58d$37q$1@fred.mathworks.com...
> Before I elaborate more on the refactoring topic one has to understand
> this in an Object Oriented context because here it is possible to detect
> the type of the variable, which is not possible with standard Matlab code
> because most variables are all doubles, cells, structs, ints... but there
> isn't realy much custom action going on there.

*snip suggestion*

Michael, Sander,

To make sure your requests are captured in our enhancement database, please
send these suggestion to Technical Support along with a brief description of
how you would make use of such a functionality when or if we implemented it.
Knowing how our users would use a piece of suggested functionality helps the
developers a great deal when designing and implementing that functionality.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Refactoring 4 Matlab

From: Ted Shaneyfelt

Date: 8 Feb, 2011 22:33:03

Message: 8 of 35

"Steven Lord" <slord@mathworks.com> wrote in message <hkh843$7m0$1@fred.mathworks.com>...
>
> "Sander Aerts" <remove.this.sander.aerts@be.atlascopco.com> wrote in message
> news:hkgm7l$ms7$1@fred.mathworks.com...
> > Hello,
> >
> > I was wondering why there are no refactoring tools for matlab?
>
> Can you share _your_ definition for "refactoring"? Many people have many
> different definitions for what qualifies as a refactoring and what doesn't.
>
> > When i look it up on the internet i see lot's of posts of people dying to
> > get their hands on it. There is an elementry find-replace (ctrl+H) tool in
> > the editor but this does not work across multiple files, thus making life
> > harder on us all. The find files feature is usefull for finding more
> > occurances of a name, but does not include a replace functionality, thus
> > making it (yet again) not as usefull as could be.
>
> Those sound like reasonable enhancement requests. You should contact
> Technical Support and ask them to enter them into the enhancement database.
> When you do that, if you can offer some examples of how specifically those
> features would have helped you in your work that would serve as excellent
> motivation to include in the enhancement requests.
>
> > I cannot imagine that simple features such as selecting code and
> > extracting a new mfile, for example, can be so hard to implement.
>
> Are you asking for a single command that does the sequence:
>
> Select a block of code
> Cut that block of code to the clipboard
> Open a new file in the Editor
> Paste that block of code into the new file
>
> or do you have something more elaborate in mind when you say "extracting a
> new mfile"?
>
> > It's not that i expect miracles here, but a minor refactoring
> > functionality would make my work much more pleasant and it would also
> > speed it up big time.
>
> So tell us what you want it to do. I can't promise that we'll implement
> what you suggest or that we'll implement it for the next release, but we
> welcome feedback and requests for new functionality.
>
> --
> Steve Lord
> slord@mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
>
The dynamic nature of the language will make it difficult, much like PHP.
See http://devzone.zend.com/article/2514
It describes well what refactoring is and how it should work along with some observations about languages like MATLAB or PHP being more troublesome than Java or CPP or ...

Subject: Refactoring 4 Matlab

From: Ted Shaneyfelt

Date: 8 Feb, 2011 22:39:06

Message: 9 of 35

"Steven Lord" <slord@mathworks.com> wrote in message <hkh843$7m0$1@fred.mathworks.com>...
>
> "Sander Aerts" <remove.this.sander.aerts@be.atlascopco.com> wrote in message
> news:hkgm7l$ms7$1@fred.mathworks.com...
> > Hello,
> >
> > I was wondering why there are no refactoring tools for matlab?
>
> Can you share _your_ definition for "refactoring"? Many people have many
> different definitions for what qualifies as a refactoring and what doesn't.
>
> > When i look it up on the internet i see lot's of posts of people dying to
> > get their hands on it. There is an elementry find-replace (ctrl+H) tool in
> > the editor but this does not work across multiple files, thus making life
> > harder on us all. The find files feature is usefull for finding more
> > occurances of a name, but does not include a replace functionality, thus
> > making it (yet again) not as usefull as could be.
>
> Those sound like reasonable enhancement requests. You should contact
> Technical Support and ask them to enter them into the enhancement database.
> When you do that, if you can offer some examples of how specifically those
> features would have helped you in your work that would serve as excellent
> motivation to include in the enhancement requests.
>
> > I cannot imagine that simple features such as selecting code and
> > extracting a new mfile, for example, can be so hard to implement.
>
> Are you asking for a single command that does the sequence:
>
> Select a block of code
> Cut that block of code to the clipboard
> Open a new file in the Editor
> Paste that block of code into the new file
>
> or do you have something more elaborate in mind when you say "extracting a
> new mfile"?
>
> > It's not that i expect miracles here, but a minor refactoring
> > functionality would make my work much more pleasant and it would also
> > speed it up big time.
>
> So tell us what you want it to do. I can't promise that we'll implement
> what you suggest or that we'll implement it for the next release, but we
> welcome feedback and requests for new functionality.
>
> --
> Steve Lord
> slord@mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
>
The dynamic nature of the language will make it difficult, much like PHP.
See http://devzone.zend.com/article/2514
It describes well what refactoring is and how it should work along with some observations about languages like MATLAB or PHP being more troublesome than Java or CPP or ...

The language is important, especially in the absence of namespaces like Java. I'm always running into problems like for example kmeans being defined by multiple authors (some routines want spider's definition, while others want the intrinsic version) and the wrong one being tried by the code. It's a kludge the way it works now and a better mechanism desperately needs to be developed to avoid name-clashes instead of having to put dirty hacks in the code to get it to work.

Subject: Refactoring 4 Matlab

From: Brad Stiritz

Date: 8 Dec, 2011 18:52:08

Message: 10 of 35

Hi everyone,

I've also been frustrated with the limited array of refactoring tools within MATLAB. Here are a couple of 3rd party utilities that I've found to be very helpful:

UltraEdit : full-featured editor aimed at programmers. Not only does it have "Find in Files" & "Replace in Files" functions, but both of these functions allow users to formulate strings using Regular Expressions..! This is a huge benefit.

Expresso : a free & very powerful Regular Expressions utility. Allows users to interactively develop & test regular expressions. A must-have for taking advantage of UltraEdit's regular expressions capabilities.

Hope this info helps,
Brad

"Ted Shaneyfelt" wrote in message <iisgma$idj$1@fred.mathworks.com>...
> "Steven Lord" <slord@mathworks.com> wrote in message <hkh843$7m0$1@fred.mathworks.com>...
> >
> > "Sander Aerts" <remove.this.sander.aerts@be.atlascopco.com> wrote in message
> > news:hkgm7l$ms7$1@fred.mathworks.com...
> > > Hello,
> > >
> > > I was wondering why there are no refactoring tools for matlab?
> >
> > Can you share _your_ definition for "refactoring"? Many people have many
> > different definitions for what qualifies as a refactoring and what doesn't.
> >
> > > When i look it up on the internet i see lot's of posts of people dying to
> > > get their hands on it. There is an elementry find-replace (ctrl+H) tool in
> > > the editor but this does not work across multiple files, thus making life
> > > harder on us all. The find files feature is usefull for finding more
> > > occurances of a name, but does not include a replace functionality, thus
> > > making it (yet again) not as usefull as could be.
> >
> > Those sound like reasonable enhancement requests. You should contact
> > Technical Support and ask them to enter them into the enhancement database.
> > When you do that, if you can offer some examples of how specifically those
> > features would have helped you in your work that would serve as excellent
> > motivation to include in the enhancement requests.
> >
> > > I cannot imagine that simple features such as selecting code and
> > > extracting a new mfile, for example, can be so hard to implement.
> >
> > Are you asking for a single command that does the sequence:
> >
> > Select a block of code
> > Cut that block of code to the clipboard
> > Open a new file in the Editor
> > Paste that block of code into the new file
> >
> > or do you have something more elaborate in mind when you say "extracting a
> > new mfile"?
> >
> > > It's not that i expect miracles here, but a minor refactoring
> > > functionality would make my work much more pleasant and it would also
> > > speed it up big time.
> >
> > So tell us what you want it to do. I can't promise that we'll implement
> > what you suggest or that we'll implement it for the next release, but we
> > welcome feedback and requests for new functionality.
> >
> > --
> > Steve Lord
> > slord@mathworks.com
> > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> >
> The dynamic nature of the language will make it difficult, much like PHP.
> See http://devzone.zend.com/article/2514
> It describes well what refactoring is and how it should work along with some observations about languages like MATLAB or PHP being more troublesome than Java or CPP or ...
>
> The language is important, especially in the absence of namespaces like Java. I'm always running into problems like for example kmeans being defined by multiple authors (some routines want spider's definition, while others want the intrinsic version) and the wrong one being tried by the code. It's a kludge the way it works now and a better mechanism desperately needs to be developed to avoid name-clashes instead of having to put dirty hacks in the code to get it to work.

Subject: Refactoring 4 Matlab

From: dpb

Date: 8 Dec, 2011 19:16:42

Message: 11 of 35

On 12/8/2011 12:52 PM, Brad Stiritz wrote:
> Hi everyone,
>
> I've also been frustrated with the limited array of refactoring tools
> within MATLAB. Here are a couple of 3rd party utilities that I've found
> to be very helpful:
>
> UltraEdit : full-featured editor aimed at programmers. Not only does it
> have "Find in Files" & "Replace in Files" functions, but both of these
> functions allow users to formulate strings using Regular Expressions..!
> This is a huge benefit.
>
> Expresso : a free & very powerful Regular Expressions utility. Allows
> users to interactively develop & test regular expressions. A must-have
> for taking advantage of UltraEdit's regular expressions capabilities.
...

Indeed...it really seems incredible to me that folks like MS, TMW, etc.,
etc., ... struggle so much to implement "real" programming-editor tools.
  I've never used the integrated editor for other than very quick
toss-off stuff; the limitations are simply too much to deal with.

I can't imagine the developers use their own tools for internal
development at any of these places...but if not, why don't they supply
the equivalent capabilities on their own or are the restrictions placed
on them really that tight that they aren't aware of what toolsets are
available????

'Tis a puzzle other than it does seem a waste of resources to keep
redeveloping the wheel so I presume the real culprit is that whoever is
responsible for the editor function isn't given the resources to really
implement yet another full programmer's editor but to make something
quick that looks pretty is the task statement.

--

Subject: Refactoring 4 Matlab

From: Rune Allnor

Date: 8 Dec, 2011 19:40:21

Message: 12 of 35

On 8 Des, 20:16, dpb <n...@non.net> wrote:

> Indeed...it really seems incredible to me that folks like MS, TMW, etc.,
> etc., ... struggle so much to implement "real" programming-editor tools.
>   I've never used the integrated editor for other than very quick
> toss-off stuff; the limitations are simply too much to deal with.
>
> I can't imagine the developers use their own tools for internal
> development at any of these places...but if not, why don't they supply
> the equivalent capabilities on their own or are the restrictions placed
> on them really that tight that they aren't aware of what toolsets are
> available????

If you look very carefully, you will find that
an awful lot of the functions supplied with matlab,
either as is or in toolboxes, are not distributed
as .m files (or evem .p files), but are 'built in'.

Which means they are probably not written in terms of
matlab code at all, but rather directly in some language
like C, C++ or fortran...

Rune

Subject: Refactoring 4 Matlab

From: dpb

Date: 8 Dec, 2011 19:52:32

Message: 13 of 35

On 12/8/2011 1:40 PM, Rune Allnor wrote:
...


> Which means they are probably not written in terms of
> matlab code at all, but rather directly in some language
> like C, C++ or fortran...

Of course. But, a lot also _are_ m-code.

But, so what? My point is that the developers surely aren't using such
brain-dead toolsets; why can't they understand to ship the features they
use w/o users begging for them (other than the obvious one of it takes
resources from somewhere else, of course, to do so)?

I've always been amazed at MS even more than TMW but the same idea
holds. VisualStudio as a tool to write/support the MS code base??? You
_must_ be kidding!!!! And so, that's the best they can ship w/ their
compilers????

--

Subject: Refactoring 4 Matlab

From: Brad Stiritz

Date: 8 Dec, 2011 20:07:08

Message: 14 of 35

Hi dpb,

Thanks for your comments..

> I've never used the integrated editor for other than very quick toss-off stuff; the limitations are simply too much to deal with.

I've actually gotten very good mileage out of the integrated editor. Over time, TMW has added quite a few great features. For example, in the current R2011b, there's an auto-replace tooltip prompt that appears if you start editing a variable name that's being assigned to. If you type Ctrl-Enter, it replaces all occurrences of the old name, in the current file, with the new name. This is really a step in the right direction!

>I presume the real culprit is that whoever is responsible for the editor function isn't given the resources to really implement yet another full programmer's editor but to make something
quick that looks pretty is the task statement.

I have to agree with you, this seems like the simplest & most obvious explanation of the facts. Keep in mind that the company founder is still at the helm & he's almost certainly quite used to what we would consider extremely primitive editing environments. He's also not a young man by any means & so may not be able to identify so easily with the younger generation(s) who have grown up with sophisticated tools.

Also, the appeal of "pretty" UIs should never be underestimated. TMW may be very rationally deciding they can't take the risk of scaring new users off with a highly complex Editor UI. It's simply a fact that the UIs of professional-grade content-creation software, whether UltraEdit, Photoshop, SolidWorks, etc etc present ever-steeper learning curves to new users. IMHO, this is why we've seen "light", stripped-down versions such as Photoshop Elements appear in the market.

Getting back to our topic, the MATLAB Editor, we seem to agree that it's essentially a "light" version of what it should be. Probably what TMW should do is offer an "Advanced Editor" as a paid add-on. This would satisfy their business-model objectives as well as the needs of professional-level MATLAB developers.

Brad

dpb <none@non.net> wrote in message <jbr2en$2r8$1@speranza.aioe.org>...
> On 12/8/2011 12:52 PM, Brad Stiritz wrote:
> > Hi everyone,
> >
> > I've also been frustrated with the limited array of refactoring tools
> > within MATLAB. Here are a couple of 3rd party utilities that I've found
> > to be very helpful:
> >
> > UltraEdit : full-featured editor aimed at programmers. Not only does it
> > have "Find in Files" & "Replace in Files" functions, but both of these
> > functions allow users to formulate strings using Regular Expressions..!
> > This is a huge benefit.
> >
> > Expresso : a free & very powerful Regular Expressions utility. Allows
> > users to interactively develop & test regular expressions. A must-have
> > for taking advantage of UltraEdit's regular expressions capabilities.
> ...
>
> Indeed...it really seems incredible to me that folks like MS, TMW, etc.,
> etc., ... struggle so much to implement "real" programming-editor tools.
> I've never used the integrated editor for other than very quick
> toss-off stuff; the limitations are simply too much to deal with.
>
> I can't imagine the developers use their own tools for internal
> development at any of these places...but if not, why don't they supply
> the equivalent capabilities on their own or are the restrictions placed
> on them really that tight that they aren't aware of what toolsets are
> available????
>
> 'Tis a puzzle other than it does seem a waste of resources to keep
> redeveloping the wheel so I presume the real culprit is that whoever is
> responsible for the editor function isn't given the resources to really
> implement yet another full programmer's editor but to make something
> quick that looks pretty is the task statement.
>
> --

Subject: Refactoring 4 Matlab

From: Rune Allnor

Date: 8 Dec, 2011 20:09:01

Message: 15 of 35

On 8 Des, 20:52, dpb <n...@non.net> wrote:
> On 12/8/2011 1:40 PM, Rune Allnor wrote:
> ...
>
> > Which means they are probably not written in terms of
> > matlab code at all, but rather directly in some language
> > like C, C++ or fortran...
>
> Of course.  But, a lot also _are_ m-code.
>
> But, so what?  My point is that the developers surely aren't using such
> brain-dead toolsets; why can't they understand to ship the features they
> use w/o users begging for them (other than the obvious one of it takes
> resources from somewhere else, of course, to do so)?

It might be a case of 'do what I say, not as I do.'
Or simply due to the fact that matlab never was
intended for serious work, but rather is a rapid
prototyping tool. Once you get to the serious
stuff one should switch to the serious tools.

> I've always been amazed at MS even more than TMW but the same idea
> holds.  VisualStudio as a tool to write/support the MS code base???  You
> _must_ be kidding!!!!  And so, that's the best they can ship w/ their
> compilers????

MS has ~100% market share, so for that reason alone
one can not ignore what they do. Just don't confuse
that for their products being good, or even half-reasonable...

Rune

Subject: Refactoring 4 Matlab

From: Loren Shure

Date: 8 Dec, 2011 20:12:51

Message: 16 of 35


"dpb" <none@non.net> wrote in message news:jbr4ht$81e$1@speranza.aioe.org...
> On 12/8/2011 1:40 PM, Rune Allnor wrote:
> ...
>
>
>> Which means they are probably not written in terms of
>> matlab code at all, but rather directly in some language
>> like C, C++ or fortran...
>
> Of course. But, a lot also _are_ m-code.
>
> But, so what? My point is that the developers surely aren't using such
> brain-dead toolsets; why can't they understand to ship the features they
> use w/o users begging for them (other than the obvious one of it takes
> resources from somewhere else, of course, to do so)?
>
> I've always been amazed at MS even more than TMW but the same idea holds.
> VisualStudio as a tool to write/support the MS code base??? You _must_ be
> kidding!!!! And so, that's the best they can ship w/ their compilers????
>
> --


I certainly can't speak for all developers at MathWorks and I DO know that
some use emacs. Many developers write code in MATLAB (not C++, Java, ...)
use the current editor and are constantly asking for more features, and I
would say it's a fairly healthy number that does so.

--
Loren
http://blogs.mathworks.com/loren/
http://www.mathworks.com/matlabcentral/

Subject: Refactoring 4 Matlab

From: dpb

Date: 8 Dec, 2011 20:49:02

Message: 17 of 35

On 12/8/2011 2:07 PM, Brad Stiritz wrote:
> Hi dpb,
>
> Thanks for your comments..
>
>> I've never used the integrated editor for other than very quick
>> toss-off stuff; the limitations are simply too much to deal with.
>
> I've actually gotten very good mileage out of the integrated editor.
> Over time, TMW has added quite a few great features. For example, in the
> current R2011b, there's an auto-replace tooltip prompt that appears if
> you start editing a variable name that's being assigned to. If you type
> Ctrl-Enter, it replaces all occurrences of the old name, in the current
> file, with the new name. This is really a step in the right direction!
...
> I have to agree with you, this seems like the simplest & most obvious
> explanation of the facts. Keep in mind that the company founder is still
> at the helm & he's almost certainly quite used to what we would consider
> extremely primitive editing environments. He's also not a young man by
> any means & so may not be able to identify so easily with the younger
> generation(s) who have grown up with sophisticated tools.

...

A) I have a date release of Matlab so don't have access to the latest
updates. I know they've added quite a lot that is ML-specific so there
is a good reason to use an integrated editor in the product. Those
aren't in my case so I still use an external editor that has the
idisosyncracies I know (and have added via macros) as opposed to the
builtin one that I don't (know the idiosyncracies of as well, that is :) )

B) Hey, be careful of audience when talking of Cleve and we old codgers
-- he's _barely_ older than I and I'm quite sure like me he has his own
very specific editor preferences. I don't know his actual
machine-history but certainly there were very capable editors in the
days of yore albeit not wysisyg we were very adept in such things as
TECO or others, depending on the environment in which one worked.

--

Subject: Refactoring 4 Matlab

From: dpb

Date: 8 Dec, 2011 20:53:56

Message: 18 of 35

On 12/8/2011 2:12 PM, Loren Shure wrote:
...

> I certainly can't speak for all developers at MathWorks and I DO know
> that some use emacs. Many developers write code in MATLAB (not C++,
> Java, ...) use the current editor and are constantly asking for more
> features, and I would say it's a fairly healthy number that does so.

That's pretty much what I would have expected (and hopefully indicated).

I tend to write in hyperbole regarding features and also that my dated
version of Matlab is quite a far cry from what they've gotten
implemented since I retired and could no longer afford to update licenses.

As noted in the other response, there's a lot of "since it doesn't work
like _my_ favorite editor that I've customized over 30-something years,
it's all hooey" in my writing, too... :)

But, anything to drive features can't be all bad... :)

--

Subject: Refactoring 4 Matlab

From: dpb

Date: 8 Dec, 2011 20:57:59

Message: 19 of 35

On 12/8/2011 2:09 PM, Rune Allnor wrote:
...

> Or simply due to the fact that matlab never was
> intended for serious work, but rather is a rapid
> prototyping tool. Once you get to the serious
> stuff one should switch to the serious tools.
...

While some truth in that initially, what with increased cpu power any
limitations on performance are generally solved by pure horsepower.

We disagree and will continue on this point so there's no point in
arguing about it--the tool is plenty serious enough for a large number
of applications.

There are some areas that need more certainly, but many are doing just
fine w/ Matlab, thank you for some very serious stuff. :)

--

Subject: Refactoring 4 Matlab

From: Brad Stiritz

Date: 8 Dec, 2011 21:03:08

Message: 20 of 35

Hi dpb,

Regarding your retort..

> Hey, be careful of audience when talking of Cleve and we old codgers -- he's _barely_ older than I and I'm quite sure like me he has his own very specific editor preferences. I don't know his actual machine-history but certainly there were very capable editors in the days of yore albeit not wysisyg we were very adept in such things as TECO or others, depending on the environment in which one worked.

I'm sorry, I certainly didn't mean any disrespect. I was simply referring to commonly known facts about the passage of time (e.g. tech. functionality improves) & observed differences between generations (e.g. people develop mindsets over time that can become out-of-sync with contemporary habits) ;)

dpb <none@non.net> wrote in message <jbr7rr$fr5$1@speranza.aioe.org>...
> On 12/8/2011 2:07 PM, Brad Stiritz wrote:
> > Hi dpb,
> >
> > Thanks for your comments..
> >
> >> I've never used the integrated editor for other than very quick
> >> toss-off stuff; the limitations are simply too much to deal with.
> >
> > I've actually gotten very good mileage out of the integrated editor.
> > Over time, TMW has added quite a few great features. For example, in the
> > current R2011b, there's an auto-replace tooltip prompt that appears if
> > you start editing a variable name that's being assigned to. If you type
> > Ctrl-Enter, it replaces all occurrences of the old name, in the current
> > file, with the new name. This is really a step in the right direction!
> ...
> > I have to agree with you, this seems like the simplest & most obvious
> > explanation of the facts. Keep in mind that the company founder is still
> > at the helm & he's almost certainly quite used to what we would consider
> > extremely primitive editing environments. He's also not a young man by
> > any means & so may not be able to identify so easily with the younger
> > generation(s) who have grown up with sophisticated tools.
>
> ...
>
> A) I have a date release of Matlab so don't have access to the latest
> updates. I know they've added quite a lot that is ML-specific so there
> is a good reason to use an integrated editor in the product. Those
> aren't in my case so I still use an external editor that has the
> idisosyncracies I know (and have added via macros) as opposed to the
> builtin one that I don't (know the idiosyncracies of as well, that is :) )
>
> B) Hey, be careful of audience when talking of Cleve and we old codgers
> -- he's _barely_ older than I and I'm quite sure like me he has his own
> very specific editor preferences. I don't know his actual
> machine-history but certainly there were very capable editors in the
> days of yore albeit not wysisyg we were very adept in such things as
> TECO or others, depending on the environment in which one worked.
>
> --

Subject: Refactoring 4 Matlab

From: Rune Allnor

Date: 8 Dec, 2011 21:32:30

Message: 21 of 35

On 8 Des, 21:57, dpb <n...@non.net> wrote:
> On 12/8/2011 2:09 PM, Rune Allnor wrote:
> ...
>
> > Or simply due to the fact that matlab never was
> > intended for serious work, but rather is a rapid
> > prototyping tool. Once you get to the serious
> > stuff one should switch to the serious tools.
>
> ...
>
> While some truth in that initially, what with increased cpu power any
> limitations on performance are generally solved by pure horsepower.

And that's the problem.

I used to do seismic processing for an oil company.
The laptop I use for writing emails these days has
comparable performance to the mainframe we did
seismic processing with, som 15 years ago.

I find it's a total waste having this much computational
power at one's disposal, and still not being able to do
much more with the PC than with an old-fashioned
typewriter.

If people only knew what the present-day PC is *really*
capable of...

Rune

Subject: Refactoring 4 Matlab

From: Steven_Lord

Date: 8 Dec, 2011 21:39:41

Message: 22 of 35



"dpb" <none@non.net> wrote in message news:jbr851$gli$1@speranza.aioe.org...
> On 12/8/2011 2:12 PM, Loren Shure wrote:
> ...
>
>> I certainly can't speak for all developers at MathWorks and I DO know
>> that some use emacs. Many developers write code in MATLAB (not C++,
>> Java, ...) use the current editor and are constantly asking for more
>> features, and I would say it's a fairly healthy number that does so.
>
> That's pretty much what I would have expected (and hopefully indicated).

Speaking from personal experience, I write a significant amount of MATLAB
code and the most common tool I use to do so is the MATLAB Editor.
[Occasionally I use FOPEN/FPRINTF/FCLOSE to write a script, function, or
class programmatically, but that's fairly rare.] Most of the MATLAB code
that I post to CSSM has (if it's longer than one or two lines) goes through
the Editor first. I've learned (the hard way) better than posting code I
haven't executed and/or inspected via Code Analyzer in the Editor :)

> I tend to write in hyperbole regarding features and also that my dated
> version of Matlab is quite a far cry from what they've gotten implemented
> since I retired and could no longer afford to update licenses.
>
> As noted in the other response, there's a lot of "since it doesn't work
> like _my_ favorite editor that I've customized over 30-something years,
> it's all hooey" in my writing, too... :)

That's true. But there have also been some suggestions in this thread that
sound like reasonable ways to improve the Editor in general. As I stated
when this thread started in February of last year, suggesting a feature here
on CSSM is good, but submitting it to Technical Support (ideally with a
description of how it would improve your workflow and productivity to
provide extra motivation) is the best way to ensure it gets into the
enhancement database. Submitting it that way doesn't guarantee that we'll
implement it right away (or ever) but it does make sure it shows up on our
radar.

You can even (with a sufficiently recent version of MATLAB, sorry dpb)
submit the enhancement request from within MATLAB, so that if you think of a
good idea you can send it to Support while it's fresh in your mind.

http://www.mathworks.com/help/techdoc/rn/bsq2ywm-1.html#bsucc1d

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Refactoring 4 Matlab

From: dpb

Date: 8 Dec, 2011 22:13:30

Message: 23 of 35

On 12/8/2011 3:32 PM, Rune Allnor wrote:
> On 8 Des, 21:57, dpb<n...@non.net> wrote:
...

>> While some truth in that initially, what with increased cpu power any
>> limitations on performance are generally solved by pure horsepower.
>
> And that's the problem.

No, that's the solution to getting something done now as opposed to
waiting for the coders to finish in the "real" toolset.

> I used to do seismic processing for an oil company.
> The laptop I use for writing emails these days has
> comparable performance to the mainframe we did
> seismic processing with, som 15 years ago.
>
> I find it's a total waste having this much computational
> power at one's disposal, and still not being able to do
> much more with the PC than with an old-fashioned
> typewriter.

As far as the user i/o, one's pretty much limited by how fast a good
typist can go but there's no doubt the ability within wordprocessors
means retyping mats is gone the way of the dodo bird while folks in turn
spend time w/ visual content instead.

Whether it's a good tradeoff or not is probably in the eye of the
beholder for the most part. Certainly expectations of appearance of
documents have changed drastically since I began writing technical
reports in the days of yore.

I came from the (commercial) nuclear power arena and the "worldclass"
mainframes of the era weren't up to much above the initial XT

<http://www.dvq.com/ads/philco_sa_12_60.jpg>
<http://ed-thelen.org/comp-hist/BRL61-0755.jpg>

When we moved later to the CDC Cybers performance went up factor of 2-5X
and Cray had another level a notch higher but weren't in the $$ mix much
outside the national lab environments. We bought some time for a few
real time-crunch instances, but only in dire emergency; otherwise
everything ran in-house.

I went from that environment to the other extreme of embedded processors
for a period of roughly 10-15 years and by came back the world was VAX
and the AT-class PC and the landscape was totally different, indeed.

> If people only knew what the present-day PC is *really*
> capable of...
...

Those that are doing "real" computing are quite aware, I'd say.

--

Subject: Refactoring 4 Matlab

From: dpb

Date: 8 Dec, 2011 22:26:03

Message: 24 of 35

On 12/8/2011 3:39 PM, Steven_Lord wrote:
...

>> I tend to write in hyperbole regarding features and also that my dated
>> version of Matlab is quite a far cry from what they've gotten
>> implemented since I retired and could no longer afford to update
>> licenses.
>>
>> As noted in the other response, there's a lot of "since it doesn't
>> work like _my_ favorite editor that I've customized over 30-something
>> years, it's all hooey" in my writing, too... :)
>
> That's true. But there have also been some suggestions in this thread
> that sound like reasonable ways to improve the Editor in general. As I
> stated when this thread started in February of last year, suggesting a
> feature here on CSSM is good, but submitting it to Technical Support
> (ideally with a description of how it would improve your workflow and
> productivity to provide extra motivation) is the best way to ensure it
> gets into the enhancement database. Submitting it that way doesn't
> guarantee that we'll implement it right away (or ever) but it does make
> sure it shows up on our radar.
>
> You can even (with a sufficiently recent version of MATLAB, sorry dpb)
> submit the enhancement request from within MATLAB, so that if you think
> of a good idea you can send it to Support while it's fresh in your mind.
>

> > http://www.mathworks.com/help/techdoc/rn/bsq2ywm-1.html#bsucc1d

Hmmm....I should have figured this was an old thread resurrected; only
Brad's response showed up out of the blue on my newsserver and as I was
sitting around today w/ not much to do it caught my fancy...

Seems like the last time I tried to submit an enhancement or report a
bug to ensure it had gotten repaired in later version(s) that not having
a current support contract it tossed me out on my ear.

Is that supposed to be or is that so? I know for some reason I'm locked
out of seeing even the documentation online for my older versions which
seems counterproductive in engendering loyalty. All it did was pxxx me
off even more about the high cost, etc., etc., etc., ... to ensure don't
upgrade.

--

Subject: Refactoring 4 Matlab

From: Rune Allnor

Date: 8 Dec, 2011 22:28:07

Message: 25 of 35

On 8 Des, 23:13, dpb <n...@non.net> wrote:
> On 12/8/2011 3:32 PM, Rune Allnor wrote:> On 8 Des, 21:57, dpb<n...@non.net>  wrote:


> > If people only knew what the present-day PC is *really*
> > capable of...
>
> ...
>
> Those that are doing "real" computing are quite aware, I'd say.

As of right now - maybe.

In a few years time: No.

The problem is that no one teach programming anymore.
Students are left with matlab, because it is 'easy'
both to teach (students can get started in minutes)
and to learn (students gets results in mere minutes).

The problem is that few if any go further, to learn
the efficient - not easy! - stuff.

Rune

Subject: Refactoring 4 Matlab

From: dpb

Date: 8 Dec, 2011 22:32:57

Message: 26 of 35

On 12/8/2011 4:28 PM, Rune Allnor wrote:
...

> The problem is that no one teach programming anymore.
> Students are left with matlab, because it is 'easy'
> both to teach (students can get started in minutes)
> and to learn (students gets results in mere minutes).
>
> The problem is that few if any go further, to learn
> the efficient - not easy! - stuff.
...

A) Nonsense

B) Only the few are really into "serious" computing where it will ever
matter. The bulk are after results. Those who have need will continue
to push the envelope.

--

Subject: Refactoring 4 Matlab

From: Rune Allnor

Date: 8 Dec, 2011 22:45:01

Message: 27 of 35

On 8 Des, 23:32, dpb <n...@non.net> wrote:
> On 12/8/2011 4:28 PM, Rune Allnor wrote:
> ...
>
> > The problem is that no one teach programming anymore.
> > Students are left with matlab, because it is 'easy'
> > both to teach (students can get started in minutes)
> > and to learn (students gets results in mere minutes).
>
> > The problem is that few if any go further, to learn
> > the efficient - not easy! - stuff.
>
> ...
>
> A) Nonsense
>
> B) Only the few are really into "serious" computing where it will ever
> matter.  The bulk are after results.  Those who have need will continue
> to push the envelope.

You might be surprised.

As I understand it, you are retired? If so, you might
not be quite up dated on the implications of inefficient
computer systems.

Over the past few years I have worked for at least two
companies that ended up in serious trouble because of
inefficient computer systems:

- One did data processing using matlab, where the turn-
around time for the processed data were such that the
company failed delivery deadlines. The company was the
victim of a hostile take-over.

- The other was an industrial manufacturer where the
MES system (to track production) was desigend to be
operated in such ways that it took longer for an
operator to extract the data from the databases than
writing the numbers with pen and paper. The company
went out of business.

When one relies on computer systems for business-critical
tasks, no matter what types of tasks, *any* computer
operation is critical.

There is no room for matlab as application platform
unders such circumstances. As a R&D platform matlab
is second to none. Use it as application platform at
your peril.

Rune

Subject: Refactoring 4 Matlab

From: dpb

Date: 9 Dec, 2011 00:16:18

Message: 28 of 35

On 12/8/2011 4:45 PM, Rune Allnor wrote:
> On 8 Des, 23:32, dpb<n...@non.net> wrote:
>> On 12/8/2011 4:28 PM, Rune Allnor wrote:
>> ...
>>
>>> The problem is that no one teach programming anymore.
>>> Students are left with matlab, because it is 'easy'
>>> both to teach (students can get started in minutes)
>>> and to learn (students gets results in mere minutes).
>>
>>> The problem is that few if any go further, to learn
>>> the efficient - not easy! - stuff.
>>
>> ...
>>
>> A) Nonsense
>>
>> B) Only the few are really into "serious" computing where it will ever
>> matter. The bulk are after results. Those who have need will continue
>> to push the envelope.
>
> You might be surprised.

Not likely...I've been around the block or off the turnip truck too many
times already to have much be surprising any longer. :)

> As I understand it, you are retired? If so, you might
> not be quite up dated on the implications of inefficient
> computer systems.
>
> Over the past few years I have worked for at least two
> companies that ended up in serious trouble because of
> inefficient computer systems:
>
...[war stories elided for brevity]...

> When one relies on computer systems for business-critical
> tasks, no matter what types of tasks, *any* computer
> operation is critical.

Certainly; that wasn't the point.

> There is no room for matlab as application platform
> unders such circumstances. As a R&D platform matlab
> is second to none. Use it as application platform at
> your peril.
...

OTOH, I have similar war stories can tell of the companies that failed
to meet deadlines while the programmers were trying to create the needed
application in one of the "real" systems languages of which you speak.

We bailed them out by using Forth; another rapid-development language
many denigrate as unsuitable for anything.

The moral of the story is that folks have to make the proper decision at
the proper time as to which particular technology is correct. Those
decisions and the results thereof can favor either result depending on
several factors including the actual application and the expertise of
the people available to implement it.

An generalization to a universal conclusion is, in general, overly
general... :)

--

Subject: Refactoring 4 Matlab

From: Rune Allnor

Date: 9 Dec, 2011 01:06:51

Message: 29 of 35

On 9 Des, 01:16, dpb <n...@non.net> wrote:
> On 12/8/2011 4:45 PM, Rune Allnor wrote:


> OTOH, I have similar war stories can tell of the companies that failed
> to meet deadlines while the programmers were trying to create the needed
> application in one of the "real" systems languages of which you speak.

Either incompetent programmers, poor managment that
did not see the problem ad prepare for the perdicament;
most likely both.

> We bailed them out by using Forth; another rapid-development language
> many denigrate as unsuitable for anything.

Which is true. The only places I have seen mentioned,
is by people well into retirement, age 75 +/-.

> The moral of the story is that folks have to make the proper decision at
> the proper time as to which particular technology is correct.  Those
> decisions and the results thereof can favor either result depending on
> several factors including the actual application and the expertise of
> the people available to implement it.

That expertise is non-existant where matlab is a
tool of choise. Even the competence necessary to
make the comparision is wanting, as very few people
are exposed to anything but matlab these days.

> An generalization to a universal conclusion is, in general, overly
> general... :)

If that was the case, I'd agree. The problem is that
very basic insights are lacking: Demanding tasks require
both proper tools, as well as skills and competence
to utilize those tools.

Rune

Subject: Refactoring 4 Matlab

From: dpb

Date: 9 Dec, 2011 01:24:42

Message: 30 of 35

On 12/8/2011 3:03 PM, Brad Stiritz wrote:
> Hi dpb,
>
> Regarding your retort..
>
>> Hey, be careful of audience when talking of Cleve and we old codgers
>> -- he's _barely_ older than I and I'm quite sure like me he has his
>> own very specific editor preferences. I don't know his actual
>> machine-history but certainly there were very capable editors in the
>> days of yore albeit not wysisyg we were very adept in such things as
>> TECO or others, depending on the environment in which one worked.
>
> I'm sorry, I certainly didn't mean any disrespect. I was simply
> referring to commonly known facts about the passage of time (e.g. tech.
> functionality improves) & observed differences between generations (e.g.
> people develop mindsets over time that can become out-of-sync with
> contemporary habits) ;)
...

Sorry, the intended (several) smiles in the previous were accidently
overlooked and certainly I didn't take it as disrespectful.

I do think it's a little overly simplistic a viewpoint and while the
generalizations may be more or less true in a broad population but I
don't think they hold up terribly well necessarily in specifics--as is
generally so w/ generalizations as I just finished gently reminding Rune
(again) upthread... :)

I'll amplify that I'm terribly selective about which technologies I've
continued to embrace wholeheartedly and others I just can't say as I
give a rat's patootie about.

I retired from the technical consulting game and returned to the family
farm when Dad passed away very unexpectedly. The use of field monitors,
gps, control systems that place a seed out of the planter at +/-1/8"
spacing including ensuring it has a specific orientation when it hits
the ground, etc., are routine. We have complete integration of
production data from soil testing to chemical and fertilizer application
to planting to yield data all tied together automagically and mapped to
the field coordinates. I can turn a $300k planter loose at one end of a
mile row and not touch it again until a turn-around at the other end and
then set it back on autosteer with 3" of the exact spacing for the next
row on a 16-row planter (at 32" row spacing that's a toolbar over 40'
wide running at roughly 8 mph). Planting at that rate covers right at
40 acres/hour so can plant a full quarter section in a morning. When I
was a young lad we ran 4-row planter at maybe 3.5 mph and that same 40A
would take a full 8-hr day or almost a week on the quarter. Technology
definitely has its place. :)

OTOH, I agree w/ Bjarne Stroustrup's plaint of "I have always wished my
computer would be as easy to use as my telephone. My wish has come
true--I no longer know how to use my telephone." in spades for much of
the consumer electronics a doodads. It depends on whether I actually
have a use for it and I really don't have any interest in so much of
what is the popular usage so I do ignore it almost in its entirety.

--

Subject: Refactoring 4 Matlab

From: dpb

Date: 9 Dec, 2011 01:40:58

Message: 31 of 35

On 12/8/2011 7:06 PM, Rune Allnor wrote:
...

>> We bailed them out by using Forth; another rapid-development language
>> many denigrate as unsuitable for anything.
>
> Which is true. The only places I have seen mentioned,
> is by people well into retirement, age 75 +/-.
...

Your experience is just in the wrong area(s)...

I know of yet many current applications in embedded systems and sensing
(specifics of which are proprietary).

Later generations of the particular (robotics) systems of which I spoke
are still in production and have core functionality built on the same
initial code base.

And you're not aware of how Sun (amongst others) boot ROMs work? :)

--

Subject: Refactoring 4 Matlab

From: Brad Stiritz

Date: 9 Dec, 2011 03:08:08

Message: 32 of 35

Steven,

Thanks for your comments.

>Speaking from personal experience, I write a significant amount of MATLAB code and the most common tool I use to do so is the MATLAB Editor.

I second your choice. I personally created & manage an O-O framework of pure-MATLAB code that runs into the hundreds of files. Bug-tolerance is essentially zero. I find the MATLAB Editor to be extremely good at static & dynamic debugging & I therefore use it exclusively for writing & testing code.

However, the topic of this thread is refactoring, & as I suggested in my original posting above (message #10), MATLAB is unfortunately weak in its ability to refactor across multiple files. For this reason, I've found the 3rd party apps I mentioned indispensable.

Here's one common refactoring example that I've had to deal with numerous times : renaming an identifier for clarity (either whole or prefix/suffix) that occurs dozens or hundreds of times in a MATLAB project. Yet due to previous refactoring work that's not complete, I have a lot of still-working code on my path which I want to exclude from this renaming operation.

This type of large-scale, contingent software refactoring simply can't be done efficiently solely within MATLAB. Maybe this just means I'm part of a small percentage of users who are doing larger-scale projects..?

In any case, I did actually submit my idea (even before you suggested it ;) for an Advanced Editor Add-On, via the in-app "Submit a Support Request" functionality..

Brad

"Steven_Lord" <slord@mathworks.com> wrote in message <jbraqt$a34$1@newscl01ah.mathworks.com>...
>
>
> "dpb" <none@non.net> wrote in message news:jbr851$gli$1@speranza.aioe.org...
> > On 12/8/2011 2:12 PM, Loren Shure wrote:
> > ...
> >
> >> I certainly can't speak for all developers at MathWorks and I DO know
> >> that some use emacs. Many developers write code in MATLAB (not C++,
> >> Java, ...) use the current editor and are constantly asking for more
> >> features, and I would say it's a fairly healthy number that does so.
> >
> > That's pretty much what I would have expected (and hopefully indicated).
>
> Speaking from personal experience, I write a significant amount of MATLAB
> code and the most common tool I use to do so is the MATLAB Editor.
> [Occasionally I use FOPEN/FPRINTF/FCLOSE to write a script, function, or
> class programmatically, but that's fairly rare.] Most of the MATLAB code
> that I post to CSSM has (if it's longer than one or two lines) goes through
> the Editor first. I've learned (the hard way) better than posting code I
> haven't executed and/or inspected via Code Analyzer in the Editor :)
>
> > I tend to write in hyperbole regarding features and also that my dated
> > version of Matlab is quite a far cry from what they've gotten implemented
> > since I retired and could no longer afford to update licenses.
> >
> > As noted in the other response, there's a lot of "since it doesn't work
> > like _my_ favorite editor that I've customized over 30-something years,
> > it's all hooey" in my writing, too... :)
>
> That's true. But there have also been some suggestions in this thread that
> sound like reasonable ways to improve the Editor in general. As I stated
> when this thread started in February of last year, suggesting a feature here
> on CSSM is good, but submitting it to Technical Support (ideally with a
> description of how it would improve your workflow and productivity to
> provide extra motivation) is the best way to ensure it gets into the
> enhancement database. Submitting it that way doesn't guarantee that we'll
> implement it right away (or ever) but it does make sure it shows up on our
> radar.
>
> You can even (with a sufficiently recent version of MATLAB, sorry dpb)
> submit the enhancement request from within MATLAB, so that if you think of a
> good idea you can send it to Support while it's fresh in your mind.
>
> http://www.mathworks.com/help/techdoc/rn/bsq2ywm-1.html#bsucc1d
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

Subject: Refactoring 4 Matlab

From: Sander Aerts

Date: 10 Dec, 2011 12:43:08

Message: 33 of 35

Hi Brad,

I think we are more or less in the same line of programming duty here, I too have created and manage an OO framework of pure matlab code. The ML-editor is also the only UI i use to write code, but over the past two years it seems as if I have given up hope.

Given the nature of how matlab works with data and has no type identification it is clear that refactoring tools are not so easy. However, the new OO syntax must certainly allow the progammers to incorporate more funtionality such better class outline... I cannot imagine that programmers who work on the matlab UI have never used an editor as Eclipse that ships with excelent refactoring tools?

There is a function on the file exchange called filegrep.m, perhaps it wouldn't be a bad idea to implement this (in the more elegant and improved version) by default in the ML-editor? It is basically a find and replace tool accross mutiple files, but it lacks the functionality as in regexprep... Perhaps your third party tools are much more efficient at this, i'll have to try them out.

@Loren: I have indeed encountered people using emacs as an imporved editor... Shame on me that I haven't been able to work a lot on unix systems, but it did not come naturally to me and i soon gave up hope on emac :-) I think it is because in all these years i have grown accustomed to my short keys.

@Steve: I too have posted something about the refactoring as an improvement and indeed I have seen the editor becoming better, especially in the R011a release... i am a fan of shift+enter to replace all occurences of a name in a confined 'base' (dont really know how to express this better). But, (always a but) they asked me to sum up all functions i wanted...

I also believe that we should be looking at a bigger picture. Refactoring tools are not limited to a single function or even a file. In the case of Brad and myself where you working with a lot of OO code that interacts with one another it can be hard to keep track of classes, their methods, inheritance trees....

How many times have i tried to instantiate a newly designed class only to discover that it was still abstract because i forgot to define some distant property or method... This can easily be approved, the meta.class instances alone provided enough information... If i so wanted i could write a function that, given the parents of a class, lists all the methods that i still have to implement, as a sort of checklist.

Hopefully the R2012 or R2013 will improve on this.

Kind regards,
Sander Aerts

Subject: Refactoring 4 Matlab

From: Brad Stiritz

Date: 10 Dec, 2011 14:10:09

Message: 34 of 35

Hi Sander,

Thanks for your comments. I'm so sorry to hear you've been giving up hope on efficient large-project creation within MATLAB..! :( From personal experience, I can assure you that you can do it..! Extreme resourcefulness is the key. Though TMW may not provide you with everything you need, there are a lot of very helpful concepts & tools floating around that can really make a difference..! :)

Here are a couple more suggestions to consider. I make use of these on a daily basis:

1) Hungarian Notation : try to be disciplined & use as much as you can possibly stand. This might not be directly about refactoring, but I'm including it b/c it's a critical part IMHO of achieving & maintaining bug-free & readable code. Here's an example from a function I'm working on right now, in a class called Parameters that facilitates meta-programming:

---------------------------------------------------
% Check possibilities (i) OR (ii)
if ~isempty(iAssignmentMatch) &&...
    any(vBoolFunctionNameMatch)...
        || sum(vBoolAnonFunctionMatch) == numel(cvReqdAnonFunctionChars)
---------------------------------------------------
 
Note that all variables have leading prefixes indicating their type:
i = scalar index (i.e. positive int)
vBool = vector of boolean (i.e. MATLAB 'logical')
cv = 1D cell vector

2) MATLAB File Exchange submission "Class Inheritance Browser" by Clayton Ernst. This is a **must-have** for any extensive O-O projects..! I don't have the Bioinformatics Toolbox, so I don't get the diagrams. But the basic browser window is 5-star functionality on its own. I create & maintain my own simple inheritance diagrams in Visio; a free equivalent is Creately.

Hope this info helps,
Best wishes,
Brad

"Sander Aerts" wrote in message <jbvk4s$5gm$1@newscl01ah.mathworks.com>...
> Hi Brad,
>
> I think we are more or less in the same line of programming duty here, I too have created and manage an OO framework of pure matlab code. The ML-editor is also the only UI i use to write code, but over the past two years it seems as if I have given up hope.
>
> Given the nature of how matlab works with data and has no type identification it is clear that refactoring tools are not so easy. However, the new OO syntax must certainly allow the progammers to incorporate more funtionality such better class outline... I cannot imagine that programmers who work on the matlab UI have never used an editor as Eclipse that ships with excelent refactoring tools?
>
> There is a function on the file exchange called filegrep.m, perhaps it wouldn't be a bad idea to implement this (in the more elegant and improved version) by default in the ML-editor? It is basically a find and replace tool accross mutiple files, but it lacks the functionality as in regexprep... Perhaps your third party tools are much more efficient at this, i'll have to try them out.
>
> @Loren: I have indeed encountered people using emacs as an imporved editor... Shame on me that I haven't been able to work a lot on unix systems, but it did not come naturally to me and i soon gave up hope on emac :-) I think it is because in all these years i have grown accustomed to my short keys.
>
> @Steve: I too have posted something about the refactoring as an improvement and indeed I have seen the editor becoming better, especially in the R011a release... i am a fan of shift+enter to replace all occurences of a name in a confined 'base' (dont really know how to express this better). But, (always a but) they asked me to sum up all functions i wanted...
>
> I also believe that we should be looking at a bigger picture. Refactoring tools are not limited to a single function or even a file. In the case of Brad and myself where you working with a lot of OO code that interacts with one another it can be hard to keep track of classes, their methods, inheritance trees....
>
> How many times have i tried to instantiate a newly designed class only to discover that it was still abstract because i forgot to define some distant property or method... This can easily be approved, the meta.class instances alone provided enough information... If i so wanted i could write a function that, given the parents of a class, lists all the methods that i still have to implement, as a sort of checklist.
>
> Hopefully the R2012 or R2013 will improve on this.
>
> Kind regards,
> Sander Aerts

Subject: Refactoring 4 Matlab

From: Ted Shaneyfelt

Date: 31 Jan, 2012 23:00:09

Message: 35 of 35

Some refactoring should be possible for local variables, especially within a class.

To begin with, we should at least have the basics:

I would like to right-click any name and click "rename"
I would like to be able to right-click a highlighted sequence of statements and click "convert to method" or "convert to function".
The reverse option "convert to inline" should also be available.
You should also be able to convert local variables to properties and back in the same manner.

I use these all the time in other languages, and it speeds up common tasks while making them less prone to errors. Find and replace is stone-age already and we need something better.

When any nontrivial refactoring is done, list of proposed changes should be presented and they should either be accepted at once, or if the programmer so chooses, selectively by marking check boxes or something similar.

All of these operations should work at least within a class file and make sense of scope of variables so that a warning is issued and appropriate options are given for name collisions.
 
Also a checkbox option should allow affecting other files in the path when appropriate.
Renaming a class or function where the filename is affected should be appropriately automated and work the same as any other name.

There are a number of more advanced optimizations that can be done with refactoring - vectorizing and un-vectorizing mathematical operations, etc. Essentially any transform that can be automatically done on the code without changing the result is a candidate for refactoring.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us