Hi Andre,
The action menu item connected to class1 exists on SalesLine, SalesQuotationLine (it's used to check existing orders in the external system by calling an api) (Enum1: is called 'examine') so u can call the menu item 'examineOrder' and you could call class1 the same examineOrder
The action menu item connected to class2 exists on SalesLine, SalesQuotationLine And a Custom table (it's used to create a new order in the external system by calling an api) (Enum2 is called 'create') and you can call the menu item 'CreateOrder' and you could call class2 the same CreateOrder
Hi Martin,
For the descriptive names, i provided this with my answer to Andre, so how would u refactor class1 and class2? would you make a common base class by doing initArgs like this where class2 can add logic to "handleMore())? but what how would the main method look like in the abstract class and in class1 and class2?
public void initFromArgs(Args _args)
{
if(_args && _args.dataset())
{
switch(_args.dataset())
{
case tableNum(SalesQuotationLine):
case tableNum(salesLine):
salesPurchline = _args.record();
break;
default:
if(!this.handleMore(_args.record()))
{
throw error(Error::wrongUseOfFunction(funcName()));
}
break;
}
}
}
protected boolean handleMore(Common _record)
{
return false;
}
for your sentence "
a class hierarchy with classCommon, ClassA and ClassB" This classCommon is used to prepare the request to the api, so maybe there should be another level for classCommon? If you saw at the end of sendA and sendB method, i called classA.send() and classB.send(), the send logic is in classCommon
Also regarding this "
Your current implementation could be replaced with single class with two methods (sendA() and sendB())" what do you mean i should do?
yes the only difference between sendA and SendB is table1, but as i said classA and classB extends classCommon to prepare the xml and send the reuqest, and the xml could have few different things between classA and classB, so i would override some of classCommon methods in classA and class B, that's why i think i need two classes
regarding this "use a
parameter to control whether Table1 should be processed or the method should thrown an exception when called with Table1. This may be a method parameter or an instance variable of the class." you mean in class1 and class2 i do this
ClassA::sendA(salesPurchLine, AAEnum::Enum2,
false); but how would sendA look like now from the inside
Regarding "
utilize the table inheritance when the base class will handle SalesLine and SalesQuotationLine, and a specialized class that will be able to handle Table1 too. The caller code will decide which logic to use by instantiating the right class instead of using a single class and setting the parameter." can you please show me
Yes i will create a new map instead of extending salespurchLine map, but table1 can't be added to the map, that's why i will still need to use common instead of map. For example Table1 doesn't contain salesPool field and Table1 contains field that don't exist in both salesline/salesQuotationLine (but there are common fields as well)