Skip to content
boicekev edited this page Apr 18, 2014 · 2 revisions

UML diagram

associationClass

Papyrus Nodes and Edges used

Class Association Class Edge

Sample Ruby output

The Association Class generation adds members variables to each of the classes representing the connections defined by the association. These variables are uninitialized since there should be only one instance of an association class between any two instances of the member classes. The structure is documented, but implementation left to the developer.

Note: You can make the attributes/members associated with the association class public, protected or private, just like regular attributes. This was done with the Person and Experience association in this example.

Person.rb

require_relative 'Competency.rb'
require_relative 'Experience.rb'

class Person

  public
  def initialize
  
  end

  attr_accessor :competency # Association class Competency linking Person and Skill
  
  protected
  
  private
  
  attr_accessor :experience # Association class Experience linking Person and Skill
  
end
Skill.rb

require_relative 'Competency.rb'
require_relative 'Experience.rb'

class Skill

  public
  def initialize
  
  end

  attr_accessor :competency # Association class Competency linking Person and Skill
  
  protected
  
  private
  
end
Competency.rb

class Competency

  public
  def initialize
    @competency_level = 0
  
  end

  attr_accessor :competency_level
  attr_accessor :person #Association Class attribute linking to Person  
  attr_accessor :skill #Association Class attribute linking to Skill
  
  protected
  
  private
  
end
Experience.rb

class Experience

  public
  def initialize
  
  end

  attr_accessor :skill #Association Class attribute linking to Skill
  
  def get_years
    # TODO
  end

  protected
  
  private
  
  attr_accessor :person #Association Class attribute linking to Person  
  
end

Quick links