Posibility to edit default get and set operations

Please use this forum to ask for a new feature or to change an existing feature.
Merci d'utiliser ce forum pour demander de nouvelles fonctionnalités ou la modification de fonctionnalités existantes.

Posibility to edit default get and set operations

Postby fbernoldi » Thu 27 Jul 2017 18:22

Hello,

For my experience during the use of bouml which PHP, I normally do all the getters and setters manually since the actual behavior does not quite adapt to my regular coding.

For code clarity it's much simpler to see something like:

Code: Select all
$obj = new MyClass();

$obj->setProperty1('somename')
    ->setProperty2('something else')
    ->setAnother1(1)
    ->setAnother2(2)
    ->setAnother3(3);


instead of:

Code: Select all
$obj = new MyClass();

$obj->setProperty1('somename');
$obj->setProperty2('something else');
$obj->setAnother1(1);
$obj->setAnother2(2);
$obj->setAnother3(3);


Although this is just some preference in coding style, I don't why not we can have a setter/getter personalization to get this things by default, setting for example:

Setter default definition:
Code: Select all
 
 ${comment}${final}${visibility}${abstract}${static}function ${name}${(}${p0}${)}
{
  $this->${property} = ${p0};
  return $this; // this is added
}


Setter default description:
Code: Select all
sets the value of ${property} name.

@param ${t0} ${p0}
@return ${type}


Getter default definition:
Code: Select all
 
  ${comment}${final}${visibility}${abstract}${static}function ${name}${(}${)}
{
  return $this->${property};
}


Getter default description:
Code: Select all
gets the value of ${property} name.

@return ${type}


Also you would need to change the method's type, currently it's set to "void" and cannot be changed.

The final result would be:

Code: Select all

class MyClass {

   /* @var int */
   private $id;

   /* @var string */
   private $name;

   /*
    * Sets the id property
    * @param int $id
    * @return MyClass
    */
   function setId($id) {
       $this->id = $id;
       return $this;
   }

   /*
    * Sets the name property
    * @param int $id
    * @return MyClass
    */
   function setName($name) {
       $this->name = $name;
       return $this;
   }
}

$c = new MyClass();

$c->setId(1)
  ->setName('test');


Without this purposed modifications, it can be done of course, but with manually editing all the descriptions and definitions of setters and getters, and on the model you would still be saying the setters are void instead of the actual type. By doing this modifications manually it kills the purpose of the add getter/setter shortcut I think.

Well, thank you very much for your time :)

Regards,
Federico.
fbernoldi
 
Posts: 22
Joined: Mon 10 Jul 2017 13:15

Re: Posibility to edit default get and set operations

Postby fbernoldi » Thu 27 Jul 2017 18:29

One more thing, ability to change set${Name} and get${name} to set${Camecase} and get${Camelcase} respectively to get something like:

attribute: last_name
setter: setLastName
getter: getLastName

Thanks!
fbernoldi
 
Posts: 22
Joined: Mon 10 Jul 2017 13:15

Re: Posibility to edit default get and set operations

Postby Bruno Pagès » Fri 28 Jul 2017 06:19

Hello,

Ok, I will see

Let's note you can create automatically your getter/setter as you expect through a plug-out rather than by hand.

Applied to an attribute or an relation this plug-out creates/updates the getter/setter (perhaps using stereotype <<setter>>/<<getter>> on the operation to easily distinguish them from the other operations, and also using a user property to save the name of the associated attribute/relation) , applied on a container (class view / package) this plug-out process recursively to update already created setter/getter including to remove the ones whose attribute/relation do not exist anymore (I don't think it is useful to have a getter/setter for all attributes/relations)
ImageAuthor of Bouml
Bruno Pagès
 
Posts: 453
Joined: Mon 20 Feb 2012 08:23
Location: France

Re: Posibility to edit default get and set operations

Postby fbernoldi » Tue 1 Aug 2017 17:02

Bruno Pagès wrote:Hello,

Ok, I will see

Let's note you can create automatically your getter/setter as you expect through a plug-out rather than by hand.


How would this be? or you refer to the "New get and set operation" menu when you right click an attribute or relation?
fbernoldi
 
Posts: 22
Joined: Mon 10 Jul 2017 13:15

Re: Posibility to edit default get and set operations

Postby Bruno Pagès » Tue 1 Aug 2017 18:13

fbernoldi wrote:
Bruno Pagès wrote:Hello,

Ok, I will see

Let's note you can create automatically your getter/setter as you expect through a plug-out rather than by hand.


How would this be? or you refer to the "New get and set operation" menu when you right click an attribute or relation?

no, "New get and set operation" is a builtin behavior of the modeler, I speak about plug-out(s) you can write by yourself (in C++ or Java) to extend Bouml
ImageAuthor of Bouml
Bruno Pagès
 
Posts: 453
Joined: Mon 20 Feb 2012 08:23
Location: France


Return to Change requests / Demandes d'évolution

Who is online

Users browsing this forum: No registered users and 2 guests