Softanza, Behind the Scence

43 views
Skip to first unread message

Mansour Ayouni

unread,
Mar 28, 2022, 6:43:05 PM3/28/22
to The Ring Programming Language
Hello Mahmoud and all,

In the course of this journey with such a large, multi-year project like Softanza, I am confident to argue the following:

Based on my modest experience in dozens of large projects in so many different programming languages, I found Ring, due to its elegant design and simple type system, as an effective option in programming in the large.

Also, the toolset provided, despite its simplicity (Notepad, RingPM, C++ Binding scripts...), is really reliable and never caused me any serious problems!

One day, I will share a number of techniques that helped me govern the complexity of this project.

Here I share with you how I use templates of reusable code to accelerate my velocity while avoiding reproducible errors.

image.png

All the best,
Mansour 


Mahmoud Fayed

unread,
Mar 28, 2022, 9:50:51 PM3/28/22
to The Ring Programming Language
Hello Mansour

>> "Also, the toolset provided, despite its simplicity (Notepad, RingPM, C++ Binding scripts...), is really reliable and never caused me any serious problems!"

Thanks for your kind words, I have the same feeling while developing applications/projects using Ring

>> "Here I share with you how I use templates of reusable code to accelerate my velocity while avoiding reproducible errors."

Thanks for sharing :D

During development, When I fell that something needs templates, if the use-case is simple, I write a code generator or use simple text files
I use the command-based user interface for code generators when things can be automated

But for advanced use-cases, I build a complete GUI application (A Designer or Wizard or Customized Editor) to use it in controlling the generation process
Having a GUI on the top of code-generators reduce the cognitive load and the things that you need to remember which reduce the complexity.

For example, PWCT 2.0 contains many components, Each component is a group of classes (User Interface class, Steps/Code Generation class, Translation class, etc.) These classes are generated quickly using a GUI tool that provide quick short-cuts for the building blocks that are common in these classes
The point is to have more productivity without missing the ability of customization and without increasing the complexity.

The point is to find a pattern where redundancy exist but can't be avoided at the language level using functions or classes and inheritance without adding unnecessary complexity or causing other problems.

wizard.png

Greetings,
Mahmoud

Mansour Ayouni

unread,
Mar 30, 2022, 4:44:53 AM3/30/22
to Mahmoud Fayed, The Ring Programming Language
Hello Mahmoud,

Thank you for sharing this interesting way of working.

In the same subject, let me share how a new feature raises up in Softanza.

As a gold principle: I always start with minimal requirements with few features. Then, all the other features are added when there is a practical need that makes them relevant.

Then, if the cost of adding them is reasonable, I add them. Please take a look at my Ring Notepad session this morning:
image.png

While working on the PerformOnSections() method in stzList, a sister-function of the Perform() function that applies a given code to all the items of the list like this, for example:

o1 = new stzList([ :one, :two, :three, :four, :five ])
o1.Perform('@item = Q(@item).Uppercased()')
? @@(o1.Content()) #--> [ "ONE", "TWO", "THREE", "FOUR", "FIVE" ]


I was faced with the need of transforming a list of sections of the form, say [ [2,5], [7,9 ] ] to a contiguous list of numbers like this [ 2, 3, 4, 5, 7, 8, 9 ]...


The good reason of doing this is that I already have a derivative function of Perform() called PerfomOn(panPositions) that we can feed with a list of items by their positions, and let it perform any action we want on them, like this:


o1 = new stzList([ :one, :two, :three, :four, :five ])
o1.PerformOn([2, 4], '@item = upper(@item)')
? @@(o1.Content()) #--> [ "TWO", "FOUR", "three", "four", "five" ]

So, the question I had: should I do it specifically for this case using a plain-Ring solution like this:

anPositions = []
for aSection in paSections
        for i = aSection[1] to aSection[2]
                if find(anPositions, i) = 0
                        anPositions + i
                next
        next
next 
sort(anPositions)


Or, generalise this feature in a new function I add to stzList class, called ExtedIfPairOfNumbers(), that we can use like this:

? StzListQ([2,5]).ExtendedIfPairOfNumbers() #--> [ 2, 3, 4, 5 ]


By evaluating the situation. I see that the same code I would have written specifically in my current context can be used, with additional minimal cheks, in a new general function, in writing a new general function, so I can express myself naturally like this:


# Getting all the positions from the provided sections
# Example: [ [2,5], [7,9 ] --> [ 2, 3, 4, 5, 7, 8, 9 ]
# Performing the ExtendIfPairOfNumbers() action on all items of paSections list
 
Q(paSections).PerformW('{
        @item = Q(@item).ExtendedIfPairOfNumbers()
}')

PS: PerformW() is a derivation function of Perform() that performs an action upon a given condition (W for Where).


Advantages are obvious:

1. The code is lean and readable.

2. A new useful yet reusable feature is added.

3. The library grows based on practical needs.


In reality, all the functions you see in the library (excluding of course the alternative names which serve for other needs I discussed previously) were added this way!


All the best,

Mansour




--

---
You received this message because you are subscribed to the Google Groups "The Ring Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-lang+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ring-lang/f2154451-5f8c-402d-acf0-159cac054fc9n%40googlegroups.com.

Mansour Ayouni

unread,
Mar 30, 2022, 4:53:04 AM3/30/22
to Mahmoud Fayed, The Ring Programming Language
Hello,

And the complete code becomes like this:
image.png

Best,
Mansour

Mahmoud Fayed

unread,
Mar 30, 2022, 5:22:27 AM3/30/22
to The Ring Programming Language
Hello Mansour

Thanks for the information :D

When trying the next code
load "stzlib.ring"


o1 = new stzList([ :one, :two, :three, :four, :five ])
o1.Perform('@item = Q(@item).Uppercased()')
? @@(o1.Content()) #--> [ "ONE", "TWO", "THREE", "FOUR", "FIVE" ]

I get this runtime error
Line 4 Error (R19) : Calling function with less number of parameters!
in file test.ring

Greetings,
Mahmoud

Mansour Ayouni

unread,
Mar 30, 2022, 5:52:55 AM3/30/22
to Mahmoud Fayed, The Ring Programming Language
Hello Mahmoud,

Yes because I didn' committed the last changes yet.
I'll let you know.

Thanks.
Best

Reply all
Reply to author
Forward
0 new messages