Slide 1

Slide 1 text

Domain Driven Desig n kinda

Slide 2

Slide 2 text

๐Ÿ‘‹

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

Refactoring

Slide 13

Slide 13 text

Life Goals

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

Domain Driven Design

Slide 16

Slide 16 text

...kinda ๐Ÿ™ˆ

Slide 17

Slide 17 text

Product Hunt favored Domain Driven Desig n

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

โ€œDomain-driven design (DDD) is the concept that the structure and language of software code (classes, methods, functions, variables).โ€ What is Domain Driven Design?

Slide 22

Slide 22 text

What problems does DDD solve? โ€œDevelopers are too wrapped up with technology and trying to solve problems using technology rather than careful thought and designโ€ 1

Slide 23

Slide 23 text

What problems does DDD solve? โ€œThe database is given too much priority, and most discussions about the solutions center around the database and a data model rather than business processes and operations.โ€ 2

Slide 24

Slide 24 text

What problems does DDD solve? โ€œDevelopers donโ€™t give proper emphasis to naming objects and operations according to the business purpose that they fi ll.โ€ 3

Slide 25

Slide 25 text

What problems does DDD solve? โ€œApplication logic is disjointed and hard to follow. It is hard to see an overview of the application featuresโ€ 4

Slide 26

Slide 26 text

What are the issues with traditional DDD? โ€œIn order to help maintain the model as a pure and helpful language construct, the team must typically implement a great deal of isolation and encapsulation within the domain model. Which overcomplicates the system.โ€ 1

Slide 27

Slide 27 text

What are the issues with traditional DDD? โ€œRails and Node doesn't fi t very well with DDD mindset. DDD comes from Java and similar languages.โ€ 2

Slide 28

Slide 28 text

What are the issues with traditional DDD? โ€œA lot of DDD practices are focused on consultancy model and are used for model complicated business processes.โ€ 3

Slide 29

Slide 29 text

Product Hunt favored Domain Driven Desig n

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

What is Domain Driven Design ?

Slide 32

Slide 32 text

Ubiquitous Language โ€œA language structured around the domain model and used by all team members to connect all the activities of the team with the software.โ€

Slide 33

Slide 33 text

Ubiquitous Language โ€œThere are only two hard things in Computer Science: cache invalidation and naming things.โ€ -- Phil Karlton

Slide 34

Slide 34 text

Ubiquitous Language app/models/use.rb ๐Ÿ™ˆ

Slide 35

Slide 35 text

Ubiquitous Language app/models/use.rb ๐Ÿคฎ

Slide 36

Slide 36 text

Ubiquitous Language app/models/stack_item.rb ๐Ÿ‘

Slide 37

Slide 37 text

Ubiquitous Language app/model/founder_club/member.rb ๐Ÿ‘

Slide 38

Slide 38 text

Domains โ€œA sphere of knowledge, in fl uence, or activity. The subject area to which the user applies a program is the domain of the software;โ€

Slide 39

Slide 39 text

Domain Types ๐ŸŽ‚ Core domain โ€จ ๐Ÿฐ Supporting sub domain โ€จ ๐Ÿง Generic sub domain

Slide 40

Slide 40 text

Domain Types ๐ŸŽ‚ Core domain โ€จ ๐Ÿฐ Supporting sub domain โ€จ ๐Ÿง Generic sub domain โ€จ ๐Ÿฅฎ Utilities (infrastructure) sub domain

Slide 41

Slide 41 text

Domain Types ๐ŸŽ‚ Core domain - Post, User, Ship โ€จ ๐Ÿฐ Supporting sub domain - Collections, Discussions โ€จ ๐Ÿง Generic sub domain - Votes, Comments, Seo โ€จ ๐Ÿฅฎ Utilities - External, ExecSQL, HandleRaceCondition

Slide 42

Slide 42 text

What is PH Code Domain

Slide 43

Slide 43 text

๐Ÿคท

Slide 44

Slide 44 text

Moderation Voting Comments Posts Collections Maker Goals Sharing Seo Discussions Ask Ship Mentors Founder Club Golden Kitty Maker Fest Topics Stories Spam Newsletter Noti fi cations Metrics Users Payments Activity Feed Jobs

Slide 45

Slide 45 text

Moderation Voting Comments Posts Collections Maker Goals Sharing Seo Discussions Ask Ship Mentors Founder Club Golden Kitty Maker Fest Topics Stories Spam Newsletter Noti fi cations Metrics Users Payments Activity Feed Jobs Core Feature Generic Context Map

Slide 46

Slide 46 text

Moderation Voting Comments Posts Collections Maker Goals Sharing Seo Discussions Ask Ship Mentors Founder Club Golden Kitty Maker Fest Topics Stories Spam Newsletter Noti fi cations Metrics Users Payments Activity Feed Jobs Core Feature Generic Context Map Utilities

Slide 47

Slide 47 text

Bounded Context โ€œA semantic contextual boundary. This means that within the boundary each component of the software model has a speci fi c meaning and does speci fi c things.โ€

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

...kinda ๐Ÿ™ˆ

Slide 50

Slide 50 text

Admin Other Bounded Context Utilities Bounded Context (Domain) Models Services Jobs GraphQL Mutations Resolvers Types

Slide 51

Slide 51 text

https://www.phoenixframework.org/

Slide 52

Slide 52 text

