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 2023/07/14 11:14:12 UTC

Usage of Singleton pattern?

Hi all,

as I’m digging into IoTDB more and more, I noticed a quite excessive usage of the Singleton pattern … some times even for things where it doesn’t really make much sense. For example in SystemFileFactory, the methods don’t really have much state and simply fire RuntimeExceptions if fsType is initialized with HDFS.

Singletons make it a bit tricky to run tests in parallel and to do dynamic reloading of modules (like in OSGI). Most projects I’ve worked on try to limit the use of singletons to an absolute minimum due to these problems.

I guess embedding IoTDB in an OSGI environment hasn’t been a use-case yet, but I could imagine that random test failures while running tests in parallel probably could have caused some issues.

Was this a design decision that is based on some real-world necessity, or for simplifying things during development?
I don’t want to put too much effort into proposing cleaning up things, if there was a conscious decision to do things otherwise.

Chris


Re: Usage of Singleton pattern?

Posted by Xiangdong Huang <sa...@gmail.com>.
+1, too.
-----------------------------------
Xiangdong Huang


Jialin Qiao <qi...@apache.org> 于2023年7月14日周五 21:30写道:
>
> +1 for cleaning it
> —————————————————
> Jialin Qiao
> Apache IoTDB PMC
>
> Yuan Tian <ja...@gmail.com> 于2023年7月14日周五 21:28写道:
> >
> > Sure! Do as you want! We would love to see these refactoring prs.
> >
> >
> > Best,
> > ------------------
> > Yuan Tian
> >
> > On Fri, Jul 14, 2023 at 9:20 PM Christofer Dutz
> > <ch...@c-ware.de> wrote:
> > >
> > > Aaah cool,
> > >
> > > and sorry for asking so much … much of IoTDBs history is not recorded and I’m just starting to get my hands dirty.
> > > I am afraid, that I’ll probably have more questions like this as they come up.
> > >
> > > But that means, if I see something that can be refactored quickly, I can create PRs for stuff like that?
> > >
> > > Just asking, cause I like to do simple maintenance tasks in order to think about other problems.
> > > In PLC4X I usually did cleanups regularly for such reasons.
> > >
> > > Chris
> > >
> > >
> > > Von: Yuan Tian <ja...@gmail.com>
> > > Datum: Freitag, 14. Juli 2023 um 13:58
> > > An: dev@iotdb.apache.org <de...@iotdb.apache.org>
> > > Betreff: Re: Usage of Singleton pattern?
> > > Hi Chris,
> > >
> > > Actually, most of the existing  Singleton pattern Class is just for
> > > simplifying things during development. And we did run into trouble
> > > when writing some UTs(In such case, I will change related Singleton
> > > pattern Class ).
> > > But there are always higher priority tasks, so there is no time to
> > > change all these singletons. Good news is that we have strictly
> > > controlled the use of singletons in the new PRs, so there should be no
> > > more new ones.
> > >
> > > Best,
> > > ----------------
> > > Yuan Tian
> > >
> > > On Fri, Jul 14, 2023 at 7:14 PM Christofer Dutz
> > > <ch...@c-ware.de> wrote:
> > > >
> > > > Hi all,
> > > >
> > > > as I’m digging into IoTDB more and more, I noticed a quite excessive usage of the Singleton pattern … some times even for things where it doesn’t really make much sense. For example in SystemFileFactory, the methods don’t really have much state and simply fire RuntimeExceptions if fsType is initialized with HDFS.
> > > >
> > > > Singletons make it a bit tricky to run tests in parallel and to do dynamic reloading of modules (like in OSGI). Most projects I’ve worked on try to limit the use of singletons to an absolute minimum due to these problems.
> > > >
> > > > I guess embedding IoTDB in an OSGI environment hasn’t been a use-case yet, but I could imagine that random test failures while running tests in parallel probably could have caused some issues.
> > > >
> > > > Was this a design decision that is based on some real-world necessity, or for simplifying things during development?
> > > > I don’t want to put too much effort into proposing cleaning up things, if there was a conscious decision to do things otherwise.
> > > >
> > > > Chris
> > > >

Re: Usage of Singleton pattern?

Posted by Jialin Qiao <qi...@apache.org>.
+1 for cleaning it
—————————————————
Jialin Qiao
Apache IoTDB PMC

Yuan Tian <ja...@gmail.com> 于2023年7月14日周五 21:28写道:
>
> Sure! Do as you want! We would love to see these refactoring prs.
>
>
> Best,
> ------------------
> Yuan Tian
>
> On Fri, Jul 14, 2023 at 9:20 PM Christofer Dutz
> <ch...@c-ware.de> wrote:
> >
> > Aaah cool,
> >
> > and sorry for asking so much … much of IoTDBs history is not recorded and I’m just starting to get my hands dirty.
> > I am afraid, that I’ll probably have more questions like this as they come up.
> >
> > But that means, if I see something that can be refactored quickly, I can create PRs for stuff like that?
> >
> > Just asking, cause I like to do simple maintenance tasks in order to think about other problems.
> > In PLC4X I usually did cleanups regularly for such reasons.
> >
> > Chris
> >
> >
> > Von: Yuan Tian <ja...@gmail.com>
> > Datum: Freitag, 14. Juli 2023 um 13:58
> > An: dev@iotdb.apache.org <de...@iotdb.apache.org>
> > Betreff: Re: Usage of Singleton pattern?
> > Hi Chris,
> >
> > Actually, most of the existing  Singleton pattern Class is just for
> > simplifying things during development. And we did run into trouble
> > when writing some UTs(In such case, I will change related Singleton
> > pattern Class ).
> > But there are always higher priority tasks, so there is no time to
> > change all these singletons. Good news is that we have strictly
> > controlled the use of singletons in the new PRs, so there should be no
> > more new ones.
> >
> > Best,
> > ----------------
> > Yuan Tian
> >
> > On Fri, Jul 14, 2023 at 7:14 PM Christofer Dutz
> > <ch...@c-ware.de> wrote:
> > >
> > > Hi all,
> > >
> > > as I’m digging into IoTDB more and more, I noticed a quite excessive usage of the Singleton pattern … some times even for things where it doesn’t really make much sense. For example in SystemFileFactory, the methods don’t really have much state and simply fire RuntimeExceptions if fsType is initialized with HDFS.
> > >
> > > Singletons make it a bit tricky to run tests in parallel and to do dynamic reloading of modules (like in OSGI). Most projects I’ve worked on try to limit the use of singletons to an absolute minimum due to these problems.
> > >
> > > I guess embedding IoTDB in an OSGI environment hasn’t been a use-case yet, but I could imagine that random test failures while running tests in parallel probably could have caused some issues.
> > >
> > > Was this a design decision that is based on some real-world necessity, or for simplifying things during development?
> > > I don’t want to put too much effort into proposing cleaning up things, if there was a conscious decision to do things otherwise.
> > >
> > > Chris
> > >

Re: Usage of Singleton pattern?

Posted by Yuan Tian <ja...@gmail.com>.
Sure! Do as you want! We would love to see these refactoring prs.


Best,
------------------
Yuan Tian

On Fri, Jul 14, 2023 at 9:20 PM Christofer Dutz
<ch...@c-ware.de> wrote:
>
> Aaah cool,
>
> and sorry for asking so much … much of IoTDBs history is not recorded and I’m just starting to get my hands dirty.
> I am afraid, that I’ll probably have more questions like this as they come up.
>
> But that means, if I see something that can be refactored quickly, I can create PRs for stuff like that?
>
> Just asking, cause I like to do simple maintenance tasks in order to think about other problems.
> In PLC4X I usually did cleanups regularly for such reasons.
>
> Chris
>
>
> Von: Yuan Tian <ja...@gmail.com>
> Datum: Freitag, 14. Juli 2023 um 13:58
> An: dev@iotdb.apache.org <de...@iotdb.apache.org>
> Betreff: Re: Usage of Singleton pattern?
> Hi Chris,
>
> Actually, most of the existing  Singleton pattern Class is just for
> simplifying things during development. And we did run into trouble
> when writing some UTs(In such case, I will change related Singleton
> pattern Class ).
> But there are always higher priority tasks, so there is no time to
> change all these singletons. Good news is that we have strictly
> controlled the use of singletons in the new PRs, so there should be no
> more new ones.
>
> Best,
> ----------------
> Yuan Tian
>
> On Fri, Jul 14, 2023 at 7:14 PM Christofer Dutz
> <ch...@c-ware.de> wrote:
> >
> > Hi all,
> >
> > as I’m digging into IoTDB more and more, I noticed a quite excessive usage of the Singleton pattern … some times even for things where it doesn’t really make much sense. For example in SystemFileFactory, the methods don’t really have much state and simply fire RuntimeExceptions if fsType is initialized with HDFS.
> >
> > Singletons make it a bit tricky to run tests in parallel and to do dynamic reloading of modules (like in OSGI). Most projects I’ve worked on try to limit the use of singletons to an absolute minimum due to these problems.
> >
> > I guess embedding IoTDB in an OSGI environment hasn’t been a use-case yet, but I could imagine that random test failures while running tests in parallel probably could have caused some issues.
> >
> > Was this a design decision that is based on some real-world necessity, or for simplifying things during development?
> > I don’t want to put too much effort into proposing cleaning up things, if there was a conscious decision to do things otherwise.
> >
> > Chris
> >

