Upgrade to Pro — share decks privately, control downloads, hide ads and more …

'Code Smells - Developing Design Sense for your Code' by Llewellyn Falco

'Code Smells - Developing Design Sense for your Code' by Llewellyn Falco

'In order to make delicious food,you must eat delicious food…. you need to develop a palate capable of discerning good and bad. Without good taste, you can't make good food.' - Jiro Ono (World’s Best Sushi Chef). The same is true for great code. If we want to make great code we need a refined palate for what great code looks like. We need to look at code and develop a sense for it’s properties and smells. Sadly this is rarely ever done. Programmers are expected to just 'know' what is good and what is bad with ever getting a chance to develop and curate an aesthetic sense. Worse, code is rarely looked at unless it is causing us problems so we are expected to be gourmets while spending our time eating at McDonalds. Come work on your sense of code. We will look at many snippets to compare and contrast different aspects of what good code is. Learning Outcomes: How to identify and correct, Clutter, Long lines, Long Methods, Bad Names, Duplication, Inconsistency.

Related slides:
* https://speakerdeck.com/agilelatvia/code-smells-developing-design-sense-for-your-code-sparrows-song-and-house-by-llewellyn-falco
* https://speakerdeck.com/agilelatvia/code-smells-developing-design-sense-for-your-code-bad-names-by-llewellyn-falco
* https://speakerdeck.com/agilelatvia/code-smells-developing-design-sense-for-your-code-clutter-by-llewellyn-falco
* https://speakerdeck.com/agilelatvia/code-smells-developing-design-sense-for-your-code-duplication-by-llewellyn-falco
* https://speakerdeck.com/agilelatvia/code-smells-developing-design-sense-for-your-code-inconsistency-by-llewellyn-falco
* https://speakerdeck.com/agilelatvia/code-smells-developing-design-sense-for-your-code-longlines-by-llewellyn-falco

Link: http://agiledayriga.lv/index.html#session13

Agile Latvia

July 07, 2017
Tweet

More Decks by Agile Latvia

Other Decks in Technology

Transcript

  1. Accounts_Receivable Balance_Sheet Cost_of_Goods Expenses Liabilities_2010 Present_Value Profit_And_Loss Outstanding_Invoices Accounts_Receivable_2010 Balance_Sheet_2010

    Cost_of_Goods_2010 Expenses_2010 Liabilities Present_Value_2010 Profit_And_Loss_2010 Outstanding_Invoices_2010 Accounts_Receivable_2010 Balance_Sheet_2010 Cost_of_Goods_2010 Expenses_2010 Liabilities Present_Value_2010 Profit_And_Loss_2010 Outstanding_Invoices_2010
  2. Long Methods // If a license key has been located...

    if (licenseKey != null) { // Decrypt licenseKey = ActiproLicenseProvider.DecryptString(licenseKey, encryptionKey); // Find the licensee and license key string[] licenseKeyData = licenseKey.Split(new Char[] { ';' }); if (BrowserInteropHelper.IsBrowserHosted) { // XBAP licensing uses required assembly / licensee / license key // Ensure that the specified assembly is in the AppDomain string requiredAssemblyName = licenseKeyData[0].Trim(); Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); bool assemblyFound = false; foreach (Assembly loadedAssembly in assemblies) { if (loadedAssembly.FullName.StartsWith(requiredAssemblyName + ",", StringCompari assemblyFound = true; break; } } if ((assemblyFound) && (plainTextLicensee == licenseKeyData[2]) && (String.Compare // Assembly was found so use license data licensee = licenseKeyData[2]; licenseKey = licenseKeyData[1]; sourceLocation = ActiproLicenseSourceLocation.AssemblySavedContext; } } else { // Regular licensing just uses licensee / license key licensee = licenseKeyData[1]; licenseKey = licenseKeyData[0]; sourceLocation = ActiproLicenseSourceLocation.AssemblySavedContext;
  3. @LlewellynFalco DoSomething EvilTo Database() Foo() ParseXml AndStoreFlight ToDatabase AndLocalCache AndStart

    Processing() StoreFlight ToDatabase AndStart Processing() Begin Tracking Flight() Intent Honest Honest & Complete Does the Right Thing Domain Abstraction Monitoring Panel .Add(flight) The 7 stages of naming Start Structural Refactoring By ArloBelshee Missing Nonsense
  4. @LlewellynFalco Foo() Missing Nonsense // If a license key has

    been located... if (licenseKey != null) { // Decrypt licenseKey = ActiproLicenseProvider.DecryptString(licenseKey, encryptionKey); // Find the licensee and license key string[] licenseKeyData = licenseKey.Split(new Char[] { ';' }); if (BrowserInteropHelper.IsBrowserHosted) { // XBAP licensing uses required assembly / licensee / license key // Ensure that the specified assembly is in the AppDomain string requiredAssemblyName = licenseKeyData[0].Trim(); Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); bool assemblyFound = false; foreach (Assembly loadedAssembly in assemblies) { if (loadedAssembly.FullName.StartsWith(requiredAssemblyName + ",", StringCompari assemblyFound = true; break; } } if ((assemblyFound) && (plainTextLicensee == licenseKeyData[2]) && (String.Compare // Assembly was found so use license data licensee = licenseKeyData[2]; licenseKey = licenseKeyData[1]; sourceLocation = ActiproLicenseSourceLocation.AssemblySavedContext; } } else { // Regular licensing just uses licensee / license key licensee = licenseKeyData[1]; licenseKey = licenseKeyData[0]; sourceLocation = ActiproLicenseSourceLocation.AssemblySavedContext; } The 7 stages of naming
  5. @LlewellynFalco ParseXml AndStoreFlight ToDatabase AndLocalCache AndStart Processing() The 7 stages

    of naming Honest Honest & Complete DoSomething EvilTo Database()
  6. @LlewellynFalco StoreFlight ToDatabase AndStart Processing() The 7 stages of naming

    Honest & Complete Does the Right Thing Start Structural Refactoring ParseXml AndStoreFlight ToDatabase AndLocalCache AndStart Processing()
  7. @LlewellynFalco The 7 stages of naming Intent Does the Right

    Thing StoreFlight ToDatabase AndStart Processing() Begin Tracking Flight()
  8. @LlewellynFalco The 7 stages of naming Intent Domain Abstraction Begin

    Tracking Flight() Monitoring Panel .Add(flight)
  9. @LlewellynFalco DoSomething EvilTo Database() Foo() ParseXml AndStoreFlight ToDatabase AndLocalCache AndStart

    Processing() StoreFlight ToDatabase AndStart Processing() Begin Tracking Flight() Intent Honest Honest & Complete Does the Right Thing Domain Abstraction Monitoring Panel .Add(flight) The 7 stages of naming Start Structural Refactoring By ArloBelshee Missing Nonsense