Monday, June 25, 2012

bubble sort vs quick sort


  • bubble sort vs quick sort

http://www.youtube.com/watch?v=vxENKlcs2Tw
bubble sort compares every adjacent element(something next to it) and moves the biggest element forward

(if you are supposed to list numbers in descending order)
the same operation is run on the remaining part of the elements


  • Bubble sort

Bubble sort  is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order.
The algorithm gets its name from the way smaller elements "bubble" to the top of the list. 
Because it only uses comparisons to operate on elements, it is a comparison sort. 
Although the algorithm is simple, most other algorithms are more efficient for sorting large lists
Bubble sort has worst-case and average complexity both ?(n2), where n is the number of items being sorted

There exist many sorting algorithms with substantially better worst-case or average complexity of O(n log n). 
Even other O(n2) sorting algorithms, such as insertion sort, tend to have better performance than bubble sort
Therefore, bubble sort is not a practical sorting algorithm when n is large.
Performance of bubble sort over an already-sorted list (best-case) is O(n).

 Large elements at the beginning of the list do not pose a problem, as they are quickly swapped. 
 Small elements towards the end, however, move to the beginning extremely slowly.
 This has led to these types of elements being named rabbits and turtles, respectively



 Pseudocode implementation

 procedure bubbleSort( A : list of sortable items )
   repeat     
     swapped = false
     for i = 1 to length(A) - 1 inclusive do:
       /* if this pair is out of order */
       if A[i-1] > A[i] then
         /* swap them and remember something changed */
         swap( A[i-1], A[i] )
         swapped = true
       end if
     end for
   until not swapped
end procedure

many modern algorithm textbooks avoid using the bubble sort algorithm in favor of insertion sort


http://en.wikipedia.org/wiki/Bubble_sort



  • Code snippets


Java

public void bubbleSort(int[] arr) {
      boolean swapped = true;
      int j = 0;
      int tmp;
      while (swapped) {
            swapped = false;
            j++;
            for (int i = 0; i < arr.length - j; i++) {                                       
                  if (arr[i] > arr[i + 1]) {                          
                        tmp = arr[i];
                        arr[i] = arr[i + 1];
                        arr[i + 1] = tmp;
                        swapped = true;
                  }
            }                
      }
}
C++

void bubbleSort(int arr[], int n) {
      bool swapped = true;
      int j = 0;
      int tmp;
      while (swapped) {
            swapped = false;
            j++;
            for (int i = 0; i < n - j; i++) {
                  if (arr[i] > arr[i + 1]) {
                        tmp = arr[i];
                        arr[i] = arr[i + 1];
                        arr[i + 1] = tmp;
                        swapped = true;
                  }
            }
      }
}


http://www.algolist.net/Algorithms/Sorting/Bubble_sort

Friday, June 22, 2012

Explain Belady's Anomaly?



Also called FIFO anomaly. Usually, on increasing the number of frames allocated to a process virtual memory, the process execution is faster, because fewer page faults occur. Sometimes, the reverse happens,

i.e., the execution time increases even when more frames are allocated to the process. This is Belady's Anomaly. This is true for certain page reference patterns.

http://www.indiabix.com/technical/operating-systems/

Monday, June 18, 2012

Reflection vs introspection

  • Reflection is a feature in the Java programming language. It allows an executing Java program to examine or "introspect" upon itself, and manipulate internal properties of the program. For example, it's possible for a Java class to obtain the names of all its members and display them.

The ability to examine and manipulate a Java class from within itself may not sound like very much, but in other programming languages this feature simply doesn't exist. For example, there is no way in a Pascal, C, or C++ program to obtain information about the functions defined within that program.

http://java.sun.com/developer/technicalArticles/ALT/Reflection/
http://yzgrafik.ege.edu.tr/~tekrei/dosyalar/projeler/JavaReflection.pdf
http://www.slideshare.net/upen.rockin/reflection-in-java



  • In computer science, reflection is the ability of a computer program to examine (see type introspection) and modify the structure and behavior (specifically the values, meta-data, properties and functions) of an object at runtime.[1]

Reflection is most commonly used in high-level virtual machine programming languages like Smalltalk and scripting languages and also in manifestly typed or statically typed programming languages such as Java, C, ML and Haskell.
http://en.wikipedia.org/wiki/Reflection_(computer_programming)




  • ReflectionApis

Reflection is a programming technique used to build code that is flexible by giving the programmer the power to modify and examine the behaviour of a program at runtime. Reflection gives the code access to internal structures of classes - constructors, fields and methods. It falls under the broad area of Metaprogramming - programs that write other programs.Reflection can be very powerful for late binding, creating new types duing run-time, examining types etc.

Reflective Languages

The concept of reflective programming was started late back in the 80's. Since then, there have been many languages that provide reflection capabilities. Reflection requires dynamic modification of the program. For this reason, compilers would have to have some metadata format to look back at it's own code. Java and C# do this through the Java virtual machine and the .NET VM respectively. On the other hand, since dynamic languages like Python and Ruby only try to interpret the code at run-time, more powerful forms of reflection can be achieved. Other languages like C, C++ lack reflection capabilities largely because of the metadata that they fail to maintain. The following are a few languages that support reflection:

   • Java
   • C#
   • Ruby
   • Smalltalk
   • Python
   • Eiffel
 
 
   Is reflection "Built-in"?
 
   Reflection naturally comes to interpreted languages. Ruby, Python, Smalltalk would not have to go out of their usual way to implement and exhibit reflective properties.
 
   Java and .NET look at the intermediate code to figure out the structure of a class and then try to add more at run-time.
   This, obviously takes a performance hit since the code cannot be compiled and optimized. Java and Microsoft .NET both have references to objects as well as built-in types. Wrappers for built-in types exist that provide reflection on primitive types.
 
   Languages like C, C++ lack reflective capabilities. They are based on the philosophy of "You don't pay for what you don't use". Maintaining information about types, methods and the like involve significant overhead. Moreover, performance can become a bottleneck, not to mention a few security concerns with reflection. C and C++ compilers optimize code to maximize performance and are not open to trade performance and overhead.
 
   If reflection is deemed necessary for such languages, there would have to be another library or a tool to take care of parsing the source code, building abstract syntax trees containing every detail of the program, build symbol tables, extract control and data flows by building a graphical representation and have custom analysers analyse this representation. The DMS Software Reengineering Toolkit is one such toolkit for C, C++ and COBOL.
 


 Java

