You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@iotdb.apache.org by Christofer Dutz <ch...@c-ware.de> on 2024/08/02 11:59:34 UTC

[DISCUSS] Refactoring IoTDB to eliminate the singleton pattern

Hi all,

So, one thing that has always been bothering me a bit with respect to the IoTDB code-base, was the usage of the singleton pattern.
Even if it simplifies composition of a project, it comes with quite some severe disadvantages.

In my last PR I tried refactoring the usage of singletons to make components more unit-testable and I was quite happy with the results.

I wrote up my ideas as well as some facts from fellow Apache projects.

https://timechor.feishu.cn/docx/QLgZdJWgUoKBLSx1t3EcBJdRnud

Please have a look and comment here. I would really like to start the progress of refactoring IoTDB (At least with this approach it doesn’t have to be an all-or-nothing big-bang type of refactoring, but instead can happen over time).

Chris

Re: [DISCUSS] Refactoring IoTDB to eliminate the singleton pattern

Posted by Xinyu Tan <ta...@apache.org>.
I believe it's a typo hahaha~ Eliminating the singleton pattern is our community's goal.

Xinyu Tan

On 2024/08/14 06:48:35 Christofer Dutz wrote:
> I assume you are referring to removing the singleton pattern, right? Because it's already everywhere :-)
> 
> Chris
> 
> Gesendet von Outlook für Android<https://aka.ms/AAb9ysg>
> ________________________________
> From: 乔嘉林 <ji...@timecho.com>
> Sent: Wednesday, August 14, 2024 3:33:27 AM
> To: dev@iotdb.apache.org <de...@iotdb.apache.org>
> Subject: Re: [DISCUSS] Refactoring IoTDB to eliminate the singleton pattern
> 
> Hi,
> 
> +1 for adding singleton pattern and UTs
> 
> Jialin
> > From: "Christofer Dutz"<ch...@c-ware.de>
> > Date:  Tue, Aug 13, 2024, 22:32
> > Subject:  AW: [DISCUSS] Refactoring IoTDB to eliminate the singleton pattern
> > To: "dev@iotdb.apache.org"<de...@iotdb.apache.org>
> > Yeah … that’s what I’m proposing to do ;-)
> >
> > Make the stuff more easily testable and then also add tests for it.
> >
> > Chris
> >
> > Von: Xinyu Tan <ta...@apache.org>
> > Datum: Dienstag, 13. August 2024 um 15:55
> > An: dev@iotdb.apache.org <de...@iotdb.apache.org>
> > Betreff: Re: [DISCUSS] Refactoring IoTDB to eliminate the singleton pattern
> > Yes, but if we want to improve line-level test coverage, we do need to make our code more testable, i.e. add more uts
> >
> > On 2024/08/07 07:08:34 Christofer Dutz wrote:
> > > I should clarify,
> > > This is the coverage from within the module itself. We definitely have more coverage when also running the integration test module, however none of the parts I recently touched seem to have had any form of tests.
> > >
> > > Chris
> > >
> > > Gesendet von Outlook für Android<https://aka.ms/AAb9ysg>
> > > ________________________________
> > > From: Xinyu Tan <ta...@apache.org>
> > > Sent: Monday, August 5, 2024 11:43:24 AM
> > > To: dev@iotdb.apache.org <de...@iotdb.apache.org>
> > > Subject: Re: [DISCUSS] Refactoring IoTDB to eliminate the singleton pattern
> > >
> > > Hi, Chris
> > >
> > > I am shocked to see our class coverage and line coverage so low.
> > >
> > > I support making changes to our use of singletons to identify more issues in unit tests, reducing the likelihood of problems surfacing in integration tests, release testing, or even user environments.
> > >
> > > In the future, I also advocate prioritizing unit tests over integration tests when testing certain functionalities.
> > >
> > > My suggestion is to adopt a test-driven approach. We should first define some quantifiable and observable metrics, and then continuously refactor the singleton pattern while improving these metrics. This approach seems more sustainable.
> > >
> > > Best
> > > -------------
> > > Xinyu Tan
> > >
> > > On 2024/08/02 11:59:34 Christofer Dutz wrote:
> > > > Hi all,
> > > >
> > > > So, one thing that has always been bothering me a bit with respect to the IoTDB code-base, was the usage of the singleton pattern.
> > > > Even if it simplifies composition of a project, it comes with quite some severe disadvantages.
> > > >
> > > > In my last PR I tried refactoring the usage of singletons to make components more unit-testable and I was quite happy with the results.
> > > >
> > > > I wrote up my ideas as well as some facts from fellow Apache projects.
> > > >
> > > > https://timechor.feishu.cn/docx/QLgZdJWgUoKBLSx1t3EcBJdRnud
> > > >
> > > > Please have a look and comment here. I would really like to start the progress of refactoring IoTDB (At least with this approach it doesn’t have to be an all-or-nothing big-bang type of refactoring, but instead can happen over time).
> > > >
> > > > Chris
> > > >
> > >
> 