defmodule Hello.Accounts do @moduledoc """ The Accounts context. """ import Ecto.Query, warn: false alias Hello.Repo alias Hello.Accounts.User @doc """ Returns the list of users. ## Examples iex> list_users() [%User{}, ...] """ def list_users do Repo.all(User) end ... end

Slide 53

Slide 53 text

Showcase 1โ€จ Feature Domain

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

/app/domain/โ€จ /app/domain/founder_club.r b /app/domain/founder_club/*.rb

Slide 56

Slide 56 text

FounderClub.join_waitlist(user:) โ€จ FounderClub.join(user:) FounderClub.request_access(user:, code:) FounderClub.deliver_waitlist_invite(invite:) FounderClub.plan_for(code:) โ€จ FounderClub.subscribe(user:, subscription_id:) FounderClub.claim_deal(user:, deal:) FounderClub.claimed_deals_by(user:) FounderClub.deals_available_to(user:) FounderClub.create_referral_code(user:, email:) FounderClub.destroy_referral_code(user:, email:) โ€จ FounderClub.referrals_of(user:) โ€จ โ€จ FounderClub.active_subscription?(user) FounderClub.list_subscriptions โ€จ FounderClub.transfer_subscription(from:, to:)

Slide 57

Slide 57 text

FounderClub::Admin::DealForm โ€จ FounderClub::Policy โ€จ FounderClub::MailerInfo ๐Ÿคท

Slide 58

Slide 58 text

FounderClub.admin_deal_form โ€จ FounderClub.policy โ€จ FounderClub.mail_info ๐Ÿค”

Slide 59

Slide 59 text

module FounderClub extend self โ€จ def admin_deal_form โ€จ FounderClub::Admin::DealForm โ€จ end โ€จ โ€จ def policy โ€จ FounderClub::Policy โ€จ end โ€จ โ€จ def mailer_info FounderClub::MailerInfo โ€จ end โ€จ end ๐Ÿค”

Slide 60

Slide 60 text

Showcase 2โ€จ Generic Domain

Slide 61

Slide 61 text

Sharing.text_for(post) โ€จ Sharing.text_for(post, current_user: user) โ€จ Sharing.image_for(post) โ€จ Sharing.image_for_comment(comment, highlighted_text: 'Awesome')

Slide 62

Slide 62 text

module Sharing extend self def text_for(subject, current_user: nil) generator = FindConst.call(Sharing::Text, subject) if generator.method(:call).arity == 1 generator.call(subject) else generator.call(subject, current_user: current_user) end end def image_for(subject) generator = FindConst.call(Sharing::ImageUrl, subject) generator.call(subject) end def image_for_comment(comment, highlighted_text:) Sharing::ImageUrl:Comment.call(comment, highlighted_text: highlighted_text) end endd

Slide 63

Slide 63 text

Domain Event โ€œA domain object that de fi nes an event (something that happens). A domain event is an event that domain experts care about.โ€

Slide 64

Slide 64 text

Domain Event != Event Souring

Slide 65

Slide 65 text

Kitty Event s https://github.com/producthunt/KittyEvents

Slide 66

Slide 66 text

Design Patterns ๐Ÿš— Entity โ€จ ๐Ÿš• Value Object โ€จ ๐Ÿš™ Aggregate ๐ŸšŒ Repository ๐ŸšŽ Facade ๐Ÿš Factory ๐Ÿšš Service โ€จ ๐Ÿš› Presenter

Slide 67

Slide 67 text

Design Patterns ๐Ÿš— Entity โ€จ ๐Ÿš• Value Object โ€จ ๐Ÿš™ Aggregate ๐ŸšŒ Repository ๐ŸšŽ Facade ๐Ÿš Factory ๐Ÿšš Service โ€จ ๐Ÿš› Presenter

Slide 68

Slide 68 text

Design Patterns ๐Ÿš— Entity โ€จ ๐Ÿš• Value Object โ€จ ๐Ÿš™ Aggregate ๐ŸšŒ Repository ๐ŸšŽ Facade ๐Ÿš Factory ๐Ÿšš Service โ€จ ๐Ÿš› Presenter

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

https://github.com/producthunt/producthunt/tree/master/app/services/sharing ๐Ÿ‘‰ https://github.com/producthunt/stacks/tree/master/backend/app/services/share

Slide 71

Slide 71 text

module Share::Subject extend self def call(subject:, current_profile: ) subject_class = subject.class.name.tr('::', '' ) share = "Share::Subjects::#{subject_class}".constantiz e share.generate subject, current_profil e end end

Slide 72

Slide 72 text

module Share extend self def message_for(subject, current_profile: nil ) subject_class = subject.class.name.tr('::', '' ) share = "Share::Subjects::#{subject_class}".constantiz e share.generate subject, current_profil e end end

Slide 73

Slide 73 text

module Share extend self def message_for(subject, current_profile: nil ) subject_class = subject.class.name.tr('::', '' ) share = "Share::Message::#{subject_class}".constantiz e share.generate subject, current_profil e end end

Slide 74

Slide 74 text

module Share extend self def message_for(subject, current_profile: nil ) share = Utils.module_for(subject, in: Share::Message ) share.generate subject, current_profil e end end ๐Ÿ’ก

Slide 75

Slide 75 text

No content

Slide 76

Slide 76 text

Books

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

Whats next...

Slide 79

Slide 79 text

... any ideas? ๐Ÿ’ก ๐Ÿ˜…

Slide 80

Slide 80 text

No content