Don't Settle for Poor Names
-
Upload
alistair-mckinnell -
Category
Technology
-
view
159 -
download
2
Transcript of Don't Settle for Poor Names
![Page 1: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/1.jpg)
Don’t Settle for Poor Names
Alistair McKinnell@ amckinnell
![Page 2: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/2.jpg)
Namingis deeply
connected to
Designing
![Page 3: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/3.jpg)
Designingis deeply
connected to
Naming
![Page 4: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/4.jpg)
Example fromQCloud
![Page 5: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/5.jpg)
QCloud has forms, sheets, and inspections
![Page 6: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/6.jpg)
QCloud has forms, sheets, and inspections
![Page 7: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/7.jpg)
![Page 8: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/8.jpg)
![Page 9: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/9.jpg)
![Page 10: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/10.jpg)
![Page 11: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/11.jpg)
![Page 12: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/12.jpg)
![Page 13: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/13.jpg)
A sheet is composed of a reviewed and a submitted
{ something or other }
![Page 14: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/14.jpg)
![Page 15: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/15.jpg)
class Sheet < ActiveRecord::Base
composed_of :submitted_attribution_event, class_name: ’AttributionEvent', allow_nil: true, mapping: [ ['submitted_by_name', 'name'], ['submitted_by_email', 'email'], ['submitted_by_id', 'user_id'], ['submitted_at', 'event_at'] ]
composed_of :reviewed_attribution_event, class_name: 'AttributionEvent', allow_nil: true, mapping: [ ['reviewed_by_name', 'name'], ['reviewed_by_email', 'email'], ['reviewed_by_id', 'user_id'], ['reviewed_at', 'event_at'] ]
![Page 16: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/16.jpg)
# # Represents the information required to attribute # an event to a user. # class AttributionEvent attr_reader :name, :email, :user_id, :event_at
def initialize(name, email, user_id, at) @name = name @email = email @user_id = user_id @event_at = at end end
composed_of :submitted_attribution_event, class_name: ’AttributionEvent', allow_nil: true, mapping: [ ['submitted_by_name', 'name'], ['submitted_by_email', 'email'], ['submitted_by_id', 'user_id'], ['submitted_at', 'event_at'] ]
![Page 17: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/17.jpg)
A sheet is composed of a reviewed and a submitted
attribution event
![Page 18: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/18.jpg)
An attribution event identifies a user and
has a timestamp
![Page 19: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/19.jpg)
An attribution event identifies a user and
has a timestamp
![Page 20: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/20.jpg)
An attribution event identifies a user and
has a timestamp
![Page 21: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/21.jpg)
# # Represents the information required to attribute # an event to a user. # class AttributionEvent attr_reader :name, :email, :user_id, :event_at
def initialize(name, email, user_id, at) @name = name @email = email @user_id = user_id @event_at = at end end
An attribution event identifies a user and
has a timestamp
![Page 22: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/22.jpg)
sheet.submitted_attribution_event = AttributionEvent.new( inspector.name, inspector.email, inspector.id, Time.zone.now )
sheet.submitted_by_name = inspector.name sheet.submitted_by_email = inspector.email sheet.submitted_by_id = inspector.id sheet.submitted_at = Time.zone.now
Before
After
![Page 23: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/23.jpg)
sheet.submitted_attribution_event = AttributionEvent.new( inspector.name, inspector.email, inspector.id, Time.zone.now )
sheet.submitted_by_name = inspector.name sheet.submitted_by_email = inspector.email sheet.submitted_by_id = inspector.id sheet.submitted_at = Time.zone.now
Before
After
![Page 24: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/24.jpg)
# # Represents the information required to attribute # an event to a user. # class AttributionEvent attr_reader :name, :email, :user_id, :event_at
def initialize(name, email, user_id, at) @name = name @email = email @user_id = user_id @event_at = at end end
An attribution event identifies a user and
has a timestamp
![Page 25: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/25.jpg)
# # Represents the information required to attribute # an event to a user. # class AttributionEvent attr_reader :name, :email, :user_id, :event_at
def self.build(user, at: Time.zone.now) new(user.name, user.email, user.id, at) end
def initialize(name, email, user_id, at) @name = name @email = email @user_id = user_id @event_at = at end end An attribution event
identifies a user andhas a timestamp
![Page 26: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/26.jpg)
sheet.submitted_attribution_event = AttributionEvent.build(inspector)
sheet.submitted_by_name = inspector.name sheet.submitted_by_email = inspector.email sheet.submitted_by_id = inspector.id sheet.submitted_at = Time.zone.now
Before
After
![Page 27: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/27.jpg)
sheet.submitted_attribution_event = AttributionEvent.build(inspector)
sheet.submitted_by_name = inspector.name sheet.submitted_by_id = inspector.id sheet.submitted_at = Time.zone.now
Before
After
!
![Page 28: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/28.jpg)
sheet.submitted_attribution_event = AttributionEvent.build(inspector)
sheet.submitted_by_name = inspector.name sheet.submitted_by_email = inspector.email sheet.submitted_by_id = inspector.id sheet.submitted_at = Time.zone.now
Before
After
![Page 29: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/29.jpg)
sheet.submitted_attribution_event = AttributionEvent.build(inspector)
sheet.submitted_by_name = inspector.name sheet.submitted_by_email = reviewer.email sheet.submitted_by_id = inspector.id sheet.submitted_at = Time.zone.now
Before
After
!
![Page 30: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/30.jpg)
sheet.submitted_attribution_event = AttributionEvent.build(inspector)
sheet.submitted_by_name = inspector.name sheet.submitted_by_email = reviewer.email sheet.submitted_by_id = inspector.id sheet.submitted_at = Time.zone.now
Before
After
![Page 31: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/31.jpg)
# # Represents the information required to attribute # an event to a user. # class AttributionEvent attr_reader :name, :email, :user_id, :event_at
def self.build(user, at: Time.zone.now) new(user.name, user.email, user.id, at) end
def initialize(name, email, user_id, at) @name = name @email = email @user_id = user_id @event_at = at end end
![Page 32: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/32.jpg)
class Sheet < ActiveRecord::Base
composed_of :reviewed_attribution_event, class_name: 'AttributionEvent', allow_nil: true, mapping: [ ['reviewed_by_name', 'name'], ['reviewed_by_email', 'email'], ['reviewed_by_id', 'user_id'], ['reviewed_at', 'event_at'] ]
composed_of :submitted_attribution_event, class_name: ’AttributionEvent', allow_nil: true, mapping: [ ['submitted_by_name', 'name'], ['submitted_by_email', 'email'], ['submitted_by_id', 'user_id'], ['submitted_at', 'event_at'] ]
![Page 33: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/33.jpg)
class Sheet < ActiveRecord::Base
composed_of :reviewed_attribution_event, class_name: ’AttributionEvent', allow_nil: true, mapping: [ [‘reviewed_by_name’, 'name'], [‘reviewed_by_email', 'email'], [‘reviewed_by_id', 'user_id'], [‘reviewed_at', 'event_at'] ]
composed_of :submitted_attribution_event, class_name: ’AttributionEvent', allow_nil: true, mapping: [ [‘submitted_by_name', 'name'], [‘submitted_by_email’, 'email'], [‘submitted_by_id', 'user_id'], [‘submitted_at’, 'event_at'] ]
![Page 34: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/34.jpg)
class Sheet < ActiveRecord::Base
attribution_event :reviewed attribution_event :submitted attribution_event :discarded
![Page 35: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/35.jpg)
![Page 36: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/36.jpg)
module Models module AttributionEvents extend ActiveSupport::Concern
module ClassMethods def attribution_event(type, allow_nil: true) attribution_event = <<-ATTRIBUTION_EVENT composed_of :#{type}_attribution_event, class_name: 'AttributionEvent', allow_nil: #{allow_nil}, mapping: [ ['#{type}_by_name', 'name'], ['#{type}_by_email', 'email'], ['#{type}_by_id', 'user_id'], ['#{type}_at', 'event_at'] ] ATTRIBUTION_EVENT
class_eval(attribution_event) end end end end
![Page 37: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/37.jpg)
module Models module AttributionEvents extend ActiveSupport::Concern
module ClassMethods def attribution_event(type, allow_nil: true) attribution_event = <<-ATTRIBUTION_EVENT composed_of :#{type}_attribution_event, class_name: 'AttributionEvent', allow_nil: #{allow_nil}, mapping: [ ['#{type}_by_name', 'name'], ['#{type}_by_email', 'email'], ['#{type}_by_id', 'user_id'], ['#{type}_at', 'event_at'] ] ATTRIBUTION_EVENT
class_eval(attribution_event) end end end end
![Page 38: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/38.jpg)
module Models module AttributionEvents extend ActiveSupport::Concern
module ClassMethods def attribution_event(type, allow_nil: true) attribution_event = <<-ATTRIBUTION_EVENT composed_of :#{type}_attribution_event, class_name: 'AttributionEvent', allow_nil: #{allow_nil}, mapping: [ ['#{type}_by_name', 'name'], ['#{type}_by_email', 'email'], ['#{type}_by_id', 'user_id'], ['#{type}_at', 'event_at'] ] ATTRIBUTION_EVENT
class_eval(attribution_event) end end end end
![Page 39: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/39.jpg)
module Models module AttributionEvents extend ActiveSupport::Concern
module ClassMethods def attribution_event(type, allow_nil: true) attribution_event = <<-ATTRIBUTION_EVENT composed_of :#{type}_attribution_event, class_name: 'AttributionEvent', allow_nil: #{allow_nil}, mapping: [ ['#{type}_by_name', 'name'], ['#{type}_by_email', 'email'], ['#{type}_by_id', 'user_id'], ['#{type}_at', 'event_at'] ] ATTRIBUTION_EVENT
class_eval(attribution_event) end end end end
![Page 40: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/40.jpg)
module Models module AttributionEvents extend ActiveSupport::Concern
module ClassMethods def attribution_event(type, allow_nil: true) attribution_event = <<-ATTRIBUTION_EVENT composed_of :#{type}_attribution_event, class_name: 'AttributionEvent', allow_nil: #{allow_nil}, mapping: [ ['#{type}_by_name', 'name'], ['#{type}_by_email', 'email'], ['#{type}_by_id', 'user_id'], ['#{type}_at', 'event_at'] ] ATTRIBUTION_EVENT
class_eval(attribution_event) end end end end
![Page 41: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/41.jpg)
include Models::AttributionEvents
attribution_event :reviewed
composed_of :reviewed_attribution_event, class_name :'AttributionEvent', allow_nil: true, mapping: [ ['reviewed_by_name', 'name'], ['reviewed_by_email', 'email'], ['reviewed_by_id', 'user_id'], ['reviewed_at', 'event_at'] ]
Before
After
![Page 42: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/42.jpg)
An attribution event identifies a user and
has a timestamp
And there are different types of attribution events
![Page 43: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/43.jpg)
sheet.submitted_attribution_event = AttributionEvent.build(inspector)
sheet.reviewed_attribution_event = AttributionEvent.build(supervisor)
class Sheet < ActiveRecord::Base include Models::AttributionEvents
attribution_event :reviewed attribution_event :submitted
...
end
![Page 44: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/44.jpg)
How do we { log, capture, assign, save, or record } an attribution event ?
![Page 45: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/45.jpg)
sheet.log_attribution_event( type: :reviewed, user: inspector, at: reviewed_at )
sheet.capture_attribution_event( type: :submitted, user: inspector, at: submitted_at )
header.assign_attribution_event( type: :reviewed, user: inspector, at: reviewed_at )
inspection.save_attribution_event( type: :submitted, user: inspector, at: reviewed_at )
inspection.record_attribution_event( type: :reviewed, user: inspector, at: reviewed_at )
![Page 46: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/46.jpg)
sheet.log_attribution_event( type: :reviewed, user: inspector, at: reviewed_at )
sheet.capture_attribution_event( type: :submitted, user: inspector, at: submitted_at )
header.assign_attribution_event( type: :reviewed, user: inspector, at: reviewed_at )
inspection.save_attribution_event( type: :submitted, user: inspector, at: reviewed_at )
inspection.record_attribution_event( type: :reviewed, user: inspector, at: reviewed_at )
![Page 47: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/47.jpg)
sheet.log_attribution_event( type: :reviewed, user: inspector, at: reviewed_at )
sheet.capture_attribution_event( type: :submitted, user: inspector, at: submitted_at )
sheet.assign_attribution_event( type: :reviewed, user: inspector, at: reviewed_at )
inspection.save_attribution_event( type: :submitted, user: inspector, at: reviewed_at )
sheet.record_attribution_event( type: :reviewed, user: inspector, at: reviewed_at )
![Page 48: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/48.jpg)
module Models module AttributionEvents extend ActiveSupport::Concern
included do def capture_attribution_event(type:, user:, at: Time.zone.now) send("#{type}_attribution_event=", AttributionEvent.build(user, at: at)) end end
module ClassMethods
...
end end end
![Page 49: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/49.jpg)
module Models module AttributionEvents extend ActiveSupport::Concern
included do def capture_attribution_event(type:, user:, at: Time.zone.now) send("#{type}_attribution_event=", AttributionEvent.build(user, at: at)) end end
module ClassMethods
...
end end end
![Page 50: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/50.jpg)
module Models module AttributionEvents extend ActiveSupport::Concern
included do def capture_attribution_event(type:, user:, at: Time.zone.now) send("#{type}_attribution_event=", AttributionEvent.build(user, at: at)) end end
module ClassMethods
...
end end end
![Page 51: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/51.jpg)
sheet.capture_attribution_event( type: :submitted, user: inspector )
Before
After
sheet.submitted_by_name = inspector.name sheet.submitted_by_email = inspector.email sheet.submitted_by_id = inspector.id sheet.submitted_at = Time.zone.now
![Page 52: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/52.jpg)
Example fromQCloud
composed_of Concern
![Page 53: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/53.jpg)
An attribution event identifies a user and
has a timestamp
And we capture different types of attribution events
![Page 54: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/54.jpg)
class Sheet < ActiveRecord::Base include Models::AttributionEvents attribution_event :reviewed attribution_event :submitted
sheet.capture_attribution_event( type: :submitted, user: inspector )
An attribution event identifies a user and
has a timestamp
And we capture different types of attribution events
![Page 55: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/55.jpg)
class Sheet < ActiveRecord::Base include Models::AttributionEvents attribution_event :reviewed attribution_event :submitted
sheet.capture_attribution_event( type: :submitted, user: inspector )
![Page 56: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/56.jpg)
Namingis deeply
connected to
Designing
![Page 57: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/57.jpg)
![Page 58: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/58.jpg)
Ubiquitous Language
The language used by everyone on the team to describe the domain model when speaking, writing user stories, and in the source code.
![Page 59: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/59.jpg)
• Passes the tests• Reveals intention
Simple Design
• No duplication• Fewest elements
![Page 60: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/60.jpg)
• Passes the tests• Reveals intention
Simple Design
• No duplication• Fewest elements
![Page 61: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/61.jpg)
• Passes the tests• Reveals intention
Simple Design
• No duplication• Fewest elements
![Page 62: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/62.jpg)
• Passes the tests• Improves names
Simple Design
• No duplication• Fewest elements
![Page 63: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/63.jpg)
• Improves names
Simple Design
• Removes duplication
![Page 64: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/64.jpg)
• Improves names
Simple Design
• Removes duplication
![Page 65: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/65.jpg)
The Simple Design Dynamo™
![Page 66: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/66.jpg)
Example fromQCloud
![Page 67: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/67.jpg)
![Page 68: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/68.jpg)
class Sheet < ActiveRecord::Base
composed_of :reviewed_attribution_event, class_name: 'AttributionEvent', allow_nil: true, mapping: [ ['reviewed_by_name', 'name'], ['reviewed_by_email', 'email'], ['reviewed_by_id', 'user_id'], ['reviewed_at', 'event_at'] ]
composed_of :submitted_attribution_event, class_name: ’AttributionEvent', allow_nil: true, mapping: [ ['submitted_by_name', 'name'], ['submitted_by_email', 'email'], ['submitted_by_id', 'user_id'], ['submitted_at', 'event_at'] ]
![Page 69: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/69.jpg)
# # Represents the information required to attribute # an event to a user. # class AttributionEvent attr_reader :name, :email, :user_id, :event_at
def initialize(name, email, user_id, at) @name = name @email = email @user_id = user_id @event_at = at end end
sheet.submitted_attribution_event = AttributionEvent.new( inspector.name, inspector.email, inspector.id, Time.zone.now )
![Page 70: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/70.jpg)
# # Represents the information required to attribute # an event to a user. # class AttributionEvent attr_reader :name, :email, :user_id, :event_at
def self.build(user, at: Time.zone.now) new(user.name, user.email, user.id, at) end
def initialize(name, email, user_id, at) @name = name @email = email @user_id = user_id @event_at = at end end An attribution event
identifies a user andhas a timestamp
![Page 71: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/71.jpg)
class Sheet < ActiveRecord::Base
composed_of :reviewed_attribution_event, class_name: ’AttributionEvent', allow_nil: true, mapping: [ [‘reviewed_by_name’, 'name'], [‘reviewed_by_email', 'email'], [‘reviewed_by_id', 'user_id'], [‘reviewed_at', 'event_at'] ]
composed_of :submitted_attribution_event, class_name: ’AttributionEvent', allow_nil: true, mapping: [ [‘submitted_by_name', 'name'], [‘submitted_by_email’, 'email'], [‘submitted_by_id', 'user_id'], [‘submitted_at’, 'event_at'] ]
![Page 72: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/72.jpg)
module Models module AttributionEvents extend ActiveSupport::Concern
module ClassMethods def attribution_event(type, allow_nil: true) attribution_event = <<-ATTRIBUTION_EVENT composed_of :#{type}_attribution_event, class_name: 'AttributionEvent', allow_nil: #{allow_nil}, mapping: [ ['#{type}_by_name', 'name'], ['#{type}_by_email', 'email'], ['#{type}_by_id', 'user_id'], ['#{type}_at', 'event_at'] ] ATTRIBUTION_EVENT
class_eval(attribution_event) end end end end
![Page 73: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/73.jpg)
![Page 74: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/74.jpg)
class Sheet < ActiveRecord::Base include Models::AttributionEvents
attribution_event :reviewed attribution_event :submitted
sheet.capture_attribution_event( type: :submitted, user: inspector )
sheet.capture_attribution_event( type: :reviewed, user: supervisor )
![Page 75: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/75.jpg)
The Simple Design Dynamo™
![Page 76: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/76.jpg)
Don’t Settle for Poor Names
![Page 77: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/77.jpg)
Don’t Settle for Poor Names
Pretty Please
![Page 78: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/78.jpg)
![Page 79: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/79.jpg)
The Simple Design Dynamo™
![Page 80: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/80.jpg)
![Page 81: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/81.jpg)
Resources
![Page 82: Don't Settle for Poor Names](https://reader031.fdocuments.net/reader031/viewer/2022030317/5a6514ba7f8b9aa2548b6bb9/html5/thumbnails/82.jpg)
http://blog.jbrains.ca/permalink/the-four-elements-of-simple-design
http://blog.thecodewhisperer.com/permalink/putting-an-age-old-battle-to-rest
One of the best thinkers around on effective software development: J. B. Rainsberger.