Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I read <a href="http://en.wikipedia.org/wiki/Referral_marketing" rel="nofollow">wiki article</a> about referral marketing, but that's not enough for me to understand Your business.</p> <ol> <li>What's a referral offer in Your case? </li> <li>What kind of problems You are trying to solve? Aim of Your application? </li> <li>Is referral offer publisher specific?</li> <li>Can more than one publisher bring persons for one particular referral offer?</li> </ol> <hr> <p>Will try to reflect some ideas in code. </p> <p>Keep in mind - I have little knowledge of business domain. </p> <p>Omitting/ignoring <strong>huge</strong> amount of details (e.g. technical difficulties that might arise or even domain related things like when referral becomes a publisher).</p> <p>But hopefully - that might give You some ideas.</p> <pre><code> public class Publisher:Root{} /* I believe it's a root, because multiple publishers can bring referrals to one particular referral offer it could be modeled as entity if offers were given for publishers individually it's certainly not a value object, because we care about identity of particular offer disregarding it's state. I'm ignoring possibility that there might be various incentives with common structure/behavior */ public class ReferralOffer:Root{ public bool IsActive(){ return _startedOn.AddMonths(-_lengthInMonths)&gt;DateTime.Now; } public void BringReferral(string referralName, Publisher boughtBy){ if (IsActive()) _referrals.Add(new Referral(referralName,boughtBy)); } private List&lt;Referral&gt; _referrals; public void SendBucksToLuckyBastards(IMoneyTransferService mts){ if (!IsActive()&amp;&amp;!_awardsSent){ _referrals.SelectMany(r=&gt;r.BoughtBy) .ForEach(p=&gt;mts.SendToPublisher(p,_award)); _awardsSent=true; } } public ReferralOffer(Money award, int lengthInMonths){ _award=award; _lengthInMonths=lengthInMonths; _startedOn=DateTime.Now; } //assuming it's amount for each referral and not total private Money _award; private int _lengthInMonths; private DateTime _startedOn; private bool _awardsSent; } /* referral - person who is bought by publisher and who eventually might become a publisher if referral automatically becomes a publisher - likely this should be modeled otherwise entity, because it makes no sense w/o referral offer */ public class Referral:Entity{ public Publisher BoughtBy{get; private set;} public string Name{get; private set;} //internal, because only offer constructs them internal Referral(string name,Publisher boughtBy){ BoughtBy=boughtBy; Name=name; } } var me=publisherRepository.ByFullName("Arnis Lapsa"); var offer=new ReferralOffer(200,2); offer.BringReferral(me, "kamal"); //two months later offer.SendBucksToLuckyBastards(moneyTransferService); </code></pre> <p>Keep in mind - this code is just to assist You. It's far from good. </p> <p>Try to understand code thoroughly and <strong>see implications</strong> every line of code makes.</p> <p>P.s. criticism is welcome as usual</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload