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.

Name Stuff

683 views

Published on

Naming stuff is one of the two hard things in Computer Science. And we fail at it every time we create another Manager or Service, or when we follow "framework conventions". Those of us living in OOP world desperately need better abstractions. And Functional Programming is no panacea since we still need DDD practices to guide our design. Regardless of your background, this talk is designed to help you improve your names and naming habits. No need to reinvent the wheel - let's borrow ideas from Eric Evans, Uncle Bob, Kent Beck and other experts.

Published in: Software
  • Be the first to comment

Name Stuff

  1. 1. Name Stuff Osvaldas Grigas » @ogrigas » ogrigas@gmail.com
  2. 2. Source: https://commons.wikimedia.org/wiki/File:Atelier_Fantasticit%C3%A9_Cr%C3%A9ation_d%27une_Ville_en_l%C3 %A9go_%C3%A0_Lille_Gare_Saint-Sauveur,_en_mai_2016a_01.jpg
  3. 3. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook. Ook. Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook. Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook. Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook. Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook. Ook. Ook? Ook. Ook? Ook. Ook. Ook! Ook. Source: https://esolangs.org/wiki/Ook! https://en.wikipedia.org/wiki/Orangutan
  4. 4. Source: https://www.rosettacode.org/wiki/Hello_world/Text https://en.wikipedia.org/wiki/Electronic_delay_storage_automatic_calculator T64K GK O13@ O14@ O15@ O16@ O17@ O18@ O19@ O20@ O21@ O22@ O23@ O24@ ZF *F HF EF LF LF OF !F WF OF RF LF DF EZPF
  5. 5. Source: https://en.wikipedia.org/wiki/Assembly_language
  6. 6. Source: https://en.wikipedia.org/wiki/George_W._Bush
  7. 7. Source: http://wiki.c2.com/?XpSimplicityRules
  8. 8. Source: http://martinfowler.com/bliki/TwoHardThings.html Phil Karlton There are only two hard things in Computer Science: » cache invalidation » and naming things
  9. 9. Length of name
  10. 10. Java: URL .NET: SR PHP: dl
  11. 11. Java: MemberSubmissionAddressingWSDLParserExtension .NET: IDataGridColumnStyleEditingNotificationService PHP: xml_set_processing_instruction_handler
  12. 12. "... when each routine you read turns out to be pretty much what you expected." -- Ward Cunningham Source: https://en.wikipedia.org/wiki/Ward_Cunningham
  13. 13. Noise
  14. 14. "Noise words are redundant. How is NameString better than Name?"
  15. 15. ● ● ● ●
  16. 16. Operation op = new OperationImpl(); op.setType(OperationType.DEBIT); op.setAmount(50); op.setCurrency("EUR"); balance = balanceService.process(balance, op); return balance.getAmount() < 0;
  17. 17. Operation op = new OperationImpl(); op.setType(OperationType.DEBIT); op.setAmount(50); op.setCurrency("EUR"); balance = balanceService.process(balance, op); return balance.getAmount() < 0; balance.after(Debit.of(50, "EUR")).isNegative()
  18. 18. Abstractions
  19. 19. { Object process(Object input); } interface ObjectProcessingService // This service is supposed to be used // in the context of ........................ // ......................................
  20. 20. SetRatingToZeroWhenNoOrdersInTheLastYear(product) ResetOutdatedRating(product)
  21. 21. Object VS. UserService VS. UserAuthentication VS. LdapAuthentication VS. ActiveDirectoryAuthentication
  22. 22. Name the abstraction after the role it fulfils for its consumers Name the concretion after its reason to change
  23. 23. "A class should have only one reason to change." -- Uncle Bob Source: https://en.wikipedia.org/wiki/Robert_Cecil_Martin
  24. 24. EierLegendeWollMilchSau Source: https://commons.wikimedia.org/wiki/File:Wollmilchsau.png FarmService
  25. 25. Source: https://en.wikipedia.org/wiki/Weasel_word "... create an impression that something specific and meaningful has been said, when in fact only a vague or ambiguous claim has been communicated" -- Wikipedia
  26. 26. AccountService AccountManager AccountHandler AccountProcessor AccountUtils AccountHelper AccountData AccountDTO AccountInfo AccountItem AccountDetails AccountObject CustomAccount DefaultAccount AbstractAccount BaseAccount SimpleAccount SmartAccount
  27. 27. AccountWhatever AccountWhatever AccountWhatever AccountWhatever AccountWhatever AccountWhatever AccountWhatever AccountWhatever AccountWhatever AccountWhatever AccountWhatever AccountWhatever WhateverAccount WhateverAccount WhateverAccount WhateverAccount WhateverAccount WhateverAccount
  28. 28. Yoda • A long time ago Bad naming leads to bad choices. Bad choices lead to bad design. Bad design leads to bad naming.
  29. 29. Bad choices Bad design Bad naming
  30. 30. Better choices Simple design Good naming
  31. 31. SmsMessageSender.sendMessage(SmsMessage msg) SmsChannel.send(SmsMessage msg)
  32. 32. a_function_is_all_you_need()
  33. 33. Domain modeling
  34. 34. "Describe scenarios out loud using the elements and interactions of the model." -- Eric Evans
  35. 35. "When user changes its username, we SetUsername in UserData and Save it by UserDAO." VS. "When user changes its username, we ChangeUsername in UserRepository." VS. "When user changes its username, we Store a UsernameChanged event to EventQueue."
  36. 36. "Listen to the language the domain experts use." "Use the same language in diagrams, writing, and especially speech." -- Eric Evans
  37. 37. AccountOperationsService CreditAndDebitLog Ledger
  38. 38. "If a developer must consider the implementation of a component in order to use it, the value of encapsulation is lost." -- Eric Evans
  39. 39. get_result() get_sum_of_debits_and_credits() calculate_balance()
  40. 40. ● AbstractInterceptorDrivenBeanDefinitionDecorator ● SimpleRemoteStatelessSessionProxyFactoryBean ● TransactionAwarePersistenceManagerFactoryProxy ● SimpleBeanFactoryAwareAspectInstanceFactory
  41. 41. " We prefer not to name classes or interfaces after patterns; what matters to us is their relationship to other classes in the system."
  42. 42. To recap ● ● ● ● ● ●
  43. 43. Source: https://en.wikipedia.org/wiki/Herd
  44. 44. Osvaldas Grigas » @ogrigas » ogrigas@gmail.com Q&A

×