I've got a fair amount of work done so far as I am able to post to my test account at zoho. I have a ZohoXml class, and a ZohoBaseFieldClass (which i named poorly as ZohoBaseModule, i'll rename that) it is an interface with one bool method called IsSendable(). ZohoPotentials implements that base field class. At first I decided to just make a property for each of the properties that Zoho has available. But that doesn't allow for custom Fields that you can put into Zoho. Also if a end user decides that they want a particular field required (even though zoho doesn't require it) then I would be up a creek.
So here is my idea. What if i make a base property class for my zoho fields? I'm thinking that I could actually kill two birds with one stone with this. With this base class if I make 2 bool properties called Required and HasValue then I could get rid of my base field interface.
Also I have to have a way to pass the Field Name to the ZohoXml. Well if my zoho Properties had 2 string properties called Key and Field Name (or value) then in my ZohoXml I could just have a Constructor with a ZohoBaseClass (guess I do need that) and have it iterate through my ZohoProperties and check if it is required and format it correctly in the proper nodes.
But is this too convoluted? is this too unclean? I'm thinking that in this case I would have less dependancies and be able to decouple my classes a bit better and it would allow for easier testing since I'm doing TDD. but I wanted to get a little feedback before i decided to change all my classes (thankfully I only have 1 FieldClass).. This is what my ZohoPotentials class looks like now.
using System;
/*
* User: Ert
* Date: 5/7/2012
* Time: 8:14 PM
*/
namespace ZohoApi
{
public class ZohoPotentials : ZohoBaseModule
{
public string PotentialOwner { get; set; }
public string PotentialName { get; set; }
public string AccountName { get; set; }
public string PotentialType {get; set;}
public string LeadSource { get; set; }
public string CampaignSource { get; set; }
public string ContactName { get; set; }
public decimal Amount { get; set; }
public DateTime ClosingDate { get; set; }
public string NextStep { get; set; }
public string PotentialStage { get; set; }
public int Probability { get; set; }
public decimal ExpectedRevenue { get; set; }
public string CreatedBy { get; set; }
public string ModifiedBy { get; set; }
public string Description { get; set; }
public ZohoPotentials(string potentialName, string accountName, DateTime closingDate, string potentialStage)
{
this.PotentialName = potentialName;
this.AccountName = accountName;
this.ClosingDate = closingDate;
this.PotentialStage = potentialStage;
}
public bool IsSendable()
{
bool HasPotentialName = !string.IsNullOrEmpty(PotentialName);
bool HasAccountName = !string.IsNullOrEmpty(AccountName);
bool HasClosingDate = ClosingDate != null;
bool HasStage = !string.IsNullOrEmpty(PotentialStage);
return HasPotentialName && HasAccountName && HasClosingDate && HasStage;
}
}
}
So i'm thinking that I would change that to somethign more like
using System;
/*
* User: Ert
* Date: 5/7/2012
* Time: 8:14 PM
*/
namespace ZohoApi
{
public class ZohoPotentials : ZohoBaseModule
{
public List<ZohoProperties> theProps {get; set;}
public ZohoPotentials(string potentialName, string accountName, DateTime closingDate, string potentialStage)
{
this.theProps.Add("Potential Name", potentialName, true)//true means require
this.theProps.Add("Account Name", accountName, true)//true means require
this.theProps.Add("Closing Date", closingDate, true)//true means require
this.theProps.Add("Stage", potentialStage, true)//true means require
}
}
}
Looking at it now I would think i would have to make my own collection too so I could use that add method. That would be good, because then I could have a is sendable in that collection! yeah. I think i might do this unless you smart people think it would be dumb and a waste of time.

New Topic/Question
Reply




MultiQuote





|