Translate between code and Gherkin with AI

A raven is translating from one language to another
A raven is translating from one language to another

Part 2 of 2

Read Part 1

In this article about “AI-learning (E-learning 3.0)” series, we delve into translation of code, to make it easier to understand. To show that AI is also about learning and not only automation.

What is Gherkin

Gherkin is a domain-specific language that makes it possible to describe software behaviors in a human readable syntax. It’s primarily used to write structured tests that can be understood by non-technical stakeholders, making it a crucial tool in Behavior-Driven Development (BDD).

We usually write Gherkin language with: Given, When, and Then.

Translating code to Gherkin

Let’s take some Python code:

Python
number1 = 1
number2 = 2
result = number1 + number2
print(result)

Let’s make ChatGPT 3.5 translate the code to Gherkin and back:

I have the following python code, and I would like you to add Given, When, Then comments into it, so they explain the code:
--
number1 = 1
number2 = 2
result = number1 + number2
print(result)
--

And the result is:

Translating from Gherkin

Let feed ChatGPT 3.5 with:

Can you please translate the following text into Python?
--
# Given there are two variables named numbers with values: 1 and 2
# When they are added together into a result variable
# Then the result variable must be printed.
--

It will give the following output:

Isn’t Given, When, Then for testing only?

It is for testing, but not only.

Given, when, then is a fantastic way to describe processes, and this is how LEGO manuals work and even IKEA.

  • Given You have the following LEGO bricks (don’t start without them).
  • When a some of the bricks are assembled in a specific way.
  • Then a specific result must be achieved.
  • When the next bricks are added.
  • Then the next result must be achieved.
  • Then the final result must be achieved.

It has been working well for LEGO and IKEA for many years.

Code is also an automated process.

By adding given, when, then comments into my code, it can make me structure my code much better.

Let’s take the following example:

Python
# given
number1 = 1
number2 = 2

# when
result = number1 + number2

# then
print(result)

Under the given: I can structure my variables or deal with null-pointers and other errors.

Under the when: I can do what is needed by the code.

Under the then: I can handle the clean the output and return it.

This makes our code clean and easier to understand.

And when it is not possible to structure code like this, then maybe it is a sign, that the code needs to be split up into smaller parts and simplified!

Want to read more?

Follow the discussion on LinkedIn

Take the following lesson:

or the full course:

Comment below or on here: https://www.linkedin.com/pulse/translate-between-programing-languages-ai-bartek-rohard-warszawski-s5vye

Translate between programing languages with AI

A raven is translating from one language to another

Part 1 of 2

Read Part 2

In this article about “AI-learning (E-learning 3.0)” series, we delve into translation of code, to make it easier to understand. To show that AI is also about learning and not only automation.

Transcending Language Barriers in Coding

One of the most formidable challenges in the world of programming is the diversity of languages. Python, JavaScript, Groovy, and C# โ€” each serves its purpose, but fluency across them can be daunting. Enter ChatGPT 3.5, an AI model that acts as a linguistic bridge, effortlessly translating code from one language to another.

So, if I take the following code:

Python
# Given
number1 = 1
number2 = 2

# When 
result = number1 + number2

# Then
print(result)

and put it into ChatGPT as:

Can you please translate the following Python script into JavaScript:
--
# Given
number1 = 1
number2 = 2

# When 
result = number1 + number2

# Then
print(result)
--

Then the result will be in ChatGPT:

code example in JavaScript

We can translate it into Groovy, C# or any other language!

It’s especially good, when you need to do something in one language, but don’t understand what this method does. Python code example:

Python
pn = str(n).zfill(5)

and put it into ChatGPT 3.5:

Can you please translate the following Python script into JavaScript:
--
pn = str(n).zfill(5)
--

and it gives the following result:

and same goes for the other languages:

Groovy:

C#:

How cool is that?

You are welcome to try the code out directly in the browser, by using web editors: ๐Ÿ’ป Python / ๐Ÿ’ป JavaScript ๐Ÿ’ป Groovy / ๐Ÿ’ป C#

You can also try yourself with PHP, Ruby, C, C++, whatever!

Part 2 of 2 – Translate between Code and Gherkin with AI

Read Part 2

Want to read more?

Follow the discussion on LinkedIn

Take the following lesson:

or the full course:

Unlocking Fun in Testing and Coding!

Learn testing and coding with TDD and AI
Learn testing and coding with TDD and AI

Hey there, Adventurers!

Have you ever imagined that learning technology could be filled with as much fun and imagination as creating your own art? Welcome to bartek.dk, where we turn that imagination into reality!

Who Am I?

I’m Bartek, a Quality Coach, Test Engineer, and an AI explorer.

I’ve witnessed first-hand the transformative power of AI across different sectors.
However, it was the integration of AI into my own field that illuminated a path less travelled.

My mission is to bring the playful spirit of kawaii (Japanese for lovely, adorable, cute, etc.) into the world of coding, testing, and automation.

Why should testing and coding be all boring and only serious?