The java virtual machine is capable of generating an instance of java.lang.Class for every object created. This Class consists of methods that can examine the properties of the object at runtime. In java, all the reference types are inherited from the Object class. The primitive types on the other hand have wrapper classes around them - for example int has the Integer class for it's wrapping. For example, to get the name of a class:



   Before using reflection, Java requires the user to import java.lang.reflect.*; This is the package that provides reflective capabilities. Java provides APIs for Retrieving class objects, Examining class modifiers and types and discovering class members. What Java lacks however is the finer granularity when compared to .NET. The Class objects that java uses tend to lose some information, for example, parameter names.

Java's reflection also includes useful methods that return classes themselves. The complete design of all the related classes can be captured using APIs such as:

    •getSuperClass()     : To return the classes' super class
    •getClasses() ;          : Return all members including inherited members
    •getEnclosingClass() : used in case of nested classes. Returns the immediate enclosing
 
 
http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2009/wiki2_5_ReflectionApis




  • In computing, type introspection is the ability for a program to examine the type or properties of an object at runtime. Some programming languages possess this capability.

Introspection should not be confused with reflection, which goes a step further and is the ability for a program to manipulate the values, meta-data, properties and/or functions of an object at runtime. Some programming languages also possess that capability.


The simplest example of type introspection in Java is the instanceof[1] operator. The instanceofoperator determines whether a particular object belongs to a particular class (or a subclass of that class, or a class that implements that interface). For instance:
if(obj instanceof Person){
   Person p = (Person)obj;
   p.walk();
}
The java.lang.Class[2] class is the basis of more advanced introspection.

For instance, if it is desirable to determine the actual class of an object (rather than whether it is a member of a particular class), Object.getClass() and Class.getName() can be used:
System.out.println(obj.getClass().getName());




http://en.wikipedia.org/wiki/Type_introspection



  • Java Reflection vs Java Introspection


"Reflection" refers to the low-level API with which you can ask "what are the methods of this class", "what parameters does this method accept", "what is the parent class of this class", and so on. "Introspection" is a higher-level concept; it generally refers to using the reflection API to learn about a class. For example, the javax.beans.Introspector class will give you the list of JavaBeans properties of a class -- i.e., the pairs of matching "Y getX()"/"void setX(Y)" methods.

Introspection is concept of querying any reference (Object) RUNTIME for its type/class /method details ..
Reflection is Java API which provides this ability .


http://www.coderanch.com/t/521121/java/java/Java-Reflection-vs-Java-Introspection




  • Reflection


    Reflection is commonly used by programs which require the ability to examine or modify the runtime behavior of applications running in the Java virtual machine. This is a relatively advanced feature and should be used only by developers who have a strong grasp of the fundamentals of the language. With that caveat in mind, reflection is a powerful technique and can enable applications to perform operations which would otherwise be impossible.

Introspection

    Introspection is the automatic process of analyzing a bean's design patterns to reveal the bean's properties, events, and methods. This process controls the publishing and discovery of bean operations and properties.

Introspection uses reflection, the relationship between Introspection and Reflection can be seen as similar to JavaBeans and other Java classes.

http://stackoverflow.com/questions/2044446/java-introspection-and-reflection


  • Reflection and Introspection


The Reflection API allows Java code to examine classes and objects at run time and to dynamically access another class's methods and instance fields.

o java.lang.reflect

? i.e., The Field Class

getfields(); getfield(); set(); etc.

? i.e., The Method Class

getMethods(); getMethod(); invoke(); etc.


Reflection versus Introspection
The terms reflection and introspection are commonly interchanged because they provide very similar functionality: both allow programmatic access to a class's underlying methods and properties. The difference is that introspection, which uses the java.beans.Introspector class, provides a more JavaBean-centric view of a class. It provides a standard mechanism to learn about the properties, events, and methods of a class.

Reflection, on the other hand, is supported directly by the java.lang.Class class, and provides lower-level access to the underlying methods. In other words, reflection focuses on methods and not on class properties.
http://www.informit.com/guides/content.aspx?g=java&seqNum=362





  • Introspection Uses Reflection


Reflection and introspection are very closely related. Reflection is a low-level facility that allows the code to examine the internals of any class or object at runtime. Introspection builds on this facility and provides a more convenient interface for examining Beans. In fact, the relationship between reflection and introspection is very similar to the relationship between JavaBeans and other Java classes. JavaBeans are simply normal Java objects with certain design patterns enforced in their nomenclature. Introspection assumes these design patterns on the object that it is inspecting and uses low-level reflection to examine the object's internals.

http://www2.sys-con.com/itsg/virtualcd/java/archives/0305/sagar2/index.html

What is the difference between abstraction and encapsulation?


Abstraction focuses on the outside view of an object (i.e. the interface)
Encapsulation (information hiding) prevents clients from seeing it’s inside view, where the behavior of the abstraction is implemented.
Abstraction solves the problem in the design side while Encapsulation is the Implementation


Object Oriented Programming: Abstraction Vs. Encapsulation
http://www.youtube.com/watch?v=57SIpmA3vcg

How is object completely encapsulated?


All the instance variables should be declared as private and public getter and setter methods should be provided for accessing the instance variables.

What is Dynamic binding?



  • Dynamic binding is a binding in which the class association is not made until the object is created at execution time.

It is also called as Late binding.


  • difference between early and late binding



Anything that is decided by compiler while compiling can be refer to EARLY/COMPILE TIME Binding and anything that is to be decided at RUNTIME is called LATE/RUNTIME binding.

For Example,

Method Overloading and Method Overriding.

1) In Method Overloading your method calls to the methods are decided by the compiler in the sense that which function is going to be called is decided by your compiler at compile time. Hence being EARLY BINDING.

2) In method Overriding, it is decided at RUNTIME which method is going to be called. So it is reffered as LATE BINDING.

Types
Late Binding: type is unknown until the variable is exercised during run-time; usually through assignment but there are other means to coerce a type; dynamically typed languages call this an underlying feature, but many statically typed languages have some method of achieving late binding

Implemented often using [special] dynamic types, introspection/reflection, flags and compiler options, or through virtual methods by borrowing and extending dynamic dispatch

Early Binding: type is known before the variable is exercised during run-time, usually through a static, declarative means

Implemented often using standard primitive types


Lazy Loading: object initialization strategy that defers value assignment until needed; allows an object to be in an essentially valid but knowingly incomplete state and waiting until the data is needed before loading it

Eager Loading: object initialization strategy that immediately performs all value assignments in order to have all the data needed to be complete before considering itself to be in a valid state.

https://programmers.stackexchange.com/questions/200115/what-is-early-and-late-binding

What is static binding?


Static binding is a binding in which the class association is made during compile time.
This is also called as Early binding

What is a destructor?


Destructor is an operation that frees the state of an object and/or destroys the object itself.
In Java, there is no concept of destructors.
Its taken care by the JVM

What is a constructor?

Constructor is an operation that creates an object and/or initialises its state.

What is a superclass?

superclass is a class from which another class inherits

What is a subclass?

Subclass is a class that inherits from one or more classes

What is a base class?

Base class is the most generalised class in a class structure.
Most applications have such root classes.
In Java, Object is the base class for all classes.

What is an Interface?

Interface is an outside view of a class or object which emphasizes its abstraction while hiding its structure and secrets of its behaviour.

Sunday, June 17, 2012

What is an Abstract Class?

Abstract class is a class that has no instances.
An abstract class is written with the expectation that its concrete subclasses will add to its structure and behaviour, typically by implementing its abstract operations

What is Polymorphism?

Polymorphism literally means taking more than one form.
Inheritance, Overloading and Overriding are used to achieve Polymorphism in java



The abiltiy to define more than one function with the same name is called Polymorphism.
In java,c++ there are two type of polymorphism: compile time polymorphism (overloading) and runtime polymorphism (overriding)

Polymorphism is briefly described as "one interface, many implementations."

When you override methods, JVM determines the proper methods to call at the program’s run time, not at the compile time.
Overriding occurs when a class method has the same name and signature as a method in parent class.


Overloading occurs when several methods have same names with

Overloading is determined at the compile time.
Different method signature and different number or type of parameters.
Same method signature but different number of parameters.
Same method signature and same number of parameters but of different type



class BookDetails{
String title;

setBook(String title){ }

}
class ScienceBook extends BookDetails{

setBook(String title){} //overriding

setBook(String title, String publisher,float price){ } //overloading

}




(Inheritance, Overloading and Overriding are used to achieve Polymorphism in java).
Polymorphism manifests itself in Java in the form of multiple methods having the same name.
In some cases, multiple methods have the same name, but different formal argument lists (overloaded methods).
In other cases, multiple methods have the same name, same return type, and same formal argument list (overridden methods).

Method overloading
Method overriding through inheritance
Method overriding through the Java interface

The overriding method cannot have a more restrictive access modifier than the method being overridden
(Ex: You can’t override a method marked public and make it protected).
You cannot override a method marked final
You cannot override a method marked static




Compile time polymorphism and the other is run time polymorphism.
Compile time polymorphism is method overloading.
Runtime time polymorphism is done using inheritance and interface.




  • static polymorphism vs dynamic polymorphism


method overloading would be an example of static polymorphism
whereas overriding would be an example of dynamic polymorphism.

Dynamic, or late, binding occurs when a method is defined for several classes in a family, but the actual code for the method is not attached, or bound, until execution time.This gives support for overriding...

Static binding occurs when a method is defined with the same name but with different headers and implementations. The actual code for the method is attached, or bound, at compile time. Static binding is used to support overloaded methods in Java.

http://www.coderanch.com/t/379004/java/java/static-polymorphism-dynamic-polymorphism


What is Inheritance?

Inheritance is a relationship among classes, wherein one class shares the structure or behaviour defined in another class


Inheritance is the property which allows a Child class to inherit some properties from its parent class.
In Java this is achieved by using extends keyword.
Only properties with access modifier public and protected can be accessed in child class.

The two most common reasons to use inheritance are:
To promote code reuse
To use polymorphism

What is Encapsulation?

Encapsulation is the process of compartmentalising the elements of an abtraction that defines the structure and behaviour


Encapsulation is a process of binding or wrapping the data and the codes that operates on the data into a single entity

Encapsulation is one of the four fundamental OOP concepts. The other three are inheritance, polymorphism, and abstraction.

Encapsulation is the technique of making the fields in a class private and providing access to the fields via public methods.
If a field is declared private, it cannot be accessed by anyone outside the class, thereby hiding the fields within the class.
For this reason, encapsulation is also referred to as data hiding.


The encapsulation is achieved by combining the methods and attribute into a class.
Encapsulation is a technique used for hiding the properties and behaviors of an object and allowing outside access only as appropriate.


What is abstraction?

Abstraction defines the essential characteristics of an object that distinguish it from all other kinds of objects


Abstraction is way of converting real world objects in terms of class.

Abstraction refers to the act of representing essential features without including the background details or explanations.

What are the core OOP’s concepts?

  • ChatGPT

2. Interface

Definition: An interface in Java is a reference type, similar to a class, that can contain only constants, method signatures, default methods, static methods, and nested types. Interfaces cannot contain instance fields. The methods in interfaces are abstract by default.

Purpose:

    Define Contracts: Interfaces define a contract that implementing classes must follow.
    Multiple Inheritance: Interfaces allow a class to implement multiple interfaces, overcoming the limitation of single inheritance in Java.

Example in Java:

// Interface
interface Drawable {
    void draw();
}

// Class implementing the interface
class Rectangle implements Drawable {
    @Override
    public void draw() {
        System.out.println("Drawing a rectangle");
    }
}

class Test {
    public static void main(String[] args) {
        Drawable myRectangle = new Rectangle();
        myRectangle.draw(); // Outputs: Drawing a rectangle
    }
}


In this example, Drawable is an interface with an abstract method draw(). The Rectangle class implements the Drawable interface and provides its own implementation of draw(). Interfaces define a contract that the Rectangle class adheres to.

1. Abstraction

Definition: Abstraction is the concept of hiding the complex implementation details and showing only the necessary features of an object. It focuses on what an object does rather than how it does it.

Purpose:

    Simplify Complex Systems: By focusing on essential characteristics, abstraction simplifies interaction with complex systems.
    Define Common Interface: Allows you to define a common interface for different implementations.

// Abstract class
abstract class Animal {
    // Abstract method (does not have a body)
    public abstract void makeSound();

    // Regular method
    public void sleep() {
        System.out.println("This animal sleeps");
    }
}

// Subclass providing specific implementation
class Dog extends Animal {
    @Override
    public void makeSound() {
        System.out.println("Bark");
    }
}

class Test {
    public static void main(String[] args) {
        Animal myDog = new Dog();
        myDog.makeSound(); // Outputs: Bark
        myDog.sleep();     // Outputs: This animal sleeps
    }
}


In this example, Animal is an abstract class with an abstract method makeSound(). The Dog class provides a specific implementation of makeSound(). Abstraction allows us to use the Animal class as a common interface without knowing the details of how makeSound() is implemented.

1. Encapsulation

Definition: Encapsulation is the concept of wrapping data (attributes) and methods (functions) that operate on the data into a single unit, usually a class. This means hiding the internal state of an object and requiring all interactions to be performed through an object’s methods.

