New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1-1 code won't compile unless the user knows how to call the constructors - needs documenting in the manual #126

Closed
Nava2 opened this Issue Aug 26, 2015 · 5 comments

Comments

@Nava2
Member

Nava2 commented Aug 26, 2015

Originally reported on Google Code with ID 226
Owned by @umple


What steps will reproduce the problem?

In the following code, you have to have a Board before you construct a company and
vice versa.

class Company {}
class BoardOfDirectors {}

association {
1 Company -- 1 BoardOfDirectors;
}

This is impossible


Reported by @umple on 2011-09-27 13:45:04

@Nava2

This comment has been minimized.

Member

Nava2 commented Aug 26, 2015

My mistake, sort of. You have to call the second constructor first on one class, and
then pass the result to the first constructor of the other class. This needs to be
documented, however, otherwise people will not know what to do


Reported by @umple on 2011-09-27 13:54:35

@Nava2

This comment has been minimized.

Member

Nava2 commented Aug 26, 2015

See also issue 184


Reported by @umple on 2012-03-05 14:59:27

@Nava2

This comment has been minimized.

Member

Nava2 commented Aug 26, 2015

Ideally, all code would compile though.


Reported by @umple on 2012-06-15 15:19:11

  • Labels added: Priority-High, Component-UserDocs, Diffic-VEasy
  • Labels removed: Priority-Medium
@Nava2

This comment has been minimized.

Member

Nava2 commented Aug 26, 2015

To clarify:
The problem occurs when the above code is used, and the user tries to do something
like
new Company(new BoardOfDirectors());
and it happens because when new BoardOfDirectors() is called, it fills its company
variable with a separately new company, then when the new BoardOfDirectors is passed
to the constructor of the company, the condition that aBoardOfDirectors.getCompany()!=null
is false.
Without a way for either class to modify the other's variable of themselves, I see
no way that this code can be changed to compile. The only option seems to be to create
a master slave relationship, where one of the two classes takes care of all the setting
and the other is oblivious to the changes, though, this doesn't seem like a good solution
either.
A work around is of course to make better documentation around the subject so that
the user would do:
BoardOfDirectors bod= new BoardOfDirectors();
Company com = bod.getCompany();


Reported by redeyedmars on 2013-05-06 15:25:02

@Nava2

This comment has been minimized.

Member

Nava2 commented Aug 26, 2015

Reported by @umple on 2013-12-13 15:55:14

  • Labels added: Priority-Medium
  • Labels removed: Priority-High

TimLethbridge added a commit that referenced this issue Oct 2, 2018

Merge pull request #1377 from umple/UserManualImprovementsA
User Manual Improvements Fixes #126 Fixes #1374 Fixes 1373
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment