Glass.Mapper.Sc is a object relational mapper (ORM) for the Sitecore platform. Glass Mapper allows you to map data from your Sitecore database directly into strongly typed C# models.
The framework was created with the following goals:
Glass Mapper removes the need for developers to spend their time writing boilerplate code to convert data from the string values stored by Sitecore to .NET types. A Sitecore developer's life is made easier because they can focus on solving business problems and not data conversion. This also keeps the code cleaner and more maintainable.
Glass Mapper is also not just about mapping simple field values to properties, it also provides developers the ability to create complex object graphs that describe the complex business relationships between items. Glass.Mapper.Sc can map simple parent / child relationships and more complex relationships that require pulling items from any location in the Sitecore database. With each relationship you can also define rules about how that relationship should be mapped to filter out the items that should not be part of your particular object graph.
Glass provides all this without sacrificing the key features that make Sitecore such a great platform. Your strongly typed models can work with the Experience Editor allowing you to make use of Editable fields without having to convert back to the original Sitecore item. You can also cache models, read and write data, use strongly typed Rendering Parameters and create Edit Frames.
The example code below is an example of the code you would need to create using the Sitecore API and Glass API to filer a collection of items.
Using the Sitecore API.
Using the Glass.Mapper.SC API.
The example shows how simple and easy to read your business logic becomes. This allows developers to write code in a more intuitive manner making it easier to maintain and support over the entire life of the application.
Additionally the models can be reused by other parts of the application. If the model needs to change, for example a property gets deleted, then the code will break when a developer tries to compile. No more hunting down field names based on magic strings.
Compile time checks mean that these common mistakes will be easily caught:
By taking advantage of the compiler developers save time by not having to track down bugs at runtime.
Your code can be unit tested! Your interactions with Sitecore are via services that come with an interface and all models are either plain old C# objects or interfaces. Using the interface for the service and plain old C# object models a developer can very quickly write a unit test using any of the common mocking and testing frameworks without any additional hopes to jump through.