For example: rename(node: T); will replace renameDataset, renameNode and potentially renameDatasetMember although this may be an alternative node interface. Job does not need this function
It feels to me as if the only interfaces we should have would be related to commands as follows. They tend to be very similar which was why I like the generics pattern rename(node: T);
It feels to me as if the only interfaces we should have would be related to commands as follows. They tend to be very similar which was why I like the generics pattern rename(node: T);
On the other hand we already have the separation between the views so maybe we would stick with specific interface methods for USS/Datasets/Jobs rather than have a generics style call that joins and then splits the logical flow?
renameUSSFavorite etc
I don't know what the right answer is here, but I'd like to share that it's possible to clean some duplication of code with the generics you suggested. And if there is a need to support specific behaviors (like renameUSSFavorite) we can certainly extend the generic in an overloaded signature faction.
// This is just an example. : )
rename<T extends UssNode>(node: T): Promise<string>;
rename<T extends DsNode>(node: T): Promise<string>;
rename(node) {
// shared-code: show the inputBox
// type-specific: API calls
// shared-code: error handling and logging
// shared-code: Update tree view
// shared-code: return promise<string>
}
I don't know what the right answer is here, but I'd like to share that it's possible to clean some duplication of code with the generics you suggested. And if there is a need to support specific behaviors (like renameUSSFavorite) we can certainly extend the generic in an overloaded signature faction.
Thanks Fernando. It feels like we're moving in the right direction. I too have been experimenting.
export type IZoweNodeType = IZoweDatasetTreeNode | IZoweUSSTreeNode | IZoweJobTreeNode;
rename(IZoweNodeType);
vscode.commands.registerCommand("zowe.renameDataSet", (node) => datasetProvider.rename(node));
Implemented in the DatasetTree (and USSTree):
public async rename(node: IZoweDatasetTreeNode) {
And whilst experimenting I secured the default behavior for instance with renaming a Job which wouldn't be implemented
public async rename(node: IZoweNodeType) { this.log.debug("not implemented"); }
Lets have a chat as I would like to understand your example for overloading better. I think we have many alternatives and just need to decide which one is makes most sense to everyone.