Activity and Sequence Diagrams are the types of UML diagrams to model the system behaviour/processes.
Before you start drawing these diagrams,it is very essential to have the usecase diagram developed completely and understand what it does.This usecase helps us in identifying the actors involved and interactions that takes place when that particular usecase gets executed.It is recommended to have the written description of the usecase as well which helps us in understanding the usecase and its working even better.Once all this is clear,you can go ahead in developing any of these diagrams.
Although both are used to represent the dynamic aspects of the process,there are few differences as follows:
Acitivity Diagram:
It is used to depict the flow of control from one activity to another in a sequential order.It is in represented in terms of System perspective.It looks very similar to a normal flow chart but has additional capabilities like showing various types of flows such as parallel,branched,concurrent,single.
To build the activity diagram,you can use various symbols :
1)Start Node:Represent the initiation of a process.
2)Final Node:Represents the completion of a process.
3)Action State:Represent the activity.
4)Control Flow:Represent the direction flow of the process.
5)Fork & Join:Represents the concurrent activities of a process.The activity after the join does not start until all the flows that lead to it are complete.
6)Guard Condition:It is in the form of text representing under what condition the activity must takes place.
7)Decision Node:It has atleast 2 paths coming out of the decision node which tells you which direction to move forward based on the guard condition.
8)Branch & Merge:
Branching :Opted when you want one sequence to be divided into several alternatives.For eg.Mode of payment while placing an order in an E-commerce website:Debit Card,Internet Banking,Wallet.
Merging:Opted when several flows lead to the same activity.For eg.After the payment is done among one of the mode of payment,all leads to the successful completion of a payment and proceeds with placement of an order in an E-commerce application.
Below is the sample diagrammatic representation of the Activity Diagram:
Few things that you need to keep in mind while developing this diagram are as follows:
1)Restrict your description to the functionalities of the system while developing it so that outsiders wont misuse it.
2)Make sure conditions involves all kinds of possibities;otherwise involve ‘else’ if you are not sure.
3)In case of fork and join,make sure that there are equal number of flows that leave and end at fork and join respectively.
Sequence Diagram:
It is used to depict the flow of interactions between the objects & objects/classes and objects in a sequential manner.The messages exchanged between them are represented by arrows.It represents the ordered flow of events in a single usecase.This is very useful for technical people to write/understand/test the code as it captures the implementation details.
Like Activity Diagram,it also has a specialized set of symbols to build the sequence diagram.Some are as follows:
1)Lifeline:represents the lifetime of the class.
2)Message:represents the communication between the classes/objects.It also specifies direction of the flow i.e.the sender and receiver of the message.
3)Loops:To represent the iterative process.
Below is just the sample diagrammatic representation of Sequence Diagram:
Few things that you need to keep in mind which technical people often tend to do while developing this diagram are as follows:
1)Dont try to add too much details into diagram as this makes it looks clumsy and difficult to be understood by others.
2)Consider the origin of the message flow.
3)Dont waste your time on making diagrams on a usecase which has simple logic.Develop sequence diagrams for a usecase which involves complex logic.