AI-Powered Developer Build software with ChatGPT and Copilot (Nathan B. Crocker) (Z-Library)

Author: Nathan B. Crocker

商业

Use groundbreaking generative AI tools to increase your productivity, efficiency, and code quality. AI coding tools like ChatGPT and GitHub Copilot are changing the way we write code and build software. AI-Powered Developer reveals the practical best practices you need to deliver reliable results with AI. It cuts through the hype, showcasing real-world examples of how these tools ease and enhance your everyday tasks, and make you more creative. In AI-Powered Developer you’ll discover how to get the most out of AI: Harness AI to help you design and plan software Use AI for code generation, debugging, and documentation Improve your code quality assessments with the help of AI Articulate complex problems to prompt an AI solution Develop a continuous learning mindset that keeps you up to date Adapt your development skills to almost any language AI coding tools give you a smart and reliable junior developer that’s fast and keen to help out with your every task and query. AI-Powered Developer helps you put your new assistant to work. You’ll learn to use AI for everything from writing boilerplate, to testing and quality assessment, managing infrastructure, delivering security, and even assisting with software design.

📄 File Format: PDF
💾 File Size: 2.4 MB
40
Views
0
Downloads
0.00
Total Donations

📄 Text Preview (First 20 pages)

ℹ️

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

📄 Page 1
M A N N I N G Nathan B. Crocker Build software with ChatGPT and Copilot
📄 Page 2
Prompt Engineering Patterns ¡ The Prompt Optimization Pattern: Enhances the user’s original prompt to elicit more accurate, relevant, or comprehensive responses from the AI to transform an initial, possibly vague or suboptimal prompt into one that is clearer, more specific, and better suited for the AI’s capabilities. ¡ Refinement Pattern: Iteratively refining or improving the prompt to get more accurate, relevant, or sophisticated responses. ¡ The Persona Pattern: Gives the AI a consistent voice and perspective, making its responses more predictable and aligned with the user’s expectations. ¡ The Audience Persona: A variation of the Persona Pattern, referred to as the “audience persona pattern” in prompt engineering.
📄 Page 3
MANN I NG Shelter ISland AI-Powered Developer Nathan B. Crocker Build software with ChatGPT and Copilot
📄 Page 4
For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 761 Shelter Island, NY 11964 Email: orders@manning.com © 2024 Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid- free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine. ∞ Manning Publications Co. 20 Baldwin Road PO Box 761 Shelter Island, NY 11964 ISBN 9781633437616 Printed in the United States of America The author and publisher have made every effort to ensure that the information in this book was correct at press time. The author and publisher do not assume and hereby disclaim any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from negligence, accident, or any other cause, or from any usage of the information herein. Development editor: Katie Sposato Johnson Technical editor: Nicolai Nielsen Review editor: Dunja Nikitovic Production editor: Andy Marinkovich Copy editor: Tiffany Taylor Proofreader: Jason Everett Technical proofreader: Mark Thomas Typesetter: Tamara ŠveliÊ SabljiÊ Cover designer: Marija Tudor
📄 Page 5
Dedicated to the memory of Catherine L. Crocker, whose strength and love continue to guide me. Though no longer beside us, her spirit and wisdom remain ever-present. Her legacy lives on in every word I write. Gone from this world, but forever in our hearts.
📄 Page 6
iv contents preface viii acknowledgments x about this book xii about the author xv about the cover illustration xvi Part 1 The foundation .............................................1 1 Understanding large language models 3 1.1 Accelerating your development 4 1.2 A developer’s introduction to LLMs 9 1.3 When to use and when to avoid generative AI 10 2 Getting started with large language models 12 2.1 A foray into ChatGPT 13 Navigating nuances with GPT-4 13 ■ Charting paths with GPT-3.5 18 ■ Navigating the AI seas: From the shores of GPT-3.5 to the horizons of GPT-4 20 2.2 Let Copilot take control 21 2.3 Let CodeWhisperer speak loudly 23 2.4 Comparing ChatGPT, Copilot, and CodeWhisperer 25
📄 Page 7
vcontents Part 2 The input .....................................................29 3 Designing software with ChatGPT 31 3.1 Introducing our project, the information technology asset management system 32 3.2 Asking ChatGPT to help with our system design 32 3.3 Documenting your architecture 36 4 Building software with GitHub Copilot 53 4.1 Laying the foundation 54 Expressing our domain model 54 ■ Favoring immutability 55 Decorating our favorite classes 57 ■ Adapting a strategy for depreciation 61 4.2 Weaving patterns, patterns, patterns 63 Paying a visit to our department 63 ■ Creating objects in a factory (pattern) 64 ■ Instructing the system on how to build 68 ■ Observing changes 72 4.3 Plugging in ports and adapters 74 Hexagonal architecture in review 74 ■ Driving our application 75 ■ Accessing our data and persisting our changes 81 ■ Centralizing (and externalizing) our data access 84 5 Managing data with GitHub Copilot and Copilot Chat 90 5.1 Amassing our dataset 91 5.2 Monitoring our assets in real time with Kafka 100 5.3 Analyzing, learning, and tracking with Apache Spark 107 Part 3 The feedback ............................................. 113 6 Testing, assessing, and explaining with large language models 115 6.1 Testing, testing … one, two, three types 116 Unit testing 116 ■ Integration testing 121 Behavior testing 122 6.2 Assessing quality 125
📄 Page 8
vi contents 6.3 Hunting for bugs 128 6.4 Covering code 130 6.5 Transliterating code—from code to descriptions 131 6.6 Translating from one language to another 134 Part 4 Into the world .......................................... 141 7 Coding infrastructure and managing deployments 143 7.1 Building a Docker image and “deploying” it locally 145 7.2 Standing up infrastructure by copiloting Terraform 147 7.3 Moving a Docker image around (the hard way) 150 7.4 Moving a Docker image around (the easy way) 150 7.5 Deploying our application onto AWS Elastic Kubernetes Service 151 7.6 Setting up a continuous integration/continuous deployment pipeline in GitHub Actions 154 8 Secure application development with ChatGPT 158 8.1 Modeling threats with ChatGPT 159 Why it matters in today’s development landscape 160 How ChatGPT can aid in threat modeling 160 Case study: Simulating threat modeling with ChatGPT 163 8.2 Scrutinizing application design and identifying potential vulnerabilities 166 Evaluating design problems 166 ■ Recognizing common vulnerabilities 167 8.3 Applying security best practices 168 Setting the security mindset 168 ■ Continuous security testing 169 8.4 Encrypting data at rest and transit 171 The importance of data encryption 171 ■ Data encryption at rest 172 ■ Data encryption in transit 175
📄 Page 9
viicontents 9 GPT-ing on the go 178 9.1 Motivating theory 178 9.2 Hosting your own LLM 179 Baselining with ChatGPT 179 ■ Asking Llama 2 to spit out an answer 180 ■ Democratizing answers with GPT-4All 186 appendix A Setting up ChatGPT 192 appendix B Setting up GitHub Copilot 197 appendix C Setting up AWS CodeWhisperer 205 index 217
📄 Page 10
viii preface Welcome to AI-Powered Developer, your gateway to exploring the symbiotic relationship between programming and artificial intelligence. This book is not just a narrative about AI and its applications in software development—it’s an invitation to venture into the uncharted territory of coding powered by cutting-edge AI models like ChatGPT and GitHub Copilot. As you turn these pages, you’ll embark on a journey of exploration and discovery, unearthing a new perspective on how AI can reshape and enhance the coding landscape. The essence of this book lies in its unconventional approach. Unlike most technical literature, it doesn’t provide a rigid script to follow. This is because the book deals with the application of large language models in software development, an area where out- comes can be surprisingly diverse even when the input remains the same. Think of it more like a compass guiding your way through an intriguing landscape of possibilities rather than a map delineating a predetermined route. AI-Powered Developer encourages you to experiment, ask questions, and, most impor- tantly, be open to unexpected results. It will ignite your curiosity, spur your creativity, and stimulate your problem-solving skills. The world of large language models like ChatGPT and Copilot offers more than just coding assistance—it provides a transfor- mative framework that has the potential to revolutionize software development at its core. At its heart, this book assumes the role of a mentor, a catalyst that nudges you to venture beyond the familiar boundaries of traditional coding, encouraging you to explore the intricate dance of AI and programming. It seeks to whet your appetite for the untapped potential that these generative AI models bring to the table. Through a myriad of real-world examples, hands-on exercises, and insights, you’ll not only learn
📄 Page 11
ixpreface how to use these AI tools but also gain a deeper understanding of their functioning, their potential, and their limitations. Yet, as with any mentorship, the rewards of this journey are proportional to the pas- sion, curiosity, and commitment you bring. By diving deep, asking questions, and chal- lenging assumptions, you’ll gain not just technical skills but also a broader perspective on what it means to be a developer in the age of AI. This is an exciting time in the field of software development. AI and machine learn- ing are disrupting traditional paradigms, offering new tools and methodologies that can significantly enhance productivity, creativity, and efficiency. By integrating AI into the development process, we can tackle more complex problems, streamline workflows, and fundamentally transform the way we approach coding. AI-Powered Developer is more than just a book—it’s a doorway to this new world, a world that blends the logic of programming with the power and flexibility of AI. Whether you’re a seasoned developer or an enthusiastic beginner, this book will equip you with the tools, techniques, and knowledge to make the most of these advancements and chart your own path in this evolving landscape. Remember, every great journey begins with a single step. By choosing to read this book, you’ve already taken that step. Now, let’s venture into the exciting world of intelli- gent coding together. Enjoy the journey!
📄 Page 12
x acknowledgments Embarking on the journey of writing this book was no small endeavor. It required com- mitment, dedication, and countless hours of meticulous labor. It was a path fraught with challenges, but every step was an enriching experience, bringing me closer to the vast and fascinating world of AI-powered coding. It’s a journey I couldn’t have begun, let alone completed, without the support and contributions of some extraordinary individuals. My profound gratitude goes to my editor, Katie Sposato Johnson, who was instru- mental in shaping this book. Her incisive comments, critical insights, and constructive feedback helped refine my thoughts and transform them into a coherent, engaging narrative. Her unwavering commitment and passionate involvement were invaluable to this project. A special note of thanks to my technical editor, Nicolai Nielsen, who is lead AI Engi- neer at SymphonyAI, and is both a coder and content creator, creating educational AI and computer vision videos on YouTube and courses that help people while scaling his brands. Nicolai’s expertise and keen eye for detail kept me on my toes, continually reminding me of how much more there is to learn in this expansive field. His inputs were not just educational but humbling, shaping my understanding and keeping me grounded. I am deeply grateful to everyone at Manning for their relentless support throughout this journey. Their professionalism, cooperative spirit, and commitment to excellence have been an inspiration. They played a critical role in bringing this book to life, for which I am immensely thankful. To all the reviewers: Carmelo San Giovanni, Chad Yantorno, Christopher Forbes, Dan McCreary, Dewang Mehta, Greg MacLean, Håvard Wall, Jeff Smith, Jim Matlock, Jonathan Boiser, Louis Aloia, Luke Kupka, Mariano Junge, Maxim Volgin, Maxime
📄 Page 13
xiacknowledgments Boillot, Mike Piscatello, Milorad Imbra, Peter Dickten, Philip Patterson, Pierre-Michel Ansel, Rambabu Posa, Rebecca Wagaman, Riccardo Marotti, Roy Wilsker, Stefano Pri- ola, Thomas Jaensch, Thomas Joseph Heiman, Tiago Boldt Sousa, Tony Holdroyd, and Walter Alexander Mata López, your suggestions helped make this a better book. My deepest gratitude is for my family—my pillars of strength. To my wife, Jenn, thank you for being my rock and for the countless hours of patience, understanding, and love you’ve poured into this endeavor. To my daughters, Maeve and Orla, you are my inspira- tion—your joy, curiosity, and boundless enthusiasm fuel my endeavors. To all my family members who supported me in myriad ways, thank you. This book is a culmination of countless hours of effort, dedication, and teamwork. I am deeply grateful to everyone who contributed to making it a reality. Thank you all.
📄 Page 14
xii about this book AI-Powered Developer is your essential guide to mastering the integration of large lan- guage models like ChatGPT and CoPilot into your software development process. This comprehensive book delivers practical advice and showcases best practices, helping you harness the power of AI to enhance your projects. From the do’s and don’ts of AI implementation to real-world examples, you’ll gain the insights and tools you need to elevate your development skills and stay ahead in the ever-evolving tech landscape. Who should read this book? Professional developers and enthusiasts alike should get value from this book. Although the book is largely aimed at experienced developers, large language models (LLMs) can be used to accelerate your learning because these tools can provide expla- nations, code examples, and guidance on programming concepts. Experienced devel- opers can use these tools to improve productivity, streamline coding processes, and tackle complex coding challenges more efficiently. These tools can assist in generating code snippets, debugging, and providing insights on best practices. How this book is organized: A roadmap The book is divided into four main parts, followed by three practical appendices for setup assistance: ¡ Part 1: The Foundation – Chapter 1 introduces LLMs, tracing their history and providing a conceptual understanding of generative AI. It also advises on the appropriate and cau- tious use of these technologies.
📄 Page 15
xiiiabout this book – Chapter 2 offers a primer on starting with LLMs, comparing ChatGPT, GitHub Copilot, and CodeWhisperer and detailing the initial steps in harnessing their potential. ¡ Part 2: The Input – Chapter 3 walks through designing software with the help of ChatGPT, using an information technology asset management (ITAM) system as a project example. – Chapter 4 focuses on building software with GitHub Copilot, covering foun- dational concepts like domain modeling, immutability, and design patterns. – Chapter 5 delves into managing data with GitHub Copilot and Copilot Chat, exploring real-time asset monitoring with Kafka and data analysis with Apache Spark. ¡ Part 3: The Feedback – Chapter 6 discusses the testing, quality assessment, and explanation processes of software developed with LLMs, including bug hunting and code translation. ¡ Part 4: Into the World – Chapter 7 covers coding infrastructure and managing deployments, from building Docker images to setting up continuous integration/continuous deployment pipelines with GitHub Actions. – Chapter 8 addresses secure application development using ChatGPT, includ- ing threat modeling and the application of security best practices. – Chapter 9 explores the concept of “GPT-ing on the go,” including hosting your own LLM and democratizing access with GPT-4All. The appendices provide straightforward guidance on setting up ChatGPT, Copilot, and CodeWhisperer, ensuring that you have the practical knowledge to begin your journey in AI-powered development. With the exception of the last chapter, this book is meant to be read in order, as each chapter builds on the previous chapters. The last chapter can be read at any point after the first. About the code You can get executable snippets of code from the liveBook (online) version of this book at https://livebook.manning.com/book/ai-powered-developer. The complete code for the examples in the book is available for download from the Manning web- site at www.manning.com/books/ai-powered-developer and from GitHub at https:// github.com/nathanbcrocker/ai_powered_developer. It is important to note that part of the value of this book is to work through the examples using the recommended (and non-recommended) tools. An additional note related to the source code is that these tools will rarely produce the same output, even given the same input. You should not get frustrated or discouraged if your code is wildly
📄 Page 16
xiv about this book different from the source code in the repository. The source code is provided for your edification and for enhancing your learning, should you find it useful. To get the most from this book, you will need a recent version of Python 3 with the ability to install new packages. To run most of the infrastructure-related systems, you will need to be able to install Docker images and run Docker containers. This book contains many examples of source code, both in numbered listings and in line with normal text. In both cases, source code is formatted in a fixed-width font like this to separate it from ordinary text. In many cases, the original source code has been reformatted; we’ve added line breaks and reworked indentation to accommodate the available page space in the book. liveBook discussion forum Purchase of AI-Powered Developer includes free access to liveBook, Manning’s online reading platform. Using liveBook’s exclusive discussion features, you can attach com- ments to the book globally or to specific sections or paragraphs. It’s a snap to make notes for yourself, ask and answer technical questions, and receive help from the author and other users. To access the forum, go to https://livebook.manning.com/ book/ai-powered-developer/discussion. You can also learn more about Manning’s forums and the rules of conduct at https://livebook.manning.com/discussion. Manning’s commitment to our readers is to provide a venue where a meaningful dia- logue between individual readers and between readers and the author can take place. It is not a commitment to any specific amount of participation on the part of the author, whose contribution to the forum remains voluntary (and unpaid). We suggest you try asking the author some challenging questions lest their interest stray! The forum and the archives of previous discussions will be accessible from the publisher’s website for as long as the book is in print.
📄 Page 17
xv about the author Nathan B. Crocker is the co-founder and chief tech- nology officer (CTO) of Checker, an API-first solution that connects the traditional capital markets infrastruc- ture to the blockchain ecosystem. Using his expertise in building digital asset infrastructure, Nathan now leads the technological vision and development at Checker, building its core infrastructure that enables new finan- cial applications on the blockchain.
📄 Page 18
xvi about the cover illustration The figure on the cover of AI-Powered Developer is captioned “Junger kroatischer Geb- irgsbauer,” or “Young Croatian Mountain Peasant,” and is taken from a collection of historical and folk clothing illustrations, published in 1912. Each illustration is finely drawn and colored by hand. In those days, it was easy to identify where people lived and what their trade or station in life was just by their dress. Manning celebrates the inventiveness and initiative of the computer business with book covers based on the rich diversity of regional culture cen- turies ago, brought back to life by pictures from collections such as this one.
📄 Page 19
Part 1 The foundation In part 1, we establish a comprehensive understanding of large language models (LLMs) and their significance in modern software development. This part of the book traces the historical evolution of generative AI, providing a solid conceptual framework for these powerful technologies. It emphasizes the impor- tance of responsible and cautious use, guiding readers through the fundamental principles and potential pitfalls of integrating AI into their workflows. Addition- ally, this part offers practical advice on getting started with LLMs, comparing popular tools such as ChatGPT, GitHub Copilot, and CodeWhisperer and detail- ing the initial steps to harness their capabilities effectively.
📄 Page 20
(This page has no text content)
The above is a preview of the first 20 pages. Register to read the complete e-book.

💝 Support Author

0.00
Total Amount (¥)
0
Donation Count

Login to support the author

Login Now
Back to List