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 1f3l62-0004gT-EB for pgadmin-hackers@arkaria.postgresql.org; Wed, 04 Apr 2018 16:17:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f3l61-0002rw-DM for pgadmin-hackers@arkaria.postgresql.org; Wed, 04 Apr 2018 16:17:13 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f3l60-0002rH-QQ for pgadmin-hackers@lists.postgresql.org; Wed, 04 Apr 2018 16:17:13 +0000 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f3l5s-00023u-MD for pgadmin-hackers@postgresql.org; Wed, 04 Apr 2018 16:17:11 +0000 Received: by mail-wm0-x233.google.com with SMTP id i3so20281034wmf.3 for ; Wed, 04 Apr 2018 09:17:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pgadmin-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=KpmUDazCuqz9dptbfNFpCEWW47qlWJwitpcMLnyEZZQ=; b=X3c4rez+4wEWYg7Nyo+jcgxtbtrS2dHkmr9Go7Q8hwGvfT0fbBUDwCmHDBwQQ/gD5N Kg7xI/l8VHjJ3cN274mGT4YyQDyKAckj9nVEcWCkQUEuGmoPPedRnDrScgkIda0FlKBx 8RIziMSo0jHrRQZ35o0v76JqfJlwllxhVQ0LmeLZONAzo0lWAdwtxmZRvTW+CA4uKErN CKkCjGZZ/889SjjsHzczflpdUwDiDEZ5glP6vwRovzMcYWX+DegIS7RBkltda9KvAucH GAN2X3AAgzOnouxTmmz5izW/cHgi/DpM1AqfcF23iAp00ifJJNQWAFD6w6DJlPPZPfVZ iXhQ== 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=KpmUDazCuqz9dptbfNFpCEWW47qlWJwitpcMLnyEZZQ=; b=eeuHs6AGJSiNIU22su360/yg3Qs1m0eutQXbn3CIn99tiCH9aisKgDkuarhQK2tx8/ ebldEp+H8xCA2m2MillYVE5+JyEZFkB9/cwl0EOZNCiGSeP9/ZMRj3CpDhmhtTHsLClB XO9toB6njbJlHDvouC0Q0jVGUs+DzPtaHDWQ8m2PwjIZvVCYsKZY7YuQii/oJvDTTCAv sORJcLKSod8CNatrEVaVINcHgFECtBlJtW1vOrNseuSp71YP0+slR/iVxFCv/FV+4G/k f7JEu66RzjcJQx04Uln/n75oz0sqIDDmOqlNmILmeEo3Umc2PrVjCy8GQZSmW+WmzkuJ cGNw== X-Gm-Message-State: ALQs6tATHPdPTRAYKgqCXo5yNQ9dSRUR2JFF19IJwxG9gW9cLy/K46xr FsfzHSlqPX8GRuaBC9ewyXDhCgLAy0sbKg2BV9m3ww== X-Google-Smtp-Source: AIpwx4/d9FofQiwtSAwqc24t614HR6afki4/NftWBy840BtcNrAowYJdrwKFKabz9oKf+O1P4HsQC/nLBa+go7TSbrs= X-Received: by 10.28.98.69 with SMTP id w66mr8704814wmb.64.1522858621578; Wed, 04 Apr 2018 09:17:01 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.69.220 with HTTP; Wed, 4 Apr 2018 09:17:01 -0700 (PDT) In-Reply-To: References: From: Dave Page Date: Wed, 4 Apr 2018 17:17:01 +0100 Message-ID: Subject: Re: [pgadmin4][patch] Initial patch to decouple from ACI Tree To: Joao De Almeida Pereira Cc: pgadmin-hackers , Khushboo Vashi , Murtuza Zabuawala Content-Type: multipart/alternative; boundary="001a1148e3d22ec98905690827b2" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --001a1148e3d22ec98905690827b2 Content-Type: text/plain; charset="UTF-8" Khushboo, Murtuza, Can you spend some time reviewing this please? I've started playing with it as well - the first thing that's irking me somewhat is the lack of comments. Descriptive function names are all well and good, but sometimes a little more is needed, especially for less experienced developers or newcomers to the application! On Mon, Apr 2, 2018 at 7:45 PM, 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 > > -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company --001a1148e3d22ec98905690827b2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Khushboo, Murtuza,

Can you spend some t= ime reviewing this please? I've started playing with it as well - the f= irst thing that's irking me somewhat is the lack of comments. Descripti= ve function names are all well and good, but sometimes a little more is nee= ded, especially for less experienced developers or newcomers to the applica= tion!

= On Mon, Apr 2, 2018 at 7:45 PM, Joao De Almeida Pereira &= lt;jdealm= eidapereira@pivotal.io> wrote:
Hi Hackers,

Attached you can find t= he 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.

Summar= y of the patch:
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 refer= ence on the available test doubles:=C2=A0https://martinfowler.com/bl= iki/TestDouble.html) that can be used to inplace to replace the ACITree= and also encapsulate the new tree behavior on our tests
=C2=A0- = Adds tests for all the tree functionalities

0002 p= atch:
=C2=A0- Extracts, refactors, adds tests and remove dependen= cy from ACI Tree on:
- getTreeNodeHierarchy
- on backup.js:= menu_enabled, menu_enabled_server, start_backup_global_server, backup_obje= cts
- on datagrid.js: show_data_grid, get_panel_title, show_query_to= ol
- Start using sprintf-js as Underscore.String is deprecating sprintf= function
=C2=A0=C2=A0
This patch represents only 10 call= s 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 i= s 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 AC= ITree. From this point we decided to replace that function with our own ver= sion. The function that we choose was "itemData".
The f= unction 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 tree with a function called itemData
Pros:<= /div>
=C2=A0- At first view this was the simpler solution
=C2=A0- = Would keep the status quo
Cons:
=C2=A0- Not a OOP approach
=C2=A0- Not very flexible
=C2=A0 b) Create a tree that wo= uld return a node given an ID and then the node would be responsible for gi= ving it's data.
Pros:=C2=A0
=C2=A0- OOP Approach
=C2=A0- More flexible and we do not need to bring the tree around, = just a node
Cons:
=C2=A0- Break the current status quo<= /div>

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

2. Af= ter we decided on the starting point we searched for occurrences of the fun= ction "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 re= sponsible for calling the itemData function.

4. Ex= tracted the function to a separate file

5. Wrap th= is 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 t= hat all tests were passing

9. Remove function from= the original file and use the new function

10. En= sure everything still works

11. Find the next func= tion and execute from step 4 until all the functions are replaced, refactor= ed 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 A= CITree 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:
=C2=A0- Finish the complete decoupling of the ACITre= e
=C2=A0- Performance of the current tree implementation
=C2=A0- Tweak the naming of the Tree class to explicitly tell us this is = to use only with ACITree.


Thanks
Joao

<= /div>



--
Dave Page
Blog: = http://pgsnake.bl= ogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com<= br>The Enterprise PostgreSQL Company
--001a1148e3d22ec98905690827b2--