Skip to content

Commit 36958b3

Browse files
committed
feat: add images and enhance content in Blog 2 for better illustration and understanding
1 parent 6556bb4 commit 36958b3

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

content/3-BlogsTranslated/3.2-Blog2/_index.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@ Let us walk you through two use cases. In our example, we will use the Visual St
3636

3737
The **Bookstore.Domain** project contains domain objects such as **Book** and **ShoppingCart**.
3838

39+
![image-1](images/3-BlogsTranslated/3.2-/Figure1-QDevVSAgentic.jpg)
40+
3941
Figure 1: Domain objects in Bookstore.Domain
4042

4143
We have a separate project called Bookstore.Domain.Tests that contains tests for the Book class.
4244

45+
![image-2](images/3-BlogsTranslated/3.2-/Figure2-QDevVSAgentic.jpg)
46+
4347
Figure 2: Tests for Book class
4448

4549
We want to add unit tests for the **ShoppingCart** class. Let’s ask Amazon Q Developer to create unit tests for **ShoppingCart**. We also want Amazon Q Developer to follow the existing pattern of creating test classes in a separate test project.
@@ -48,14 +52,26 @@ By default, the agentic experience is on. If you are in the planning phase of th
4852

4953
Then, we ask Q Developer *“Can you create a test for @ShoppingCart.cs? Look at existing test and use the same libraries”*. First, notice that we are giving a command instead of just asking a question. Second, we are referencing the file ShoppingCart.cs explicitly to provide Q Developer the appropriate context. In the following image, you can see that Q Developer is acting on our behalf. In agentic coding mode, Q Developer can take actions and run commands. In our example, it is reading files, writing to files, and running commands with your permission.
5054

55+
![image-3](images/3-BlogsTranslated/3.2-/Figure3-QDevVSAgentic-537x1024.jpg)
56+
5157
Figure 3: Prompt to create new tests
5258

5359
Using commands, Q Developer was able to analyze our solution structure, understand that we have a project called **Bookstore.Domain.Tests**, and create a new file containing unit tests for **ShoppingCart**.
5460

61+
![image-4](images/3-BlogsTranslated/3.2-/Figure4-QDevVSAgentic.jpg)
62+
63+
Figure 4: Summary of test cases
64+
5565
We can verify that there is a new file called **ShoppingCartTests** in the **Bookstore.Domain.Tests** project, which is aligned with our existing test creation strategy.
5666

67+
![image-5](images/3-BlogsTranslated/3.2-/Figure5-QDevVSAgentic.jpg)
68+
69+
Figure 5: New file with generated test cases
70+
5771
In Visual Studio, we can now run the unit tests and verify that they pass.
5872

73+
![image-6](images/3-BlogsTranslated/3.2-/Figure6-QDevVSAgentic.jpg)
74+
5975
Figure 6: Successful test run of new tests
6076

6177
**Resolving build errors**
@@ -64,20 +80,28 @@ In the following example, we will demonstrate the power of the agentic coding ex
6480

6581
In our example, we have deliberately misspelled one of the methods in the **IShoppingCartRepository** interface. The **AddAsync** method is now incorrectly spelled **AddAsyn**.
6682

83+
![image-7](images/3-BlogsTranslated/3.2-/Figure7-QDevVSAgentic-1024x414.jpg)
84+
6785
Figure 7: Spelling mistake in a method name
6886

6987
When we try to build the **Bookstore.Domain** project, we get a build error as expected. Let’s ask Q Developer to fix the error. Without the agentic coding experience, we would have to copy the text of the build error into the chat window and ask Q Developer to provide recommendations. Then we would have to act on its recommendations by manually making changes and trying to build. This is one of many examples of the power of the agentic chat, which runs commands and uses the command’s output to enrich the context of the prompt to take actions.
7088

7189
With the agentic coding experience, we just ask Q Developer *“Can you fix the error I am getting while building the solution? Please build and check it”*. In the following image, you will see how Q Developer runs the .NET build commands to get build errors and read the relevant files.
7290

91+
![image-8](images/3-BlogsTranslated/3.2-/Figure8-QDevVSAgentic.jpg)
92+
7393
Figure 8: Building the solution
7494

7595
After it reads the files, it finds the spelling mistake and fixes it automatically. As shown in the following image, it then builds the solution to verify that its fix worked.
7696

97+
![image-9](images/3-BlogsTranslated/3.2-/Figure9-QDevVSAgentic.jpg)
98+
7799
Figure 9: Fixing the spelling mistake
78100

79101
In the following image, Amazon Q Developer provides a summary of the error, the actions it took to build it. It even helps me with some recommendations to fix the warnings it got while running the build.
80102

103+
![image-10](images/3-BlogsTranslated/3.2-/Figure10-QDevVSAgentic.jpg)
104+
81105
Figure 10: Summary of changes and suggestions
82106

83107
**Conclusion**

content/3-BlogsTranslated/3.2-Blog2/_index.vi.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ Hãy cùng đi qua hai use case. Trong ví dụ của chúng tôi, chúng tôi s
3737

3838
Project **Bookstore.Domain** chứa các domain objects như **Book****ShoppingCart**.
3939

40+
![image-1](images/3-BlogsTranslated/3.2-/Figure1-QDevVSAgentic.jpg)
41+
4042
Hình 1: Domain objects trong Bookstore.Domain
4143

4244
Chúng tôi có một project riêng tên là Bookstore.Domain.Tests chứa các tests cho lớp Book.
4345