Purpose:

    Protection: It protects an object’s internal state from unintended or harmful modifications.
    Controlled Access: By providing public methods (getters and setters), encapsulation allows controlled access to the internal data.
    Flexibility: Changes to the internal implementation of a class can be made with minimal impact on other parts of the code.
Example in Java:

public class Person {
    private String name; // private attribute

    // Constructor
    public Person(String name) {
        this.name = name;
    }

    // Public method to access private attribute
    public String getName() {
        return name;
    }

    // Public method to modify private attribute
    public void setName(String name) {
        this.name = name;
    }
}


2. Polymorphism

Definition: Polymorphism allows objects to be treated as instances of their parent class rather than their actual class. The most common use of polymorphism is method overriding, where a subclass provides a specific implementation of a method that is already defined in its superclass.

Purpose:

    Flexibility: Allows objects of different classes to be treated through a common interface.
    Method Overriding: Enables a subclass to provide a specific implementation of a method that is already defined in its superclass.

Example in Java:

class Animal {
    public void makeSound() {
        System.out.println("Some sound");
    }
}

class Dog extends Animal {
    @Override
    public void makeSound() {
        System.out.println("Bark");
    }
}

class Cat extends Animal {
    @Override
    public void makeSound() {
        System.out.println("Meow");
    }
}

public class Test {
    public static void main(String[] args) {
        Animal myDog = new Dog();
        Animal myCat = new Cat();

        myDog.makeSound(); // Outputs: Bark
        myCat.makeSound(); // Outputs: Meow
    }
}


3. Inheritance

Definition: Inheritance is a mechanism where one class (subclass or derived class) inherits attributes and methods from another class (superclass or base class). This promotes code reusability and establishes a natural hierarchy between classes.

Purpose:

    Reusability: Allows a subclass to reuse code from the superclass, reducing redundancy.
    Hierarchy: Establishes a natural hierarchical relationship between classes.
    Extensibility: Facilitates the creation of new classes based on existing ones, adding or modifying functionality as needed.

Example in Java:

class Animal {
    public void eat() {
        System.out.println("This animal eats food");
    }
}

class Dog extends Animal {
    public void bark() {
        System.out.println("Dog barks");
    }
}

public class Test {
    public static void main(String[] args) {
        Dog myDog = new Dog();
        myDog.eat(); // Inherited method
        myDog.bark(); // Subclass-specific method
    }
}

Summary:

    Encapsulation: Bundles data and methods, restricting direct access to some of the object's components.
    Polymorphism: Allows objects to be treated as instances of their parent class, enabling method overriding and flexibility.
    Inheritance: Enables a new class to inherit attributes and methods from an existing class, fostering code reuse and hierarchy


  • 1. Encapsulation

  • Definition: Encapsulation is the concept of wrapping data (attributes) and methods (functions) that operate on the data into a single unit, usually a class. This means hiding the internal state of an object and requiring all interactions to be performed through an object’s methods.

  • Purpose:

  •     Protection: It protects an object’s internal state from unintended or harmful modifications.
  •     Controlled Access: By providing public methods (getters and setters), encapsulation allows controlled access to the internal data.
  •     Flexibility: Changes to the internal implementation of a class can be made with minimal impact on other parts of the code.
  • Example in Java:

  • public class Person {
  •     private String name; // private attribute

  •     // Constructor
  •     public Person(String name) {
  •         this.name = name;
  •     }

  •     // Public method to access private attribute
  •     public String getName() {
  •         return name;
  •     }

  •     // Public method to modify private attribute
  •     public void setName(String name) {
  •         this.name = name;
  •     }
  • }


  • 2. Polymorphism

  • Definition: Polymorphism allows objects to be treated as instances of their parent class rather than their actual class. The most common use of polymorphism is method overriding, where a subclass provides a specific implementation of a method that is already defined in its superclass.

  • Purpose:

  •     Flexibility: Allows objects of different classes to be treated through a common interface.
  •     Method Overriding: Enables a subclass to provide a specific implementation of a method that is already defined in its superclass.

  • Example in Java:

  • class Animal {
  •     public void makeSound() {
  •         System.out.println("Some sound");
  •     }
  • }

  • class Dog extends Animal {
  •     @Override
  •     public void makeSound() {
  •         System.out.println("Bark");
  •     }
  • }

  • class Cat extends Animal {
  •     @Override
  •     public void makeSound() {
  •         System.out.println("Meow");
  •     }
  • }

  • public class Test {
  •     public static void main(String[] args) {
  •         Animal myDog = new Dog();
  •         Animal myCat = new Cat();

  •         myDog.makeSound(); // Outputs: Bark
  •         myCat.makeSound(); // Outputs: Meow
  •     }
  • }


  • 3. Inheritance

  • Definition: Inheritance is a mechanism where one class (subclass or derived class) inherits attributes and methods from another class (superclass or base class). This promotes code reusability and establishes a natural hierarchy between classes.

  • Purpose:

  •     Reusability: Allows a subclass to reuse code from the superclass, reducing redundancy.
  •     Hierarchy: Establishes a natural hierarchical relationship between classes.
  •     Extensibility: Facilitates the creation of new classes based on existing ones, adding or modifying functionality as needed.

  • Example in Java:

  • class Animal {
  •     public void eat() {
  •         System.out.println("This animal eats food");
  •     }
  • }

  • class Dog extends Animal {
  •     public void bark() {
  •         System.out.println("Dog barks");
  •     }
  • }

  • public class Test {
  •     public static void main(String[] args) {
  •         Dog myDog = new Dog();
  •         myDog.eat(); // Inherited method
  •         myDog.bark(); // Subclass-specific method
  •     }
  • }

  • Summary:

  •     Encapsulation: Bundles data and methods, restricting direct access to some of the object's components.
  •     Polymorphism: Allows objects to be treated as instances of their parent class, enabling method overriding and flexibility.
  •     Inheritance: Enables a new class to inherit attributes and methods from an existing class, fostering code reuse and hierarchy
  1. Abstraction
  2. Encapsulation
  3. Inheritance
  4. Polymorphism



Polymorphism, Inheritance and Encapsulation

Inheritance is the process by which one object acquires the properties of another object. Inheritance allows well-tested procedures to be reused and enables changes to

make once and have effect in all relevant places

Explain the Polymorphism principle. Explain the different forms of Polymorphism.
Polymorphism in simple terms means one name many forms.
Polymorphism exists in three distinct forms in Java:
• Method overloading
• Method overriding through inheritance
• Method overriding through the Java interface

method overloading is the primary way polymorphism is implemented in Java

overloaded methods:
appear in the same class or a subclass
have the same name but,
have different parameter lists, and,
can have different return types

