GSoC Code Sharing - weboptions

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

GSoC Code Sharing - weboptions

siko1056
Dear Sahil,

I've just seen your commit [1], where you added setters for the weboptions class.  In my opinion this happened in a very complicated way.  There is a "cleaner" syntax to define setters in classdef classes, that is working in Octave 4.4.0.  For example:

classdef myClass < handle
  properties
    A
  endproperties
  methods
    function set.A (obj, val)
      if (val > 0)
        obj.A = val;
      else
        error ("Serious?");
      endif
    endfunction
  endmethods
endclassdef

There is to admit, that the classdef documentation in Octave has potential for improvement. Thus it might sometimes be beneficial to sneak at Matlab [2], to get an idea how it will once be working in Octave. A similar example can be found in [3].

Best,
Kai

[3] https://github.com/vsdp/vsdp-2018/blob/master/vsdp_options.m
Reply | Threaded
Open this post in threaded view
|

Re: GSoC Code Sharing - weboptions

Sahil
siko1056 wrote
> I've just seen your commit [1], where you added setters for the weboptions
> class.  In my opinion this happened in a very complicated way.  There is a
> "cleaner" syntax to define setters in classdef classes, that is working in
> Octave 4.4.0.
>
> There is to admit, that the classdef documentation in Octave has potential
> for improvement. Thus it might sometimes be beneficial to sneak at Matlab
> [2], to get an idea how it will once be working in Octave. A similar
> example can be found in [3].

Indeed, the syntax is way more cleaner than what I had previously
implemented! I too was surfing through MATLAB docs lately for this and I
read their example as well, but I didn't know that the 'handle' class could
be inherited in Octave as well, because there's no documentation about this
except one line here [4] and the straight away "no" to built-in class as
superclass [5]. Anyway, thanks for letting me know about this, this has
saved some of our time in the weekly meeting.

Needless to say, now we need to set the isempty () block in every property
setter, as in [6] and the subsequent setters because the initial values
assigned to the given properties are null, so the setter raises an error
even when initialising the object.

Also, I'll change the validation of input to properties from strcmpi to
validatestring and validateattribute, but before that I am working on
webwrite.

As for the webserver, the wikimedia server (wiki.octave.space) will also
serve as a good starting point because we do have some requests from
wiki_upload.m which can be tested using webwrite. OTOH, I have my own Java's
play framework's server setup (because I knew about this server more than
any other alternative) on my DigitalOcean instance, so we can hit that as
well for extra testing with the HTTP requests, without having to be worried
about disrupting something already stable.

I'll post this week's blog in a day or two when I'll have initial
implementation of webwrite.m

Thanks and Regards
Sahil

> [1]
> https://bitbucket.org/me_ydv_5/octave/commits/abbc8f5c151b437848a9530f5c17f555f609bdcb
> [2]
> https://www.mathworks.com/help/matlab/matlab_oop/property-set-methods.html
> [3] https://github.com/vsdp/vsdp-2018/blob/master/vsdp_options.m

[4] https://octave.org/doc/v4.2.2/classdef-Classes.html#classdef-Classes
[5] http://wiki.octave.org/Classdef
[6]
https://bitbucket.org/me_ydv_5/octave/commits/c73be77f2e6af2bdf732d5e239ecaf0918b9e007#Lscripts/miscellaneous/weboptions.mT314



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-Maintainers-f1638794.html