CX Ideas for good code structure

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
878
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?
 

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
878
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.
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
3,135
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.
 

Phil7

Administrator
CX Code Contributor
3rd Party Tool Dev
Joined
Jun 26, 2017
Messages
636
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:

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
878
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.
 
Top Bottom