Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f42BS-0003l1-4u for pgadmin-hackers@arkaria.postgresql.org; Thu, 05 Apr 2018 10:31:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f42BR-0007jS-3r for pgadmin-hackers@arkaria.postgresql.org; Thu, 05 Apr 2018 10:31:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f42BQ-0007jI-Pn for pgadmin-hackers@lists.postgresql.org; Thu, 05 Apr 2018 10:31:56 +0000 Received: from mail-ot0-x235.google.com ([2607:f8b0:4003:c0f::235]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f42BL-0002jx-RQ for pgadmin-hackers@postgresql.org; Thu, 05 Apr 2018 10:31:56 +0000 Received: by mail-ot0-x235.google.com with SMTP id h55-v6so25115228ote.9 for ; Thu, 05 Apr 2018 03:31:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=lMriC06Xj+yuNOSegKxckXtCfpD3UyrmGS6QiyP+jew=; b=pxDbfBVu1Szz+UdR4VPDidMXzWHNjjnxI77RQUe3Xw4MyjVcxh+Zewh4o4qJ1h93SY yLq90NqI11LQtuOxyPm3GBw48Wm3j+PXnCFzEP+QUPirrVckHJB0zDB00YM1lXft3nep J0Zs1fEYpN8CSj2XNTlBNeY0/qhQjFivhplE9AXuK9oo4KUoQg2hFQeDZ/Xm6ngskOQa 8yulRYi8Y9aTZcbTCjZaD5WZV7HQvjYngzx/JA/E+EFyGU+qJpRNb5Oyq8EhFt5KBFzV 2W1ezZ1JMy013pjgmKvjSiBA0pEED47vNaUlMNL6UVc6d8c4z2CqW6XmQUrmIyKwUMSZ rlHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=lMriC06Xj+yuNOSegKxckXtCfpD3UyrmGS6QiyP+jew=; b=bSYmJeJGqERS2Xzh7g3cIE/tan0N3Xw+LesG5CyAUmmuKZEIWSFWzr3/8d2Jo3nu1x 5LLFyShIPoiOaMEweI1SXMQBqbU2N6HLXflAapWS8cxO8ILfZYc4xSywdd1v70UZHQNh IgR3afRzxEX6RkjjgOAqUg+YDPF3MvSL5xegbTMn2uzVlZngNiMG0Z/AHg15lB5rBeL2 NYF9PZzfnopsAZ1H9DDWNEO8d+VizbhwJHeQGJhbqfTFq8RojC1WcQJdjgJ5dWt8IMhP rc9Jzivpd1Q94QZF0v+5NVgeRGeOklEW9mir28vxOj5zEqlepjjazhTtwWfPW+Jm+D2U +6pA== X-Gm-Message-State: ALQs6tCQRb5HXtMAf7BjYqQjKm//8ZlF4lzO3nEQFh8uAoVnZ8R9iNwH bo1fgnM1nXrUh7HKlbI3lNHm77fcNA7Zigg5jVwJjA== X-Google-Smtp-Source: AIpwx4/BJEwfvbDmrI2G+WDnMQgLLajFFvx3Wp0/jyGOQUgo+BeCzUVLELoaEQGTs0S1uBNfpPqSV5vMc8auveGW8q8= X-Received: by 2002:a9d:2b54:: with SMTP id f20-v6mr12265288otd.277.1522924308452; Thu, 05 Apr 2018 03:31:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.74.138.251 with HTTP; Thu, 5 Apr 2018 03:31:48 -0700 (PDT) In-Reply-To: References: From: Khushboo Vashi Date: Thu, 5 Apr 2018 16:01:48 +0530 Message-ID: Subject: Re: [pgadmin4][patch] Initial patch to decouple from ACI Tree To: Joao De Almeida Pereira Cc: pgadmin-hackers Content-Type: multipart/alternative; boundary="0000000000006ced310569177209" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --0000000000006ced310569177209 Content-Type: text/plain; charset="UTF-8" Hi Joao, Can you please rebase the second patch? Thanks, Khushboo On Tue, Apr 3, 2018 at 12:15 AM, Joao De Almeida Pereira < jdealmeidapereira@pivotal.io> wrote: > Hi Hackers, > > Attached you can find the patch that will start to decouple pgAdmin from > ACITree library. > This patch is intended to be merged after 3.0, because we do not want to > cause any entropy or delay the release, but we want to start the discussion > and show some code. > > This job that we started is a massive tech debt chore that will take some > time to finalize and we would love the help of the community to do it. > > *Summary of the patch:* > 0001 patch: > - Creates a new tree that will allow us to create a separation between > the application and ACI Tree > - Creates a Fake Tree (Test double, for reference on the available test > doubles: https://martinfowler.com/bliki/TestDouble.html) that can be used > to inplace to replace the ACITree and also encapsulate the new tree > behavior on our tests > - Adds tests for all the tree functionalities > > 0002 patch: > - Extracts, refactors, adds tests and remove dependency from ACI Tree on: > - getTreeNodeHierarchy > - on backup.js: menu_enabled, menu_enabled_server, > start_backup_global_server, backup_objects > - on datagrid.js: show_data_grid, get_panel_title, show_query_tool > - Start using sprintf-js as Underscore.String is deprecating sprintf > function > > This patch represents only 10 calls to ACITree.itemData out of 176 that > are spread around our code > > > *In Depth look on the process behind the patch:* > > We started writing this patch with the idea that we need to decouple > pgAdmin4 from ACITree, because ACITree is no longer supported, the > documentation is non existent and ACITree is no longer being actively > developed. > > Our process: > 1. We "randomly" selected a function that is part of the ACITree. From > this point we decided to replace that function with our own version. The > function that we choose was "itemData". > The function gives us all the "data" that a specific node of the tree find. > Given in order to replace the tree we would need to have a function that > would give us the same information. We had 2 options: > a) Create a tree with a function called itemData > Pros: > - At first view this was the simpler solution > - Would keep the status quo > Cons: > - Not a OOP approach > - Not very flexible > b) Create a tree that would return a node given an ID and then the node > would be responsible for giving it's data. > Pros: > - OOP Approach > - More flexible and we do not need to bring the tree around, just a node > Cons: > - Break the current status quo > > Given these 2 options we decided to go for a more OOP approach creating a > Tree and a TreeNode classes, that in the future will be renamed to > ACITreeWrapper and TreeNode. > > 2. After we decided on the starting point we searched for occurrences of > the function "itemData" and we found out that there were 303 occurrences of > "itemData" in the code and roughly 176 calls to the function itself (some > of the hits were variable names). > > 3. We selected the first file on the search and found the function that > was responsible for calling the itemData function. > > 4. Extracted the function to a separate file > > 5. Wrap this function with tests > > 6. Refactor the function to ES6, give more declarative names to variables > and break the functions into smaller chunks > > 7. When all the tests were passing we replaced ACITree with our Tree > > 8. We ensured that all tests were passing > > 9. Remove function from the original file and use the new function > > 10. Ensure everything still works > > 11. Find the next function and execute from step 4 until all the functions > are replaced, refactored and tested. > > As you can see by the process this is a pretty huge undertake, because of > the number of calls to the function. This is just the first step on the > direction of completely isolating the ACITree so that we can solve the > problem with a large number of elements on the tree. > > *What is on our radar that we need to address:* > - Finish the complete decoupling of the ACITree > - Performance of the current tree implementation > - Tweak the naming of the Tree class to explicitly tell us this is to use > only with ACITree. > > > Thanks > Joao > > --0000000000006ced310569177209 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Joao,

Can you please rebase the seco= nd patch?

Thanks,
Khushboo

On Tue, Apr 3, 2018 at 12:1= 5 AM, Joao De Almeida Pereira <jdealmeidapereira@pivotal.io= > wrote:
Hi Ha= ckers,

Attached you can find the patch that will start t= o decouple pgAdmin from ACITree library.
This patch is intended t= o be merged after 3.0, because we do not want to cause any entropy or delay= the release, but we want to start the discussion and show some code.
=

This job that we started is a massive tech debt chore t= hat will take some time to finalize and we would love the help of the commu= nity to do it.

Summary of the patch:
<= div>0001 patch:=C2=A0
=C2=A0- Creates a new tree that will allow = us to create a separation between the application and ACI Tree
= =C2=A0- Creates a Fake Tree (Test double, for reference on the available te= st doubles:=C2=A0https://martinfowler.com/bliki/TestDouble.html)= that can be used to inplace to replace the ACITree and also encapsulate th= e new tree behavior on our tests
=C2=A0- Adds tests for all the t= ree functionalities

0002 patch:
=C2=A0- = Extracts, refactors, adds tests and remove dependency from ACI Tree on: - getTreeNodeHierarchy
- on backup.js: menu_enabled, menu_enab= led_server, start_backup_global_server, backup_objects
- on datagrid= .js: show_data_grid, get_panel_title, show_query_tool
- Start using spr= intf-js as Underscore.String is deprecating sprintf function
=C2=A0= =C2=A0
This patch represents only 10 calls to ACITree.itemData ou= t of 176 that are spread around our code


In Depth look on the process behind the patch:

We started writing this patch with the idea that we need t= o decouple pgAdmin4 from ACITree, because ACITree is no longer supported, t= he documentation is non existent and ACITree is no longer being actively de= veloped.

Our process:
1. We "random= ly" selected a function that is part of the ACITree. From this point w= e decided to replace that function with our own version. The function that = we choose was "itemData".
The function gives us all the= "data" that a specific node of the tree find.
Given in= order to replace the tree we would need to have a function that would give= us the same information. We had 2 options:
=C2=A0 a) Create a tr= ee with a function called itemData
Pros:
=C2=A0- At fir= st view this was the simpler solution
=C2=A0- Would keep the status qu= o
Cons:
=C2=A0- Not a OOP approach
=C2=A0- Not very= flexible
=C2=A0 b) Create a tree that would return a node given = an ID and then the node would be responsible for giving it's data.
Pros:=C2=A0
=C2=A0- OOP Approach
=C2=A0- More fle= xible and we do not need to bring the tree around, just a node
Co= ns:
=C2=A0- Break the current status quo