an example of an overloaded method is print() in the java.io.PrintStream class
public void print(boolean b)
public void print(char c)
public void print(char[] s)
public void print(float f)
public void print(double d)
public void print(int i)
public void print(long l)
public void print(Object obj)
public void print(String s)



Overriding methods
appear in subclasses
have the same name as a superclass method
have the same parameter list as a superclass method
have the same return type as as a superclass method
the access modifier for the overriding method may not be more restrictive than the access modifier of the superclass method



Explain Encapsulation, Polymorphism and Inheritance.
http://www.youtube.com/watch?v=QzX7REqciPY




  • Inheritance - comes under Relationship -> Generalization/Specilization -> enables code resuability. But also enables maintanence nightmare of managing classes.

Polymorphism - comes unders Behaviour->Compile time/Runtime -> enables the varying behaviour of the operations depending upon the type of the object(runtime entity).

http://www.linkedin.com/groups/what-is-difference-between-dynamic-70526.S.217712129?view=&srchtype=discussedNews&gid=70526&item=217712129&type=member&trk=eml-anet_dig-b_pd-ttl-cn&ut=23CVDF6gnvwlE1

  • Class versus object
A class is a template for objects. A class defines object properties including a valid range of values, and a default value. A class also describes object behavior. An object is a member or an "instance" of a class. An object has a state in which all of its properties have values that you either explicitly define or that are defined by default settings.
https://www.ncl.ucar.edu/Document/HLUs/User_Guide/classes/classoview.shtml#:~:text=A%20class%20defines%20object%20properties,are%20defined%20by%20default%20settings.

  • Let's see some real life example of class and object in java to understand the difference well:

Class: Human Object: Man, Woman

Class: Fruit Object: Apple, Banana, Mango, Guava wtc.

Class: Mobile phone Object: iPhone, Samsung, Moto

Class: Food Object: Pizza, Burger, Samosa

https://www.javatpoint.com/difference-between-object-and-class

What is an Object?

Object is an instance of a class

What is a Class?


Class is a template for a set of objects that share a common structure and a common behaviour.

Decorator (Wrapper) Pattern


  • Introducing the Decorator Design Pattern

http://www.youtube.com/watch?v=Xk8durvtiys&feature=channel&list=UL
wrapper classes
using wrapper classes to avoid changing code continuously


  • Overview of the Decorator Design Pattern

http://www.youtube.com/watch?v=MI_qyfeRk8c&feature=autoplay&list=ULXk8durvtiys&playnext=1


  • Coding the Decorator Design Pattern

http://www.youtube.com/watch?v=HkOdDMePE4Q&feature=autoplay&list=ULMI_qyfeRk8c&playnext=2


  • Executing the Decorator Design Pattern

http://www.youtube.com/watch?v=Ra-33SFHq6M&feature=autoplay&list=ULHkOdDMePE4Q&playnext=3



  • JAVA: Decorator Design Pattern

http://www.youtube.com/watch?v=9FQVs85fZd8&list=UUUvwlMMaeppKPdtAK8PxO8Q&index=2&feature=plcp
also known as wrapper pattern
extends class functionality by delegation
alternative to extending class functionality by inheritance(subclassing)


  • Decorator Pattern

http://www.youtube.com/watch?v=T9kqwyhQP24&feature=related
Structural Design Pattern
attach additional responsibility dynamically
alternative to subclassing  through composite and delegation
object level pattern



  • Java Design Pattern Decorator with Eclipse

http://www.youtube.com/watch?v=k_uTRC7DO68&feature=related




  • Decorator sablonu belirli nesnelerin davranislarini yeni türetilmis siniflar olusturmadan degistirmemizi saglar. 


Siniflarin varsayilan kodlarini degistirmeden  ek
davranislar kazanmasini saglamak için kullanilir.

Bu sekilde her zaman degisen ihtiyaçlarimiza cevap
verebilecek olan siniflari tasarlayabiliriz.


Örnegin; bir GUI bilesenine kenarliklar(border) eklemek
istiyoruz yada kaydirma çubugu (scrollbars) eklemek
istiyoruz.
Bu nesneden iki yeni nesne türeterek bu islemi
yapabiliriz. Bu sekilde yaparsak her nesne için kenarlik
çizdirmek için kenarlik çizimide yapabilen yeni nesneler
türetmemiz gereklidir. Hepsinde yapilan islem kenarlik
çizmedir, buna ragmen tüm kenarliga ihtiyaci olan
bilesenler için yeni siniflar türetmemiz gerekir.
Bu gibi durumlarda Decorator kullanilir


http://members.comu.edu.tr/msahin/courses/ust_duzey_files/patterns/decorator.pdf




  • Decorating Servlet Request Objects

how to apply the Decorator pattern to servlet request objects
how to use the pattern in servlets and lists popular servlet-related projects that use it
http://www.oracle.com/technetwork/articles/entarch/decorators-099517.html






what's the difference between abstract and concrete class?


Concrete class - Provides implementation for all its methods & also for methods from extended abstract classes or implemented interfaces
Abstract class - Does not provide implementation for one or more of its methods
Interface - Does not provide implementation for any of its methods

Read more: http://wiki.answers.com/Q/Difference_between_concrete_class_and_abstract_class_and_interface#ixzz1y2HulwzD


The default class is a concrete class. The class keyword is used to define classes (e.g. in Java).
And usually they are simply referred to as classes (without the adjective concrete). (adjective concrete).
Abstract classes usually have partial or no implementation. On the other hand, concrete classes always have full implementation of its behavior.
Unlike concrete classes, abstract classes cannot be instantiated.
Therefore abstract classes have to be extended in order to make them useful.
Abstract classes may contain abstract methods, but concrete classes can’t.
When an abstract class is extended, all methods (both abstract and concrete) are inherited.
The inherited class can implement any or all the methods.
If all the abstract methods are not implemented, then that class also becomes an abstract class.

Read more: http://www.differencebetween.com/difference-between-abstract-class-and-vs-concrete-class/#ixzz1y2IGPCHk

Java Programming Tutorial - 58 - Abstract and Concrete Classes
http://www.youtube.com/watch?v=TyPNvt6Zg8c


Strategy (Policy) Pattern



  1. Strategy Class can be an interface or an abstract class
  2. There are a set of classes which extend abstract class or implement interface
  3. Switching between these classes changes the behaviour of application
  4. Using a class which extends or implements strategy class with conditional logic,conditional logic represents the behaviour of  application
  5. This pattern helps add or remove specific behaviour to application without having recode or retest all part of application
  6. algorithms can be changed at runtime or design time


JAVA: Strategy Design Pattern
http://www.youtube.com/watch?v=x3saJPT4SaE&list=PL028D1E25AAF87B8E&index=2&feature=plpp_video


