Education

Bootcamps

Remote live bootcamps to lead your career onto a new path.

Web development 24 weeks

Courses

Upgrade your career with new skills while staying at work.

UI design 6 weeks

Free classes

Classes and workshops for you to learn new skills.

Free coding workshop
Stories
Resources
Events
For companies

Courses

Training courses for your organisation.

Training courses

Connect

Meet our graduates and build your future talent pool.

Meet our students
About us
Education

Bootcamps

Remote live bootcamps to lead your career onto a new path.

Web development 24 weeks

Courses

Upgrade your career with new skills while staying at work.

UI design 6 weeks

Free classes

Classes and workshops for you to learn new skills.

Free coding workshop
popcorn
Stories
Resources
Events
For companies

Courses

Training courses for your organisation.

Training courses

Connect

Meet our graduates and build your future talent pool.

Meet our students
popcorn
About us
Daniel Mnich

Tips

AI for Developers: How to Write Code Faster

Learn about the benefits that a web developer can reap from AI assistance tools.

Daniel Mnich

Code Coach at Technigo

LinkedIn

What is ChatGPT?

There’s a lot of talk about AI doing your work for you lately. Programmers, office workers, and various experts that have a lot of domain knowledge are scared that those tools will push them out of business. In this short article, I want to go through the benefits that a web developer can reap from AI assistance tools and show that we will not be replaced just yet.

First, let us start with debunking some of the myths that surround the most talked about tool - ChatGPT. What actually is ChatGPT?

As a language model, it is not sentient - it creates responses based on the likelihood of certain words or phrases that appear, and the calculation of that probability is based on the data the model was trained on. That’s a very brief summary, but you should keep it in mind whenever someone tries to scare you with a Terminator doomsday scenario.

Now let me show you what we can use the assistant for.

Automate your code writing

Make ChatGPT write your boilerplate code for you!

Writing boilerplate code means creating the basic structure of a program or application, which can be reused for different projects. It's like creating a template that can be customised later. For example, if you're building a web application, you might need to set up connections to databases or create endpoints for the Frontend to get or post data. By using AI assistance tools like chatGPT, you can break down the requirements into simple words and get a starting point for your code.

For example, if you would like to create a form in HTML. The form would have three fields and send the data to https://some-website-you-want-to-send-data.to - you can break this task into simple words, so a generator will be able to provide good output. An example prompt could be: Create an HTML form that will have three inputs - name, email, hobby and sends the form data to "<https://some-website-you-want-to-send-data.to>".

Example output:

<form action="https://some-website-you-want-to-send-data.to" method="POST">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<label for="hobby">Hobby:</label>
<input type="text" id="hobby" name="hobby">
<button type="submit">Submit</button>
</form>

This will give you a starting point from which you can build on however you like.

Testing your code

A unit test is a type of test that checks if a specific piece of code (usually a function or class) works as intended. It is used to ensure that the code behaves correctly in isolation, regardless of the rest of the codebase.

Delegating the task of writing unit tests to an AI assistant has personally saved me several hours per week. To ensure your code base behaves in a predictable way, it needs to be tested, there’s no way around it. And a simple prompt is sufficient. An example prompt is - write unit tests to the following code: const sum = (arr) =>{ return arr.reduce((acc, num) => acc + num); }

Example output:

// Import the function to be tested
const sum = require('./sum');
describe('sum function', () => {
// Test case for empty array
test('should return 0 for an empty array', () => {
expect(sum([])).toBe(0);
});
// Test case for array with positive numbers
test('should return the sum of an array of positive numbers', () => {
expect(sum([1, 2, 3])).toBe(6);
});
// Test case for array with negative numbers
test('should return the sum of an array of negative numbers', () => {
expect(sum([-1, -2, -3])).toBe(-6);
});
// Test case for array with mixed positive and negative numbers
test('should return the sum of an array of mixed positive and negative numbers', () => {
expect(sum([-1, 2, -3, 4])).toBe(2);
});
});

If you’re already writing tests - make sure to try it - you’ll be amazed by the results!

Learning

To stay relevant in the tech market and be able to advance in your career, it is necessary to keep up with new tech. Sometimes you need to learn a new technology even for your current job, because it will get the task done Harder, Better, Faster, Stronger. Whether it’s a new design pattern, a new language or exploring deeper the current technology, you can make use of an AI assistance tool to help you process the information. To test it, we will start with the prompt: Explain to me the CQRS design pattern using JavaScript.

Example output:

CQRS stands for Command Query Responsibility Segregation, which is a design pattern that separates the application's read and write operations into two distinct parts. In a CQRS system, write operations are handled by a command model, while read operations are handled by a separate query model.

In JavaScript, this pattern can be implemented by creating separate functions or classes for handling commands and queries. The command model would handle functions that change the application state, such as creating or modifying data, while the query model would handle functions that retrieve data from the application state. By separating these two concerns, the application can more easily scale and evolve over time.

One example of implementing CQRS in JavaScript is by using the Event Sourcing pattern, which involves storing all changes to the application state as a series of events. This allows the application to reconstruct its state at any point in time using the event log.

Overall, CQRS is a powerful design pattern that can help to simplify complex applications and promote scalability and maintainability.

If from this point I still don’t quite get what it is, I can dive deeper into it by asking questions about specifics:

What is the mentioned Event Sourcing pattern?

Example output:

The Event Sourcing pattern is a way of storing data by recording all changes to the application state as a sequence of events. Instead of storing the current state of the application, the event sourcing pattern captures every change to the state as a discrete event. Each event represents a specific state change that has occurred in the application.

This approach has several benefits, such as the ability to reconstruct the state of the application at any point in time by replaying the events. It also allows for easy auditing and debugging, since all state changes are recorded and can be traced back to their source.

In JavaScript, the Event Sourcing pattern can be implemented using a variety of tools and techniques, such as event sourcing libraries or frameworks. By using the Event Sourcing pattern, developers can create more robust and reliable applications that are easier to maintain and debug.

You can go ahead and ask as many questions as you want!

Conclusion

OpenAI's ChatGPT and others like it (ex.: Hugging Face's Transformers, Google's BERT) are powerful tools that we can incorporate in different ways to do our repeatable tasks for us. Just remember to always proofread the outputs and take them with a grain of salt - you can find several cases where they are wrong if the language models make the answers sound plausible.

We're a female-founded, remote-first community helping people get a career they love. 90% of those attending our boot camps are women.

Our next boot camps start in August - apply today to secure a place!

👉 Web Development Boot Camp

👉 UX Design Boot Camp