Friday, August 6, 2010

Use Case Diagram

Describe what a system does from the standpoint of an external observer. The emphasis is on what a system does rather than how.
Displays the relationship among actors and use cases



EXAMPLE : A patient calls the clinic to make an appointment for a yearly check up. The receptionist finds the nearest empty time slot in the appointment book and schedules the appointment for that time slot.

Relationships in Use Cases
There are different kinds of relationships between use cases. Reuse of an existing use case using different types of relationships reduces the overall effort required in defining use cases in a system. A similar reuse established using relationships. Use case relationships can be one of the following:

  • Include: When a use case is depicted as using the functionality of another use case in a diagram, this relationship between the use cases is named as an include relationship.

  • Extend: In an extend relationship between two use cases, the child use case adds to the existing functionality and characteristics of the parent use case

  • Generalizations: A generalization relationship is also a parent-child relationship between use cases. The child use case in the generalization relationship has the underlying business process meaning, but is an enhancement of the parent use case.

Use case diagrams are helpful in three areas.
Determining features (requirements)- New use cases often generate new requirements as the system is analyzed and the design takes shape.

Communicating with clients- Their notational simplicity makes use case diagrams a good way for developers to communicate with clients.
Generating test cases- The collection of scenarios for a use case may suggest a suite of test cases for those scenarios.

Unified Modeling Language (UML)

Mostly graphical modelling language that is used to express designs. It is a standardized language in which to specify the artefacts and components of a software system. It is important to understand that the UML describes a notation and not a process.

Types of UML Diagrams

  • Use Case Diagram

  • Class Diagram

  • Object diagram

  • State diagram

  • Activity diagram

  • Sequence diagram

  • Collaboration diagram

  • Component diagram

  • Deployment diagram

Tuesday, August 3, 2010

Abstract Class vs. Interface in C#

abstract classes are not support multiple inheritance
interface is support multiple inheritance
not allows creating instances
not allows creating instances
Abstract class can contain abstract methods, abstract property as well as other members (just like normal class)
Interface can only contain abstract methods, properties but we don’t need to put abstract and public keyword.
All the methods and properties are by default Public.
An abstract class may contain complete or incomplete methods
Interfaces can contain only the signature of a method but no body
abstract class can contain fields, constructors, or destructors and implement properties
An interface cannot contain fields, constructors, or destructors and it has only the property's signature but no implementation
Various access modifiers such as abstract, protected, internal, public, virtual, etc can be used
By default they are public so no need to define

Related Posts
Abstract Class In C#
Sealed Class In C#
Interface In C#
Abstract Class vs. Interface in C#
NET framework Comparison
C# Interview Questions

Interface In C#

  • In C# we can define an Interface using Interface key word. Define
    //Difine an Interface
    interface MyInterface
    {
} 
  • Interfaces can be consisting of methods, properties, events, indexers or any combination of those types.
  • By default all the interface members are Public. So if we use any access modifiers it will prompt compile time error.
  • Add Interface methods have only declarations, not method implementations.
  • Class can be inherited by more than one Interface.
  • Interface can be inherited from other interface as well.
  • Interface not allows creating instances. 
    //Difine an Interface
    interface MyInterface
    {
        void MyMethods();
        void MyMethods2();
    }
    class clsMyClass : MyInterface
{
    //Can’t create Privet member
        public void MyMethods()
        {
            //Method Implementation
            Console.WriteLine("Implement Method MyMethods()");
        }

        public void MyMethods2()
        {
            //Method Implementation
            Console.WriteLine("Implement Method MyMethods2()");
        }

        public static void Main()
        {
            clsMyClass oclsMyClass = new clsMyClass();
            oclsMyClass.MyMethods();
            oclsMyClass.MyMethods2();
        }
    } 
  • When inherit from an Interface need to provide the implementation for all methods. Unless a compile error will be generated.
  • If the Class or struct is unable to provide the implementation for all methods, which are in the Interface have to be marked as Abstract.
//Difine an Interface
    interface MyInterface
    {
        void MyMethods();
        void MyMethods2();
    }
    class clsMyClass : MyInterface
    {
        public void MyMethods()
        {
            //Method Implementation
            Console.WriteLine("Implement Method MyMethods()");
        }

        //No Implementation
        abstract public void MyMethods2();


        public static void Main()
        {
            clsMyClass oclsMyClass = new clsMyClass();
            oclsMyClass.MyMethods();
            oclsMyClass.MyMethods2();
        }
    }



Related Posts
Abstract Class In C#
Sealed Class In C#
Interface In C#
Abstract Class vs. Interface in C#
NET framework Comparison
C# Interview Questions