Introducing the Strategy Design Pattern
http://www.youtube.com/watch?v=9n3gF39-trE

Overview of the Strategy Design Pattern
http://www.youtube.com/watch?v=F1841_llRSw&feature=channel&list=UL

Coding the Strategy Design Pattern
http://www.youtube.com/watch?v=vYByr2u8gqk&feature=autoplay&list=ULF1841_llRSw&playnext=1


Executing the Strategy Design Pattern
http://www.youtube.com/watch?v=mmiWFcjMTLw&feature=autoplay&list=ULvYByr2u8gqk&playnext=2
verbs are objects now


The strategy pattern is a behavioral design pattern that allows you to decide which course of action a program should take, based on a specific context during runtime. You encapsulate two different algorithms inside two classes, and decide at runtime which strategy you want to go with.
http://net.tutsplus.com/articles/general/a-beginners-guide-to-design-patterns/

Iterator Pattern

Intent

Iterator Pattern provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation


We use iterators quite frequently in everyday life. For example, remote control of TV. We just pick up the TV remote control and start pressing Up and Down or Forward and Back keys to iterate through the channels.


Motivation
Need to traverse different data structures so that algorithms can be defined that are capable of interfacing with each transparently.



Reference:
http://kapilnevatia.blogspot.com/2011/12/iterator-pattern.html





Saturday, June 16, 2012

dependency vs association


Dependency is normally created when you receive a reference to a class as part of a particular operation / method.
Dependency indicates that you may invoke one of the APIs of the received class reference and any modification to that class may break your class as well.
Dependency is represented by a dashed arrow starting from the dependent class to its dependency.
Multiplicity normally doesn’t make sense on a Dependency.

http://nirajrules.wordpress.com/2011/07/15/association-vs-dependency-vs-aggregation-vs-composition/

One class depends on another if the latter is a parameter variable or local variable of a method of the former.
This is different from an association, where an attribute of the former is an instance of the latter.

http://en.wikipedia.org/wiki/Class_diagram#Analysis_stereotypes

Dependency


Dependency is a weaker form of relationship which indicates that one class depends on another because it uses it at some point of time

One class depends on another if the latter is a parameter variable or local variable of a method of the former.

This is different from an association, where an attribute of the former is an instance of the latter.

http://en.wikipedia.org/wiki/Class_diagram#Analysis_stereotypes



  • Dependency relationships


a dependency is displayed in the diagram editor as a dashed line with an open arrow that points from the client model element to the supplier model element.

a dependency relationship is a relationship in which changes to one model element (the supplier) impact another model element (the client). You can use dependency relationships in class diagrams, component diagrams, deployment diagrams, and use case diagrams.


Example
In an e-commerce application, a Cart class depends on a Product class because the Cart class uses the Product class as a parameter for an add operation. In a class diagram, a dependency relationship points from the Cart class to the Product class. The Cart class is, therefore, the client model element, and the Product class is the supplier model element. This relationship indicates that a change to the Product class might require a change to the Cart class

http://publib.boulder.ibm.com/infocenter/rsdvhelp/v6r0m1/index.jsp?topic=%2Fcom.ibm.xtools.modeler.doc%2Ftopics%2Fcdepend.html

bi-directional association

For instance, a flight class is associated with a plane class bi-directionally

Realization


In java when one class implements and interface it is called realization, the class realizes the interface.

In UML modeling, a realization relationship is a relationship between two model elements, in which one model element (the client) realizes (implements or executes) the behavior that the other model element (the supplier) specifies

a realization is displayed in the diagram editor as a dashed line with an unfilled arrowhead that points from the client (realizes the behavior) to the supplier (specifies the behavior).
http://publib.boulder.ibm.com/infocenter/rsmhelp/v7r0m0/index.jsp?topic=/com.ibm.xtools.modeler.doc/topics/creal.html

Generalization


The generalization relationship is also known as the inheritance or "is a" relationship.
When one class inherits or extends another class, it is called Generalization.

composition vs aggregation


  • composition vs aggregation

Composition is more restrictive.
When there is a composition between two objects, the composed object cannot exist without the other object.

This restriction is not there in aggregation.

A Library contains students and books.
Relationship between library and student is aggregation.
Relationship between library and book is composition.
A student can exist without a library and therefore it is aggregation
A book cannot exist without a library and therefore its a composition.

http://javapapers.com/oops/association-aggregation-composition-abstraction-generalization-realization-dependency/


  • composition vs aggregation
composition is stronger than aggregation relation
in composition a part only belongs to a whole
if you destroy a building you destroy a room as well

in aggregation relation this is different because if you destroy a band musician can continue to exist




  • What is the difference between aggregation and composition?


Aggregation 
Aggregation is an association in which one class
belongs to a collection. This is a part of a whole
relationship where a part can exist without a whole.
For example a line item is a whole and product is a
part. If a line item is deleted then corresponding
product need not be deleted. So aggregation has a
weaker relationship.

Composition
Composition is an association in which one class belongs to a
collection. This is a part of a whole relationship where a part
cannot exist without a whole. If a whole is deleted then all parts are
deleted. For example An order is a whole and line items are parts.
If an order is deleted then all corresponding line items for that
order should be deleted. So composition has a stronger
relationship.


Composition


Composition is a stronger variant of the "owns a" or association relationship
composition is more specific than aggregation.
It is represented with a solid diamond shape.
Composition has a strong life cycle dependency between instances of the container class and instances of the contained class(es)
If the container is destroyed, normally every instance that it contains is destroyed as well

Aggregation


Aggregation is a variant of the "has a" or association relationship;
aggregation is more specific than association.
It is an association that represents a part-whole relationship which means that one object contains another object.
Aggregation can occur when a class is a collection or container of other classes,
but where the contained classes do not have a strong life cycle dependency on the container--essentially

Stereotypes


stereotypes are used to show how this element of a class is specialized

4.03_Stereotypes
http://www.youtube.com/watch?v=g7O6R8loCss&feature=relmfu


Visibility


  • Visibility
To specify the visibility of a class member (i.e., any attribute or method)

All the Visibility of a Class Members Are:
+         Public 
-         Private 
#         Protected 
~         Package
/         Derived
underline Static


4.02_Attributes & Operations
http://www.youtube.com/watch?v=Brjle3R_iXA&feature=relmfu


reflexive (recursive) association



a class can be associated with itself

Association


When two objects are associated, one object will be having a variable that points to the other object


 Association is a relationship type between classes
"has a " relationship
manager has an employee or an employee has a manager
manager manages an employee or an employee works for a manager


