Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Collection pipeline par Mathieu Godart

6,654 views

Published on

Comment Transformer vos boucles Objective-C en “collection pipelines” en utilisant le framework BlocksKit (ou Swift), par Mathieu Godart (votre serviteur). Cette présentation s’inspire de la série d’articles publiée par Martin Fowler, Refactoring with Loops and Collection Pipelines (http://martinfowler.com/articles/refactoring-pipelines.html).

Published in: Software
  • Sex in your area is here: ♥♥♥ http://bit.ly/39sFWPG ♥♥♥
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Dating direct: ❶❶❶ http://bit.ly/39sFWPG ❶❶❶
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

Collection pipeline par Mathieu Godart

  1. 1. Migration vers le patron « Collection Pipeline » en Objective-C Mathieu Godart — @MonsieurDart Jeudi 10 septembre 2015 @ CocoaHeads
  2. 2. L’INSPIRATION • Martin Fowler • Refactoring with Loops and Collection Pipelines
 
 http://martinfowler.com/articles/refactoring-pipelines.html • Many use cases in the article • Here, only one case, translated into ObjC
  3. 3. L’IDÉE SOUS-JACENTE • Traitement des collections d’objets : • La boucle est la méthode la plus basique • Mais ce n’est pas la seule : approche en « pipeline » [Liste initiale] — fonction —> [Liste filtrée] • Pas seulement pour la programmation fonctionnelle…
  4. 4. L’IDÉE SOUS-JACENTE • ObjC (et Swift) possèdent ce qu’il faut pour ça : • Lambdas : pour nous les blocs • Bibliothèques : pour nous YOLOKit ou BlocksKit
  5. 5. BRIQUES DE BASE • Les bibliothèques YOLOKit ou BlocksKit • Fonctions de filtrage sur collections (NSArray, NSSet…) • Autres fonctions de manipulation avec des blocs • Chaînage des appels généralisé
  6. 6. CODE DE DÉPART - (NSArray *)twitterHandles:(NSArray *)authors
 forCompany:(NSString *)company
 { NSMutableArray *result = [NSMutableArray new]; for (MGAuthor *a in authors) { if ([a.company isEqual:company]) { var handle = a.twitterHandle; if (handle != null)
 [result addObject:handle]; } } return [NSArray arrayWithArray:result]; }
  7. 7. CODE DE DÉPART - (NSArray *)twitterHandles:(NSArray *)authors
 forCompany:(NSString *)company
 { NSMutableArray *result = [NSMutableArray new]; for (MGAuthor *a in authors) { if ([a.company isEqual:company]) { var handle = a.twitterHandle; if (handle != null)
 [result addObject:handle]; } } return [NSArray arrayWithArray:result]; }
  8. 8. VARIABLE TEMPORAIRE - (NSArray *)twitterHandles:(NSArray *)authors
 forCompany:(NSString *)company
 { NSMutableArray *result = [NSMutableArray new]; NSArray *loopStart = authors; for (MGAuthor *a in loopStart) { if ([a.company isEqual:company]) { var handle = a.twitterHandle; if (handle != null)
 [result addObject:handle]; } } return [NSArray arrayWithArray:result]; }
  9. 9. PREMIER FILTRAGE - (NSArray *)twitterHandles:(NSArray *)authors
 forCompany:(NSString *)company
 { NSMutableArray *result = [NSMutableArray new]; NSArray *loopStart = authors .select(^(MGAuthor *a){ return [a.company isEqual:company];}); for (MGAuthor *a in loopStart) { if ([a.company isEqualToString:company]) { var handle = a.twitterHandle; if (handle != null)
 [result addObject:handle]; } } return [NSArray arrayWithArray:result]; }
  10. 10. CE DONT ON A BESOIN - (NSArray *)twitterHandles:(NSArray *)authors
 forCompany:(NSString *)company
 { NSMutableArray *result = [NSMutableArray new]; NSArray *loopStart = authors .select(^(MGAuthor *a){ return [a.company isEqual:company]; }) .map(^(MGAuthor *a){ return a.twitterHandle; }); for (NSString *handle in loopStart) { var handle = a.twitterHandle; if (handle != null)
 [result addObject:handle]; } return [NSArray arrayWithArray:result]; }
  11. 11. CODE DE DÉPART - (NSArray *)twitterHandles:(NSArray *)authors
 forCompany:(NSString *)company
 { NSMutableArray *result = [NSMutableArray new]; NSArray *loopStart = authors .select(^(MGAuthor *a){ return [a.company isEqual:company]; }) .map(^(MGAuthor *a){ return a.twitterHandle; }) .select(^(NSString *h){ return h != null; }); for (NSString *handle in loopStart) { if (handle != null)
 [result addObject:handle]; } return [NSArray arrayWithArray:result]; }
  12. 12. NETTOYAGE FINAL - (NSArray *)twitterHandles:(NSArray *)authors
 forCompany:(NSString *)company
 { NSMutableArray *result = [NSMutableArray new]; return authors .select(^(MGAuthor *a){ return [a.company isEqual:company]; }) .map(^(MGAuthor *a){ return a.twitterHandle; }) .select(^(NSString *h){ return h != null; }); for (NSString *handle in loopStart) {
 [result addObject:handle]; } return [NSArray arrayWithArray:result]; }
  13. 13. TA DA ! - (NSArray *)twitterHandles:(NSArray *)authors
 forCompany:(NSString *)company
 { return authors .select(^(MGAuthor *a){ return [a.company isEqual:company]; }) .map (^(MGAuthor *a){ return a.twitterHandle; }) .select(^(NSString *h){ return h != null; }); }
  14. 14. TA DA ! - (NSArray *)twitterHandles:(NSArray *)authors
 forCompany:(NSString *)company
 { return authors .select(^(MGAuthor *a){ return [a.company isEqual:company]; }) .map (^(MGAuthor *a){ return a.twitterHandle; }) .select(^(NSString *h){ return h != null; }); }
  15. 15. - (NSArray *)twitterHandles:(NSArray *)authors
 forCompany:(NSString *)company
 { return authors .select(^(MGAuthor *a){ return [a.company isEqual:company]; }) .map (^(MGAuthor *a){ return a.twitterHandle; }) .select(^(NSString *h){ return h != null; }); } - (NSArray *)twitterHandles:(NSArray *)authors
 forCompany:(NSString *)company
 { NSMutableArray *result = [NSMutableArray new]; for (MGAuthor *a in authors) { if ([a.company isEqual:company]) { var handle = a.twitterHandle; if (handle != null) [result addObject:handle]; } } return [NSArray arrayWithArray:result]; }
  16. 16. ENCORE PLUS CONCIS EN SWIFT -(阵列*)的⼿手:(阵列*)作者公司:(字符串*)公司 { 返回作家 。选择(^(作者* A){返回[公司是平等:公司];}) 。地图(^(作者* A){返回⼀一个句柄;}) 。选择(^(字符串* H){返回H =空;}); }
  17. 17. AUTRE FONCTIONS UTILES • select, map, slice • groupBy • first, any, sort • flatMap • …
  18. 18. DU POUR ET DU CONTRE… • Philosophie ou manière de penser différente • Lourde barrière à l’entrée, mais peut s’avérer plus claire : • À l’écriture, à la relecture et à la maintenance • Favorise les variables immuables (immutable) • Vous ouvre au fonctionnel… et au map-reduce
  19. 19. DES QUESTIONS ? DES REMARQUES ? DES AVIS ?
  20. 20. MERCI LES AMIS… Mathieu Godart — @MonsieurDart Jeudi 10 septembre 2015 @ CocoaHeads

×