Java State machines: State enum privacy

2 views
Skip to first unread message

Kevin Brightwell

unread,
Mar 24, 2015, 1:45:18 PM3/24/15
to umpl...@googlegroups.com
Hello,

I'm wondering if there is a justification for having the "state" enumeration of a state machine in Java code be "package" or "default" private instead of public.

If there isn't I would like to propose it is made public due to having methods like "getState" already public but the value can't be saved anywhere outside the package of the generated class.

e.g.: (trimmed output for brevity)

class GarageDoor
{
   status {
   }
}

produces:

public class GarageDoor
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //GarageDoor State Machines
  enum Status {  }
  private Status status;

  // ... snip ...

  public Status getStatus()
  {
    return status;
  }

}

As for side effects of this change, there are none as decreasing visibility does not create compile issues unless the name has been reused AND the type was directly imported (extremely unlikely).

I'll open an issue if there are no complaints.

Thanks,

Kevin

Kevin Brightwell

unread,
Mar 24, 2015, 1:46:57 PM3/24/15
to umpl...@googlegroups.com
Sorry, just realized I was unclear, I meant exposing the enum type as public and leave the attribute/field that stores it as private.

--
You received this message because you are subscribed to the Google Groups "Umple-Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to umple-dev+...@googlegroups.com.
To post to this group, send email to umpl...@googlegroups.com.
Visit this group at http://groups.google.com/group/umple-dev.
For more options, visit https://groups.google.com/d/optout.



--
Kevin Brightwell
BESc. and BSc. Candidate 2015
Western University www.westernu.ca
e. kevin.br...@gmail.com c. 647.678.4927

Timothy Lethbridge

unread,
Mar 24, 2015, 1:56:07 PM3/24/15
to umpl...@googlegroups.com
Hi,

I wouldn't mind having this type be public. Feel free to generate an
appropriate patch. As long as the variable is private.

Tim
Timothy C. Lethbridge, PhD, P.Eng., I.S.P., CSDP
Professor of Software Engineering and Computer Science
/ Professeur Titulaire de génie logiciel et d'informatique
and Vice-Dean (governance) / et vice-doyen (gouvernance)
Faculté de genie / Faculty of Engineering
University of Ottawa / Université d'Ottawa
Tel: 613-562-5800x6685 Fax: 613-562-5664 Mobile: 613-252-1850
http://www.eecs.uottawa.ca/~tcl

Kevin Brightwell

unread,
Mar 24, 2015, 1:58:05 PM3/24/15
to umpl...@googlegroups.com
Great, I'll get to it later today, if not tomorrow morning.

The variable would definitely remain private.

Kevin


To post to this group, send email to umpl...@googlegroups.com.
Visit this group at http://groups.google.com/group/umple-dev.
For more options, visit https://groups.google.com/d/optout.




--
Kevin Brightwell
BESc. and BSc. Candidate 2015
Western University www.westernu.ca
e. kevin.br...@gmail.com c. 647.678.4927

--
You received this message because you are subscribed to the Google Groups "Umple-Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to

To post to this group, send email to umpl...@googlegroups.com.
Visit this group at http://groups.google.com/group/umple-dev.
For more options, visit https://groups.google.com/d/optout.


Timothy C. Lethbridge, PhD, P.Eng., I.S.P., CSDP
Professor of Software Engineering and Computer Science
/ Professeur Titulaire de génie logiciel et d'informatique
and Vice-Dean (governance) / et vice-doyen (gouvernance)
Faculté de genie / Faculty of Engineering
University of Ottawa / Université d'Ottawa
Tel: 613-562-5800x6685   Fax: 613-562-5664    Mobile: 613-252-1850
http://www.eecs.uottawa.ca/~tcl
Reply all
Reply to author
Forward
0 new messages