There are four different types of association

  1.  bi-directional
  2.  uni-directional
  3.  Aggregation (includes Composition aggregation) 
  4.  Reflexive( Recursive)



4.04_Associations & Multiplicity
http://www.youtube.com/watch?v=eDO-okP-kaU&feature=relmfu
http://en.wikipedia.org/wiki/Class_diagram#Analysis_stereotypes


object oriented software system


  • object oriented software system
usecase view(requirements of system)
design view
process view
implementation view
deployment view





UML


  • UML,unified modelling language
visualizing,constructing and documenting all parts of system

UML Views of the World


  • UML Views of the World


  1. Use Case Model
  2. Static Models
  3. Interaction Models



  • Use Case Model


  1. use case diagram
  2. use cases



  • Use Case Diagram

initial system model
provides a graphical representation of services the system will provide
inception phase

actor:person,system etc
use case:a function of value for the actor
communication:link between actor and use case


  • Use Cases

represent function as experienced by the actor
eloboration phase



  • Static Models: show the structure of the system

  1. Class
  2. Object
  3. Package
  4. Component
  5. Deployment



  • Class Diagram

shows relationship between classes
elaboration phase


  • Object Diagram

used to give an example of how a system will look like under specific circumstances


  • Package Diagram

depicts the dependencies between the packages that make up a model.


  • Component Diagram

depicts how components are wired together to form larger components and or software systems.


  • Deployment Diagram

models the physical deployment of artifacts on nodes.




  • Interaction Models :shows the interaction of the system


  1. Sequence
  2. Communication
  3. Activity
  4. State Machine



  • Sequence Diagram

kind of interaction diagram that shows how processes operate with one another and in what order
represents sequence of events
show messages passing between objects


  • Communication(Collaboration) diagram

relationships between classes


  • Activity Diagram

flowchart with object notation
represents task activity


  • State Machine Diagram

shows how activities change the state of an object




Reference:
http://en.wikipedia.org/wiki/Deployment_diagram

RUP


  • RUP presents Software Architecture 4+1 views
logical view
implementation view
use-case view
process view
deployment view



  • RUP ,rational unified process (software development process)
inception
elaboration
construction
transition



Reference:
http://www.jkang.com/0602-574/ooad/sld001.htm

uml interview questions-1



  • Define UML?

Unified Modeling Language, a standard language for designing and documenting a system in an object-oriented manner
It has nine diagrams which can be used in design document to express design of software architecture.


  • Can you explain use case diagrams?

Use case diagram answers what system does from the user point of view.
Use case answer ‘What will the system do?


Scenario: A scenario is a sequence of events which happen when a user interacts with the system.
Actor: Actor is the who of the system, in other words the end user.
Use Case: Use case is task or the goal performed by the end user


  • Can you explain class diagrams?

Class is basically a prototype which helps us create objects.


  • Multiplicity?

Multiplicity can be termed as classes having multiple associations or one class can be linked to instances of many other classes.

  • Can you explain object diagrams in UML?

Classes come to live only when objects are created from them. Object diagram gives a pictorial representation of class diagram at any point of time.


  • Can you explain sequence diagrams?

Sequence diagram shows interaction between objects over a specific period time

http://www.codeproject.com/Articles/28445/UML-Interview-Questions-Part-1#Canyouexplainusecasediagrams







  • What are the different views that are considered when building an object-oriented software system?

Normally there are 5 views.

Use Case view - This view exposes the requirements of a system.
Design View - Capturing the vocabulary.
Process View - modeling the distribution of the systems processes and threads.
Implementation view - addressing the physical implementation of the system.
Deployment view - focus on the modeling the components required for deploying the system




  • What are the different views that are commonly used when developing Software in Java?

A) 1) Use Case View - Describes the system from the User's point of view, Describes the various functionalities expected from the system to be developed and how user is going to interact with those features.
2) Class Diagram - Shows graphically the relationships between classes and packages.
3) Sequence Diagram - Shows the sequence of method calls and interactions between classes.
4) Component Diagram - Shows the components within the system and the interaction between components.

http://www.javajotter.net/uml/interview_questions/umlinterviewquestions.php


  • What are diagrams? 

Diagrams are graphical representation of a set of elements


  • How are the diagrams divided? 

The nine diagrams are divided into static diagrams and dynamic diagrams.

Static Diagrams (Also called Structural Diagram):
Class diagram, Object diagram, Component Diagram, Deployment diagram.

Dynamic Diagrams (Also called Behavioral Diagrams):
Use Case Diagram, Sequence Diagram, Collaboration Diagram, Activity diagram, Statechart diagram.



  • What are the major three types of modeling used? 

Major three types of modeling are structural, behavioral, and architectural.



  • the different kinds of modeling diagrams used?


Use case diagram
Class Diagram
Object Diagram
Sequence Diagram
statechart Diagram
Collaboration Diagram
Activity Diagram
Component diagram
Deployment Diagram




  • What is SDLC? 

SDLC is Software Development Life Cycle.
SDLC of a system included processes that are Use case driven, Architecture centric and Iterative and Incremental.
This Life cycle is divided into phases.
Phase is a time span between two milestones.
The milestones are Inception, Elaboration, Construction, and Transition.
Process Workflows that evolve through these phase are Business Modeling, Requirement gathering, Analysis and Design, Implementation, Testing, Deployment.
Supporting Workflows are Configuration and change management, Project management


  • What are Relationships? 


There are different kinds of relationships:
Dependencies
Generalization
Association


Dependencies are relations ships between two entities that that a change in specification of one thing may affect another thing
Most commonly it is used to show that one class uses another class as an argument in the signature of the operation

Generalization is relationships specified in the class subclass scenario, it is shown when one entity inherits from other.

Associations are structural relationships that are: a room has walls, Person works for a company
Aggregation is a type of association where there is a has a relation ship,
That is a room has walls, if there are two classes room and walls then the relation ship is called a association and further defined as an aggregation.



http://www.techinterviews.com/uml-interview-questions-and-answers



  • What is Association?


Association is a relationship between two classes.
In this relationship the object of one instance perform an action on behalf of the other class.
The typical behaviour can be invoking the method of other class and using the member of the other class.

public class MyMainClass{

public void init(){

new OtherClass.init();
}

}




  • What is Aggregation?

Aggregation has a relationship between two classes.
In this relationship the object of one class is a member of the other class.
Aggregation always insists for a direction.

