This document outlines a presentation on Sitecore development best practices given by Ben Hoelting and Dave Youngerman. The agenda includes accessing Sitecore data, using the configuration system, DevOps demonstrations, indexing tips, cache management, and unit testing Sitecore demonstrations. The speakers provide guidance on using templates and identifiers to access data, patching configurations, deployment tools, indexing strategies, caching approaches, and unit testing with Sitecore.FakeDb. Resources like Habitat and documentation links are also provided.
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Do This, Don't Do That: A Primer on Sitecore Development
1. DoThis, Don’t DoThat:
A Primer on Sitecore
Development
Presented by:
Ben Hoelting and
DaveYoungerman
2. Do This, Don’t Do That: A Primer on Sitecore Development
Ben
Hoelting
In truth, he’s just a big kid. He loves designing
systems that solve real world problems. There is
nothing more satisfying than seeing something you
helped develop being used by the end users. Ben is
also involved in the technology community and runs
the South Colorado .NET user group. He also
enjoys speaking at tech groups and events around
the country.
Ben Hoelting
@benhnet
b.hoelting@aspenware.com
3. Do This, Don’t Do That: A Primer on Sitecore Development
Dave
Youngerman
Dave Youngerman
@DavidYoungerman
d.youngerman@aspenware.com
Originally from Ohio, Dave was a biologist before he
discovered building software was his calling and
never looked back. When not creating software,
Dave likes to spend time with his wife, two boys,
and way too many pets. He also enjoys skiing,
running, scuba diving, and fishing.
4. Do This, Don’t Do That: A Primer on Sitecore Development
Agenda
• Accessing Sitecore Data
• Using Config System
• Dev Ops - DEMO
• Indexing
• Cache Management
• Unit Testing Sitecore - DEMO
6. Do This, Don’t Do That: A Primer on Sitecore Development
Accessing Sitecore Data
• Sitecore templates contain the fields needed to
display data.
• There are two ways to access fields on a template
• By Name
• By ID
7. Do This, Don’t Do That: A Primer on Sitecore Development
The Wrong Way
• What happens if someone renames the field to
“Blurb”?
8. Do This, Don’t Do That: A Primer on Sitecore Development
The Right Way
9. Next steps/Resources/Questions
9
What to do
• Take a look at Glass Mapper and decide if it is right for
you
• If not create structs, constants or classes with the ids to
your templates and fields
Resources available
• http://glass.lu/
• Use Habitat as an Example.
• http://habitat.sitecore.net
11. Do This, Don’t Do That: A Primer on Sitecore Development
Using the Config System
• Sitecore has a very robust configuration
system
• Use showconfig.aspx to view configs
• App_config Folder
• App_configInclude Folder
12. Do This, Don’t Do That: A Primer on Sitecore Development
Using the Config System Cont.
• Patching Sitecore configs
13. Next steps/Resources/Questions
13
What to do
• Refactor any web.config changes to patches
• Use Slow Cheetah to create transforms for different
environments
Resources available
• http://tinyurl.com/j9armlv
• Use Habitat as an Example.
• http://habitat.sitecore.net
15. Do This, Don’t Do That: A Primer on Sitecore Development
Dev Ops
• Deployment of any system that is based
on metadata is difficult
• 3rd party tools are needed
• Unicorn
• Team Development for Sitecore (TDS)
• MSBuild
• Octopus
17. Next steps/Resources/Questions
17
What to do
• Decide between Unicorn orTeam Development for
Sitecore (TDS)
• Create build configurations for each environment and
configure them with your build server
Resources available
• http://www.teamdevelopmentforsitecore.com
• https://github.com/kamsar/Unicorn
19. Do This, Don’t Do That: A Primer on Sitecore Development
Indexing
• Index update strategies
• You can use multiple strategies (max
of 3) to keep your indexes up to date.
• Strategies are:
• RebuildAfterFullPublish
• OnPublishEndAsync
• IntervalAsynchronous
• Synchronous
• RemoteBuild
• TimeIndexRefresh
• Manual
21. Do This, Don’t Do That: A Primer on Sitecore Development
Indexing - Lucene
• Lucene is configured by default for content
searching.
• Stick with Lucene when...
• You don't have to index a large number of
items.
• You don't need multiple content delivery
servers.
22. Do This, Don’t Do That: A Primer on Sitecore Development
Indexing - Solr
• Solr is more robust, so use it when...
• You need to index large numbers of items
(50,000 and up).
• Search is your site's primary interface.
• You use multiple content delivery servers, or
you plan to in the future.
23. Next Steps/Resources/Questions
23
What to do
• Review Sitecore Documentation on Lucene vs Solr.
• Determine your data and scaling requirements.
Resources available
• http://tinyurl.com/gtb9bcj
25. Do This, Don’t Do That: A Primer on Sitecore Development
Cache Types
• Different Caching Options
HTML/Web Cache
Item Cache
Data Cache
Prefetch Cache
Database
26. Do This, Don’t Do That: A Primer on Sitecore Development
Cache Definitions
• Prefetch Cache
• Item Information prefilled on App startup
• You configure what items are Prefetched
• Data Cache
• Cache of Item Information.
• Pretty much a flat text representation of an item
• Item Cache
• Cache an entire Item object
• HTML/Web Cache
• Cache the HTML output of a rendering
27. Next steps/Resources/Questions
27
What to do
• Run performance tests against your site to identify
bottlenecks where caching can be applied.
• Review Sitecore cache documentation.
Resources available
• http://tinyurl.com/h7oerhy
29. Do This, Don’t Do That: A Primer on Sitecore Development
Unit Testing Sitecore
• Do use Sitecore.FakeDb to mock Sitecore
dependencies
• FakeDb allows you to create and manipulate Sitecore
content in memory.
• Enables unit testing for areas that are not unit testable from
first look (e.g. static classes, content tree, etc.)
30. Do This, Don’t Do That: A Primer on Sitecore Development
Unit Testing Sitecore Cont.
• Do use Sitecore.FakeDb.Autofixture to create
fake data rather than creating your own.
31. Do This, Don’t Do That: A Primer on Sitecore Development
Unit Testing Sitecore Cont.
• Add the following classes to your solution:
33. Next steps/Resources/Questions
33
What to do
• Read the Sitecore.FakeDb GitHubWiki and start
mocking Sitecore dependencies.
• Use Autofixture to prepopulate your Sitecore mocks.
• Review Sitecore.Habitat's unit tests.
Resources available
• http://tinyurl.com/z5jn4sa
34. Tools for Modern Web Development
34
Sitecore Development
Don’t Forget About
Performance
Unit Testing Helps Keep
Your Sanity
Developer Productivity Is
Key
If you do the right things
up front, developers can
be highly productive with
Sitecore. Setup Dev ops,
coding standards and
best practice frameworks
to increase developer
effectiveness and
efficiency.
Sitecore is relatively
heavy. That’s because it
delivers so much
functionality. It also
provides ways to tweak
the system to deliver
great performance. For
example: Caching and
Indexing.
One best practice that
will help system statbility
is unit testing. Unit
testing has been a
challenge for Sitecore
developers in the past.
Today, Sitecore FakeDB
makes unit testing
Sitecore a reality.
35. Do This, Don’t Do That: A Primer on Sitecore Development
Resources:
• http://www.sitecore.com
• http://habitat.sitecore.net
• Cache Info: http://tinyurl.com/gn325mc
• Solr or Lucene: http://tinyurl.com/zcu3ex6
• Sitecore.FakeDb: http://tinyurl.com/hzu9dn5