36
Do This, Don’t Do That: A Primer on Sitecore Development Presented by: Ben Hoelting and Dave Youngerman

Do This, Don't Do That: A Primer on Sitecore Development

Embed Size (px)

Citation preview

Page 1: Do This, Don't Do That: A Primer on Sitecore Development

Do This, Don’t Do That: A Primer on Sitecore DevelopmentPresented by:Ben Hoelting andDave Youngerman

Page 2: Do This, Don't Do That: A Primer on Sitecore Development

Do This, Don’t Do That: A Primer on Sitecore Development

BenHoeltingIn 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 [email protected]@aspenware.com

Page 3: Do This, Don't Do That: A Primer on Sitecore Development

Do This, Don’t Do That: A Primer on Sitecore Development

DaveYoungerman

Dave [email protected]@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.

Page 4: Do This, Don't Do That: A Primer on Sitecore Development

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

Page 5: Do This, Don't Do That: A Primer on Sitecore Development

Accessing Sitecore Data

Page 6: Do This, Don't Do That: A Primer on Sitecore Development

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

Page 7: Do This, Don't Do That: A Primer on Sitecore Development

Do This, Don’t Do That: A Primer on Sitecore Development

The Wrong Way

• What happens if someone renames the field to “Blurb”?

Page 8: Do This, Don't Do That: A Primer on Sitecore Development

Do This, Don’t Do That: A Primer on Sitecore Development

The Right Way

Page 9: Do This, Don't Do That: A Primer on Sitecore Development

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

Page 10: Do This, Don't Do That: A Primer on Sitecore Development

Using the Config System

Page 11: Do This, Don't Do That: A Primer on Sitecore Development

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_config\Include Folder

Page 12: Do This, Don't Do That: A Primer on Sitecore Development

Do This, Don’t Do That: A Primer on Sitecore Development

Using the Config System Cont.• Patching Sitecore configs

Page 13: Do This, Don't Do That: A Primer on Sitecore Development

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

Page 14: Do This, Don't Do That: A Primer on Sitecore Development

Dev Ops

Page 15: Do This, Don't Do That: A Primer on Sitecore Development

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

Page 16: Do This, Don't Do That: A Primer on Sitecore Development

Dev OpsDemo

Page 17: Do This, Don't Do That: A Primer on Sitecore Development

Next steps/Resources/Questions

17

What to do• Decide between Unicorn or Team 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

Page 18: Do This, Don't Do That: A Primer on Sitecore Development

Indexing Tips

Page 19: Do This, Don't Do That: A Primer on Sitecore Development

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

Page 20: Do This, Don't Do That: A Primer on Sitecore Development

IndexingLucene vs Solr

Page 21: Do This, Don't Do That: A Primer on Sitecore Development

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.

Page 22: Do This, Don't Do That: A Primer on Sitecore Development

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.

Page 23: Do This, Don't Do That: A Primer on Sitecore Development

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

Page 24: Do This, Don't Do That: A Primer on Sitecore Development

CacheManagement

Page 25: Do This, Don't Do That: A Primer on Sitecore Development

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

Page 26: Do This, Don't Do That: A Primer on Sitecore Development

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

Page 27: Do This, Don't Do That: A Primer on Sitecore Development

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

Page 28: Do This, Don't Do That: A Primer on Sitecore Development

Unit TestingSitecore

Page 29: Do This, Don't Do That: A Primer on Sitecore Development

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.)

Page 30: Do This, Don't Do That: A Primer on Sitecore Development

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.

Page 31: Do This, Don't Do That: A Primer on Sitecore Development

Do This, Don’t Do That: A Primer on Sitecore Development

Unit Testing Sitecore Cont.• Add the following classes to your solution:

Page 32: Do This, Don't Do That: A Primer on Sitecore Development

Unit TestingSitecore Demo

Page 33: Do This, Don't Do That: A Primer on Sitecore Development

Next steps/Resources/Questions

33

What to do• Read the Sitecore.FakeDb GitHub Wiki and start mocking Sitecore dependencies.• Use Autofixture to prepopulate your Sitecore mocks.• Review Sitecore.Habitat's unit tests.

Resources available• http://tinyurl.com/z5jn4sa

Page 34: Do This, Don't Do That: A Primer on Sitecore Development

Tools for Modern Web Development34

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.

Page 35: Do This, Don't Do That: A Primer on Sitecore Development

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

Page 36: Do This, Don't Do That: A Primer on Sitecore Development

FOR DISCUSSION PURPOSES ONLY. Sitecore Confidential and Proprietary. © 2016 Sitecore Corporation A/S. All

rights reserved. Sitecore® and Own the Experience® are registered

trademarks of Sitecore Corporation A/S. All other brand and product names are the property of their

respective owners.