Comparison: Object oriented programming in Matlab (Pre R-2008 and Post R-2008)

Hi, I've recently started to learn Object-Oriented Programming to develop a toolbox for nonlinear control algorithms (optimization-based)in Matlab. I came across a book "A Guide to MATLAB Object-Oriented Programming" by A. H. Register from year 2007. It uses old syntax for OOP in Matlab and read some threads that this old syntax is obsolete but still supported in Matlab. The new syntax looks more intuitive and easy to understand and somewhat close to C++ class. Before I start to implementing code, I need to get some expertise opinions regarding pros and cons of each syntax according to the following criteria:
  1. Performance regarding execution time: My algorithms will be based on nonlinear optimization techniques, therefore, performance is the most important key factor. Which OOP syntax leads to better execution time for the same problem?
  2. Support: Will old OOP-syntax be supported in the future releases?
If there are some other criteria related to the pros and cons of OOP-syntax's, I'll be very glad to know.
Many thanks in advance.
Regards, Saif

5 commentaires

per isakson
per isakson le 26 Mar 2017
Modifié(e) : per isakson le 27 Mar 2017
  • A.H. Register describes an enhanced version of the old OOP, which I assume he had developed without knowledge of the new OOP.
  • The old OOP is removed from the documentation. If the code is still included in MATLAB, that's to make it possible to run old programs.
  • I'm convinced that old or new won't significantly affect the performance of your nonlinear optimization.
  • Maybe you shouldn't use OOP at all.
Adam
Adam le 27 Mar 2017
Modifié(e) : Adam le 27 Mar 2017
Matlab OOP and performance don't generally mix too well unfortunately. There are things you can do to avoid some of the more obvious OOP performance problems, but when I have got to optimising an OOP algorithm that is time-sensitive I find myself feeling the need to strip it down to almost render the OOP aspect pointless.
I use OOP for ~90% or more of my programming (though didn't start until after 2008 and always use the huge Matlab OOP pdf as my reference), but in most cases performance is not such a big issue. However, for my current work on a highly iterative algorithm it is hard to make OOP performant.
Thank you @Adam and @per isakson for your comments.
I got some spaghetti code for a toolbox implemented in Matlab. It's hard to follow, secondly it is quite difficult to include new functionalities. So my task is to re-implement it in a systematic way keeping in mind extensibility and scalability. The only way which I googled is to opt OOP in Matlab. Keeping in mind your arguments, I'll use the new OOP framework in Matlab.
Certainly it sounds like it is worth redesigning to OOP. Performance can always be considered afterwards too using the profiler.

Connectez-vous pour commenter.

Réponses (0)

Question posée :

le 22 Mar 2017

Commenté :

le 31 Mar 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by