Code to UML - Does an association exist if a class uses another classes methods? [duplicate]
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
This question already has an answer here:
Class diagram - dependency or association from class to interface?
1 answer
Having difficulty finding any information that relates to UML's too coding examples.
(Insert Scores Method is missing from the UML - ignore this, I am changing it now)
The Choice class uses methods from the Scores class, does this mean that there is a link between the classes? There is plenty of information regarding inheritance however, it seems.
I have created a UML:
Choice to Score Link
Choice Method
//Attributes Check
public int CheckVariables(int optionR, int optionV, int TurnCount, string Username)
{
if (optionR >= 100 || optionV <= 0)
{
//return 2; //Win
var Score = new Score();
if(Score.InsertScores(TurnCount,Username) == true)
{
return 3;
}
else
{
return 2;
}
}
else if (optionR <= 0 || optionV >= 100)
{
return 1; //Lose
}
else
{
return 0; //Not Finished
}
}
Score Method
public bool InsertScores(int ScoreValue,string Username)
{
ShowScores(); //Populate Lists with Highscores
if(ScoreValue < Turns[9])
{
SqlCommand sql = new SqlCommand("UPDATE gameScores SET scoreValue = @scoreValue, username = @Username WHERE scoreid = @ScoreId;", con);
sql.Parameters.AddWithValue("@scoreValue", ScoreValue);
sql.Parameters.AddWithValue("@Username", Username);
sql.Parameters.AddWithValue("@ScoreId", ScoreID[9]);
//Insert
sql.ExecuteNonQuery();
return true;
}
else
{
return false;
}
}
c# uml
marked as duplicate by Geert Bellekens, Thomas Kilian
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 17 '18 at 8:37
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Class diagram - dependency or association from class to interface?
1 answer
Having difficulty finding any information that relates to UML's too coding examples.
(Insert Scores Method is missing from the UML - ignore this, I am changing it now)
The Choice class uses methods from the Scores class, does this mean that there is a link between the classes? There is plenty of information regarding inheritance however, it seems.
I have created a UML:
Choice to Score Link
Choice Method
//Attributes Check
public int CheckVariables(int optionR, int optionV, int TurnCount, string Username)
{
if (optionR >= 100 || optionV <= 0)
{
//return 2; //Win
var Score = new Score();
if(Score.InsertScores(TurnCount,Username) == true)
{
return 3;
}
else
{
return 2;
}
}
else if (optionR <= 0 || optionV >= 100)
{
return 1; //Lose
}
else
{
return 0; //Not Finished
}
}
Score Method
public bool InsertScores(int ScoreValue,string Username)
{
ShowScores(); //Populate Lists with Highscores
if(ScoreValue < Turns[9])
{
SqlCommand sql = new SqlCommand("UPDATE gameScores SET scoreValue = @scoreValue, username = @Username WHERE scoreid = @ScoreId;", con);
sql.Parameters.AddWithValue("@scoreValue", ScoreValue);
sql.Parameters.AddWithValue("@Username", Username);
sql.Parameters.AddWithValue("@ScoreId", ScoreID[9]);
//Insert
sql.ExecuteNonQuery();
return true;
}
else
{
return false;
}
}
c# uml
marked as duplicate by Geert Bellekens, Thomas Kilian
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 17 '18 at 8:37
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
If yourChoice
class stores a instance ofScore
class as an attribute we consider it anAssociation
. If it merely uses it temporarily then it's aDependency
.
– Geert Bellekens
Nov 17 '18 at 8:17
Please think about your design. How can you callShowScores
without having an association (attribute) to aScore
object?
– Thomas Kilian
Nov 17 '18 at 8:38
ShowScores is inside the class, it is a method. An association attribute would make no sense. I assumed that was pretty straightforward
– HARV mackie
Nov 17 '18 at 18:19
add a comment |
This question already has an answer here:
Class diagram - dependency or association from class to interface?
1 answer
Having difficulty finding any information that relates to UML's too coding examples.
(Insert Scores Method is missing from the UML - ignore this, I am changing it now)
The Choice class uses methods from the Scores class, does this mean that there is a link between the classes? There is plenty of information regarding inheritance however, it seems.
I have created a UML:
Choice to Score Link
Choice Method
//Attributes Check
public int CheckVariables(int optionR, int optionV, int TurnCount, string Username)
{
if (optionR >= 100 || optionV <= 0)
{
//return 2; //Win
var Score = new Score();
if(Score.InsertScores(TurnCount,Username) == true)
{
return 3;
}
else
{
return 2;
}
}
else if (optionR <= 0 || optionV >= 100)
{
return 1; //Lose
}
else
{
return 0; //Not Finished
}
}
Score Method
public bool InsertScores(int ScoreValue,string Username)
{
ShowScores(); //Populate Lists with Highscores
if(ScoreValue < Turns[9])
{
SqlCommand sql = new SqlCommand("UPDATE gameScores SET scoreValue = @scoreValue, username = @Username WHERE scoreid = @ScoreId;", con);
sql.Parameters.AddWithValue("@scoreValue", ScoreValue);
sql.Parameters.AddWithValue("@Username", Username);
sql.Parameters.AddWithValue("@ScoreId", ScoreID[9]);
//Insert
sql.ExecuteNonQuery();
return true;
}
else
{
return false;
}
}
c# uml
This question already has an answer here:
Class diagram - dependency or association from class to interface?
1 answer
Having difficulty finding any information that relates to UML's too coding examples.
(Insert Scores Method is missing from the UML - ignore this, I am changing it now)
The Choice class uses methods from the Scores class, does this mean that there is a link between the classes? There is plenty of information regarding inheritance however, it seems.
I have created a UML:
Choice to Score Link
Choice Method
//Attributes Check
public int CheckVariables(int optionR, int optionV, int TurnCount, string Username)
{
if (optionR >= 100 || optionV <= 0)
{
//return 2; //Win
var Score = new Score();
if(Score.InsertScores(TurnCount,Username) == true)
{
return 3;
}
else
{
return 2;
}
}
else if (optionR <= 0 || optionV >= 100)
{
return 1; //Lose
}
else
{
return 0; //Not Finished
}
}
Score Method
public bool InsertScores(int ScoreValue,string Username)
{
ShowScores(); //Populate Lists with Highscores
if(ScoreValue < Turns[9])
{
SqlCommand sql = new SqlCommand("UPDATE gameScores SET scoreValue = @scoreValue, username = @Username WHERE scoreid = @ScoreId;", con);
sql.Parameters.AddWithValue("@scoreValue", ScoreValue);
sql.Parameters.AddWithValue("@Username", Username);
sql.Parameters.AddWithValue("@ScoreId", ScoreID[9]);
//Insert
sql.ExecuteNonQuery();
return true;
}
else
{
return false;
}
}
This question already has an answer here:
Class diagram - dependency or association from class to interface?
1 answer
c# uml
c# uml
asked Nov 17 '18 at 0:48
HARV mackieHARV mackie
567
567
marked as duplicate by Geert Bellekens, Thomas Kilian
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 17 '18 at 8:37
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Geert Bellekens, Thomas Kilian
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 17 '18 at 8:37
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
If yourChoice
class stores a instance ofScore
class as an attribute we consider it anAssociation
. If it merely uses it temporarily then it's aDependency
.
– Geert Bellekens
Nov 17 '18 at 8:17
Please think about your design. How can you callShowScores
without having an association (attribute) to aScore
object?
– Thomas Kilian
Nov 17 '18 at 8:38
ShowScores is inside the class, it is a method. An association attribute would make no sense. I assumed that was pretty straightforward
– HARV mackie
Nov 17 '18 at 18:19
add a comment |
If yourChoice
class stores a instance ofScore
class as an attribute we consider it anAssociation
. If it merely uses it temporarily then it's aDependency
.
– Geert Bellekens
Nov 17 '18 at 8:17
Please think about your design. How can you callShowScores
without having an association (attribute) to aScore
object?
– Thomas Kilian
Nov 17 '18 at 8:38
ShowScores is inside the class, it is a method. An association attribute would make no sense. I assumed that was pretty straightforward
– HARV mackie
Nov 17 '18 at 18:19
If your
Choice
class stores a instance of Score
class as an attribute we consider it an Association
. If it merely uses it temporarily then it's a Dependency
.– Geert Bellekens
Nov 17 '18 at 8:17
If your
Choice
class stores a instance of Score
class as an attribute we consider it an Association
. If it merely uses it temporarily then it's a Dependency
.– Geert Bellekens
Nov 17 '18 at 8:17
Please think about your design. How can you call
ShowScores
without having an association (attribute) to a Score
object?– Thomas Kilian
Nov 17 '18 at 8:38
Please think about your design. How can you call
ShowScores
without having an association (attribute) to a Score
object?– Thomas Kilian
Nov 17 '18 at 8:38
ShowScores is inside the class, it is a method. An association attribute would make no sense. I assumed that was pretty straightforward
– HARV mackie
Nov 17 '18 at 18:19
ShowScores is inside the class, it is a method. An association attribute would make no sense. I assumed that was pretty straightforward
– HARV mackie
Nov 17 '18 at 18:19
add a comment |
1 Answer
1
active
oldest
votes
Per the UML specification: "The objective of UML is to provide system
architects, software engineers, and software developers with tools for analysis, design, and implementation of softwarebased
systems as well as for modeling business and similar processes.".
This means that whether you consider "dependency" and "inheritance" equivalent depends upon your representation. Based on your images, you are defining a "meta-model" model relationship as defined by section 7.11 of the specification: https://www.omg.org/spec/UML/2.4.1/About-UML/
If you have some class A that uses methods of class B then the relationship can be modeled as 11.7.1 ElementImport.
The only real difference here is what edge descriptor you use:
That being said, I would urge against mixing inheritance and dependency model diagrams and to complete your current diagram, not include the import.
I don't think this answer is relevant for the question and might lead the OP in the wrong direction.
– Geert Bellekens
Nov 17 '18 at 8:23
Inheritance is not the problem. I am questioning what makes an association between classes. The Choice method checking attributes creates an instance of the Score object and accesses one of the methods (Insert Scores )that are inside the Score class, does this mean that there is a link, if so how would this be represented via a UML class diagram?
– HARV mackie
Nov 17 '18 at 18:25
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Per the UML specification: "The objective of UML is to provide system
architects, software engineers, and software developers with tools for analysis, design, and implementation of softwarebased
systems as well as for modeling business and similar processes.".
This means that whether you consider "dependency" and "inheritance" equivalent depends upon your representation. Based on your images, you are defining a "meta-model" model relationship as defined by section 7.11 of the specification: https://www.omg.org/spec/UML/2.4.1/About-UML/
If you have some class A that uses methods of class B then the relationship can be modeled as 11.7.1 ElementImport.
The only real difference here is what edge descriptor you use:
That being said, I would urge against mixing inheritance and dependency model diagrams and to complete your current diagram, not include the import.
I don't think this answer is relevant for the question and might lead the OP in the wrong direction.
– Geert Bellekens
Nov 17 '18 at 8:23
Inheritance is not the problem. I am questioning what makes an association between classes. The Choice method checking attributes creates an instance of the Score object and accesses one of the methods (Insert Scores )that are inside the Score class, does this mean that there is a link, if so how would this be represented via a UML class diagram?
– HARV mackie
Nov 17 '18 at 18:25
add a comment |
Per the UML specification: "The objective of UML is to provide system
architects, software engineers, and software developers with tools for analysis, design, and implementation of softwarebased
systems as well as for modeling business and similar processes.".
This means that whether you consider "dependency" and "inheritance" equivalent depends upon your representation. Based on your images, you are defining a "meta-model" model relationship as defined by section 7.11 of the specification: https://www.omg.org/spec/UML/2.4.1/About-UML/
If you have some class A that uses methods of class B then the relationship can be modeled as 11.7.1 ElementImport.
The only real difference here is what edge descriptor you use:
That being said, I would urge against mixing inheritance and dependency model diagrams and to complete your current diagram, not include the import.
I don't think this answer is relevant for the question and might lead the OP in the wrong direction.
– Geert Bellekens
Nov 17 '18 at 8:23
Inheritance is not the problem. I am questioning what makes an association between classes. The Choice method checking attributes creates an instance of the Score object and accesses one of the methods (Insert Scores )that are inside the Score class, does this mean that there is a link, if so how would this be represented via a UML class diagram?
– HARV mackie
Nov 17 '18 at 18:25
add a comment |
Per the UML specification: "The objective of UML is to provide system
architects, software engineers, and software developers with tools for analysis, design, and implementation of softwarebased
systems as well as for modeling business and similar processes.".
This means that whether you consider "dependency" and "inheritance" equivalent depends upon your representation. Based on your images, you are defining a "meta-model" model relationship as defined by section 7.11 of the specification: https://www.omg.org/spec/UML/2.4.1/About-UML/
If you have some class A that uses methods of class B then the relationship can be modeled as 11.7.1 ElementImport.
The only real difference here is what edge descriptor you use:
That being said, I would urge against mixing inheritance and dependency model diagrams and to complete your current diagram, not include the import.
Per the UML specification: "The objective of UML is to provide system
architects, software engineers, and software developers with tools for analysis, design, and implementation of softwarebased
systems as well as for modeling business and similar processes.".
This means that whether you consider "dependency" and "inheritance" equivalent depends upon your representation. Based on your images, you are defining a "meta-model" model relationship as defined by section 7.11 of the specification: https://www.omg.org/spec/UML/2.4.1/About-UML/
If you have some class A that uses methods of class B then the relationship can be modeled as 11.7.1 ElementImport.
The only real difference here is what edge descriptor you use:
That being said, I would urge against mixing inheritance and dependency model diagrams and to complete your current diagram, not include the import.
edited Nov 17 '18 at 8:12
Thomas Kilian
24.2k63864
24.2k63864
answered Nov 17 '18 at 7:08
AlchemyAlchemy
4253
4253
I don't think this answer is relevant for the question and might lead the OP in the wrong direction.
– Geert Bellekens
Nov 17 '18 at 8:23
Inheritance is not the problem. I am questioning what makes an association between classes. The Choice method checking attributes creates an instance of the Score object and accesses one of the methods (Insert Scores )that are inside the Score class, does this mean that there is a link, if so how would this be represented via a UML class diagram?
– HARV mackie
Nov 17 '18 at 18:25
add a comment |
I don't think this answer is relevant for the question and might lead the OP in the wrong direction.
– Geert Bellekens
Nov 17 '18 at 8:23
Inheritance is not the problem. I am questioning what makes an association between classes. The Choice method checking attributes creates an instance of the Score object and accesses one of the methods (Insert Scores )that are inside the Score class, does this mean that there is a link, if so how would this be represented via a UML class diagram?
– HARV mackie
Nov 17 '18 at 18:25
I don't think this answer is relevant for the question and might lead the OP in the wrong direction.
– Geert Bellekens
Nov 17 '18 at 8:23
I don't think this answer is relevant for the question and might lead the OP in the wrong direction.
– Geert Bellekens
Nov 17 '18 at 8:23
Inheritance is not the problem. I am questioning what makes an association between classes. The Choice method checking attributes creates an instance of the Score object and accesses one of the methods (Insert Scores )that are inside the Score class, does this mean that there is a link, if so how would this be represented via a UML class diagram?
– HARV mackie
Nov 17 '18 at 18:25
Inheritance is not the problem. I am questioning what makes an association between classes. The Choice method checking attributes creates an instance of the Score object and accesses one of the methods (Insert Scores )that are inside the Score class, does this mean that there is a link, if so how would this be represented via a UML class diagram?
– HARV mackie
Nov 17 '18 at 18:25
add a comment |
If your
Choice
class stores a instance ofScore
class as an attribute we consider it anAssociation
. If it merely uses it temporarily then it's aDependency
.– Geert Bellekens
Nov 17 '18 at 8:17
Please think about your design. How can you call
ShowScores
without having an association (attribute) to aScore
object?– Thomas Kilian
Nov 17 '18 at 8:38
ShowScores is inside the class, it is a method. An association attribute would make no sense. I assumed that was pretty straightforward
– HARV mackie
Nov 17 '18 at 18:19