46+
![image-2](images/3-BlogsTranslated/3.2-/Figure2-QDevVSAgentic.jpg)
47+
4448
Figure 2: Tests for Book class
4549

4650
Chúng ta muốn thêm unit tests cho lớp **ShoppingCart**. Hãy nhờ Amazon Q Developer tạo unit tests cho **ShoppingCart**. Chúng tôi cũng muốn Amazon Q Developer tuân theo pattern hiện có là tạo test classes trong một project test riêng biệt.
@@ -49,16 +53,26 @@ Theo mặc định, trải nghiệm agentic được bật. Nếu bạn đang tr
4953

5054
Sau đó, chúng tôi hỏi Q Developer: *“Can you create a test for @ShoppingCart.cs? Look at existing test and use the same libraries.”* Đầu tiên, hãy chú ý rằng chúng tôi đưa ra một command thay vì chỉ đặt câu hỏi. Thứ hai, chúng tôi tham chiếu rõ ràng file ShoppingCart.cs để cung cấp context phù hợp cho Q Developer. Trong hình tiếp theo, bạn có thể thấy rằng Q Developer đang hành động thay mặt chúng tôi. Trong chế độ agentic coding, Q Developer có thể thực hiện hành động và chạy commands. Trong ví dụ của chúng tôi, nó đang đọc file, ghi vào file, và chạy commands với sự cho phép của bạn.
5155

56+
![image-3](images/3-BlogsTranslated/3.2-/Figure3-QDevVSAgentic-537x1024.jpg)
57+
5258
Hình 3: Prompt để tạo các bài test mới
5359

5460
Bằng cách dùng commands, Q Developer có thể phân tích cấu trúc solution của chúng tôi, hiểu rằng chúng tôi có một project tên là **Bookstore.Domain.Tests**, và tạo một file mới chứa unit tests cho **ShoppingCart**.
5561

62+
![image-4](images/3-BlogsTranslated/3.2-/Figure4-QDevVSAgentic.jpg)
63+
64+
Figure 4: Tóm tắt về các test case
65+
5666
Ta có thể thấy rằng đã có một file mới tên là **ShoppingCartTests** trong project **Bookstore.Domain.Tests**, phù hợp với chiến lược tạo test hiện có.
5767

68+
![image-5](images/3-BlogsTranslated/3.2-/Figure5-QDevVSAgentic.jpg)
69+
5870
Hình 5: File mới với test cases được sinh ra
5971

6072
Trong Visual Studio, chúng tôi bây giờ có thể chạy các unit tests và xác nhận rằng chúng pass.
6173

74+
![image-6](images/3-BlogsTranslated/3.2-/Figure6-QDevVSAgentic.jpg)
75+
6276
Hình 6: Chạy các bài test mới thành công
6377

6478
**Xử lý build errors**
@@ -67,20 +81,28 @@ Trong ví dụ tiếp theo, chúng tôi sẽ minh họa sức mạnh của trả
6781

6882
Trong ví dụ, chúng tôi cố ý viết sai chính tả một method trong interface **IShoppingCartRepository**. Method **AddAsync** đã bị viết sai thành **AddAsyn**.
6983

84+
![image-7](images/3-BlogsTranslated/3.2-/Figure7-QDevVSAgentic-1024x414.jpg)
85+
7086
Hình 7: Lỗi chính tả trong tên method
7187

7288
Khi chúng tôi cố gắng build project **Bookstore.Domain**, chúng tôi nhận được build error như mong đợi. Hãy nhờ Q Developer sửa lỗi này. Nếu không có agentic coding experience, chúng tôi sẽ phải copy text của build error vào cửa sổ chat và yêu cầu Q Developer đưa ra khuyến nghị. Sau đó chúng tôi sẽ phải làm theo khuyến nghị bằng cách chỉnh sửa thủ công và thử build lại. Đây chỉ là một trong nhiều ví dụ về sức mạnh của agentic chat, cái có thể chạy commands và dùng output của commands để làm giàu context cho prompt nhằm thực hiện hành động.
7389

7490
Với agentic coding experience, chúng tôi chỉ cần hỏi Q Developer: *“Can you fix the error I am getting while building the solution? Please build and check it.”* Trong hình dưới đây, bạn sẽ thấy Q Developer chạy các lệnh build .NET để lấy build errors và đọc các file liên quan.
7591

92+
![image-8](images/3-BlogsTranslated/3.2-/Figure8-QDevVSAgentic.jpg)
93+
7694
Hình 8: Amazon Q Developer đang tạo ra giải pháp
7795

7896
Trong hình tiếp theo, Amazon Q Developer cung cấp một bản tóm tắt của lỗi, các hành động nó đã thực hiện để build, và thậm chí giúp tôi với một số khuyến nghị để sửa các warnings mà nó gặp trong khi chạy build.
7997

98+
![image-9](images/3-BlogsTranslated/3.2-/Figure9-QDevVSAgentic.jpg)
99+
80100
Hình 9: Sửa lỗi chính tả
81101

82102
In the following image, Amazon Q Developer provides a summary of the error, the actions it took to build it. It even helps me with some recommendations to fix the warnings it got while running the build.
83103

104+
![image-10](images/3-BlogsTranslated/3.2-/Figure10-QDevVSAgentic.jpg)
105+
84106
Hình 10: Tóm tắt các thay đổi và gợi ý
85107

86108
**Kết luận**

0 commit comments

Comments
 (0)