Using Code Share Projects in


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Show how quick and easy it is to build and deploy – had to stretch out the content because it is so quick to build and dev.
  • After explaining, download source include source into eclipse.
  • ===================================Null-safety===================================Save following class:public class Foo{ public void doSomethingWithAString(String str){ System.debug(str.trim().length()); }}Run anonymously:new Foo().doSomethingWithAString('test123');Run with null and of course, null pointerModify to use StringUtilspublic class Foo{ public void doSomethingWithAString(String str){ System.debug(al.StringUtils.length(al.StringUtils.trim(str))); }}===================================isEmpty/isBlank======================================================================isEmpty/isBlank===================================
  • After explaining the changes, switch to running example
  • Further explain the interaction via this diagram.Next, show more complex example with nested paginators
  • Switch to eclipse run following example anonymouslySystem.debug('\\n\\n#################################\\n' + new SoqlBuilder().selectx('ID').selectx('Name').fromx('Account').toSoql() + '\\n#################################\\n\\n');========================selecting fields========================.selectx(new Set<Object>{'ID','Name'}).fromx('Account').selectx(new List<Object>{'ID','Name'}).fromx('Account')========================relationship queries========================.selectx('id').selectx(new SoqlBuilder().selectx('id').fromx('OpportunityLineItems')).fromx('Opportunity')========================conditions - multiple ways========================.fromx('account').wherex(new FieldCondition().field('name').equals('acme'))//.fromx('account').wherex(new FieldCondition('name').equals('acme'))//.fromx('account').wherex(new FieldCondition('name',Operator.EQUALS,'acme'))//.fromx('account').wherex(new FieldCondition('name','acme')) ========================Primitives to String literals========================.fromx('account').wherex(new FieldCondition('x').equals('acme')).fromx('account').wherex(new FieldCondition('x').equals('ac\\'me')).fromx('account').wherex(new FieldCondition('x').equals(Datetime.newinstance(2010,1,1,1,1,1)))========================Conditions========================//simple NOT condition.fromx('account').wherex( new NotCondition(new AndCondition() .add(new FieldCondition('name','acme')) .add(new FieldCondition('ispartner',true))) )//nested ANDs and ORs.fromx('account').wherex( new NotCondition( new AndCondition() .add( new OrCondition() .add(new FieldCondition('name','acme')) .add( new AndCondition() .add(new FieldCondition('ispartner',true)) .add(new FieldCondition('NumberOfEmployees').lessThan(10)) ) ) .add( new OrCondition() .add(new FieldCondition('createddate').lessThan(new DateFormula().yesterdayx())) .add(new FieldCondition('Rating','Hot')) ) ))========================Wildcarding========================.fromx('account').wherex( new OrCondition() .add(new FieldCondition('name').likex('acme')) .add(new FieldCondition('name').likex('test'))).toSoql(new SoqlOptions().wildcardStringsInLikeOperators())
  • Using Code Share Projects in

    1. 1. Using Code Share Projects in<br />Developers<br />Quinton<br />Richard Vanhook:EDL Consulting<br />
    2. 2. Safe Harbor<br />Safe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services.<br />The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of intellectual property and other litigation, risks associated with possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of, inc. is included in our annual report on Form 10-K for the most recent fiscal year ended January 31, 2010. This documents and others are available on the SEC Filings section of the Investor Information section of our Web site. <br />Any unreleased services or features referenced in this or other press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available., inc. assumes no obligation and does not intend to update these forward-looking statements.<br />
    3. 3. What is Code Share?<br /><br />Directory of Open Source Projects for<br />Commit. Share. Rate. Comment.<br />
    4. 4. Using Code Share Projects<br />Search for Projects<br />Top Rated<br />Latest Added<br />All Projects<br />Stay Up to Date<br />RSS of Latest Projects<br />Rate & Comment<br />Reviews help everyone!<br />
    5. 5. Installing Code Share Projects<br />As A Package<br />Via Code Repository<br />Eclipse plugins available (subclipse, egit etc.)<br />
    6. 6. How to Start a Project – Share the Love<br />Login with your DE account<br />Create a new Project<br />Link it to a web code repository<br />Google Code etc.<br />Add Project Members<br />Add Articles and Docs.<br />Keep it up to date<br />Blog & Tweet it.<br /><br />
    7. 7. Enough Talk….Let’s see a Project in Action!<br />
    8. 8. apex-lang Overview<br />A collection of just over 100 apex classes aimed at making core Apex/VF programming easier<br />Consists of only code - no objects, pages, etc<br />Has 100% code coverage<br />Project Website: <br /><br />Documented via my blog <br />Contributions are certainly welcome! Contact me at or post suggestion on my blog.<br />
    9. 9. Install Options<br />From<br />Install the Managed Package<br />Easiest install option but of course, the code is hidden<br />All classes must prefixed with al; example: al.StringUtils<br />Directly add source code<br />Download source zip file and expand into eclipse src/classes <br />Just copy & paste what you need!<br />Use apex-lang as reference<br />
    10. 10. String Manipulation<br />Use StringUtils<br />Ported directly from Apache Commons Lang therefore Javadoc for very much applies. (see<br />Examples:<br />All methods follow “null safe” pattern<br />Empty/Blank checks: <br />isEmpty(), isBlank(), isNotEmpty(), isNotBlank()<br />Joining Strings: <br />new List<String>{'a','b','c'} to 'a:b:c’<br />Filtering characters<br />
    11. 11. Pagination<br />Modified to utilize apex-lang pagination<br />Controller:<br />global class MyController implements SObjectPaginatorListener { <br /> global List<Account> records {get;private set;}<br /> global SObjectPaginatorpaginator {get;private set;}<br /> global MyController(){<br />paginator = new SObjectPaginator(5,this);<br />paginator.setRecords([select name from Account limit 100]); <br /> } <br /> global void handlePageChange(List<SObject> newPage){<br /> if(records == null){records = new List<Account>();}<br />records.clear();<br /> if(newPage != null && newPage.size() > 0){<br /> for(SObject record : newPage){ <br />records.add((Account)record);<br /> }<br /> }<br /> }<br />}<br />VF Page:<br /><apex:page controller="MyController"> <br /> <apex:repeat value="{!records}" var="record"> <br /> <apex:outputText value="{!}"/><br/> <br /> </apex:repeat> <br /> <apex:form ><br /> <apex:commandLink value="Previous" action="{!paginator.previous}"/> <br /> &nbsp;&nbsp;|&nbsp;&nbsp;<br /> <apex:commandLink value="Next" action="{!}"/><br /> </apex:form> <br /></apex:page><br />
    12. 12. Pagination<br />
    13. 13. SOQL Builder<br />Use SoqlBuilder.cls and supporting classes<br />Useful for dynamically creating SOQL query strings<br />Think: <br />String soql = new SoqlBuilder().fromx('Account').toSoql()<br />List<Account> a = Database.query(soql);<br />Instead of: <br />String soql = 'select id from Account';<br />List<Account> a = Database.query(soql);<br />Above example is intentionally simplified – real world use cases for SoqlBuilder more complex<br />Not intended as replacement for static query strings:<br />List<Account> a = [select id from Account];<br />
    14. 14. Recap & Summary<br />Before coding, search CodeShare!<br />Take time to rate, commit, and commit!<br />Apex-lang rocks man<br />Share the love!<br />
    15. 15. Helpful Links<br />Code Share Home Page<br /><br />Creating a Code Share Project Article<br /><br />Eclipse/ IDE Plugins:<br />Subclipse (SVN):<br />eGit (GIT):<br />Apex-Lang Project Home Page<br /><br />
    16. 16. Using Code Share Projects in<br />
    17. 17. Visit the Developer Training and Support Booth in Zone<br />D I S C O V E R<br />Developer training, certification and support resources <br />that help you achieve<br />S U C C E S S<br />Find us in the Partner Demo Area of <br /> Zone 2nd Floor Moscone West<br />Learn about Developer Certifications<br />Discover Developer Learning Paths<br />
    18. 18. Remember. . .<br /><ul><li>Check Chatter for additional session information
    19. 19. Get your developer Workbooks and Cheat Sheets in the Zone
    20. 20. Visit for more information related to this topic</li></ul>Don’t forget the survey!<br />
    21. 21. How Could Dreamforce Be Better? Tell Us!<br />Log in to the Dreamforce app to submit<br />surveys for the sessions you attended<br />Use the Dreamforce Mobile app to submit surveys<br />OR<br />Every session survey you submit is a chance to win an iPod nano!<br />