Re: [DISCUSS] Refactoring IoTDB to eliminate the singleton pattern

Posted by Christofer Dutz <ch...@c-ware.de>.
I assume you are referring to removing the singleton pattern, right? Because it's already everywhere :-)

Chris

Gesendet von Outlook für Android<https://aka.ms/AAb9ysg>
________________________________
From: 乔嘉林 <ji...@timecho.com>
Sent: Wednesday, August 14, 2024 3:33:27 AM
To: dev@iotdb.apache.org <de...@iotdb.apache.org>
Subject: Re: [DISCUSS] Refactoring IoTDB to eliminate the singleton pattern

Hi,

+1 for adding singleton pattern and UTs

Jialin
> From: "Christofer Dutz"<ch...@c-ware.de>
> Date:  Tue, Aug 13, 2024, 22:32
> Subject:  AW: [DISCUSS] Refactoring IoTDB to eliminate the singleton pattern
> To: "dev@iotdb.apache.org"<de...@iotdb.apache.org>
> Yeah … that’s what I’m proposing to do ;-)
>
> Make the stuff more easily testable and then also add tests for it.
>
> Chris
>
> Von: Xinyu Tan <ta...@apache.org>
> Datum: Dienstag, 13. August 2024 um 15:55
> An: dev@iotdb.apache.org <de...@iotdb.apache.org>
> Betreff: Re: [DISCUSS] Refactoring IoTDB to eliminate the singleton pattern
> Yes, but if we want to improve line-level test coverage, we do need to make our code more testable, i.e. add more uts
>
> On 2024/08/07 07:08:34 Christofer Dutz wrote:
> > I should clarify,
> > This is the coverage from within the module itself. We definitely have more coverage when also running the integration test module, however none of the parts I recently touched seem to have had any form of tests.
> >
> > Chris
> >
> > Gesendet von Outlook für Android<https://aka.ms/AAb9ysg>
> > ________________________________
> > From: Xinyu Tan <ta...@apache.org>
> > Sent: Monday, August 5, 2024 11:43:24 AM
> > To: dev@iotdb.apache.org <de...@iotdb.apache.org>
> > Subject: Re: [DISCUSS] Refactoring IoTDB to eliminate the singleton pattern
> >
> > Hi, Chris
> >
> > I am shocked to see our class coverage and line coverage so low.
> >
> > I support making changes to our use of singletons to identify more issues in unit tests, reducing the likelihood of problems surfacing in integration tests, release testing, or even user environments.
> >
> > In the future, I also advocate prioritizing unit tests over integration tests when testing certain functionalities.
> >
> > My suggestion is to adopt a test-driven approach. We should first define some quantifiable and observable metrics, and then continuously refactor the singleton pattern while improving these metrics. This approach seems more sustainable.
> >
> > Best
> > -------------
> > Xinyu Tan
> >
> > On 2024/08/02 11:59:34 Christofer Dutz wrote:
> > > Hi all,
> > >
> > > So, one thing that has always been bothering me a bit with respect to the IoTDB code-base, was the usage of the singleton pattern.
> > > Even if it simplifies composition of a project, it comes with quite some severe disadvantages.
> > >
> > > In my last PR I tried refactoring the usage of singletons to make components more unit-testable and I was quite happy with the results.
> > >
> > > I wrote up my ideas as well as some facts from fellow Apache projects.
> > >
> > > https://timechor.feishu.cn/docx/QLgZdJWgUoKBLSx1t3EcBJdRnud
> > >
> > > Please have a look and comment here. I would really like to start the progress of refactoring IoTDB (At least with this approach it doesn’t have to be an all-or-nothing big-bang type of refactoring, but instead can happen over time).
> > >
> > > Chris
> > >
> >

