Srividhya Umashanker

About Srividhya Umashanker

A Highly motivated engineer experienced is telecom/marketing and server management domain with a wide variety of technology experience.

Quick Summary : Object Associations

 
 
 
 
 
 
 
 
 
 
 
 
 

Composition

final class Company{
private final Employee Employee;
{
    Company(EmpDetails details) {
    engine = new Employee(details);
  }
   void assign() {
      emp.work();
   } 
}

Aggregation

final class Company{
  private Employee engine;
  void addEmployee(Employee emp) {
    this.emp = emp;
  }
  void assign() {
    if (emp != null)
      emp.work();
  }
}

Dependency

final class Company{
  void assign(Employee emp) {
    if (emp != null)
      emp.work();
  }
}

Abstraction

public interface Employee{
 public void work();
 public void off();
 public void quit();
}

Realisation

public abstract class Engineer implements Employee
{
 public void work();
 public void off();
 public void quit();
}

Generalization

public class SWEngineer extends Engineer
{
 public void work()
 {
  System.out.println('SW Engineer working');
 }
 public void off()
 {
  System.out.println('SW Engineer is off today');
 }

 public void quit()
 {
  System.out.println('SW Engineer is quitting');
 }

}

Relationships

Association Defines a relationship between classes. Compositon and Aggregation are types of associations
Composition the Employee is encapsulated within the Company . There is no way for the outside world to get a reference to the Employee. The Employee is created and destroyed with the company
Aggregation The Company also performs its functions through an Employee, but the Employee is not always an internal part of the Company . Employees can be exchanged, or even completely removed. As the employee is injected, the Employee reference can live outside the Company.
Dependency The company does not hold the employee reference. It receives an employee reference only to the scope an operation. Company is dependent on the Employee object to perform an operation
Abstraction Defines the basic operations the implementer should adher to. Employee interface lists the general behavior of an employee
Realization A class implements the behavior defined by the other other class or interface
Generalization A class which is a special form of a parent class

UML Relationship Pointers

Resources

 

Reference: Quick Summary : Object Associations from our JCG partner Srividhya Umashanker at the Thoughts of a Techie blog.

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

JPA Mini Book

Learn how to leverage the power of JPA in order to create robust and flexible Java applications. With this Mini Book, you will get introduced to JPA and smoothly transition to more advanced concepts.

JVM Troubleshooting Guide

The Java virtual machine is really the foundation of any Java EE platform. Learn how to master it with this advanced guide!

Given email address is already subscribed, thank you!
Oops. Something went wrong. Please try again later.
Please provide a valid email address.
Thank you, your sign-up request was successful! Please check your e-mail inbox.
Please complete the CAPTCHA.
Please fill in the required fields.

One Response to "Quick Summary : Object Associations"

Leave a Reply


− 5 = three



Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
Do you want to know how to develop your skillset and become a ...
Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

Get ready to Rock!
You can download the complementary eBooks using the links below:
Close