Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

Into The Box 2018 cf fractal

107 vues

Publié le

Jon Clausen

Publié dans : Logiciels
  • Soyez le premier à commenter

  • Soyez le premier à aimer ceci

Into The Box 2018 cf fractal

  1. 1. C F F R A C TA L : I N P R A C T I C E
  2. 2. Me: Jon Clausen Team Ortus Member Grand Rapids, Michigan
  3. 3. Y O U M I G H T WA N T T O U S E C F F R A C TA L I F… • You need to transform your business models to different types of data in many different places. • You need to include and exclude relationships depending on the endpoint. • You don't want to repeat yourself all over the place.
  4. 4. function get( event, rc, prc ){ event.paramValue( "format", "json" ); switch( rc.format ){ case "xml":{ var serializer = getInstance( "XMLSerializer@cffractal" ); break; } default:{ var serializer = getInstance( "SimpleSerializer@cffractal" ); } } event.renderData( data = fractal.builder() .collection( getInstance( "Family" ).getFamilyData() ) .withTransformer( "FamilyTransformer" ) .withSerializer( serializer ) .convert(), type = rc.format ) } FA M I LY. C F C
  5. 5. M O R E R E A S O N S • “Includes” conventions - default and available • Nested tranformers • Consistency in responses to consumers • Encapsulation and separation of concern
  6. 6. C F F R A C TA L S E R I A L I Z E R S
  7. 7. var model = { "foo" = "bar", "baz" = "qux" }; // becomes var transformed = { "foo" = "bar", "baz" = "qux", "meta" = {} }; S I M P L E S E R I A L I Z E R
  8. 8. var model = { "foo" = "bar", "baz" = "qux" }; // becomes var transformed = { "data" = { "foo" = "bar", "baz" = "qux" }, "meta" = {} }; D ATA S E R I A L I Z E R
  9. 9. var items = [ { "id" = "F29958B1-5A2B-4785-BE0A11297D0B5373", "name" = "foo" }, { "id" = "42A6EB0A-1196-4A76-8B9BE67422A54B26", "name" = "bar" } ]; // becomes var transformed = { "results" = [ "F29958B1-5A2B-4785-BE0A11297D0B5373", "42A6EB0A-1196-4A76-8B9BE67422A54B26" ], "resultsMap" = { "F29958B1-5A2B-4785-BE0A11297D0B5373" = { "id" = "F29958B1-5A2B-4785-BE0A11297D0B5373", "name" = "foo" }, "42A6EB0A-1196-4A76-8B9BE67422A54B26" = { "id" = "42A6EB0A-1196-4A76-8B9BE67422A54B26", "name" = "bar" } }, "meta" = {} }; R E S U LT S M A P S E R I A L I Z E R
  10. 10. var model = { "foo" = "bar", "baz" = "qux" }; // becomes var transformed = " <root> <data> <foo>bar</foo> <baz>qux</baz> </data> <meta></meta> </root> "; X M L S E R I A L I Z E R
  11. 11. C F F R A C TA L : C A S E S T U D Y
  12. 12. GET STARTED! box install cffractal https://github.com/coldbox-modules/cffractal

×