Re: [DISCUSS] Refactoring IoTDB to eliminate the singleton pattern

Posted by 乔嘉林 <ji...@timecho.com>.
Hi,

+1 for adding singleton pattern and UTs

Jialin
> From: "Christofer Dutz"<ch...@c-ware.de>
> Date:  Tue, Aug 13, 2024, 22:32
> Subject:  AW: [DISCUSS] Refactoring IoTDB to eliminate the singleton pattern
> To: "dev@iotdb.apache.org"<de...@iotdb.apache.org>
> Yeah … that’s what I’m proposing to do ;-)
> 
> Make the stuff more easily testable and then also add tests for it.
> 
> Chris
> 
> Von: Xinyu Tan <ta...@apache.org>
> Datum: Dienstag, 13. August 2024 um 15:55
> An: dev@iotdb.apache.org <de...@iotdb.apache.org>
> Betreff: Re: [DISCUSS] Refactoring IoTDB to eliminate the singleton pattern
> Yes, but if we want to improve line-level test coverage, we do need to make our code more testable, i.e. add more uts
> 
> On 2024/08/07 07:08:34 Christofer Dutz wrote:
> > I should clarify,
> > This is the coverage from within the module itself. We definitely have more coverage when also running the integration test module, however none of the parts I recently touched seem to have had any form of tests.
> >
> > Chris
> >
> > Gesendet von Outlook für Android<https://aka.ms/AAb9ysg>
> > ________________________________
> > From: Xinyu Tan <ta...@apache.org>
> > Sent: Monday, August 5, 2024 11:43:24 AM
> > To: dev@iotdb.apache.org <de...@iotdb.apache.org>
> > Subject: Re: [DISCUSS] Refactoring IoTDB to eliminate the singleton pattern
> >
> > Hi, Chris
> >
> > I am shocked to see our class coverage and line coverage so low.
> >
> > I support making changes to our use of singletons to identify more issues in unit tests, reducing the likelihood of problems surfacing in integration tests, release testing, or even user environments.
> >
> > In the future, I also advocate prioritizing unit tests over integration tests when testing certain functionalities.
> >
> > My suggestion is to adopt a test-driven approach. We should first define some quantifiable and observable metrics, and then continuously refactor the singleton pattern while improving these metrics. This approach seems more sustainable.
> >
> > Best
> > -------------
> > Xinyu Tan
> >
> > On 2024/08/02 11:59:34 Christofer Dutz wrote:
> > > Hi all,
> > >
> > > So, one thing that has always been bothering me a bit with respect to the IoTDB code-base, was the usage of the singleton pattern.
> > > Even if it simplifies composition of a project, it comes with quite some severe disadvantages.
> > >
> > > In my last PR I tried refactoring the usage of singletons to make components more unit-testable and I was quite happy with the results.
> > >
> > > I wrote up my ideas as well as some facts from fellow Apache projects.
> > >
> > > https://timechor.feishu.cn/docx/QLgZdJWgUoKBLSx1t3EcBJdRnud
> > >
> > > Please have a look and comment here. I would really like to start the progress of refactoring IoTDB (At least with this approach it doesn’t have to be an all-or-nothing big-bang type of refactoring, but instead can happen over time).
> > >
> > > Chris
> > >
> >

AW: [DISCUSS] Refactoring IoTDB to eliminate the singleton pattern

Posted by Christofer Dutz <ch...@c-ware.de>.
Yeah … that’s what I’m proposing to do ;-)

Make the stuff more easily testable and then also add tests for it.

Chris

