Implementing State DiagramsA state diagram can be implemented in three dịch - Implementing State DiagramsA state diagram can be implemented in three Việt làm thế nào để nói

Implementing State DiagramsA state

Implementing State Diagrams
A state diagram can be implemented in three main ways: nested switch, the State pattern, and state tables. The most direct approach to handling a state
Figure 10.5 Concurrent orthogonal states diagram is a nested switch statement, such as Figure 10.6. Although it’s direct, it’s long-winded, even for this simple case. It’s also very easy for this approach to get out of control, so I don’t like using it even for simple cases.
The State pattern [Gang of Four] creates a hierarchy of state classes to handle behavior of the states. Each state in the diagram has one state subclass. The controller has methods for each event, which simply forwards to the state class. The state diagram of Figure 10.1 would yield an implementation indicated by the classes of Figure 10.7.
The top of the hierarchy is an abstract class that implements all the event- handling methods to do nothing. For each concrete state, you simply override the specific event methods for which that state has transitions.
The state table approach captures the state diagram information as data. So Figure 10.1 might end up represented in a table like Table 10.1. We then build either an interpreter that uses the state table at runtime or a code generator that generates classes based on the state table.
Obviously, the state table is more work to do once, but then you can use it every time you have a state problem to hold. A runtime state table can also be
public void HandleEvent (PanelEvent anEvent) { switch (CurrentState) { case Panel State.Open : switch (anEvertt) { case Panel Event.SafeClosed : CurrentState = Panel State.Wait; break;
0/5000
Từ: -
Sang: -
Kết quả (Việt) 1: [Sao chép]
Sao chép!
Implementing State DiagramsA state diagram can be implemented in three main ways: nested switch, the State pattern, and state tables. The most direct approach to handling a stateFigure 10.5 Concurrent orthogonal states diagram is a nested switch statement, such as Figure 10.6. Although it’s direct, it’s long-winded, even for this simple case. It’s also very easy for this approach to get out of control, so I don’t like using it even for simple cases.The State pattern [Gang of Four] creates a hierarchy of state classes to handle behavior of the states. Each state in the diagram has one state subclass. The controller has methods for each event, which simply forwards to the state class. The state diagram of Figure 10.1 would yield an implementation indicated by the classes of Figure 10.7.The top of the hierarchy is an abstract class that implements all the event- handling methods to do nothing. For each concrete state, you simply override the specific event methods for which that state has transitions.The state table approach captures the state diagram information as data. So Figure 10.1 might end up represented in a table like Table 10.1. We then build either an interpreter that uses the state table at runtime or a code generator that generates classes based on the state table.Obviously, the state table is more work to do once, but then you can use it every time you have a state problem to hold. A runtime state table can also bekhu vực void HandleEvent (PanelEvent anEvent) {chuyển (CurrentState) {trường hợp bảng State.Open: chuyển đổi (anEvertt) {trường hợp bảng Event.SafeClosed: CurrentState = bảng State.Wait; break;
đang được dịch, vui lòng đợi..
Kết quả (Việt) 2:[Sao chép]
Sao chép!
Thực hiện sơ đồ nhà nước
Một sơ đồ nhà nước có thể được thực hiện theo ba cách chính: switch lồng nhau, các mô hình nhà nước, và bảng trạng thái. Phương pháp trực tiếp nhất để xử lý tình trạng một
hình 10.5 sơ đồ trạng thái trực giao đồng thời là một câu lệnh switch lồng nhau, chẳng hạn như hình 10.6. Mặc dù đó là trực tiếp, nó dài dòng, ngay cả đối với trường hợp đơn giản này. Nó cũng rất dễ dàng cho phương pháp này để có được ra khỏi kiểm soát, vì vậy tôi không muốn sử dụng nó ngay cả đối với các trường hợp đơn giản.
Các mô hình nhà nước [Gang of Four] tạo ra một hệ thống phân cấp của các lớp học nhà nước để xử lý các hành vi của các tiểu bang. Mỗi bang trong sơ đồ có một lớp con của nhà nước. Bộ điều khiển có các phương thức cho mỗi sự kiện, mà chỉ đơn giản chuyển tiếp đến các lớp học nhà nước. Sơ đồ trạng thái của Hình 10.1 sẽ mang lại một thực hiện chỉ định bởi các loại hình 10.7.
Các cấp trên cùng là một lớp trừu tượng mà thực hiện tất cả các phương pháp xử lý event- để làm gì cả. Đối với mỗi quốc gia cụ thể, bạn chỉ cần ghi đè các phương pháp sự kiện cụ thể mà nhà nước có chuyển tiếp.
Phương pháp bảng trạng thái nắm bắt được những thông tin sơ đồ trạng thái như dữ liệu. Vì vậy, hình 10.1 có thể kết thúc được đại diện trong một bảng như bảng 10.1. Sau đó chúng tôi xây dựng hoặc một thông dịch viên có sử dụng bảng nhà nước trong thời gian chạy hoặc một bộ tạo mã để tạo ra các lớp học dựa trên bảng trạng thái.
Rõ ràng, bảng nhà nước là nhiều việc phải làm một lần, nhưng sau đó bạn có thể sử dụng nó mỗi khi bạn có một nhà nước vấn đề để giữ. Một bảng trạng thái thời gian chạy cũng có thể là
public void handleEvent (PanelEvent anEvent) {switch (CurrentState) {case Chỉnh State.Open: switch (anEvertt) {case Chỉnh Event.SafeClosed: CurrentState = Chỉnh State.Wait; phá vỡ;
đang được dịch, vui lòng đợi..
 
Các ngôn ngữ khác
Hỗ trợ công cụ dịch thuật: Albania, Amharic, Anh, Armenia, Azerbaijan, Ba Lan, Ba Tư, Bantu, Basque, Belarus, Bengal, Bosnia, Bulgaria, Bồ Đào Nha, Catalan, Cebuano, Chichewa, Corsi, Creole (Haiti), Croatia, Do Thái, Estonia, Filipino, Frisia, Gael Scotland, Galicia, George, Gujarat, Hausa, Hawaii, Hindi, Hmong, Hungary, Hy Lạp, Hà Lan, Hà Lan (Nam Phi), Hàn, Iceland, Igbo, Ireland, Java, Kannada, Kazakh, Khmer, Kinyarwanda, Klingon, Kurd, Kyrgyz, Latinh, Latvia, Litva, Luxembourg, Lào, Macedonia, Malagasy, Malayalam, Malta, Maori, Marathi, Myanmar, Mã Lai, Mông Cổ, Na Uy, Nepal, Nga, Nhật, Odia (Oriya), Pashto, Pháp, Phát hiện ngôn ngữ, Phần Lan, Punjab, Quốc tế ngữ, Rumani, Samoa, Serbia, Sesotho, Shona, Sindhi, Sinhala, Slovak, Slovenia, Somali, Sunda, Swahili, Séc, Tajik, Tamil, Tatar, Telugu, Thái, Thổ Nhĩ Kỳ, Thụy Điển, Tiếng Indonesia, Tiếng Ý, Trung, Trung (Phồn thể), Turkmen, Tây Ban Nha, Ukraina, Urdu, Uyghur, Uzbek, Việt, Xứ Wales, Yiddish, Yoruba, Zulu, Đan Mạch, Đức, Ả Rập, dịch ngôn ngữ.

Copyright ©2025 I Love Translation. All reserved.

E-mail: