• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

CX Ideas for good code structure

Wingnut

Well-known member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
1,414
My code is growing quickly now and I really need to re-structure everything I do feel. So what better way is there than starting all over from zero.
So I will use a week or two to re-build everything using whatever new insights I now have compared to when I started.

Are there any articles or good example source-code that I can learn the more advanced OO-features that Cerberus-X offers?
 
To be specific there's 4 features I want to see how close I can come :

1) I want to explore generic classes as far as I can go..

2) Callbacks. I got some code that adds callbacks to CXS that I want to try out.

3) I also want to see if I can replicate a behaviour that's called a-pointer-to-a-pointer-to-a-pointer, explained here by Professor Brailsford : https://www.youtube.com/watch?v=t5NszbIerYc
It's interesting concept but you need pointers of course so that rules out most modern languages.
But the concept might be possible?

4) I want also to explore something that is possible only in CLOS to my knowledge (which is the most powerful LISP dialect).
Things like being able to infinitely add shapes and also to add actions binded to those shapes, without the need to go back and change old code. I'm sure there is a way to do this in Cerberus. I want to explore that.

This will be some kind of workshop weekend for me, I hope to find at least a few answers from these questions.
 
Are there any articles or good example source-code that I can learn the more advanced OO-features that Cerberus-X offers?
The admob, httprequest and cerberusstore module are good examples regarding interfaces and callbacks.

Good luck with pointers. CX doesn't have them, so I am curios what you come up with.
Things like being able to infinitely add shapes and also to add actions binded to those shapes
Drawlists come to my mind. But actions.... I don't see that.
 
My code is growing quickly now and I really need to re-structure everything I do feel. So what better way is there than starting all over from zero.
The key word here is refactoring. The first thing is to keep your code clean and easy to read. So some kind of housekeeping is the best alternative to starting from scratch. A lot of things can be improved without breaking the whole thing.
The videos by Bob Martin about clean code are great for that, but your have to watch them at 1.5 speed, because he enjoys his own talking a bit to much IMAO.

Apart from that, it seems you have to take the risk that your first large project will not be state of the art designwise and you need get some experience by doing it in a more naive fashion to see some issues by yourself. And things like design patterns are harder to change later on.

I also want to see if I can replicate a behaviour that's called a-pointer-to-a-pointer-to-a-pointer, explained here by Professor Brailsford
I had a look at the video that follows the one you linked to and I think you meant a pointer to a pointer (... to a thing), right? With CX we don't have pointers, but the main thing he is talking about is not the bare pointer to manipulate points in memory, but to have references. As long as you don't use something like *(somePointer+3) a pointer is just a value by reference and List.node is therefore something like a reference to a reference.
I am interested in what you want to achieve with this concept.


Things like being able to infinitely add shapes and also to add actions binded to those shapes, without the need to go back and change old code.
I am not sure, what you mean here. It looks a bit to me like an example for the open-closed-principle of SOLID or are you really only talking about adding shapes with actions. Open-closed just means you want to write your code in a way so that you can easily add features to it, without the need to modify the main structure of your code. In your example this would be a shape Interface containing methods like CalculateArea(), CalculatePerimeter() and then you can deal in your old code with all the objects implementing this interface as type shape without knowing their true class name.

That was a bit of a guessing... Hope it helps a bit
 
Last edited:
Thanks a bunch!! It's been a slow weekend so I have not much to say yet, but this week I need to get off my ass and start coding for real. I can be a bit of a perfectionist sometimes which doesn't help.
 
Back
Top Bottom