Caruychen / 42Hive-Lem_in

Integrated smart ant colony transport system
2 stars 0 forks source link

Should node_get be edge_get? #8

Closed crl-n closed 2 years ago

crl-n commented 2 years ago

Hi, this is a small issue. I think node_get could have a better name. Here's the function.

t_flow_edge *node_get(t_flow_node *node, size_t index)
{
    return (*(t_flow_edge **)vec_get(&node->edges, index));
}

The function returns a t_flow_edge *, so maybe it would be better if we called it edge_get or something along those lines, as you're not really getting a node.

Caruychen commented 2 years ago

Happy to take suggestions.

The name node_get has node at the start as I wanted it to belong to a family of functions that are part of the node 'object'. You'll see that all the functions begin with a noun of some sort, in this case, node. It's a naming convention that I think helps organise things. It's a bit of a workaround the fact that C doesn't do OOP.

So perhaps to improve this name, maybe something like node_get_edge

crl-n commented 2 years ago

Ok, I see what you mean and I think that naming convention makes a lot of sense. Actually, I could, too, try to stick to that naming convention in the code I write for this project, just to keep things coherent.

I think node_get_edge would be great and more clear. 👍 I can submit a change for that.