AW: Usage of Singleton pattern?

Posted by Christofer Dutz <ch...@c-ware.de>.
Aaah cool,

and sorry for asking so much … much of IoTDBs history is not recorded and I’m just starting to get my hands dirty.
I am afraid, that I’ll probably have more questions like this as they come up.

But that means, if I see something that can be refactored quickly, I can create PRs for stuff like that?

Just asking, cause I like to do simple maintenance tasks in order to think about other problems.
In PLC4X I usually did cleanups regularly for such reasons.

Chris


Von: Yuan Tian <ja...@gmail.com>
Datum: Freitag, 14. Juli 2023 um 13:58
An: dev@iotdb.apache.org <de...@iotdb.apache.org>
Betreff: Re: Usage of Singleton pattern?
Hi Chris,

Actually, most of the existing  Singleton pattern Class is just for
simplifying things during development. And we did run into trouble
when writing some UTs(In such case, I will change related Singleton
pattern Class ).
But there are always higher priority tasks, so there is no time to
change all these singletons. Good news is that we have strictly
controlled the use of singletons in the new PRs, so there should be no
more new ones.

Best,
----------------
Yuan Tian

On Fri, Jul 14, 2023 at 7:14 PM Christofer Dutz
<ch...@c-ware.de> wrote:
>
> Hi all,
>
> as I’m digging into IoTDB more and more, I noticed a quite excessive usage of the Singleton pattern … some times even for things where it doesn’t really make much sense. For example in SystemFileFactory, the methods don’t really have much state and simply fire RuntimeExceptions if fsType is initialized with HDFS.
>
> Singletons make it a bit tricky to run tests in parallel and to do dynamic reloading of modules (like in OSGI). Most projects I’ve worked on try to limit the use of singletons to an absolute minimum due to these problems.
>
> I guess embedding IoTDB in an OSGI environment hasn’t been a use-case yet, but I could imagine that random test failures while running tests in parallel probably could have caused some issues.
>
> Was this a design decision that is based on some real-world necessity, or for simplifying things during development?
> I don’t want to put too much effort into proposing cleaning up things, if there was a conscious decision to do things otherwise.
>
> Chris
>

Re: Usage of Singleton pattern?

Posted by Yuan Tian <ja...@gmail.com>.
Hi Chris,

Actually, most of the existing  Singleton pattern Class is just for
simplifying things during development. And we did run into trouble
when writing some UTs(In such case, I will change related Singleton
pattern Class ).
But there are always higher priority tasks, so there is no time to
change all these singletons. Good news is that we have strictly
controlled the use of singletons in the new PRs, so there should be no
more new ones.

Best,
----------------
Yuan Tian

On Fri, Jul 14, 2023 at 7:14 PM Christofer Dutz
<ch...@c-ware.de> wrote:
>
> Hi all,
>
> as I’m digging into IoTDB more and more, I noticed a quite excessive usage of the Singleton pattern … some times even for things where it doesn’t really make much sense. For example in SystemFileFactory, the methods don’t really have much state and simply fire RuntimeExceptions if fsType is initialized with HDFS.
>
> Singletons make it a bit tricky to run tests in parallel and to do dynamic reloading of modules (like in OSGI). Most projects I’ve worked on try to limit the use of singletons to an absolute minimum due to these problems.
>
> I guess embedding IoTDB in an OSGI environment hasn’t been a use-case yet, but I could imagine that random test failures while running tests in parallel probably could have caused some issues.
>
> Was this a design decision that is based on some real-world necessity, or for simplifying things during development?
> I don’t want to put too much effort into proposing cleaning up things, if there was a conscious decision to do things otherwise.
>
> Chris
>