Von: Xinyu Tan <ta...@apache.org>
Datum: Dienstag, 13. August 2024 um 15:55
An: dev@iotdb.apache.org <de...@iotdb.apache.org>
Betreff: Re: [DISCUSS] Refactoring IoTDB to eliminate the singleton pattern
Yes, but if we want to improve line-level test coverage, we do need to make our code more testable, i.e. add more uts

On 2024/08/07 07:08:34 Christofer Dutz wrote:
> I should clarify,
> This is the coverage from within the module itself. We definitely have more coverage when also running the integration test module, however none of the parts I recently touched seem to have had any form of tests.
>
> Chris
>
> Gesendet von Outlook für Android<https://aka.ms/AAb9ysg>
> ________________________________
> From: Xinyu Tan <ta...@apache.org>
> Sent: Monday, August 5, 2024 11:43:24 AM
> To: dev@iotdb.apache.org <de...@iotdb.apache.org>
> Subject: Re: [DISCUSS] Refactoring IoTDB to eliminate the singleton pattern
>
> Hi, Chris
>
> I am shocked to see our class coverage and line coverage so low.
>
> I support making changes to our use of singletons to identify more issues in unit tests, reducing the likelihood of problems surfacing in integration tests, release testing, or even user environments.
>
> In the future, I also advocate prioritizing unit tests over integration tests when testing certain functionalities.
>
> My suggestion is to adopt a test-driven approach. We should first define some quantifiable and observable metrics, and then continuously refactor the singleton pattern while improving these metrics. This approach seems more sustainable.
>
> Best
> -------------
> Xinyu Tan
>
> On 2024/08/02 11:59:34 Christofer Dutz wrote:
> > Hi all,
> >
> > So, one thing that has always been bothering me a bit with respect to the IoTDB code-base, was the usage of the singleton pattern.
> > Even if it simplifies composition of a project, it comes with quite some severe disadvantages.
> >
> > In my last PR I tried refactoring the usage of singletons to make components more unit-testable and I was quite happy with the results.
> >
> > I wrote up my ideas as well as some facts from fellow Apache projects.
> >
> > https://timechor.feishu.cn/docx/QLgZdJWgUoKBLSx1t3EcBJdRnud
> >
> > Please have a look and comment here. I would really like to start the progress of refactoring IoTDB (At least with this approach it doesn’t have to be an all-or-nothing big-bang type of refactoring, but instead can happen over time).
> >
> > Chris
> >
>

Re: [DISCUSS] Refactoring IoTDB to eliminate the singleton pattern

Posted by Xinyu Tan <ta...@apache.org>.
Yes, but if we want to improve line-level test coverage, we do need to make our code more testable, i.e. add more uts

On 2024/08/07 07:08:34 Christofer Dutz wrote:
> I should clarify,
> This is the coverage from within the module itself. We definitely have more coverage when also running the integration test module, however none of the parts I recently touched seem to have had any form of tests.
> 
> Chris
> 
> Gesendet von Outlook für Android<https://aka.ms/AAb9ysg>
> ________________________________
> From: Xinyu Tan <ta...@apache.org>
> Sent: Monday, August 5, 2024 11:43:24 AM
> To: dev@iotdb.apache.org <de...@iotdb.apache.org>
> Subject: Re: [DISCUSS] Refactoring IoTDB to eliminate the singleton pattern
> 
> Hi, Chris
> 
> I am shocked to see our class coverage and line coverage so low.
> 
> I support making changes to our use of singletons to identify more issues in unit tests, reducing the likelihood of problems surfacing in integration tests, release testing, or even user environments.
> 
> In the future, I also advocate prioritizing unit tests over integration tests when testing certain functionalities.
> 
> My suggestion is to adopt a test-driven approach. We should first define some quantifiable and observable metrics, and then continuously refactor the singleton pattern while improving these metrics. This approach seems more sustainable.
> 
> Best
> -------------
> Xinyu Tan
> 
> On 2024/08/02 11:59:34 Christofer Dutz wrote:
> > Hi all,
> >
> > So, one thing that has always been bothering me a bit with respect to the IoTDB code-base, was the usage of the singleton pattern.
> > Even if it simplifies composition of a project, it comes with quite some severe disadvantages.
> >
> > In my last PR I tried refactoring the usage of singletons to make components more unit-testable and I was quite happy with the results.
> >
> > I wrote up my ideas as well as some facts from fellow Apache projects.
> >
> > https://timechor.feishu.cn/docx/QLgZdJWgUoKBLSx1t3EcBJdRnud
> >
> > Please have a look and comment here. I would really like to start the progress of refactoring IoTDB (At least with this approach it doesn’t have to be an all-or-nothing big-bang type of refactoring, but instead can happen over time).
> >
> > Chris
> >
> 

Re: [DISCUSS] Refactoring IoTDB to eliminate the singleton pattern

Posted by Christofer Dutz <ch...@c-ware.de>.
I should clarify,
This is the coverage from within the module itself. We definitely have more coverage when also running the integration test module, however none of the parts I recently touched seem to have had any form of tests.

Chris

Gesendet von Outlook für Android<https://aka.ms/AAb9ysg>
________________________________
From: Xinyu Tan <ta...@apache.org>
Sent: Monday, August 5, 2024 11:43:24 AM
To: dev@iotdb.apache.org <de...@iotdb.apache.org>
Subject: Re: [DISCUSS] Refactoring IoTDB to eliminate the singleton pattern

Hi, Chris

I am shocked to see our class coverage and line coverage so low.

I support making changes to our use of singletons to identify more issues in unit tests, reducing the likelihood of problems surfacing in integration tests, release testing, or even user environments.

In the future, I also advocate prioritizing unit tests over integration tests when testing certain functionalities.

My suggestion is to adopt a test-driven approach. We should first define some quantifiable and observable metrics, and then continuously refactor the singleton pattern while improving these metrics. This approach seems more sustainable.

Best
-------------
Xinyu Tan

On 2024/08/02 11:59:34 Christofer Dutz wrote:
> Hi all,
>
> So, one thing that has always been bothering me a bit with respect to the IoTDB code-base, was the usage of the singleton pattern.
> Even if it simplifies composition of a project, it comes with quite some severe disadvantages.
>
> In my last PR I tried refactoring the usage of singletons to make components more unit-testable and I was quite happy with the results.
>
> I wrote up my ideas as well as some facts from fellow Apache projects.
>
> https://timechor.feishu.cn/docx/QLgZdJWgUoKBLSx1t3EcBJdRnud
>
> Please have a look and comment here. I would really like to start the progress of refactoring IoTDB (At least with this approach it doesn’t have to be an all-or-nothing big-bang type of refactoring, but instead can happen over time).
>
> Chris
>

Re: [DISCUSS] Refactoring IoTDB to eliminate the singleton pattern

Posted by Xinyu Tan <ta...@apache.org>.
Hi, Chris

I am shocked to see our class coverage and line coverage so low.

I support making changes to our use of singletons to identify more issues in unit tests, reducing the likelihood of problems surfacing in integration tests, release testing, or even user environments.

In the future, I also advocate prioritizing unit tests over integration tests when testing certain functionalities.

My suggestion is to adopt a test-driven approach. We should first define some quantifiable and observable metrics, and then continuously refactor the singleton pattern while improving these metrics. This approach seems more sustainable.

Best
-------------
Xinyu Tan

On 2024/08/02 11:59:34 Christofer Dutz wrote:
> Hi all,
> 
> So, one thing that has always been bothering me a bit with respect to the IoTDB code-base, was the usage of the singleton pattern.
> Even if it simplifies composition of a project, it comes with quite some severe disadvantages.
> 
> In my last PR I tried refactoring the usage of singletons to make components more unit-testable and I was quite happy with the results.
> 
> I wrote up my ideas as well as some facts from fellow Apache projects.
> 
> https://timechor.feishu.cn/docx/QLgZdJWgUoKBLSx1t3EcBJdRnud
> 
> Please have a look and comment here. I would really like to start the progress of refactoring IoTDB (At least with this approach it doesn’t have to be an all-or-nothing big-bang type of refactoring, but instead can happen over time).
> 
> Chris
>