Given these 2 options we decided to go for a more OOP approach creating a = Tree and a TreeNode classes, that in the future will be renamed to ACITreeW= rapper and TreeNode.

2. After we decided on the st= arting point we searched for occurrences of the function "itemData&quo= t; and we found out that there were 303 occurrences of "itemData"= in the code and roughly 176 calls to the function itself (some of the hits= were variable names).

3. We selected the first fi= le on the search and found the function that was responsible for calling th= e itemData function.

4. Extracted the function to = a separate file

5. Wrap this function with tests

6. Refactor the function to ES6, give more declarat= ive names to variables and break the functions into smaller chunks

7. When all the tests were passing we replaced ACITree wit= h our Tree

8. We ensured that all tests were passi= ng

9. Remove function from the original file and u= se the new function

10. Ensure everything still wo= rks

11. Find the next function and execute from st= ep 4 until all the functions are replaced, refactored and tested.

As you can see by the process this is a pretty huge underta= ke, because of the number of calls to the function. This is just the first = step on the direction of completely isolating the ACITree so that we can so= lve the problem with a large number of elements on the tree.

=
What is on our radar that we need to address:
= =C2=A0- Finish the complete decoupling of the ACITree
=C2=A0- Per= formance of the current tree implementation
=C2=A0- Tweak the nam= ing of the Tree class to explicitly tell us this is to use only with ACITre= e.


Thanks
Joao


--0000000000006ced310569177209--