public class MyMainClass{

OtherClass otherClassObj = new OtherClass();




http://www.java-questions.com/oops_interview_questions.html
http://www.tutorialspoint.com/java/java_encapsulation.htm
http://www.interview-questions-java.com/
http://www.janeg.ca/scjp/overload/poly.html


8 Core Beliefs of Extraordinary Bosses


8 Core Beliefs of Extraordinary Bosses

1. Business is an ecosystem, not a battlefield.

2. A company is a community, not a machine.

3. Management is service, not control.
They push decision making downward, allowing teams form their own rules and intervening only in emergencies.

4. My employees are my peers, not my children
Average bosses see employees as inferior, immature beings who simply can't be trusted if not overseen by a patriarchal management.
Employees take their cues from this attitude, expend energy on looking busy and covering their behinds.

5. Motivation comes from vision, not from fear.
Average bosses see fear--of getting fired, of ridicule, of loss of privilege--as a crucial way to motivate people.
As a result, employees and managers alike become paralyzed and unable to make risky decisions.

6. Change equals growth, not pain.

7. Technology offers empowerment, not automation
trengthen management control and increase predictability

8. Work should be fun, not mere toil

http://www.inc.com/geoffrey-james/8-core-beliefs-of-extraordinary-bosses.html

5 Toxic Beliefs That Ruin Careers



5 Toxic Beliefs That Ruin Careers

1. My self-worth is based on what others think of me.

2. My past equals my future.
When some people experience a series of setbacks, they assume that their goals are not achievable.
Over time, they become dispirited and discouraged, and avoid situations where failure is a risk.
Because any significant effort entails risk, such people are then unable to make significant achievements

3. My destiny is controlled by the supernatural.
Some people believe that their status in life–or even their potential as a human being–is determined by luck, fate, or divine intervention.
This all-too-common (and ultimately silly) belief robs such people of initiative, making them passive as they wait for their "luck" to change.

4. My emotions accurately reflect objective reality.

5. My goal is to be perfect or do something perfectly.
Because perfection is unattainable, the people who seek it are simply setting themselves up for disappointment.
Perfectionists blame the world (and everything in it) rather than doing what's necessary to accomplish extraordinary results.
That's why "successful perfectionist" is an oxymoron


http://www.inc.com/geoffrey-james/5-toxic-beliefs-that-ruin-careers.html?utm_source=twitterfeed&utm_medium=twitter&utm_campaign=Feed%3A+inc%2Fheadlines+%28Inc.com+Headlines%29


Bouncing Back from Job Loss: The 7 Habits of Highly Effective Job Hunters

Bouncing Back from Job Loss: The 7 Habits of Highly Effective Job Hunters

if you look at job loss, like any setback from an enlarged perspective, you realize that success in life is measured far less by our opportunities than by how we respond to life’s setbacks and challenges.

The challenge people in that situation face is how they handle not only the loss of their job, but the many emotions that can arise. These range from a sense of humiliation, failure and vulnerability, to anxiety, resentment and self-pity. Sure, losing your job can be a blow to your back pocket, but it’s often an even bigger blow to your ego and self worth.

When it comes to a successful job hunt, attitude is everything.  A proactive and positive mindset will differentiate you from the masses, making all the difference in how “lucky” you get in an unlucky economy

1. Stay future-focused

2. Don’t let your job status define you.
Who you are is not what you do. Never was. Never will be.
People who interpret losing their job as a sign of personal inadequacy or failure are less likely to ‘get back on the horse’ in their job hunt than those who interpret it as an unfortunate circumstance that provided a valuable opportunity to grow in self-awareness, re-evaluate priorities and build resilience.

3. Prioritize self-care.
mental and emotional resilience requires physical resilience
(After all, you now have no excuse that you don’t have time for exercise.)
Studies have found that exercise builds resilience, leaving you more immune to stress.
just do something that lifts your spirits

4. Surround yourself with positive people
Emotions are contagious.
The people around you impact how you see yourself, your situation and what you do to improve it
Surround yourself with people who lift you up, and avoid those who don’t.
Let them know that while you may not have chosen your circumstances, you are confident that with time and effort, you will all pull through together, and be all the stronger and wiser for it.

5. Tap your network

6. Treat finding a job as a job.
Sure you have more time on your hands than you had before, but you will be amazed at how little you can do in a day if you aren’t intentional about what you want to get done
Then prioritize, structure your day and treat finding a job as a job.


7. Extend kindness.
extending kindness toward others makes us feel good.
scientists have found that acts of kindness produce some of the same “feel good” chemicals in the brain as anti-depressants
In addition, when we give our time to help others, it helps us stop dwelling on our own problems, and makes us realize how much we have to be thankful for.

http://www.forbes.com/sites/womensmedia/2012/06/12/bouncing-back-from-job-loss-the-7-habits-of-highly-effective-job-hunters/


class diagram


In software engineering, a class diagram in the Unified Modeling Language (UML) is a type of static structure diagram that describes the structure of a system by showing the system's classes, their attributes, operations (or methods), and the relationships among the classes.

A relationship is a general term covering the specific types of logical connections found on class and object diagrams. 

UML shows the following relationships:
  • Instance level relationships
  • Class level relationships
  • General relationship


1) Instance Level Relationships
a. Association
b. Aggregation
c. Composition

2) Class Level Relationships
a. Generalization
b. Realization

3) General Relationships
a. Dependency
b. Multiplicity

Thursday, June 14, 2012

New dimensions in UML2.0


  • New dimensions in UML2.0


The major difference is the enhancement and additional features added to the diagrams in UML2.0

Sequence diagram is a time dependent view of the interaction between objects to accomplish a behavioral goal of the system. The time sequence is similar to the earlier version of sequence diagram.

Communication diagram is a new name added in UML2.0. A Communication diagram is a structural view of the messaging between objects, taken from the Collaboration diagram concept of UML 1.4 and earlier versions. This can be defined as a modified version of collaboration diagram.

Interaction Overview diagram is also a new addition in UML2.0. An Interaction Overview diagram describes a high-level view of a group of interactions combined into a logic sequence, including flow-control logic to navigate between the interactions.

Timing diagram is also added in UML2.0. It is an optional diagram designed to specify the time constraints on messages sent and received in the course of an interaction.

if we analyze the new diagrams then it is clear that all the diagrams are created based upon the interaction diagrams described in the earlier versions

http://www.tutorialspoint.com/uml/uml_2_overview.htm





  • some of the new notations added to the class diagram from UML 1.x.


Instances
When modeling a system's structure it is sometimes useful to show example instances of the classes.
To model this, UML 2 provides the instance specification element, which shows interesting information using example (or real) instances in the system.

However, merely showing some instances without their relationship is not very useful; therefore, UML 2 allows for the modeling of the relationships/associations at the instance level as well

http://www.ibm.com/developerworks/rational/library/content/RationalEdge/sep04/bell/#N1031B