[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnulib-tool.py: Use the GLModule's name variable directly.
From: |
Collin Funk |
Subject: |
gnulib-tool.py: Use the GLModule's name variable directly. |
Date: |
Wed, 1 May 2024 01:51:51 -0700 |
User-agent: |
Mozilla Thunderbird |
I pushed this patch removing getName() from GLModule, preferring
it's name variable directly. I mentioned previously I found
differentiating these a bit confusing [1]:
module.getName()
module.name
str(module)
Especially when they were mixed together in the same function or same
line.
Bruno said [2]:
> In pure OO, one would not make the 'name' public, since it's meant to
> be a read-only property. It eliminates possible side effects on the
> 'name' property from the beginning.
and the previous knowledge summarization engine gave some other details.
I chose to just use GLModule.name since I prefer it and I think it is
what I am most accustomed to seeing in Python code.
I guess you see setters/getters more frequently in something like Java
because it is more pure OO. More worrying about encapsulation and
such. Then you have to deal with public/private/protected. In Python
there is no such thing. You even can define instance variables
anywhere:
module = GLModule(...)
module.non_existent = 'now exists'
I don't think accidental modifying the 'module.name' will be a
problem. I think the most common way to avoid that would be @property,
but no point in adding that unnecessarily.
[1] https://lists.gnu.org/archive/html/bug-gnulib/2024-04/msg00307.html
[2] https://lists.gnu.org/archive/html/bug-gnulib/2024-04/msg00309.html
Collin
0001-gnulib-tool.py-Use-the-GLModule-s-name-variable-dire.patch
Description: Text Data
- gnulib-tool.py: Use the GLModule's name variable directly.,
Collin Funk <=