The name of functions, classes, variables has always been very important to me. I love it when they consist of one word, but it does not always work. For example, I have an Admin module (admin panel) for which I made a file manager. Connecting the file manager from the outside is not possible. In order to avoid conflict with other methods, you need to add something like fm to each method that is related to the file manager. But it seems to me not beautiful. Then I came up with this option: I create one large array property (for example, $this->fm , $this is our class) and create a lamba function in it. Thus, if I want, for example, to get information about a folder, I call $this->fm['folder']("/test") . This option also seems to me not super-beautiful, tell me, please, is it possible to do this in general and are there other options?

  • >> It is not possible to connect the file manager from the outside. Why else? And how is it implemented now? Everything that requires a manager directly inherited from him or what? And what will you do if you need more, for example, to connect encryption and it turns out that "connecting from the outside is not possible"? Invent multiple inheritance? What is the reason for not connecting the FM? Maybe you should solve this problem and forget about all other problems? - BOPOH

3 answers 3

In my opinion, you have somewhere lost sight of the upcoming problems with the implementation of the admin panel, but rewriting the existing ones is not an option. Beautiful use of the design


In the future, or if there is an opportunity to rewrite the code, look towards the namespace

  • one
    I used to use namespaces, but then they got out of use for some reason. Thanks, I'll think about it. - cheremushkin

Read about camelCase is very convenient - even if the names are similar.

  • Well, I just described that I did not really like camelCase. - cheremushkin

Use more than one word.