-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question about LCOM4 with Singleton-likes classes #262
Comments
I'm really sorry, but I'll speack french here. Do not hesitate to translate the thread if you're motivated... Bonjour @niconoe- , content de te voir ici :) C'est une bonne question, à la quelle je ne sais pas répondre. Je vais me pencher sur le sujet, mais je pense pouvoir dire que cette métrique ne s'applique pas aux objets sans état (la méthode de la factory est ici statique).
En attendant de trouver une réponse plus définitive, penses-tu pouvoir faire une PR sur le sujet ? Si oui je la mergerai. Merci de ton retour ! (et désolé pour la latence) |
This is the translation of the @Halleck45 previous comment. If you understood it, you can skip this comment. Hi @niconoe- , glad to see you here :) That is a good question, in which I can't answer. I'll study the topic, but I think I can tell you that metric doesn't apply to stateless objects (the factory's method here is static).
Before being absolutely sure about this answer, do you think you can make a PR on this subject? In this case, I'll merge it. Thank you for being back! (and sorry about the delay) |
D'après ta réponse, j'ai du mal à saisir pourquoi dans le cas où Dans ce contexte d'objet sans état, ta réponse m'a rappelé un élément que j'avais oublié au sujet des constructeurs : ils sont eux-mêmes implicitement statiques (comme on peut l'apercevoir lorsqu'on appelle J'ai un peu trop d'incertitudes pour te faire une PR à ce sujet, comme tu peux le voir ici ;). Mais dès que ces voiles noirs seront levés, ce sera avec plaisir ! ;). Merci encore.
Based on your previous comment, I barely know why, in case In this context of stateless objects, your answer reminds me an element I forgot about constructors: they're implicitly static (as we can guess when we call I'm too much incertain to make you a PR about this issue, as you can read here ;). But as soon as we'll get final answers, it will be with pleasure! ;). Thanks again. |
@niconoe- Petite typo dans mon message :( . J'ai édité ; je voulais dire :
|
Ah ah, très bien, je saisis mieux ;). Donc effectivement, pour le
Est-ce que tu vois une autre façon d'instancier (l'appel explicite à Je te laisse approfondir tes recherches et tes réflexions pour le cas du |
@niconoe can I close this issue ? |
Well, I did not provide a PR to make it, but there is certainly something wrong in the way we calculate the LCOM4 in this case. Considering a method calling a You could close this one if you open another (maybe in English) explaining this status. |
Hi, still me 😄 ,
I have a question about the LCOM4 value used and even after reseach I wasn't able to find any document or explaination.
Basically, the LCOM4 is used to calculate how many responsabilities a class have.
Now, I have a class that looks like a singleton (but it's NOT a singleton) in its structure and it should have only 1 responsability.
Here is my class:
Using both PhpMetrics 1.10.0 and PhpMetrics 2.0, I can see an LCOM4 = 2 for this kind of class.
My question is: "Is LCOM4 = 2 the expected result?".
This is obvious that this class only have 1 responsability, which is build an object with it's properties. But the counter says "2" because
Foo::build
is related to nothing (nbWorkflow = 1) and the constructor (with all its accessors) is related to all properties (nbWorkflow = 2).So, what is the position of the "creators" of the LCOM4 method about this? Does static methods must be ignored? In this case, a class with 6 static methods doing 6 unrelated stuffs (understand the class owns 6 responsabilities) should have an LCOM4 = 0, which is also incorrect?
Maybe because of the presence of
new self
in theFoo::build
method, we can add the link betweenFoo::build
andFoo::__construct
, but how can we manage inheritance in this case?I hope you understood what I wanted to explain with this issue, and if you want, I can make the same thread in French for a better understanding between us about this.
Thank you for your great tool.
Regards,
The text was updated successfully, but these errors were encountered: