Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Angular for Enterprise Applications

You're reading from   Angular for Enterprise Applications Build scalable Angular apps using the minimalist Router-first architecture

Arrow left icon
Product type Paperback
Published in Jan 2024
Publisher Packt
ISBN-13 9781805127123
Length 592 pages
Edition 3rd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Doguhan Uluca Doguhan Uluca
Author Profile Icon Doguhan Uluca
Doguhan Uluca
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Angular’s Architecture and Concepts FREE CHAPTER 2. Forms, Observables, Signals, and Subjects 3. Architecting an Enterprise App 4. Creating a Router-First Line-of-Business App 5. Designing Authentication and Authorization 6. Implementing Role-Based Navigation 7. Working with REST and GraphQL APIs 8. Recipes – Reusability, Forms, and Caching 9. Recipes – Master/Detail, Data Tables, and NgRx 10. Releasing to Production with CI/CD 11. Other Books You May Enjoy
12. Index
Appendix A

Generating apps with ChatGPT

Let’s see what result we get if we ask ChatGPT to generate a weather app. In August 2023, I asked ChatGPT to generate a weather app using GPT-4 with the CodeInterpreter plugin. I gave it the following prompt:

Write an Angular app that displays real-time weather data from openweathermap.org APIs, using Angular Material, with a user input that accepts city name, country, or postal code as input.

After making a few minor corrections, this is the result I got:

A screenshot of a computer  Description automatically generated

Figure 2.11: ChatGPT weather app – August 2023

ChatGPT created a very simple and straightforward app for me, with a weather-display component using two-way binding for the input field. The service call was correctly implemented in a dedicated weather service triggered by the Fetch Weather button. To achieve similar results to the LocalCast app we built, we would have to provide a prompt with far more technical details. Non-technical people won’t know to ask for specific implementation details, and developers may simply find it easier to iteratively develop their solution. Nevertheless, the results are impressive.

Four months later, I questioned my premise from the paragraph above.

What if developers were okay with providing one or two more prompts?

In December 2023, I provided the same prompt from above to ChatGPT using GPT-4 without using any plugins, and after it generated the code, I provided an additional prompt:

Can you rewrite weather.component.html and style it in a way that looks like a professional design on desktop and mobile devices alike?

And boom, I got a result that looked a lot better!

A screenshot of a computer  Description automatically generated

Figure 2.12: ChatGPT Weather app initial version – December 2023

Still, this output doesn’t look like my design. Of course, ChatGPT has no idea what my design is, and it’s too cumbersome to meticulously describe it in writing. Then I remembered I had a hand-drawn mockup of the weather app I created for the 1st edition in 2018.

A picture containing text, handwriting, drawing, diagram  Description automatically generated

Figure 2.13: Hand-drawn wireframe for LocalCast

Yes, I did use a ruler!

In August 2023, ChatGPT couldn’t see, but since then, it has gained computer vision. I uploaded the mockup as is and said, “Redesign the UI to follow this mockup.” Remember that my mockup has three screens and difficult-to-read handwriting in it.

Initial result with Sidenav

Figure 2.14: ChatGPT weather app second version – December 2023

I’m shocked that it picked up on SideNav and incorporated it using proper Material components and FlexLayout media queries to make it responsive – never mind the misinterpretation of my handwriting.

I updated the generated UI code to make it interactive and included it as a project named chat-get-dec23 in the repo. Here’s the result:

Initial result with Sidenav

Figure 2.15: ChatGPT weather app final version – December 2023

This is beyond impressive. By the time the next edition of this book is published, this chapter may be only a few pages long and filled with tips, highlighting the crucial need to use a ruler when drawing your mockups.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime