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
Interface and naming conventions #1557
Comments
Regarding "Parallel": In my view "Par" is much more common in the code than "Parallel", so I would recommend:
|
Regarding "Number": "N" is used very often but is probably not always clear to users, and I would recommend replacing it with "Num":
|
One thing that will definitely help is to document what the methods do, so there is no room for misinterpretation, if you read the documentation. One additional item I can add:
Having clear conventions for naming things is great and can help a lot but one still needs to learn and remember what they are. Documentation is where one can learn these. Even in the current state, there is some logic and conventions used for naming things, even if they are not fully consistent. For example, based on the context, I don't think using one or the other of the following is really confusing: |
When you are looking at Num vs Number, I agree that there is no real ambiguity. It's more a matter of when you want to invoke one of those methods, and you don't remember which way it is named, so you have to go look it up each time. It is a minor thing, but nice to have. Whether it is worth breaking old code to change it? I don't know. |
If we start renaming things, I think we should definitely keep the old names too, at least for some time. |
Hi @rw-anderson , So, here is my round of semantic problems which I would like to address in this thread.
Since I think this thread is also an oppurtunity to improve documentation in general, here two more points which catched my attention
Btw, for documentation which must be shared between functions and methods, Doxygen has a feature called grouping, which may become handy. Especially since the classes have quite some methods and finding the "right" ones can take some time and often methods share some common documentation (and context). |
"Inf = 64 * LocalFaceIndex + FaceOrientation" You don't find raw bit shifting and packing intuitively obvious? |
@termi-official Thanks for your very detailed comments! Honestly I did not intend this issue to be quite so broad when I opened it - I am wondering if things like const-correctness and ownership of pointers should be documented and discussed in separate issues? |
Keeping the old names is a very good idea. However, I have a question that is more or less related to this. I noticed that there are 2 functions Tamas |
These two are exactly the same -- just alternative names. I had to check the 1-line implementations to see that, since we the only "documentation" for these is that they are part of the "documentation group" that starts here: Lines 503 to 507 in 3c5dc27
|
@barker29 In case the question was directed at me, I would keep it in this thread. Simply because the mentioned contracts (i.e. pre-, postconditions, invariants and possibly local or global side effects) are part of an interface and its conventions. |
Yes, I saw that the implementations are the same. That's why I thought that one of those will be deleted at some point and that could cause a problem. (The same problem will happen if you rename anything that is suggested in this issue and delete the old names anytime in the future.) |
If this issue is for general interface issues, I thought I'd raise the issue of the "Coefficient" classes which I presume were originally used to describe coefficients in PDEs, but seem to now function as more of a general non-FE function interface that is used for other things like defining initial conditions, exact solutions, due to the convenience of being able to project into a FE space. I wonder if something as simple as a typedef to allow the alias "Function" in place of "Coefficient" would make programmer intent a bit less confusing in places. |
I found another small one in the Mesh regarding the connectivity information, which is at least not obvious to me. Going through the implementation I guess the latter two are specific to 3D meshes while the former are for "ND" meshes? It also looks like the Mesh has the ownership of the latter? EDIT: Forgot |
|
Bumping because I think this is a useful discussion, even if most of this is not likely to be fixed soon. |
Another source of inconsistencies is whether accessors should include the prefix Get. For example, Similarly, to get the mesh from a finite element space, you use
|
Are Mesh.Print() and GridFunction.Save() named differently for a reason? They seem to be very similar. |
I think |
I have just started working with MFEM and as I was looking at
I think
Actually this function, though it should be const cannot be marked as |
|
Has it ever been considered to use a naming convention to distinguish member variables? Like google's convention to use a trailing underscore? I find this helpful when trying to understand complex classes. I recognize this would be a sweeping change. |
It could be something to consider for |
Ok. Only if there is broad support for it. I know opinions vary on this. |
In Qt Creator (and maybe other editors), you can configure it to show member variables with a different style -- e.g. I configured it to show then in italic. That said, I don't see a problem in using some convention for that. A common choice is to use the prefix |
Interesting. Does Qt Creator parse the code with a C++ compiler to determine that?
m_ is what I am most accustomed to. I have been told recently by younger developers that this is considered archaic. But I personally would be comfortable with it. |
Yes, it uses a version of clang that comes with it. |
Found some issues related to the matrix infrastructure. Since this is giving me constant issues in my code I am wondering why Further matrix patching/elimination methods are inconsistent and In the HypreParMatrix some time the eliminated entries are returned, but no option how the diagonal should be handled or docs on what happens to the entry.
Here the elimination methods have even different semantics. The first method eliminates the rows/cols of the input matrix and assigns itself the eliminated entries, which is not true for the latter two methods. Again no way to handle the diagonal entries.
Here we the EliminateCols method is missing completely. Also, row elimination does not give an option to handle the diagonal entry or docs on what happens to the entry.
Not quite sure about the "vanilla" one.
|
The names of objects, methods, and so forth are not always consistent throughout the code. This issue is intended to collect some of the known inconsistencies and discuss how the code could be changed or documented to remove or mitigate some of these inconsistencies.
Mesh
) or "Dim" (as inFiniteElement
)GroupCommunicator
SparseMatrix
) or "Col" (as inHypreParMatrix
)Vector
class, we haveAddElementVector
butGetSubVector
andSetSubVector
.The text was updated successfully, but these errors were encountered: