list of dots Digital Research Alliance of Canada logo  NSERC logo  University of Ottawa logo / UniversitĂ© d'Ottawa

User Manual    [Previous]   [Next]   

E220 Two Methods With the Same Name

Umple semantic error related to changing name of a provided method in traits to one which already exists

When changing the name of provided methods in traits, it is necessary to be sure that there are no other methods with the same names that come from other traits. If the changed name already exists inside of a class, in this case there is no problem becase methods of classes have priority over ones coming from traits. In this case, the method from traits will be disregarded. Otherwise, there is a conflict on the name of methods. The Umple compiler detects this case and raises the error.

Example

// In this example, there is an error
// because in class "A" there will be
// two methods with the name "ShowInConsole".
class A{
	isA T<show() as ShowInConsole>;
}
trait T{
	isA T1;
	void show(){/*T*/}
}
trait T1{
	void ShowInConsole(){/*T1*/}
}
      

Load the above code into UmpleOnline

 

Another Example

// In this example, there is an error
// because in class "A" there will be
// two methods with the name "ShowInConsole".
class A{
	isA T<show() as ShowInConsole>;
	isA T1;
}
trait T{
	void show(){/*T*/}
}
trait T1{
	void ShowInConsole(){/*T1*/}
}
      

Load the above code into UmpleOnline

 

Solution to The Above So the Message No Longer Appears

// In this example, there is no error
// because in class "A"
// method "ShowInConslole" has high priority.
class A{
	isA T<show() as ShowInConsole>;
	isA T1;
	void ShowInConsole(){
	//Implementation 
	}  
}
trait T{
	void show(){
	//Implementation
	}
}
trait T1{
	void ShowInScreen(){
	//Implementation
	}
}
      

Load the above code into UmpleOnline