Re: [pgadmin4][patch] Initial patch to decouple from ACI Tree - Mailing list pgadmin-hackers

From Anthony Emengo
Subject Re: [pgadmin4][patch] Initial patch to decouple from ACI Tree
Date
Msg-id CAG8BBZNndOje9T-B=Jrxj0tqJbDYc489yYbkJkJx_V5LKzsM-w@mail.gmail.com
Whole thread Raw
In response to Re: [pgadmin4][patch] Initial patch to decouple from ACI Tree  (Ashesh Vashi <ashesh.vashi@enterprisedb.com>)
Responses Re: [pgadmin4][patch] Initial patch to decouple from ACI Tree  (Anthony Emengo <aemengo@pivotal.io>)
Re: [pgadmin4][patch] Initial patch to decouple from ACI Tree  (Ashesh Vashi <ashesh.vashi@enterprisedb.com>)
List pgadmin-hackers
export function canCreate(pgBrowser, childOfCatalogType) { return canCreateObject.bind({   browser: pgBrowser,   childOfCatalogType: childOfCatalogType, });
}

With respect to the above code: this bind pattern looks good and seems like the idiomatic way to handle this in JavaScript. On a lighter node, I don’t even see the need for an additional method to wrap it. The invocation could have easily been like canCreate: canCreateObject.bind({ browser: pgBrowser, childOfCatalogType: childOfCatalogType }), I don’t feel too strongly here.

I renamed it as isValidTreeNodeData, because - we were using it in for testing the tree data. Please suggest me the right place, and name.

We’re not sure; maybe after continued refactoring, we will come across more generic functions. At that point we can revisit this and create a utils.js file.

The original patch was separating them in different places, but - still uses some of the functionalities directly from the tree, which was happening because we have contextual menu.
To give a better solution, I can think of putting the menus related code understand ‘sources/tree/menu’ directory.

We’re particularly worried because we’re trying to avoid the coupling that we see in the code base today. We want to decouple application state from business domain logic as much as we can - because this makes the code much easier to understand. We achieve lower coupling by have more suitable interfaces to retrieve application state like: anyParent (the menu doesn’t care how this happens). This is the direction that we’re trying to move towards, we just don’t want the package structure to undermine that developer intent.

How about nodeMenu.isSupportedNode(…)?

Naming is one of the hardest problems in programming. I don’t feel too strongly about this one. For now, let’s keep it as is

Thanks
Anthony && Victoria




pgadmin-hackers by date:

Previous
From: Dave Page
Date:
Subject: pgAdmin 4 commit: Rough cleanup of the environment setup
Next
From: Dave Page
Date:
Subject: pgAdmin 4 commit: Further cleanup of the environment setup