<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Shan</title>
    <description>The latest articles on DEV Community by Shan (@shanshaji).</description>
    <link>https://dev.to/shanshaji</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F297775%2Fa57b631b-6022-4626-9b1e-d3ba332ae9c4.png</url>
      <title>DEV Community: Shan</title>
      <link>https://dev.to/shanshaji</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shanshaji"/>
    <language>en</language>
    <item>
      <title>🔧 Flutter Clean Architecture - Fast Feature-First Setup Guide</title>
      <dc:creator>Shan</dc:creator>
      <pubDate>Sun, 06 Jul 2025 10:05:26 +0000</pubDate>
      <link>https://dev.to/shanshaji/flutter-clean-architecture-fast-feature-first-setup-guide-342l</link>
      <guid>https://dev.to/shanshaji/flutter-clean-architecture-fast-feature-first-setup-guide-342l</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;📘 &lt;strong&gt;Note:&lt;/strong&gt; This is a &lt;strong&gt;fast and simple setup guide&lt;/strong&gt; for structuring Flutter projects using Clean Architecture with a feature-first approach. It is &lt;strong&gt;consolidated from multiple references&lt;/strong&gt; and shaped by practical experience in real projects. Intended for quick implementation. This is how i structure and work on projects. &lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🧪 Step-by-Step Plan
&lt;/h2&gt;




&lt;h3&gt;
  
  
  1. Analyze the Figma Design
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Review the Figma design thoroughly.&lt;/li&gt;
&lt;li&gt;Identify all &lt;strong&gt;distinct features&lt;/strong&gt; based on the UI/UX.&lt;/li&gt;
&lt;li&gt;Each feature should be represented as a folder inside the &lt;code&gt;features/&lt;/code&gt; directory.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Define API Properties per Feature
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;For each feature, identify the &lt;strong&gt;API endpoints&lt;/strong&gt; it depends on.&lt;/li&gt;
&lt;li&gt;Extract only the &lt;strong&gt;necessary properties&lt;/strong&gt; from each API response (avoid using the entire response).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Create the &lt;code&gt;features/&lt;/code&gt; Folder
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Add a subfolder for each feature inside &lt;code&gt;features/&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Each feature will contain its own:

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;data/&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;domain/&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;presentation/&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Create Data Models (DTOs)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Define models inside &lt;code&gt;features/&amp;lt;feature&amp;gt;/data/models/&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Deserialize only the fields needed from the API.&lt;/li&gt;
&lt;li&gt;Add a &lt;code&gt;toEntity()&lt;/code&gt; method to convert the model to its corresponding entity.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5. Define the Entity Object
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Place entity classes inside &lt;code&gt;features/&amp;lt;feature&amp;gt;/domain/entities/&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;These classes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Contain &lt;strong&gt;business logic&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Do &lt;strong&gt;not&lt;/strong&gt; contain &lt;code&gt;fromJson&lt;/code&gt; / &lt;code&gt;toJson&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Add validation and domain-level calculations here.&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. Create the Data Source Layer
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Inside &lt;code&gt;features/&amp;lt;feature&amp;gt;/data/datasources/&lt;/code&gt;:

&lt;ul&gt;
&lt;li&gt;Define an &lt;strong&gt;abstract class&lt;/strong&gt; (e.g., &lt;code&gt;UserRemoteDataSource&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Implement a concrete class (e.g., &lt;code&gt;UserRemoteDataSourceImpl&lt;/code&gt;) using &lt;code&gt;http&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;This layer returns &lt;strong&gt;models&lt;/strong&gt;, not entities.&lt;/li&gt;

&lt;li&gt;Optionally, support local data sources (Hive, SharedPreferences, etc.).&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  7. Create the Repository Layer
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Define an &lt;strong&gt;abstract repository&lt;/strong&gt; in &lt;code&gt;features/&amp;lt;feature&amp;gt;/domain/repositories/&lt;/code&gt;.

&lt;ul&gt;
&lt;li&gt;Return &lt;strong&gt;entities&lt;/strong&gt;, not models.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Implement the repository in &lt;code&gt;data/repositories/&lt;/code&gt;:

&lt;ul&gt;
&lt;li&gt;Use the data source &lt;strong&gt;abstract class&lt;/strong&gt;, not concrete one [0].&lt;/li&gt;
&lt;li&gt;Optionally use &lt;strong&gt;multiple data sources&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;try/catch&lt;/code&gt; for error handling.&lt;/li&gt;
&lt;li&gt;Return results using the &lt;strong&gt;Result pattern&lt;/strong&gt; [2].&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  8. Create the Use Cases Layer
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Inside &lt;code&gt;features/&amp;lt;feature&amp;gt;/domain/usecases/&lt;/code&gt;, define use case classes.&lt;/li&gt;
&lt;li&gt;Each use case:

&lt;ul&gt;
&lt;li&gt;Performs &lt;strong&gt;one responsibility&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Depends on the repository abstract class&lt;/li&gt;
&lt;li&gt;Returns either entities or &lt;code&gt;Result&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  9. Create the Presentation Layer
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Inside &lt;code&gt;features/&amp;lt;feature&amp;gt;/presentation/&lt;/code&gt;:

&lt;ul&gt;
&lt;li&gt;Add &lt;code&gt;ui/&lt;/code&gt; (screens, widgets)&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;controllers/&lt;/code&gt; (ViewModels, BLoC, etc.)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Separate screens and controllers for each UI if needed.&lt;/li&gt;

&lt;li&gt;Use &lt;strong&gt;internationalization&lt;/strong&gt; for all labels and strings.&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  10. Create Shared and Core Folders
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Outside &lt;code&gt;features/&lt;/code&gt;, create:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;shared/&lt;/code&gt;: Shared features.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;core/&lt;/code&gt;: constants, error handling, API clients, utilities&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;These folders hold &lt;strong&gt;reusable&lt;/strong&gt; components for the entire app.&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔁 Example Folder Structure
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lib/
├── core/
│   └── (helpers, utils, constants, etc.)
├── shared/
│   └── (shared features)
├── features/
│   ├── &amp;lt;feature_name&amp;gt;/
│   │   ├── data/
│   │   │   ├── models/
│   │   │   ├── datasources/
│   │   │   └── repositories/
│   │   ├── domain/
│   │   │   ├── entities/
│   │   │   ├── repositories/
│   │   │   └── usecases/
│   │   └── presentation/
│   │       ├── ui/
│   │       └── controllers/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  📚 References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[0] &lt;a href="https://techdynasty.medium.com/solid-principles-in-flutter-b868fb5ef60e" rel="noopener noreferrer"&gt;https://techdynasty.medium.com/solid-principles-in-flutter-b868fb5ef60e&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;[1] &lt;a href="https://codewithandrea.com/articles/flutter-project-structure/" rel="noopener noreferrer"&gt;https://codewithandrea.com/articles/flutter-project-structure/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;[2] &lt;a href="https://docs.flutter.dev/app-architecture/design-patterns/result#putting-it-all-together" rel="noopener noreferrer"&gt;https://docs.flutter.dev/app-architecture/design-patterns/result#putting-it-all-together&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/@yamen.abd98/clean-architecture-in-flutter-mvvm-bloc-dio-79b1615530e1" rel="noopener noreferrer"&gt;https://medium.com/@yamen.abd98/clean-architecture-in-flutter-mvvm-bloc-dio-79b1615530e1&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>designpatterns</category>
      <category>mobile</category>
    </item>
    <item>
      <title>Create Flavors for Flutter App - iOS</title>
      <dc:creator>Shan</dc:creator>
      <pubDate>Sat, 13 Apr 2024 20:33:03 +0000</pubDate>
      <link>https://dev.to/shanshaji/create-flavors-for-flutter-app-ios-fnl</link>
      <guid>https://dev.to/shanshaji/create-flavors-for-flutter-app-ios-fnl</guid>
      <description>&lt;p&gt;Note: If you're new to Flutter and find it tricky to sift through many resources on setting up flavors, this article is for you. Experienced Flutter developers might already be familiar with this so please feel free to skip this. If you just want to have a quick refresh then you can go through the videos 😁.&lt;/p&gt;

&lt;p&gt;Note: It's better to save this for later reference. &lt;/p&gt;

&lt;p&gt;Have you ever wanted to manage different versions of your Flutter app for different needs? 'Flavors' in Flutter help you do just that. They're similar to 'build configurations' in iOS. Using flavors, you can create a production version of your app for real users, a staging version for debugging, and a preview version for QA testing — all from the same code base.&lt;/p&gt;

&lt;p&gt;To know more about 'Flavors' please go through the official documentation &lt;a href="https://docs.flutter.dev/deployment/flavors#launching-your-app-flavors" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Environment set up
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Prerequisites:

&lt;ul&gt;
&lt;li&gt;Xcode installed&lt;/li&gt;
&lt;li&gt;An existing Flutter project&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  Creating flavors in iOS
&lt;/h2&gt;

&lt;p&gt;Open your project in Xcode by going to the iOS folder and double-clicking on the &lt;code&gt;Runner.xcworkspace&lt;/code&gt; file. This action will launch Xcode for your project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fonsqxgik2nafj3gp73ks.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fonsqxgik2nafj3gp73ks.png" alt="iOS Folder" width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Step 2
&lt;/h3&gt;

&lt;p&gt;The second step would be to define schemes. Select Product &amp;gt; Scheme &amp;gt; New Scheme from the menu to add a new Scheme.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A scheme describes how Xcode runs different actions. In this article we will define two schemes &lt;code&gt;staging&lt;/code&gt; and &lt;code&gt;production&lt;/code&gt;. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/WEASQLPvrKs"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/sFOrRQmp3GU"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;h3&gt;
  
  
  Step 3
&lt;/h3&gt;

&lt;p&gt;Let's duplicate the existing build configurations to create separate configurations for different flavors. This process involves replicating the default configurations and appending "staging" and "production"  as a suffix.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/6BQCr3RXGFE"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/6FO1ejkfuPY"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;h3&gt;
  
  
  Step 4
&lt;/h3&gt;

&lt;p&gt;Let's now edit the &lt;code&gt;staging&lt;/code&gt; and &lt;code&gt;production&lt;/code&gt; schemes to align with the newly created build configurations. Similarly, map the newly created build configurations to the &lt;code&gt;production&lt;/code&gt; scheme.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/N8VsUrd-bmA"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;h3&gt;
  
  
  Step 5
&lt;/h3&gt;

&lt;p&gt;Now that we've got our &lt;code&gt;staging&lt;/code&gt; and &lt;code&gt;production&lt;/code&gt; flavors ready, we can assign different bundle identifiers for each. &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/amiPEh_WCQU"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Give it a shot—assign the bundle identifier for the production flavor yourself! 😁&lt;/p&gt;




&lt;h3&gt;
  
  
  Step 6
&lt;/h3&gt;

&lt;p&gt;In the Build Settings, set the Product Name value to match each flavor. For example, add Todo Staging. For those unfamiliar, the product name in Xcode refers to the name of the app as it appears in the App Store and on devices once it's installed. Also we will be using this product name in the next step.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/BUhhEKrtMVo"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Oops! no video for production😌. Please try to do it yourself!&lt;/p&gt;




&lt;h3&gt;
  
  
  Step 7
&lt;/h3&gt;

&lt;p&gt;Add the display name to &lt;code&gt;Info.plist&lt;/code&gt;. Update the Bundle Display Name value to &lt;code&gt;$(PRODUCT_NAME)&lt;/code&gt;. When we set the Bundle Display Name to &lt;code&gt;$(PRODUCT_NAME)&lt;/code&gt;, Xcode dynamically replaces it with the actual product name of our app during the build process.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/8Cm05iyUhXM"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;h3&gt;
  
  
  Step 8
&lt;/h3&gt;

&lt;p&gt;Now it's time to setup our app icon for our &lt;code&gt;staging&lt;/code&gt; flavor. When we create your project from a template, it automatically includes a default asset catalog (Assets.xcassets) that contains the AppIcon. &lt;/p&gt;

&lt;p&gt;If we don’t have a default asset catalog or existing AppIcon or we want to add another, we can add an app icon to an asset catalog manually:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the Project navigator, select an asset catalog.&lt;/li&gt;
&lt;li&gt;Click the Add button (+) at the bottom of the outline view.&lt;/li&gt;
&lt;li&gt;In the pop-up menu, choose OS variant &amp;gt; OS variant App Icon. Xcode creates a new app icon set or image stack with the name AppIcon.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/oIUDuWo-_bs"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;h3&gt;
  
  
  Step 9
&lt;/h3&gt;

&lt;p&gt;Now that we've created the asset catalog, it's time to add the icons. To ensure compatibility with all the sizes specified in Xcode, we'll need to generate icons for each size. I typically use an app icon generator like &lt;a href="https://www.appicon.co/" rel="noopener noreferrer"&gt;appicon.co&lt;/a&gt; for this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbvb7m8y4nrzn00zrad2z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbvb7m8y4nrzn00zrad2z.png" alt=" " width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you've generated the icons, simply download them and then either drag and drop them directly into the new staging asset catalog in Xcode or into the designated folder, following the steps outlined in the video.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/Yv2ceg8dt-A"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Next, we'll need to associate the build configuration with the newly created app icon set name.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/KnA0gQcSKCg"&gt;
&lt;/iframe&gt;
 &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Please follow the same steps for &lt;code&gt;production&lt;/code&gt; as well. &lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Step 10
&lt;/h3&gt;

&lt;p&gt;"Hurray 🎉! We're almost done. Now it's time to test the changes we've made so far.&lt;/p&gt;

&lt;p&gt;In Android Studio, add flavor configurations for both staging and production, as shown in the screenshot below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2bk7qsaxyujbqdu81y9k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2bk7qsaxyujbqdu81y9k.png" alt=" " width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's try running the staging app. If everything works fine, you should see the app installed on your emulator, similar to the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxvg2mtdilzycrwv228s0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxvg2mtdilzycrwv228s0.png" alt="Simulator Screenshot" width="800" height="1734"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>beginners</category>
      <category>ios</category>
    </item>
    <item>
      <title>The Art of Inferring with Large Language Models</title>
      <dc:creator>Shan</dc:creator>
      <pubDate>Tue, 23 May 2023 20:03:16 +0000</pubDate>
      <link>https://dev.to/shanshaji/the-art-of-inferring-with-large-language-models-243m</link>
      <guid>https://dev.to/shanshaji/the-art-of-inferring-with-large-language-models-243m</guid>
      <description>&lt;p&gt;Note: This is a documented version of ChatGPT Prompt Engineering for Developers course. You can find the course &lt;a href="https://learn.deeplearning.ai/chatgpt-prompt-eng/lesson/1/introduction" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Inferring is a powerful tool that can be used to extract meaning from text. It can be used to understand customer feedback, to identify trends in social media.&lt;/p&gt;

&lt;p&gt;Here are some examples of how inferring can be used in prompt engineering: &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sentiment analysis&lt;/strong&gt;: Inferring can be used to identify the sentiment of a piece of text, such as whether it is positive, negative, or neutral. This can be used to understand customer feedback, identify trends in social media, and generate new ideas. &lt;/p&gt;

&lt;p&gt;Eg: We can use sentiment analysis to categorize playstore reviews into positive, negative, or neutral reviews. This will help us to prioritise the issues mentioned in the reviews and identify the issues that need to be addressed. This will allow the customer support team to quickly identify and resolve issues, and the engineers to focus on fixing high priority bugs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Topic modeling&lt;/strong&gt;: Inferring can be used to identify the topics of a piece of text. This can be used to understand the content of a document, identify patterns in data, and generate new ideas.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Named entity recognition&lt;/strong&gt;: Inferring can be used to identify named entities in a piece of text, such as people, places, and organizations. This can be used to understand the context of a document, identify potential customers, and generate new ideas.&lt;/p&gt;

&lt;p&gt;For example, if you are running an e-commerce website and you have received reviews from consumers who have purchased from your website, you can use a large language model (LLM) to analyse the reviews and identify named entities, such as the shop name and product name. This information can then be used to improve the customer experience, such as by recommending similar products or providing customer support.&lt;/p&gt;

&lt;p&gt;Section from the course starts here: &lt;/p&gt;

&lt;p&gt;*&lt;em&gt;In this article we will infer sentiment and topics from product reviews and news articles. *&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lamp_review = """
Needed a nice lamp for my bedroom, and this one had \
additional storage and not too high of a price point. \
Got it fast.  The string to our lamp broke during the \
transit and the company happily sent over a new one. \
Came within a few days as well. It was easy to put \
together.  I had a missing part, so I contacted their \
support and they very quickly got me the missing piece! \
Lumina seems to me to be a great company that cares \
about their customers and products!!
"""


What is the sentiment of the following product review, 
which is delimited with triple single quotes?

Review text: '''{lamp_review}'''

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqgjcs9coufh7nxgxmpzh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqgjcs9coufh7nxgxmpzh.png" alt="Review sentiment analysis" width="800" height="239"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see from the screenshot it's a long output. We can  ask the LLM to either output positive / negative as keywords.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"""
What is the sentiment of the following product review, 
which is delimited with triple single quotes?

Give your answer as a single word, either "positive" \
or "negative".

Review text: '''{lamp_review}'''
"""
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4wckdg0t3qbmohgyavnb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4wckdg0t3qbmohgyavnb.png" alt=" " width="800" height="96"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;we can ask an LLM to identify the emotions that the writer of a review is expressing. We can also ask the LLM if the writer is expressing any anger in their review. Additionally, we can ask the LLM to identify the company name and product name from the review. All of these tasks can be performed in a single prompt.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"""
Identify the following items from the review text: 
- Sentiment (positive or negative)
- List all the emotions expressed in the review not more than 5
- Is the reviewer expressing anger? (true or false)
- Item purchased by reviewer
- Company that made the item

The review is delimited with triple backticks. \
Format your response as a JSON object with \
"Sentiment", "Anger", Emotions, "Item" and "Brand" as the keys.
If the information isn't present, use "unknown" \
as the value.
Make your response as short as possible.
Format the Anger value as a boolean.

Review text: '''{lamp_review}'''
"""
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3fyq9loyps3xep7sm2uf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3fyq9loyps3xep7sm2uf.png" alt="Analyse contents from text" width="800" height="278"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next topic in the course topic analysis 🙃.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Inferring can be used to identify the topics of a piece of long text.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;story = """
In a recent survey conducted by the government, 
public sector employees were asked to rate their level 
of satisfaction with the department they work at. 
The results revealed that NASA was the most popular 
department with a satisfaction rating of 95%.

One NASA employee, John Smith, commented on the findings, 
stating, "I'm not surprised that NASA came out on top. 
It's a great place to work with amazing people and 
incredible opportunities. I'm proud to be a part of 
such an innovative organization."

The results were also welcomed by NASA's management team, 
with Director Tom Johnson stating, "We are thrilled to 
hear that our employees are satisfied with their work at NASA. 
We have a talented and dedicated team who work tirelessly 
to achieve our goals, and it's fantastic to see that their 
hard work is paying off."

The survey also revealed that the 
Social Security Administration had the lowest satisfaction 
rating, with only 45% of employees indicating they were 
satisfied with their job. The government has pledged to 
address the concerns raised by employees in the survey and 
work towards improving job satisfaction across all departments.
"""

Determine five topics that are being discussed in the \
following text, which is delimited by triple backticks.

Make each item one or two words long. 

Format your response as a list of items separated by commas.

Text sample: '''{story}'''
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see from the output we got different topics in the article that we gave to the LLM. This information can be used to recommend articles to users who are interested in those topics. &lt;/p&gt;

&lt;p&gt;For example, Suppose if a user is subscribed to the topics "java, javascript, and AI," and the user wants to only receive article suggestions based on his/her subscription the LLM can be used to identify the topic and we could create a service that will send notifications when a new article on any of those topic comes.&lt;/p&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz10brdq3n1xrc11o7g2y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz10brdq3n1xrc11o7g2y.png" alt=" " width="800" height="95"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>beginners</category>
      <category>ai</category>
      <category>chatgpt</category>
    </item>
    <item>
      <title>Iterative Prompt Development: Iteratively analyse and refine your prompts</title>
      <dc:creator>Shan</dc:creator>
      <pubDate>Sun, 21 May 2023 13:07:43 +0000</pubDate>
      <link>https://dev.to/shanshaji/iterative-prompt-development-iteratively-analyse-and-refine-your-prompts-3ibl</link>
      <guid>https://dev.to/shanshaji/iterative-prompt-development-iteratively-analyse-and-refine-your-prompts-3ibl</guid>
      <description>&lt;p&gt;Note: This is a documented version of ChatGPT Prompt Engineering for Developers course. You can find the course &lt;a href="https://learn.deeplearning.ai/chatgpt-prompt-eng/lesson/1/introduction" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Note: This article is pretty boring. I have added a general summary here for all those who don't have time to read this. &lt;/p&gt;

&lt;p&gt;In this article, we will see how to iteratively analyse and refine prompts to generate marketing copy from a product fact sheet. We will start with a simple prompt that generated a long, rambling text. We then iteratively will refine the prompt to limit the number of words, focus on the relevant details, and include the product IDs. Finally, we will add a table of dimensions. By following this iterative approach, we will be able to generate a concise and polished output that meets the needs of the marketing team. This is based on the example that is mentioned in the course.&lt;/p&gt;

&lt;p&gt;Note: Before reading this please try to read two another articles which is part of this course. It will give you a general guidelines on how to interact with LLM in a better way.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/shanshaji/writing-effective-prompts-for-large-language-models-two-prompting-principles-and-their-related-tactics-151a"&gt;Writing Effective Prompts for Large Language Models: Two Prompting Principles and Their Related Tactics.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/shanshaji/principle-2-of-writing-effective-prompts-for-large-language-models-give-them-time-to-think-25j3"&gt;Principle 2 of Writing Effective Prompts for Large Language Models: Give Them Time to Think&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note: In this Article, you'll learn how to iteratively analyse and refine prompts. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We will iteratively analyse and refine our prompts to generate marketing copy from a product fact sheet.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fact_sheet_chair = """
OVERVIEW
- Part of a beautiful family of mid-century inspired office furniture, 
including filing cabinets, desks, bookcases, meeting tables, and more.
- Several options of shell color and base finishes.
- Available with plastic back and front upholstery (SWC-100) 
or full upholstery (SWC-110) in 10 fabric and 6 leather options.
- Base finish options are: stainless steel, matte black, 
gloss white, or chrome.
- Chair is available with or without armrests.
- Suitable for home or business settings.
- Qualified for contract use.

CONSTRUCTION
- 5-wheel plastic coated aluminum base.
- Pneumatic chair adjust for easy raise/lower action.

DIMENSIONS
- WIDTH 53 CM | 20.87”
- DEPTH 51 CM | 20.08”
- HEIGHT 80 CM | 31.50”
- SEAT HEIGHT 44 CM | 17.32”
- SEAT DEPTH 41 CM | 16.14”

OPTIONS
- Soft or hard-floor caster options.
- Two choices of seat foam densities: 
 medium (1.8 lb/ft3) or high (2.8 lb/ft3)
- Armless or 8 position PU armrests 

MATERIALS
SHELL BASE GLIDER
- Cast Aluminum with modified nylon PA6/PA66 coating.
- Shell thickness: 10 mm.
SEAT
- HD36 foam

COUNTRY OF ORIGIN
- Italy
"""

Your task is to help a marketing team create a 
description for a retail website of a product based 
on a technical fact sheet.

Write a product description based on the information 
provided in the technical specifications delimited by 
triple hyphen.

Technical specifications: ---{fact_sheet_chair}---
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As the prompt is bit big. When I unleashed this on GPT-3, it erupted with a whopping 369 words!😁. I won't be sharing the output here as it's a long text. To limit the number of words to certain limit we can tell GPT to generate at most x amount of words.&lt;/p&gt;

&lt;p&gt;The new prompt will be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Your task is to help a marketing team create a 
description for a retail website of a product based 
on a technical fact sheet.

Write a product description based on the information 
provided in the technical specifications delimited by 
triple hyphen.

Use at most 50 words.

Technical specifications: ---{fact_sheet_chair}---
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this prompt we are mentioning the number of words to GPT to limit the output.&lt;/p&gt;

&lt;p&gt;Issue 2 of the generated output:  Text focuses on the wrong details.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
Your task is to help a marketing team create a 
description for a retail website of a product based 
on a technical fact sheet.

Write a product description based on the information 
provided in the technical specifications delimited by 
triple hyphen.

The description is intended for furniture retailers, 
so should be technical in nature and focus on the 
materials the product is constructed from.

Use at most 50 words.

Technical specifications: ---{fact_sheet_chair}---

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here in this prompt we are asking the model to focus on the aspects that are relevant to the intended audience. Here we need to generate the description for furniture retailers.&lt;/p&gt;

&lt;p&gt;Output: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdmr80bt78590avh9y1hj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdmr80bt78590avh9y1hj.png" alt="Limit Words Generated" width="800" height="192"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can further improve this prompt to attach the product ids in the description. The updated prompt will be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"""
Your task is to help a marketing team create a 
description for a retail website of a product based 
on a technical fact sheet.

Write a product description based on the information 
provided in the technical specifications delimited by 
triple hyphen.

The description is intended for furniture retailers, 
so should be technical in nature and focus on the 
materials the product is constructed from.

At the end of the description, include every 7-character 
Product ID in the technical specification.

Use at most 50 words.

Technical specifications: ---{fact_sheet_chair}---
"""

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9kv1yu4ui2z4rwc0rq8w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9kv1yu4ui2z4rwc0rq8w.png" alt="Output with product id" width="800" height="174"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Issue 3 - Description needs a table of dimensions&lt;/p&gt;

&lt;p&gt;We can ask the model to generate a table for us along with the description. Here we will be generating a table of dimensions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Your task is to help a marketing team create a 
description for a retail website of a product based 
on a technical fact sheet.

Write a product description based on the information 
provided in the technical specifications delimited by 
triple hyphen.

The description is intended for furniture retailers, 
so should be technical in nature and focus on the 
materials the product is constructed from.

At the end of the description, include every 7-character 
Product ID in the technical specification.

After the description, include a table that gives the 
product's dimensions. The table should have two columns.
In the first column include the name of the dimension. 
In the second column include the measurements in inches only.

Give the table the title 'Product Dimensions'.

Format everything as HTML that can be used in a website. 
Place the description in a &amp;lt;div&amp;gt; element.

Technical specifications: ---{fact_sheet_chair}---
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output generated is in HTML. I am not going to add the screenshot here as the output is a bit long. You can copy and paste this prompt to know how the output will look like. &lt;/p&gt;

&lt;p&gt;Here is another example of how the iterative approach can be used to improve the quality of generated outputs. Let's say you want to write a poem about a flower. Your first prompt might be something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Write a poem about a flower.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prompt is too general and will likely result in a poem that is not very specific or creative. To improve the prompt, you could add more details about the flower, such as its colour, shape, or smell. You could also specify the tone of the poem, such as whether you want it to be happy, sad, or reflective.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Write a happy poem about a red lily.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prompt is more likely to result in a poem that is both specific and creative. Once you have written the poem, you can then evaluate it and see if it meets your needs. If not, you can iterate on the prompt and try again until the desired output is achieved.&lt;/p&gt;

</description>
      <category>chatgpt</category>
      <category>ai</category>
      <category>beginners</category>
      <category>prompts</category>
    </item>
    <item>
      <title>Principle 2 of Writing Effective Prompts for Large Language Models: Give Them Time to Think</title>
      <dc:creator>Shan</dc:creator>
      <pubDate>Sat, 20 May 2023 05:42:14 +0000</pubDate>
      <link>https://dev.to/shanshaji/principle-2-of-writing-effective-prompts-for-large-language-models-give-them-time-to-think-25j3</link>
      <guid>https://dev.to/shanshaji/principle-2-of-writing-effective-prompts-for-large-language-models-give-them-time-to-think-25j3</guid>
      <description>&lt;p&gt;Note: This is a documented version of ChatGPT Prompt Engineering for Developers course. You can find the course &lt;a href="https://learn.deeplearning.ai/chatgpt-prompt-eng/lesson/1/introduction" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Note: In this Article, you'll practice one prompting principle and it's related tactics in order to write effective prompts for large language models. You can view my previous article &lt;a href="https://dev.to/shanshaji/writing-effective-prompts-for-large-language-models-two-prompting-principles-and-their-related-tactics-151a"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Principle 2&lt;/strong&gt;: Give the model time to “think”.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Large language models can make reasoning errors by rushing to an incorrect conclusion. This can happen if the model is given a task that is too complex or if it is not given enough time to consider all of the evidence. To prevent this, you can reframe the query to request a chain or series of relevant reasoning. This will help the model to slow down and consider all of the evidence before drawing a conclusion. Just like humans, large language models can make mistakes if they are rushed or given too much to do. Instructing the model to think longer about a problem can help to improve its accuracy.&lt;/p&gt;

&lt;p&gt;Here are some tips for reframing a query to request a chain or series of relevant reasoning:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use the word "explain" or "justify" in your query.&lt;/li&gt;
&lt;li&gt;Ask the model to provide evidence to support its conclusion.&lt;/li&gt;
&lt;li&gt;Ask the model to consider all of the relevant information.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are the outputs that were generated for the same question asked in different ways.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frloqjwz612bs19v91kaa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frloqjwz612bs19v91kaa.png" alt="Give Them Time to Think" width="800" height="493"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F73179uloinlgq3rioij4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F73179uloinlgq3rioij4.png" alt="Give Them Time to Think" width="800" height="576"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tactic 1&lt;/strong&gt;: Specify the steps required to complete a task&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;text = """
In a charming village, siblings Jack and Jill set out on \ 
a quest to fetch water from a hilltop \ 
well. As they climbed, singing joyfully, misfortune \ 
struck—Jack tripped on a stone and tumbled \ 
down the hill, with Jill following suit. \ 
Though slightly battered, the pair returned home to \ 
comforting embraces. Despite the mishap, \ 
their adventurous spirits remained undimmed, and they \ 
continued exploring with delight.
"""

prompt_1 = """
Perform the following actions: 
1 - Summarise the following text delimited by triple \
hyphen with 1 sentence.
2 - Translate the summary into French.
3 - List each name in the French summary.
4 - Output a json object that contains the following \
keys: french_summary, num_names.

Separate your answers with line breaks.

Text:
---{text}---
"""
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this prompt we are specifying all the steps that should be performed by the model before arriving at a conclusion. &lt;br&gt;
As seen from the screenshot, the model provided a clear and concise answer for our query.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frwr4vyahbt7whqzfh7z4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frwr4vyahbt7whqzfh7z4.png" alt=" " width="800" height="465"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let us try to give another prompt that will give us a more structured output.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;text = """
In a charming village, siblings Jack and Jill set out on \ 
a quest to fetch water from a hilltop \ 
well. As they climbed, singing joyfully, misfortune \ 
struck—Jack tripped on a stone and tumbled \ 
down the hill, with Jill following suit. \ 
Though slightly battered, the pair returned home to \ 
comforting embraces. Despite the mishap, \ 
their adventurous spirits remained undimmed, and they \ 
continued exploring with delight.
"""

Your task is to perform the following actions: 
1 - Summarise the following text delimited by 
  &amp;lt;&amp;gt; with 1 sentence.
2 - Translate the summary into French.
3 - List each name in the French summary.
4 - Output a json object that contains the 
  following keys: french_summary, num_names.

Use the following format:

Summary: summary
Translation: summary translation
Names: list of names in Italian summary
Output JSON: json with summary and num_names

Text: &amp;lt;{text}&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As seen from the screenshot the output is now more structured and follows a format.&lt;/p&gt;

&lt;p&gt;Output: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4a31grlzw7ca1otvjpbc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4a31grlzw7ca1otvjpbc.png" alt="Structured Response" width="800" height="465"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tactic 2&lt;/strong&gt;: Instruct the model to work out its own solution before rushing to a conclusion&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Determine if the student's solution is correct or not.

Question:
I'm building a solar power installation and I need \
 help working out the financials. 
- Land costs $100 / square foot
- I can buy solar panels for $250 / square foot
- I negotiated a contract for maintenance that will cost \ 
me a flat $100k per year, and an additional $10 / square \
foot

What is the total cost for the first year of operations 
as a function of the number of square feet.

Student's Solution:

Let x be the size of the installation in square feet.
Costs:
1. Land cost: 100x
2. Solar panel cost: 250x
3. Maintenance cost: 100,000 + 100x
Total cost: 100x + 250x + 100,000 + 100x = 450x + 100,000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prompt will give the output as the student's answer is correct but the answer is wrong because the calculation "100,000 + 100x" is wrong it should be "100,000 + 10x". So the answer should be "360x + 100,000". &lt;/p&gt;

&lt;p&gt;Output: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7hea656y0p6ucivrrpzx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7hea656y0p6ucivrrpzx.png" alt=" " width="800" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To get the correct output we need to ask the model to first generate it's own answer and then compare the answer with the student's answer. Here we asking the model to do it's own analysis on the question and generate an answer for us.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;To solve the problem do the following:
- First, work out your own solution to the problem. 
- Then compare your solution to the student's solution 
and evaluate if the student's solution is correct or not. 
Don't decide if the student's solution is correct until 
you have done the problem yourself.

Use the following format:
Question:
----
question here
----

Student's solution:
----
student's solution here
----

Actual solution:
----
steps to work out the solution and your solution here
----

Is the student's solution the same as actual solution \
just calculated:
---
yes or no
---

Student grade:
---
correct or incorrect
----

Question:
""""
I'm building a solar power installation and I need help \
working out the financials. 
- Land costs $100 / square foot
- I can buy solar panels for $250 / square foot
- I negotiated a contract for maintenance that will cost \
me a flat $100k per year, and an additional $10 / square \
foot
What is the total cost for the first year of operations \
as a function of the number of square feet.
""""
Student's solution:
""""
Let x be the size of the installation in square feet.
Costs:
1. Land cost: 100x
2. Solar panel cost: 250x
3. Maintenance cost: 100,000 + 100x
Total cost: 100x + 250x + 100,000 + 100x = 450x + 100,000
""""
Actual solution:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjbsfuo3tlktt8rf3pdlm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjbsfuo3tlktt8rf3pdlm.png" alt=" " width="800" height="780"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is an example of how asking the model to do a calculation itself and breaking down the task into steps to give the model more time to think can help you &lt;br&gt;
get more accurate responses. Here i am using hyphen and triple double quotes as delimiters. You can use any delimiters as you like. &lt;/p&gt;

&lt;p&gt;To improve the accuracy and quality of the responses from large language models, it is important to give them time to "think". This can be done by reframing your query to request a chain or series of relevant reasoning, or by instructing the model to work out its own solution before rushing to a conclusion. Additionally, it is important to be as specific as possible in your queries, use natural language, use keywords, and be patient when waiting for a response.&lt;/p&gt;

</description>
      <category>chatgpt</category>
      <category>promptengineering</category>
      <category>beginners</category>
      <category>ai</category>
    </item>
    <item>
      <title>Writing Effective Prompts for Large Language Models: Two Prompting Principles and Their Related Tactics</title>
      <dc:creator>Shan</dc:creator>
      <pubDate>Fri, 19 May 2023 18:42:11 +0000</pubDate>
      <link>https://dev.to/shanshaji/writing-effective-prompts-for-large-language-models-two-prompting-principles-and-their-related-tactics-151a</link>
      <guid>https://dev.to/shanshaji/writing-effective-prompts-for-large-language-models-two-prompting-principles-and-their-related-tactics-151a</guid>
      <description>&lt;p&gt;Note: This is a documented version of ChatGPT Prompt Engineering for Developers course. You can find the course &lt;a href="https://learn.deeplearning.ai/chatgpt-prompt-eng/lesson/1/introduction" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Note: In this Article, you'll practice one prompting principle and it's related tactics in order to write effective prompts for large language models. I will create another article on principle 2.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prompting Principles
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Principle 1: Write clear and specific instructions.&lt;/li&gt;
&lt;li&gt;Principle 2: Give the model time to “think”.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Tactic 1&lt;/strong&gt;: Use delimiters to clearly indicate distinct parts of the input.&lt;/p&gt;

&lt;p&gt;Delimiters can be anything like:&lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Triple Quotes: ''' '''&lt;/li&gt;
&lt;li&gt;Triple Backticks:```&lt;/li&gt;
&lt;li&gt;Triple Dashes: --- ---&lt;/li&gt;
&lt;li&gt;Angle Brackets: &amp;lt;&amp;gt;&lt;/li&gt;
&lt;li&gt;Xml Tags: &amp;lt;tag&amp;gt; &amp;lt;/tag&amp;gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
text = """
You should express what you want a model to do by \ 
providing instructions that are as clear and \ 
specific as you can possibly make them. \ 
This will guide the model towards the desired output, \ 
and reduce the chances of receiving irrelevant \ 
or incorrect responses. Don't confuse writing a \ 
clear prompt with writing a short prompt. \ 
In many cases, longer prompts provide more clarity \ 
and context for the model, which can lead to \ 
more detailed and relevant outputs.
"""

prompt = """
Summarise the text delimited by angle brackets\ 
into a single sentence.
&amp;lt;text&amp;gt;
"""

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output that i got after giving this prompt to chat GPT.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8e8sj2text6gcv31mgcw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8e8sj2text6gcv31mgcw.png" alt="Delimiter GPT prompt output " width="800" height="220"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tactic 2&lt;/strong&gt;: Ask for a structured output&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JSON, HTML
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"""
Generate a list of three made-up book titles along \ 
with their authors and genres. 
Provide them in JSON format with the following keys: 
book_id, title, author, genre.
"""
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prompt will generate the output in json format. If we change the value JSON to HTML then the output will be in HTML format.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JSON&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"books"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"book_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"The Secret Garden"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"author"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Emily Greenfield"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"genre"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Children's Fiction"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"book_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Midnight Shadows"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"author"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Jacob Nightfall"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"genre"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Thriller"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For those who don't know what is JSON and HTML it is fine. HTML is a markup language used for structuring and presenting web content, while JSON is a data interchange format used for storing and exchanging structured data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tactic 3&lt;/strong&gt;: Ask the model to check whether conditions are satisfied&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;text_1 = """
Making a cup of tea is easy! First, you need to get some \ 
water boiling. While that's happening, \ 
grab a cup and put a tea bag in it. Once the water is \ 
hot enough, just pour it over the tea bag. \ 
Let it sit for a bit so the tea can steep. After a \ 
few minutes, take out the tea bag. If you \ 
like, you can add some sugar or milk to taste. \ 
And that's it! You've got yourself a delicious \ 
cup of tea to enjoy.
"""
prompt = """
You will be provided with text delimited by triple quotes. 
If it contains a sequence of instructions, \ 
re-write those instructions in the following format:

Step 1 - ...
Step 2 - …
…
Step N - …

If the text does not contain a sequence of instructions, \ 
then simply write \"No steps provided.\"

\"\"\"{text_1}\"\"\"
"""
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs8rcfn1bori34uqn2wic.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs8rcfn1bori34uqn2wic.png" alt="Ask the model to check whether conditions are satisfied" width="800" height="313"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An effective use case for this tactic involves providing a code snippet that encompasses essential business logic, and subsequently leveraging AI to verify the comprehensive handling of all conditions within the code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;text_2 = """
The sun is shining brightly today, and the birds are \
singing. It's a beautiful day to go for a \ 
walk in the park. The flowers are blooming, and the \ 
trees are swaying gently in the breeze. People \ 
are out and about, enjoying the lovely weather. \ 
Some are having picnics, while others are playing \ 
games or simply relaxing on the grass. It's a \ 
perfect day to spend time outdoors and appreciate the \ 
beauty of nature.
"""
prompt = """
You will be provided with text delimited by triple quotes. 
If it contains a sequence of instructions, \ 
re-write those instructions in the following format:

Step 1 - ...
Step 2 - …
…
Step N - …

If the text does not contain a sequence of instructions, \ 
then simply write \"No steps provided.\"

\"\"\"{text_2}\"\"\"
"""
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example you can clearly see there are not tasks mentioned in the text. Since there are not steps we need to get "No steps provided." as the output.&lt;/p&gt;

&lt;p&gt;Output: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvozodh287kk1wtnzpypk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvozodh287kk1wtnzpypk.png" alt="Ask the model to check whether conditions are satisfied" width="800" height="176"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tactic 4&lt;/strong&gt;: "Few-shot" prompting&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;prompt = """
Your task is to answer in a consistent style.

&amp;lt;child&amp;gt;: Teach me about patience.

&amp;lt;grandparent&amp;gt;: The river that carves the deepest \ 
valley flows from a modest spring; the \ 
grandest symphony originates from a single note; \ 
the most intricate tapestry begins with a solitary thread.

&amp;lt;child&amp;gt;: Teach me about resilience.
"""
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This tactic involves training the model with successful examples of tasks and subsequently requesting the model to perform a specific task based on the provided examples.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpb7yw77o50j48i0a2ioj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpb7yw77o50j48i0a2ioj.png" alt="" width="800" height="214"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In conclusion, Principle 1 emphasizes the significance of providing clear and specific instructions to ChatGPT in order to achieve desired outputs. By expressing instructions in a precise manner, we guide the model towards the intended outcome and minimize the risk of irrelevant or incorrect responses. This principle emphasizes that clarity should not be compromised for the sake of brevity, as longer prompts can provide additional context and enhance the quality of the model's responses. When crafting prompts, it is essential to focus on writing instructions that are as explicit as possible, leaving no room for ambiguity. Following Principle 1 ensures that we harness the full potential of ChatGPT and obtain detailed and relevant outputs that align with our expectations.&lt;/p&gt;

</description>
      <category>chatgpt</category>
      <category>prompt</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>AI Industry Shakeup: Massive Announcements from Top Companies Signal a New Era of Innovation</title>
      <dc:creator>Shan</dc:creator>
      <pubDate>Sun, 14 May 2023 06:40:00 +0000</pubDate>
      <link>https://dev.to/shanshaji/ai-industry-shakeup-massive-announcements-from-top-companies-signal-a-new-era-of-innovation-pj7</link>
      <guid>https://dev.to/shanshaji/ai-industry-shakeup-massive-announcements-from-top-companies-signal-a-new-era-of-innovation-pj7</guid>
      <description>&lt;p&gt;This week has been a game-changer for the AI industry, with major announcements from a wide range of companies, including OpenAI, Warren Buffet, Microsoft, AMD, Palantir, Tesla, Meta, Humane, IBM, Wendy's, Google, HuggingFace, Scale AI, Synthesia, Anthropic, and Stability AI.&lt;/p&gt;

&lt;p&gt;These announcements are significant and have the potential to shape the future of AI. Each company's announcement has unique importance, and understanding them is crucial for anyone interested in the AI industry.&lt;/p&gt;

&lt;p&gt;Overall, this week's announcements indicate that AI is rapidly evolving and becoming more integrated into our lives. From advances in language processing and computer vision to increased investment in AI research, the industry is moving at a fast pace, and these announcements demonstrate the importance of keeping up with the latest developments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OPEN AI&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;OpenAI has recently made headlines again with the launch of their latest groundbreaking project. The company has released the research and code for their state-of-the-art text-to-3D model, called Shap-E. They have made the code open source and is available &lt;a href="https://github.com/openai/shap-e" rel="noopener noreferrer"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5fc7937rbptjosuza6kb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5fc7937rbptjosuza6kb.png" alt=" " width="800" height="879"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Google&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PaLM 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This week, Google has made waves in the AI community with the release of PaLM 2, the latest iteration of its advanced language learning model. Since its launch in August 2022, developers have been utilizing the PaLM API to create various generative AI applications, including chatbots and content generation. With PaLM 2, Google aims to push the boundaries of what its predecessor achieved, boasting a more lightweight and easily deployable model, as well as more advanced technical capabilities&lt;/p&gt;

&lt;p&gt;To know more about PaLM 2 checkout this &lt;a href="https://ai.google/discover/palm2" rel="noopener noreferrer"&gt;page&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bard&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Google's rush to compete with the success of ChatGPT led to the release of their own chatbot, Google Bard, before it was fully prepared to deliver substantial value to users. However, with an upgrade to PaLM 2, Bard's capabilities have significantly improved, including enhanced coding abilities and support for more languages. Furthermore, upcoming features such as visual responses, integration with Google Lens, and extensions with external partners, demonstrate Google's continued commitment to advancing the capabilities of its AI chatbot.&lt;/p&gt;

&lt;p&gt;To learn more and to try bard, check out this &lt;a href="https://bard.google.com/" rel="noopener noreferrer"&gt;page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Google Search's AI integration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Google unveiled its new Search Generative Experience (SGE) at Google I/O, which will provide users with AI-powered snapshots that offer concise and conversational answers to any search query. The SGE will also help users make shopping decisions by presenting them with a table that compares product features, prices, reviews, and more. This move is a smart strategy for Google to leverage its dominance in the search engine market to establish itself as a leader in the AI space.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Google's Push into AI: Generative AI Features Coming to Google Search and Workspace&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Google has brought generative AI to its productivity tools such as Gmail, Google Docs, and Slides in a major update to its Google Workspace. The update also includes new AI features in Gmail, Sheets, and Slides that help users with organisation and visualisation. Google Maps and Photos are also getting AI enhancements, such as a bird's eye view of a user's route and an AI-powered photo editing tool. With this AI update, Google has a chance to outperform Microsoft, which has yet to release its own AI revamp to Office 365 apps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Personalisation to Android Devices&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Google announced new personalisation features for Android, enabled by generative AI. Magic Compose in Google messages allows users to add different tones to their messages such as "professional", "funny", and "chill". Android 14 also brings new customisable aspects to the lock screen, while new wallpaper features such as the emoji wallpaper and the cinematic wallpaper will come to Pixel devices next month.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Google unveils Duet AI, a development interface powered by AI for cloud developers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Google has unveiled Duet AI, a development interface powered by AI that assists developers on the Google Cloud platform with code and chat assistance. With AI-driven code completion and generation, the code assistant can identify errors and suggest fixes in real-time. The chat assistant can provide responses to specific cloud questions using simple natural language prompts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Gemini&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;At Google I/O, DeepMind introduced Gemini, a new large language model that is currently in its early stages of development. It is expected to be utilized similarly to PaLM 2 and may potentially compete with OpenAI's GPT-4, which is their latest and most advanced language model&lt;/p&gt;

</description>
      <category>ai</category>
      <category>google</category>
      <category>chatgpt</category>
    </item>
    <item>
      <title>Unlocking the Power of JSON Web Tokens: Real-World Applications and Examples</title>
      <dc:creator>Shan</dc:creator>
      <pubDate>Thu, 20 Apr 2023 16:47:58 +0000</pubDate>
      <link>https://dev.to/shanshaji/unlocking-the-power-of-json-web-tokens-real-world-applications-and-examples-1m30</link>
      <guid>https://dev.to/shanshaji/unlocking-the-power-of-json-web-tokens-real-world-applications-and-examples-1m30</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;JSON Web Tokens (JWTs) are a popular method for securely transmitting information between parties. JWTs provide a standardized way to represent claims that can be encoded and signed, making them useful for authentication, authorization, and data exchange. In this article, we'll explore what JWTs are, how they work, and some real-world applications of JWTs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are JSON Web Tokens?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;JSON Web Tokens (JWTs) are a compact and self-contained method for transmitting information between parties. A JWT consists of three parts: a header, a payload, and a signature. The header and payload are Base64Url encoded JSON strings, and the signature is a cryptographic hash of the header, payload, and a secret key.&lt;/p&gt;

&lt;p&gt;The header contains metadata about the JWT, such as the algorithm used to sign the token. The payload contains claims, which are statements about an entity and additional data. Claims can be used to represent user information, permissions, or other metadata. The signature is used to verify that the JWT is valid and has not been tampered with.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do JSON Web Tokens work?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When a user authenticates with a server, the server can issue a JWT containing the user's information and a signature. The JWT can then be transmitted to the client, which can use it to authenticate future requests.&lt;/p&gt;

&lt;p&gt;To verify the JWT, the client can decode the header and payload and use the information to verify the signature. If the signature is valid, the JWT is considered authentic and can be used to authorize the user.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-world applications of JSON Web Tokens&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are many real-world applications of JWTs, including authentication, authorization, and data exchange. Let's explore some examples of how JWTs are used in practice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Single Sign-On (SSO)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Single Sign-On (SSO) is a method of authentication that allows users to access multiple applications with a single set of credentials. JWTs can be used to implement SSO by encoding the user's authentication information in a JWT and transmitting it to the client. The client can then use the JWT to authenticate with other applications without requiring the user to re-enter their credentials.&lt;/p&gt;

&lt;p&gt;For example, consider a user who wants to access two applications: a website and a mobile app. The user logs in to the website and is issued a JWT containing their authentication information. When the user launches the mobile app, the app can use the JWT to authenticate the user without requiring them to enter their credentials again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Authorization&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;JWTs can also be used for authorization, which is the process of determining whether a user has permission to access a particular resource or perform a particular action. In this scenario, the JWT contains claims that specify the user's permissions or roles.&lt;/p&gt;

&lt;p&gt;For example, consider an application that allows users to perform different actions based on their role. An admin user might be able to create and delete records, while a regular user can only view records. The application can use JWTs to encode the user's role in the JWT, and verify the JWT to determine the user's permissions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data exchange&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;JWTs can be used for secure data exchange between parties. In this scenario, the JWT contains claims that represent the data being transmitted. The JWT can be signed by the sender to ensure that the data has not been tampered with, and verified by the receiver to ensure that the data is authentic.&lt;/p&gt;

&lt;p&gt;For example, consider an e-commerce website that needs to transmit order information to a payment gateway. The website can encode the order information in a JWT and sign it using a secret key. The payment gateway can then verify the JWT to ensure that the order information has not been tampered with, and process the payment accordingly.&lt;/p&gt;

&lt;p&gt;An example of how to generate a JSON Web Token (JWT) in JavaScript using the jsonwebtoken library:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;jwt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;jsonwebtoken&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;payload&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
  &lt;span class="na"&gt;username&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;john_doe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;john_doe@example.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;isAdmin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;secret&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;my-secret-key&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;expiresIn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1h&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;algorithm&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;HS256&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;jwt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;secret&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the &lt;code&gt;jwt.sign&lt;/code&gt; function is used to generate a JWT. The payload object contains the claims that will be encoded in the JWT. Claims are statements about the user or entity that the token represents, such as user ID, role, or email address.&lt;/p&gt;

&lt;p&gt;The secret string is a shared secret between the client and server that is used to sign and verify the JWT. The options object contains additional options for the JWT, such as the expiration time (expiresIn) and the algorithm used to sign the token (algorithm).&lt;/p&gt;

&lt;p&gt;When the &lt;code&gt;jwt.sign&lt;/code&gt; function is called, it encodes the claims in the payload and generates a signature using the secret key and algorithm specified in the options. The resulting JWT can be sent to the client for use in subsequent requests.&lt;/p&gt;

&lt;p&gt;Now let's talk about claims. Claims are statements about an entity (typically, the user) that can be encoded and signed in a JWT. Claims can contain any information that the server wants to share with the client or vice versa, such as user ID, email address, role, or permissions.&lt;/p&gt;

&lt;p&gt;JWTs contain three types of claims: registered claims, public claims, and private claims.&lt;/p&gt;

&lt;p&gt;Registered claims are a set of predefined claims that are recommended but not required. Registered claims include &lt;code&gt;iss&lt;/code&gt; (issuer), &lt;code&gt;sub&lt;/code&gt; (subject), &lt;code&gt;aud&lt;/code&gt; (audience), &lt;code&gt;exp&lt;/code&gt; (expiration time), &lt;code&gt;nbf&lt;/code&gt; (not before), and &lt;code&gt;iat&lt;/code&gt; (issued at).&lt;/p&gt;

&lt;p&gt;Public claims are custom claims that are defined by the application and are meant to be shared with other parties. Public claims can contain any information that the server wants to share with the client or vice versa.&lt;/p&gt;

&lt;p&gt;Private claims are custom claims that are used by the application for its own purposes and are not meant to be shared with other parties. Private claims can contain any information that the server wants to store in the JWT for its own use.&lt;/p&gt;

&lt;p&gt;When encoding claims in a JWT, it's important to keep in mind that JWTs are not encrypted and can be decoded by anyone with access to the token. Therefore, sensitive information should not be included in the JWT.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
      <category>jsonwebtokens</category>
    </item>
    <item>
      <title>Boost Your Productivity: How to Create and Use Custom Snippets in VS Code</title>
      <dc:creator>Shan</dc:creator>
      <pubDate>Sat, 01 Apr 2023 04:25:36 +0000</pubDate>
      <link>https://dev.to/shanshaji/boost-your-productivity-how-to-create-and-use-custom-snippets-in-vs-code-5bbo</link>
      <guid>https://dev.to/shanshaji/boost-your-productivity-how-to-create-and-use-custom-snippets-in-vs-code-5bbo</guid>
      <description>&lt;p&gt;As a developer, you might find yourself frequently using the same code patterns or syntax. Repeatedly typing out the same code can be tedious and can slow down your workflow. This is where snippets come in handy.&lt;/p&gt;

&lt;p&gt;Visual Studio Code (VS Code) provides a built-in feature for defining and using snippets. Snippets are predefined templates of code that you can insert into your code file using a simple keyboard shortcut. In this article, we’ll explore how to create and use snippets in VS Code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Defining Snippets&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;VS Code provides an easy way to create and define your own snippets. You can define snippets either for a specific language or for all languages. To create or edit your own snippets, go to the Command Palette by pressing Ctrl+Shift+P (Windows, Linux) or Cmd+Shift+P (macOS), and then search for "Configure User Snippets". Selecting this option will bring up a dropdown menu that allows you to choose a language-specific snippets file or a global snippets file.&lt;/p&gt;

&lt;p&gt;Snippets files are written in JSON format, which supports C-style comments, and can define an unlimited number of snippets. Snippets support most TextMate syntax for dynamic behavior and can intelligently format whitespace based on the insertion context.&lt;/p&gt;

&lt;p&gt;Let’s look at an example of defining a snippet for a JavaScript for loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;// &lt;span class="k"&gt;in &lt;/span&gt;file &lt;span class="s1"&gt;'Code/User/snippets/javascript.json'&lt;/span&gt;
&lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"For Loop"&lt;/span&gt;: &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"prefix"&lt;/span&gt;: &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"for"&lt;/span&gt;, &lt;span class="s2"&gt;"for-const"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;,
    &lt;span class="s2"&gt;"body"&lt;/span&gt;: &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"for (const &lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;2&lt;/span&gt;:element&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; of &lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;1&lt;/span&gt;:array&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;) {"&lt;/span&gt;, &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="nv"&gt;$0&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;, &lt;span class="s2"&gt;"}"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;,
    &lt;span class="s2"&gt;"description"&lt;/span&gt;: &lt;span class="s2"&gt;"A for loop."&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, &lt;code&gt;For Loop&lt;/code&gt; is the name of the snippet. It will be displayed via IntelliSense if no description is provided. The &lt;code&gt;prefix&lt;/code&gt; property defines one or more trigger words that display the snippet in IntelliSense. Substring matching is performed on prefixes, so in this case, &lt;code&gt;fc&lt;/code&gt; could match &lt;code&gt;for-const&lt;/code&gt;. The &lt;code&gt;body&lt;/code&gt; property is one or more lines of content, which will be joined as multiple lines upon insertion. Newlines and embedded tabs will be formatted according to the context in which the snippet is inserted. Finally, the &lt;code&gt;description&lt;/code&gt; property is an optional description of the snippet displayed by IntelliSense.&lt;/p&gt;

&lt;p&gt;Additionally, the body of the example above has three placeholders (listed in order of traversal): ${1:array}, ${2:element}, and $0. You can quickly jump to the next placeholder with Tab, at which point you may edit the placeholder or jump to the next one. The string after the colon : (if any) is the default text, for example element in ${2:element}. Placeholder traversal order is ascending by number, starting from one; zero is an optional special case that always comes last and exits snippet mode with the cursor at the specified position.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using Snippets&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once you’ve defined your snippets, you can start using them in your code. To insert a snippet, simply type the prefix in your code file and press Tab. The snippet will then be inserted into your code with the cursor placed at the first placeholder. You can then use Tab to jump to the next placeholder or use Shift+Tab to jump to the previous one.&lt;/p&gt;

&lt;p&gt;For example, if we had the "For Loop" snippet defined as above, we could use it in our JavaScript file by typing for and then pressing Tab. The snippet would be inserted into the code, and we could then fill in the placeholders as needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;More Detailed Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you're interested in using the 'Freezed' package in Flutter, I've created a handy VS Code extension that provides code snippets to speed up your development process. You can find the extension on GitHub at &lt;a href="https://github.com/ArkrootHQ/freezed-snippets" rel="noopener noreferrer"&gt;https://github.com/ArkrootHQ/freezed-snippets&lt;/a&gt;, and it's completely free to use. If you have any suggestions or ideas for improving the extension, feel free to contribute to the project. Your contributions are always welcome and greatly appreciated!&lt;/p&gt;

&lt;p&gt;Here's a quick overview of the snippets currently included in the extension.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "Part statement": {
    "prefix": "pts",
    "body": ["part '${TM_FILENAME_BASE}.g.dart';"],
    "description": "Creates a filled-in part statement"
  },
  "Part 'Freezed' statement": {
    "prefix": "ptf",
    "body": ["part '${TM_FILENAME_BASE}.freezed.dart';"],
    "description": "Creates a filled-in freezed part statement"
  },
  "Freezed Data Class": {
    "prefix": ["fdataclass", "fdc"],
    "body": [
      "@freezed",
      "class ${1:DataClass} with _$${1:DataClass}{",
      "  const factory ${1:DataClass}(${2}) = _${1:DataClass};",
      "}",
      "factory ${1:DataClass}.fromJson(Map&amp;lt;String, dynamic&amp;gt; json)",
      "=&amp;gt; _$${1:DataClass}FromJson(json);"
    ],
    "description": "Freezed Data Class"
  },
  "Freezed Union": {
    "prefix": "funion",
    "body": [
      "@freezed",
      "class ${1:Union} with _$${1:Union}{",
      "  const factory ${1:Union}.${2}(${4}) = ${3};",
      "}"
    ],
    "description": "Freezed Union"
  },
  "Freezed Union Case": {
    "prefix": "funioncase",
    "body": ["const factory ${1:Union}.${2}(${4}) = ${3};"],
    "description": "Freezed Union Case"
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is an explanation of each snippet:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"Part statement": inserts a filled-in "part" statement for the current file.&lt;/li&gt;
&lt;li&gt;"Part 'Freezed' statement": inserts a filled-in "part" statement for the generated Freezed file.&lt;/li&gt;
&lt;li&gt;"Freezed Data Class": creates a new Freezed data class with a constructor and a "fromJson" factory method.&lt;/li&gt;
&lt;li&gt;"Freezed Union": creates a new Freezed union with a specified number of cases.&lt;/li&gt;
&lt;li&gt;"Freezed Union Case": inserts a new case into an existing Freezed union.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Snippets are a powerful feature in VS Code that can greatly increase your productivity as a developer. By defining your own snippets, you can save time&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Interfaces in typescript</title>
      <dc:creator>Shan</dc:creator>
      <pubDate>Fri, 31 Mar 2023 18:55:28 +0000</pubDate>
      <link>https://dev.to/shanshaji/interfaces-in-typescript-55f8</link>
      <guid>https://dev.to/shanshaji/interfaces-in-typescript-55f8</guid>
      <description>&lt;p&gt;In TypeScript, interfaces are used to define the shape of an object, including its properties and methods. They serve as a contract that specifies what properties and methods an object should have, without specifying how they should be implemented. In this article, we will explore the use of interfaces in TypeScript with examples.&lt;/p&gt;

&lt;p&gt;Defining an Interface&lt;/p&gt;

&lt;p&gt;To define an interface in TypeScript, we use the keyword interface, followed by the name of the interface and a pair of curly braces. Inside the curly braces, we specify the properties and methods that should be present in the object that implements this interface. Here is an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface Person {
    firstName: string;
    lastName: string;
    age: number;
    sayHello(): void;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we have defined an interface called Person that specifies that any object that implements this interface must have firstName, lastName, and age properties that are of type string, string, and number, respectively. Additionally, the object must have a sayHello() method that returns void.&lt;/p&gt;

&lt;p&gt;Implementing an Interface&lt;/p&gt;

&lt;p&gt;To implement an interface, we create a new object and specify the properties and methods that are required by the interface. Here is an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Employee implements Person {
    firstName: string;
    lastName: string;
    age: number;

    constructor(firstName: string, lastName: string, age: number) {
        this.firstName = firstName;
        this.lastName = lastName;
        this.age = age;
    }

    sayHello() {
        console.log("Hello, my name is " + this.firstName + " " + this.lastName);
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let employee = new Employee("John", "Doe", 30);
employee.sayHello(); // Output: "Hello, my name is John Doe"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we have created a Person interface, which specifies the properties and methods that should be present in an object that implements this interface. We have also created a class called Employee that implements the Person interface by defining all the required properties and methods.&lt;/p&gt;

&lt;p&gt;Using an Interface as a Type&lt;/p&gt;

&lt;p&gt;In addition to defining the shape of an object, interfaces can also be used as a type. This allows us to specify that a variable or function parameter should be of a certain type, based on an interface. Here is an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function printPerson(person: Person) {
    console.log("Name: " + person.firstName + " " + person.lastName);
    console.log("Age: " + person.age);
    person.sayHello();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let employee = new Employee("John", "Doe", 30);
printPerson(employee); // Output: "Name: John Doe", "Age: 30", "Hello, my name is John Doe"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we have defined a printPerson() function that takes an argument of type Person. We have also created an Employee object and passed it as an argument to the printPerson() function. Since the Employee class implements the Person interface, it is also considered to be of type Person, and the function can be called with an instance of Employee.&lt;/p&gt;

&lt;p&gt;Interfaces in TypeScript have several real-world applications, and they are used extensively in the development of software systems. Here are some examples of how interfaces are used in real-world applications.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;API Design&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When designing an API, interfaces are used to define the data structures that will be used to exchange data between the client and the server. This allows the client and server to agree on the format of the data, making it easier to communicate and reducing the likelihood of errors. For example, consider the following interface that defines the structure of a User object in a social media application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface User {
  id: number;
  name: string;
  email: string;
  dateOfBirth: Date;
  gender: 'Male' | 'Female' | 'Other';
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This interface can be used to define the structure of the JSON data that is sent and received by the API.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Object-oriented Programming&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In object-oriented programming, interfaces are used to define contracts that classes must adhere to. This allows classes to be interchangeable, making it easier to write modular and maintainable code. For example, consider the following interface that defines the contract for a Vehicle class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface Vehicle {
  startEngine(): void;
  stopEngine(): void;
  accelerate(speed: number): void;
  brake(): void;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This interface can be implemented by various classes such as Car, Motorcycle, and Truck, each of which would provide their own implementation of the methods.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Third-party Libraries&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Interfaces are also used by third-party libraries to define the structure of their API. This allows developers to use the library in a consistent and predictable manner, reducing the likelihood of errors. For example, the following interface defines the structure of the Moment.js library, which is used to manipulate dates and times in JavaScript:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface Moment {
  (input?: MomentInput, format?: MomentFormatSpecification, strict?: boolean): Moment;
  format(format: string): string;
  add(amount: MomentInput, unit: MomentUnit): Moment;
  subtract(amount: MomentInput, unit: MomentUnit): Moment;
  isBefore(other: Moment | string | number | Date | (number | string | Date)[]): boolean;
  isAfter(other: Moment | string | number | Date | (number | string | Date)[]): boolean;
  // ...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This interface allows developers to use the Moment.js library in a consistent and predictable manner, without having to understand the underlying implementation.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;/p&gt;

&lt;p&gt;Interfaces in TypeScript are a powerful tool for defining the shape of an object, and specifying the properties and methods that should be present in an object that implements this interface. They allow us to write more robust and maintainable code by enforcing a certain level of type safety. By implementing an interface, we can ensure that our classes conform to a certain shape, and by using an interface as a type, we can specify that a variable or function parameter should be of a certain type, based on an interface.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>web</category>
    </item>
    <item>
      <title>What are pre-commit hooks and How to use in flutter projects?</title>
      <dc:creator>Shan</dc:creator>
      <pubDate>Sat, 11 Mar 2023 07:42:02 +0000</pubDate>
      <link>https://dev.to/shanshaji/what-are-pre-commit-hooks-and-how-to-use-in-flutter-projects-4c0m</link>
      <guid>https://dev.to/shanshaji/what-are-pre-commit-hooks-and-how-to-use-in-flutter-projects-4c0m</guid>
      <description>&lt;p&gt;Version control systems (VCS) like Git are essential tools for software development, allowing developers to track changes to their code and collaborate with others. One important feature of Git is the ability to use pre-commit hooks, which are scripts or programs that are run automatically before a commit is made. Pre-commit hooks can be used to perform various checks and validations on the code changes being committed, ensuring that they meet certain standards or requirements.&lt;/p&gt;

&lt;p&gt;In this article, we'll discuss what pre-commit hooks are, why they're useful, and how to configure them in a Flutter project. We'll also discuss some examples of pre-commit hooks you can use in your projects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a Pre-Commit Hook?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A pre-commit hook is a script or program that is executed automatically before a commit is made to a VCS. A pre-commit hook aims to check the changes being committed to ensure they meet certain standards or requirements. For example, a pre-commit hook might be used to enforce code style guidelines, prevent certain files from being committed, or check for syntax errors and other issues.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why use Pre-Commit Hooks?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Pre-commit hooks offer several benefits to software development teams:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Consistency: Pre-commit hooks can enforce consistent coding standards and practices across the entire team, ensuring that all code adheres to the same guidelines.&lt;/li&gt;
&lt;li&gt;Error prevention: By running automated checks before commits are made, pre-commit hooks can catch errors and other issues early in the development process, preventing them from being introduced into the codebase.&lt;/li&gt;
&lt;li&gt;Time savings: Pre-commit hooks can automate time-consuming tasks such as linting and code formatting, freeing up developers to focus on more important tasks.&lt;/li&gt;
&lt;li&gt;Collaboration: Pre-commit hooks can help ensure that all team members are aware of code changes and are able to review them before they are committed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Configuring Pre-Commit Hooks in a Flutter Project:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Configuring a pre-commit hook in a Flutter project involves creating a script that will be executed before a commit is made, and then configuring Git to run that script automatically. Here are the steps to configure a pre-commit hook in a Flutter project:&lt;/p&gt;

&lt;p&gt;Step 1: Create a Pre-Commit Hook Script&lt;/p&gt;

&lt;p&gt;The first step is to create a pre-commit hook script that will be run automatically before each commit. This script can be written in any scripting language, but in this article, we'll be using Bash.&lt;/p&gt;

&lt;p&gt;Create a file named pre-commit (without any file extension since we are using bash) in the .git/hooks/ directory of your project. If the .git/hooks/ directory does not exist, create it.&lt;/p&gt;

&lt;p&gt;Here's an example pre-commit hook script that runs &lt;code&gt;flutter analyze&lt;/code&gt; and &lt;code&gt;dart analyze&lt;/code&gt; to check for errors in the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;

&lt;span class="c"&gt;# Run Flutter analyze and check for errors&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nv"&gt;output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;flutter analyze&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"COMMIT REJECTED: Flutter analyze found the following errors:"&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$output&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="c"&gt;# Run Dart analyze and check for errors&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nv"&gt;output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;dart analyze&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"COMMIT REJECTED: Dart analyze found the following errors:"&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$output&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="c"&gt;# If we made it this far, the commit is allowed&lt;/span&gt;
&lt;span class="nb"&gt;exit &lt;/span&gt;0

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This script runs &lt;code&gt;flutter analyze&lt;/code&gt; and &lt;code&gt;dart analyz&lt;/code&gt;e to check for errors in the code. If either command detects an error, the commit will be rejected.&lt;/p&gt;

&lt;p&gt;Step 2: Make the Script Executable&lt;/p&gt;

&lt;p&gt;Next, you'll need to make the script executable. To do this, open a terminal and navigate to your Flutter project directory. Then, run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chmod&lt;/span&gt; +x pre-commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command gives the &lt;code&gt;pre-commit&lt;/code&gt; script executable permissions.&lt;/p&gt;

&lt;p&gt;Step 3: Configure Git to Run the Script&lt;/p&gt;

&lt;p&gt;The final step is to configure Git to run the pre-commit hook script automatically before each commit. To do this, navigate to your Flutter project directory in a terminal and run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; .git/hooks
&lt;span class="nb"&gt;ln&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; ../../pre-commit pre-commit

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command creates a symbolic link to the pre-commit script in the .git/hooks directory, which Git will use to run the script automatically before each commit.&lt;/p&gt;

&lt;p&gt;If you have successfully configured a pre-commit hook in your Flutter project and if your codebase has analyzer problems, then you will get an error message indicating that the commit has been rejected.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3rs4beb336mhwsa6e722.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3rs4beb336mhwsa6e722.png" alt=" " width="800" height="78"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it! You've now configured a pre-commit hook in your Flutter project.&lt;/p&gt;

&lt;p&gt;Pre-commit hooks are a powerful tool for ensuring code quality and consistency in your Flutter projects. They can be used to enforce coding standards, catch errors and security vulnerabilities, and automate time-consuming tasks. By following the steps outlined in this article, you can easily configure pre-commit hooks in your own projects and improve your development workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus
&lt;/h2&gt;

&lt;p&gt;You can find an easy to use pre-commit hook &lt;a href="https://github.com/shan-shaji/flutter-pre-commit-hook-script" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>flutter</category>
      <category>productivity</category>
    </item>
    <item>
      <title>What is e2e Testing?</title>
      <dc:creator>Shan</dc:creator>
      <pubDate>Tue, 07 Mar 2023 20:46:41 +0000</pubDate>
      <link>https://dev.to/shanshaji/what-is-e2e-testing-1eg0</link>
      <guid>https://dev.to/shanshaji/what-is-e2e-testing-1eg0</guid>
      <description>&lt;p&gt;End-to-end (e2e) testing is a type of software testing that assesses the functionality of a system from start to finish. This type of testing is particularly useful for identifying any issues or problems that may arise when a user interacts with a software application, website or service.&lt;/p&gt;

&lt;p&gt;E2e testing can be an important part of the software development lifecycle, particularly for large and complex projects. In this article, we will explore what e2e testing is, why it is important, and some popular tools that can be used for e2e testing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is e2e testing?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;E2e testing, also known as functional testing, tests the functionality of an application from the user’s perspective. It is designed to simulate real-world scenarios and workflows that a user would typically encounter while using an application. The testing process includes checking for any bugs or errors that may occur during normal usage and ensuring that the system works as expected.&lt;/p&gt;

&lt;p&gt;The goal of e2e testing is to ensure that the software application functions correctly from start to finish, including any integrations with external systems or services. E2e testing aims to catch issues before they reach the end-user, reducing the likelihood of user complaints, negative reviews, and ultimately, loss of business.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples of e2e testing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To better understand e2e testing, let’s look at some examples of what e2e testing can involve:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Testing an eCommerce site&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine an eCommerce site where a customer needs to browse products, add them to their cart, enter their billing and shipping information, and finally make a payment. E2e testing in this scenario would involve simulating these actions and ensuring that the checkout process is smooth, with no issues or errors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Testing a login page&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A login page is a critical part of any web application. E2e testing for a login page would involve verifying that a user can successfully log in using their credentials and that the system handles incorrect login attempts appropriately.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Testing a mobile app&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;E2e testing for a mobile app would involve testing the app’s features and functionality on various devices and operating systems. The testing process would include scenarios such as logging in, navigating the app, and performing tasks such as making a purchase or booking a reservation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tools for e2e testing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are many tools available for e2e testing, and the choice of tool will depend on several factors, including the programming language used, the type of application being tested, and the team’s experience with testing tools.&lt;/p&gt;

&lt;p&gt;Here are some of the most popular e2e testing tools:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Selenium&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Selenium is an open-source tool used for testing web applications. It supports various programming languages, including Java, Python, C#, and Ruby. Selenium allows testers to create automated tests that simulate user interactions with a web application, such as clicking on links, filling out forms, and navigating between pages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cypress&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Cypress is a JavaScript-based testing tool used for testing web applications. It is designed to simplify the process of writing and debugging tests and offers real-time feedback during the testing process. Cypress also allows testers to write tests in an easy-to-understand syntax that closely resembles the syntax of the application being tested.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Appium&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Appium is an open-source tool used for testing mobile applications. It supports both Android and iOS platforms and allows testers to write tests in various programming languages, including Java, Python, and Ruby. Appium can also test hybrid and native apps and supports simulators and emulators.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;what are the tools used in flutter for e2e testing?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Flutter provides several tools for end-to-end (e2e) testing of mobile applications. These tools allow developers to test their Flutter applications across multiple platforms, including iOS and Android, to ensure that their apps work as expected. In this article, we will discuss some of the commonly used e2e testing tools in Flutter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flutter Driver&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Flutter Driver is a testing framework provided by Flutter to test the behavior and performance of Flutter applications. It provides a set of APIs for interacting with the application at the widget level, such as tapping buttons, scrolling, entering text, and more. With Flutter Driver, developers can write tests in Dart language, which is the same language used for developing Flutter applications. Flutter Driver also provides support for automated e2e testing using real devices, simulators, or emulators.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Appium&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Appium is an open-source testing framework that supports multiple platforms, including iOS, Android, and web. It uses the WebDriver protocol to automate the testing of mobile applications, allowing developers to write tests in a variety of programming languages, including Java, JavaScript, and Python. With Appium, developers can write automated tests that simulate user interactions with their Flutter application, such as tapping buttons, entering text, and scrolling. Appium supports real devices, simulators, and emulators, and it can run tests on multiple devices simultaneously.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