Let’s find the fun in it!!!

Crafting Automation Scripts: Your Digital Magic Spells

Remember the wonder of seeing a machine do something amazing for the first time? That’s the thrill of learning to code!

We’ll guide you through creating automation scripts that are incredibly fun to build but also fulfilling to watch in action. It’s like when my grandmother got her new washing machine and watched it do its magic.

And why not learn it with the AI-tools of today?

This is not another: “Learn to program” course. It’s a new way to do it with AI!

This is an excellent example: https://bartek.dk/2-learn-coding-with-ai/

The Magic of Testing and TDD Explained

But how do you make sure your digital creations do exactly what you want them to do, every single time?

That’s where testing and Test-Driven Development (TDD) come in. We’re here to demystify these concepts, showing you step by step how you can be the master of your code. To learn how you ideas actually work and what system-behavior actually needs to be implemented!

Precision in Communication: Beyond AI Guesswork

I had a dialog with Alan Turing (simulated with AI), about the future of programming. He pointed out, that programming is not dead, but more needed than ever before.

In a world increasingly run by AI, the need for precision in our commands and codes has never been more critical.

Yes, AI can guess what we need from our prompts written popular language, except it often guesses based on the majority’s needs.

TDD provides us with a tool for communicating our deepest thoughts and wishes to the computer and AI, ensuring our creative vision comes to life exactly as we imagine.

The future of programming is not dead, but programming languages will go from hardware-specific to concept-specific.

Are You In?

Ready to embark on a journey where learning coding and testing becomes a canvas for your creativity?

Aided by the charm of kawaii and the cutting-edge capabilities of AI?

Let’s not just code; let’s inspire and be inspired, blending the artistry of programming with the precision of TDD, to express our self and grow in areas we never could imagine before.

Join the adventure at bartek.dk โ€“ where coding meets creativity and imagination!

Looking forward to creating magic together,

Bartek

Follow the discussion on LinkedIn

Adding web editors for coding

A raven is coding

Let’s talk about learning to code – it’s like unlocking a whole new world of possibilities, right? But wait, here’s the thing: sometimes, getting started can feel like hitting a roadblock, especially when it comes to installing all those fancy tools.

But guess what? I’ve got your back! I’ve whipped up some super cool editors for JavaScript and Python, and I’ve even thrown in some existing ones for Groovy and C#! ๐ŸŽ‰

Direct link

Now, here’s the kicker – we might not be able to code anything just yet, but we’re gonna learn the basics together. It’s like laying down the foundation for a super cool coding adventure! ๐Ÿ’ปโœจ

Stay tuned, because I’m about to show you the ropes in these editors. And get this – we’re gonna dive into the world of Test Driven Development and AI too! It’s gonna be an epic journey of learning and discovery. ๐ŸŒˆ๐Ÿ“š

So, wish me luck on this exciting adventure, and get ready to join me on this coding quest! Let’s do this! ๐Ÿ’ช๐Ÿค–๐Ÿ€

Unlock Your Inner Zen: With coding Music!

Listening to chill music
Listening to chill music

Hey there, awesome inner child at 40! ๐ŸŒŸ

Guess what? I’ve just launched a super cool music page that’s all about helping you chill out and dive deep into your thoughts like a fearless explorer! ๐ŸŽตโœจ

Picture this: you’re in your own little world, coding away like a pro. But wait, something’s missing… Ah, that’s it! With our totally free meditation/musication music playing in the background, you’ll feel like you’re on a magical journey to uncover hidden treasures within your mind! ๐Ÿ’ก๐ŸŽถ

So, what are you waiting for? Grab those headphones and let the adventure begin! Check out our awesome selection of tunes and get ready to embark on a journey of peaceful coding bliss! ๐Ÿš€๐Ÿ’ป

Putting the inner child into the text

From intellectual to kawaii

I have a specific way of writing things. It comes from, that I have tried to remove emotional meaning from my words and use as much intellectual as I can. (Maybe it also comes from all the programming I have done, since my childhood?)

My point is, that this is not always easy to read or fun.

Since I have moved to a kawai style (adorable, cute & lovely) in my images, then maybe I should include the inner child in my texts?

All of this could be rewritten to:

Let’s chat about something super important – my way of writing stuff! So, you see, I’ve always been kinda serious, trying to keep emotions out and use big brain words instead. Maybe it’s ’cause I’ve been coding since forever?

But guess what? Reading my stuff isn’t always a breeze, and definitely not a party!

Lately, I’ve been thinking: since I’ve gone all in on this super cute kawaii style in my pics – you know, all adorable and sweet – maybe I should sprinkle a little bit of that magic into my words too?

What do you think about that, huh?

0
Lets vote for: 1) easier, 2) more fun, 3) both or 4) neither

Testing of a background

tiled background image

Since I got the new kawaii (Japanese for lovely, cute, and adorable):

I needed to update my old tiled background:

Into a kawaii one, so I started with something pretty and detailed, but had to make it less detailed and eye catchy, to not steal attention from the text and other content:

cute office wall
cute office wall
cute office wall
cute office wall

It works well with content, while the prettiest one took too much attention.

Here is an example, that when we test something, we need to test it in the correct context.

Because in a different context, we might select the wrong solution.

Why the cute style?

Illustration of a what is testing
Illustration of a what is testing

I have always been fascinated by visuals, just like programming.

In the first version of the website, I made a lot of pretty images:

It’s pretty, but I wanted it to also be more fun, so I got an idea:
Why not include fun and cuteness, like kawaii?
(kawaii in Japanese means lovely, adorable, cute)

Why does testing and programming always have to be so serious?
Maybe I should loosen up a bit and have some fun?

So I made an alternative gallery:

I loved it!

But what would be best for my site?
What would testers, developers, and others think?

An A/B test could give an result.
(An A/B test is a test, where I post both solutions, but the 50% users see the A version, while the other see the B version. Then we can compare which version, works best for the users).

There was also another option:
Who would I preferer to eat lunch with?
I might loose 98% people, if I use the kawaii style.
At the same time, the rest 2 % will be fun to eat lunch with!

So, why not try it?

So this is how this kawaii style came about:

First edition of my new website

front image of bartek.dk
front image of bartek.k
binary comment

๐ŸŽจ Intro Image Exploration

I use DALL-E 3, because I can specify better what my image is about, and I used the following prompt:

Can you create an image from Norse Mythology? It should be a cover image for a website about software testing. Here you can find auxiliary tools, theory with AI-learning within test management, test analysis, and test automation. You can also learn about Test Driven Development. And purchase Onsite Keynotes and workshops. There are also dialogues with historical figures, simulated with AI.

No text or runes.

It creates a rather boring image, adding “Norse Mythology” can make it more mystical, but it still is rather boring:

๐Ÿค” The Unpromptable Prompt

I also added an unpromptable prompt, where I asked the AI-model to tell me, what style and colors it sees, so I know how I can communicate with this model. It won’t work with other models, but I want something specific and this is how I can learn how the AI understands the world. The image I used, that I have created another time:

Combining these prompts gave me this result:

๐Ÿš€ Upscaling Adventures

I needed it to be 2000×1200 pixels, but the image generated was only 1024×1024.

I use Upscayl – Free and Open Source AI Image Upscaler for Linux, MacOS and Windows built with Linux-First philosophy. https://github.com/upscayl/upscayl

Which can upscale my image up to 16 times!

And I only have a laptop with a NVIDIA GTX 1650.

๐Ÿ” Zooming-Out

I needed it to work on mobile devices, which would zoom too much on the image:

So I needed to Zoom out.

I copied, flipped an pasted of the image again and again (left, right, up and down):

And then put it into https://creator.nightcafe.studio/ (which runs with Stable Diffusion AI), because I can add an mask on top, to select where the image generation must happen:

It gave me images like this:

I then combined multiple of these images in GIMP2 (The Free & Open Source Image Editor) https://www.gimp.org/downloads/ to the following result:

I had to upscale it again, because the rendered image is only 1344×768, but with Upscayl it was easy.’

Incredible what multiple AI tools and open source tools can bring to the table!

๐Ÿ”ฎ Unlocking AI’s limitations

Midjourney and Stable diffusion has keyword prompting, but its too simple.
Often I feel I can’t get out of a template. Let me give an example of 2 similar images, that have 2 different prompts :

Dynamic transpose in Excel as a mythological digital art

Another example is, when I wanted Sisyphus pushing his stone up hill, but couldn’t get it. Either the stone was already at the top. Or flying. Or there was no stone, but a moon!

The image below is one funny example, because if Sisyphus is trying to push the stone with his butt. If that was the case, then I understand why the stone keep rolling down again and again.

DALL-E 3 can take more details into account, which makes it easier to specify.

Prompt:

A man writes "ABC" on a piece of paper. He sits under a tree with his block of paper and beside him is a bike. It is fall and crows fly in the air. The style must be "cute".

Output:


It is better to specify, but again not all details. That’s why we often need to combine images.

๐ŸŽจ AI-images require skill

Yea, right!

I use AI to produce tons of images, that I can choose what direction I want to take them.
I use my Gimp-skills (Open source photoshop), to combine these images.
I use creative ways to understand my tools, AI included – like unpromptable prompting.
Sometimes I simulate historical people with AI, to inspire me or see things from new angle!

All this required me to:
Test, fail, redo, learn,
test, fail, redo, learn,
test, fail, redo, learn,


Not everything went as I wanted, even though it is pretty:

And that is my point: Creative work is not dead. Our tools have just upgraded. Just like Portrait painters complained about photographers, at one time.

And this my friends, requires a lot of
testing, learning, and experience
which is the definition of
creativity and skill!

– Bartek / Bartlomiej Rohard Warszawski

End of this post

And my site is not finished yet. I have just made the first step of:

testing, doing, reflecting, changing, and testing some more.