Flowchart
Flowchart is a well known and intuitive paradigm to visually represent business processes. Business Analysts, Architects and Developers use often flowcharts as common language to express process definitions and flow of logic.
Sequenceis not a requirement to create workflows that use the sequential modeling style. As we will explain later in this post, any activity in WF 4 can be the root of a workflow. Therefore, we can create a workflow that does not contain a Sequence but still uses the sequential modeling style and procedural activities. In the figure below, we have a workflow that has as a ForEach as root activity that prints all the items in a list of strings with a length higher than 5.
Using Sequence and Flowchart together
WF3 had a notion of a root activity. Only root activities could be used as the top level activity in a WF 3 workflow. WF4 does not have a similar restriction. There is no notion of a root activity any more. Any activity can be the root of a workflow.
Let me explain this in more detail… Activities are a unit of work in WF. Activities can be composed together into larger Activities. When an Activity is used as a top-level entry point, we call it a "Workflow", just like Main is simply another function that represents a top level entry point to CLR programs. Hence, there is nothing special about using Sequence or Flowchart as the top level activity; and they can be composed at will.
The next figure shows a Flowchart inside a Sequence. The workflow below has three activities: a composite activity that does some work, a Flowchart (highlighted in green) and finally another composite activity that does some more work.
Decision Our decision making skills are put to good use to solve problems and make choices. Making a decision implies choosing one course of action that has the highest probability of success from several alternative choices. The most difficult task in decision making involves picking the desired alternative by keeping the level of uncertainty low. But, very few decisions are made with absolute certainty because complete knowledge about the alternatives is hardly available. Thus, decision making involves risk taking, but the degree of risk involved varies between alternatives.
When you are building a software solution to solve a particular problem, you need to be focused on solving the problem and solving it well. Here at Creately, we chose to use a third party solution to complete a product that we were working on. In the excitement of getting the product out, we signed up with a 3rd party service without brainstorming on the list of other available alternatives. Once we executed the decision, we realised our mistakes. Lesson learned the hard way indeed!
This is exactly when we decided to use flowcharts in our decision making process. As flowcharting is considered to be a proven method in documenting processes, we adopted this to brainstorm, evaluate and identify the best alternative possible.
Below is an example of a typical flowchart used in decision making. This would help us evaluate the consequences of each alternative.
Building Loops Using Iteration Statements
The next set of statements we’ll look at are the iteration statements, which are used to build loops in C#. Loops enable you to execute one or more statements multiple times. You can specify that your loop is to be executed a specific number of times, or you can iterate until a specified condition occurs. C# offers four iteration statements, each of which is well-suited for a specific kind of loop.
The for loop is used to execute a loop until a specified condition becomes true. the loop are located in one place, at the top of the loop.
Repeat loop. Note that the repeat loop has the process preceding the decision. This means that a repeat loop will always execute the process part at least once. This is an important point to remember because it may not be what you want to do. For instance assume you are a world power in control of an arsenal of nuclear weapons and have written a program to launch missiles in the event of an attack. Your program contains a loop which launches a missile each time you are struck by an enemy missile, for example:REPEAT LAUNCH MISSILE UNTIL ENEMY STOPS
While loop. The while loop is basically the reverse of the repeat loop, the decision comes first, followed by the process. The while loop is usually written so that it iterates while the condition is true, the repeat iterates until the condition becomes true. An interesting question is: When should a repeat loop be used rather than a while loop? and vice-versa. The while loop should be used when it is possible that the process or processes which are in the scope of the decision (that is, in the loop) may not need to execute. For example assume you have a designed an air-conditioner controller program and the program turns on the compressor while the ambient temperature is above the desired temperature. A while loop is a good choice here since the ambient temperature may be at the desired level before the compressor part of the program is executed. If a repeat loop was used then the compressor would be turned on but it wouldn't be necessary. That would be wickedly ignorant of green sensitivities. A repeat loop would be a good candidate for the kind of situation in which a program needs to check for an external event at least once. For example: assume you have now written a program for a video cassete recorder and it has a menu for doing things like tuning TV channels, setting the date and time, programming events and so on. When the menu is displayed it is a QUIT option along with all the others, the VCR doesn't know which option will be chosen so it stays in the menu mode, that is repeats it, until QUIT is selected.
รูปแบบการเขียนผังงาน
1. การทำงานแบบตามลำดับ(Sequence)
รูปแบบการเขียนโปรแกรมที่ง่ายที่สุดคือ เขียนให้ทำงานจากบนลงล่าง เขียนคำสั่งเป็นบรรทัด และทำทีละบรรทัดจากบรรทัดบนสุดลงไปจนถึงบรรทัดล่างสุด สมมติให้มีการทำงาน 3 กระบวนการคือ อ่านข้อมูล คำนวณ และพิมพ์
การตัดสินใจ หรือเลือกเงื่อนไขคือ เขียนโปรแกรมเพื่อนำค่าไปเลือกกระทำ โดยปกติจะมีเหตุการณ์ให้ทำ 2 กระบวนการ คือเงื่อนไขเป็นจริงจะกระทำกระบวนการหนึ่ง และเป็นเท็จจะกระทำอีกกระบวนการหนึ่ง แต่ถ้าซับซ้อนมากขึ้น จะต้องใช้เงื่อนไขหลายชั้น เช่นการตัดเกรดนักศึกษา เป็นต้น ตัวอย่างผังงานนี้ จะแสดงผลการเลือกอย่างง่าย เพื่อกระทำกระบวนการเพียงกระบวนการเดียว 2. การเลือกกระทำตามเงื่อนไข(Decision or Selection)
การทำกระบวนการหนึ่งหลายครั้ง โดยมีเงื่อนไขในการควบคุม หมายถึงการทำซ้ำเป็นหลักการที่ทำความเข้าใจได้ยากกว่า 2 รูปแบบแรก เพราะการเขียนโปรแกรมแต่ละภาษา จะไม่แสดงภาพอย่างชัดเจนเหมือนการเขียนผังงาน ผู้เขียนโปรแกรมต้องจินตนาการด้วยตนเอง 3. การทำซ้ำ(Iteration or Loop)




No comments:
Post a Comment