SlideShare a Scribd company logo
CODE CRIME SCENEVERSION 1.2
Paweł Klimczyk
Gemotial 2017
About me
■ Software engineer
■ Running Gemotial Software Studio
■ Co-organizer of WrocNET
■ Blog: http://blog.klimczyk.pl
■ Contact:
– Twitter: @pwlklm
– Mail: pawel@klimczyk.pl
What is a crime scene? (1)
■ Duplicate Code
■ Long Method
■ Comments
■ Long Parameter List
■ Large Class
■ Switch Statements
■ Parallel Inheritance Hierarchies
■ Conditional Complexity
■ Combinitorial Explosion
■ Uncommunicative Name
■ Dead Code
■ Inconsistent Names
■ Temporary Field
What is a crime scene? (2)
■ AlternativeClasses with
Different Interfaces
■ Primitive ObsessionData
Class
■ Data Clumps
■ Refused Bequest
■ Inappropriate Intimacy
■ Indecent Exposure
■ Feature Envy
■ Lazy Class
■ Message Chains
■ Middle Man
■ DivergentChange
■ Shotgun Surgery
■ Parallel Inheritance
Hierarchies
■ Incomplete Library Class
■ Solution Sprawl
Crime scene samples – code level
Crime scene samples – class level
Crime scene samples – SOLID violation
Crime scene samples – multiple test
assertions
SmartStore.NET introduction
https://github.com/smartstoreag/SmartStoreNET
SmartStore.NET is a free, open source, full-featured e-commerce solution for
companies of any size. It is web standards compliant and incorporates the
newest Microsoft web technology stack.
SmartStore.NET includes all essential features to create multilingual and multi-
currency stores targeting desktop or mobile devices and enabling SEO
optimized rich product catalogs with support for an unlimited number of
products and categories, variants, bundles, datasheets, ESD, discounts, coupons
and many more.
The state-of-the-art architecture of SmartStore.NET - with ASP.NET 4.5 + MVC
5, Entity Framework 6 and Domain Driven Design approach - makes it easy to
extend, extremely flexible and essentially fun to work with ;-)
SmartStore.NET production deployments
■ http://2stonedshop.de/
■ http://indo-divers.de/
■ http://www.adr-shop.com/
■ http://www.mobilesat.co.uk/
trendspro.builtwith.com
+500 online stores
SmartStore.NET Screen (1)
SmartStore.NET Screen (2)
SmartStore.NET Screen (3)
CodeBase Stats (June 2016)
Finding the crime
How to find
code crime in
project ?
Code crime scene (Ndepend)
•Dependency graph
•Dependency matrix
•LINQ queries
•Code quality metrics (+custom)
•More…
NDepend – Project overview
NDepend – Dependency diagram
NDepend – Dependency matrix
NDepend – Metricts
NDepend – Cyclomatic complexity
NDepend – SOLID violation (S)
NDepend – SOLID violation (I)
NDepend – Code coverage
NDepend – Coupling
NDepend – GC.Collect
June – October 2016 compare
Source control systems – measure behavior
* 1a660f0 | (HEAD -> master, origin/master, origin/HEAD) dd (Fri May 13 17:03:40 2016) [User1]
* dfcd431 | screenshots attepmt 2 (Fri May 13 16:59:35 2016) [User1]
* f29f63e | Apropriate screenshotting added (Fri May 13 16:54:46 2016) [User1]
* 9203bdb | disabled native events for IE (Fri May 13 16:38:44 2016) [User1]
* 45a6f12 | More setting for screenshots (Fri May 13 15:13:36 2016) [User1]
* 690180c | IE only (Fri May 13 15:01:22 2016) [User1]
* b687d21 | ScreenShots added (Fri May 13 15:00:51 2016) [User1]
* f98748f | Added waiting for page fully loaded (Fri May 13 14:44:48 2016) [User1]
* 2f15015 | Wait till page fully loaded for IE (Fri May 13 11:46:25 2016) [User1]
* 46dafc1 | Enabled IE and Chrome (Fri May 13 11:23:21 2016) [User1]
* 4faa96c | eliminated reposting form twice (Fri May 13 11:13:15 2016) [User1]
* ea6e879 | Improved user profile edit tests (Fri May 13 10:53:38 2016) [User1]
* 83f2f28 | removed retry forTestLauncher (Fri May 13 10:32:31 2016) [User1]
* ff0e1ff | Changed retry count and added message text for asserts (Fri May 13 10:25:13 2016) [User1]
* 2f27e2a |Temporary disabled most of the tests to (Fri May 13 10:08:46 2016) [User1]
* b6dcb02 | FireFox enabled for tests (Thu May 12 14:02:29 2016) [User1]
Code maat - introduction
Features:
■ Analize GIT/SVN history
■ Command line tool
■ Various analizers
■ CSV output
■ Open source
Work flow:
Git log….
Parse log with code maat
Generate graph from csv
Code maat – sample
entity,n-authors,n-revs
src/Presentation/SmartStore.Web/Controllers/ShoppingCartController.cs,4,14
src/Plugins/SmartStore.PayPal/Providers/PayPalExpressProvider.cs,4,6
src/Libraries/SmartStore.Services/Catalog/Importer/ProductImporter.cs,3,48
src/Presentation/SmartStore.Web/Administration/Controllers/ImportController.cs,3,38
src/Libraries/SmartStore.Services/Catalog/Importer/CategoryImporter.cs,3,35
src/Presentation/SmartStore.Web/Administration/Controllers/ExportController.cs,3,31
src/Libraries/SmartStore.Data/Migrations/201601262000441_ImportFramework1.cs,3,30
src/Libraries/SmartStore.Services/Customers/Importer/CustomerImporter.cs,3,29
java -jar code-maat-0.8.5-standalone.jar -l log_file.log -c git -a authors
Code maat – hot files
entity n.authors n.revs
src/Libraries/SmartStore.Services/Catalog/Importer/ProductImporter.cs 3 48
src/Presentation/SmartStore.Web/Administration/Controllers/ImportController.cs 3 38
src/Libraries/SmartStore.Services/Catalog/Importer/CategoryImporter.cs 3 35
src/Presentation/SmartStore.Web/Administration/Controllers/ExportController.cs 3 31
src/Libraries/SmartStore.Data/Migrations/201601262000441_ImportFramework1.cs 3 30
src/Libraries/SmartStore.Services/Customers/Importer/CustomerImporter.cs 3 29
src/Libraries/SmartStore.Data/Migrations/201512151526290_ImportFramework.cs 2 28
src/Libraries/SmartStore.Data/Migrations/201603121451066_ThirdPartyEmailHandOver.cs 2 21
src/Plugins/SmartStore.PayPal/Localization/resources.en-us.xml 3 20
src/Plugins/SmartStore.PayPal/Localization/resources.de-de.xml 3 20
src/Plugins/SmartStore.PayPal/Services/PayPalService.cs 1 20
src/Libraries/SmartStore.Services/DataExchange/Export/DataExporter.cs 3 19
src/Libraries/SmartStore.Services/DataExchange/Import/DataImporter.cs 3 19
src/Libraries/SmartStore.Services/DataExchange/Import/ImportRow.cs 3 18
src/Presentation/SmartStore.Web/Administration/Views/Import/_ColumnMappings.cshtml 3 18
src/Presentation/SmartStore.Web/Administration/Views/Import/_CreateOrUpdate.cshtml 1 18
src/Presentation/SmartStore.Web/Administration/Controllers/ProductController.cs 2 16
src/Presentation/SmartStore.Web/Administration/Models/DataExchange/ImportProfileModel.cs 2 16
src/Presentation/SmartStore.Web/Controllers/CommonController.cs 2 15
src/Presentation/SmartStore.Web/Scripts/smartstore.entityPicker.js 2 15
Code maat – Author importance
0
20000
40000
60000
80000
100000
120000
Christian Oliff James Bright Marcus Gesing Michael Herzog Murat Cakir
Authors importance 2016
added deleted diff
Code maat – module ownership
5956 2449
226
6
10053
3747
32
7040
1604
0
90351
3662
0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
Marcus Gesing
Murat Cakir
Michael Herzog
src/Plugins/SmartStore.AmazonPay src/Plugins/SmartStore.Clickatell src/Plugins/SmartStore.DevTools
src/Plugins/SmartStore.DiscountRules src/Plugins/SmartStore.FacebookAuth src/Plugins/SmartStore.GoogleAnalytics
src/Plugins/SmartStore.GoogleMerchantCenter src/Plugins/SmartStore.OfflinePayment src/Plugins/SmartStore.Shipping
src/Plugins/SmartStore.ShippingByWeight src/Plugins/SmartStore.Tax src/Plugins/SmartStore.WebApi
src/Libraries/SmartStore.Core src/Libraries/SmartStore.Data src/Libraries/SmartStore.Services
src/Libraries/SmartStore.Services/Catalog src/Libraries/SmartStore.Services/Common src/Libraries/SmartStore.Services/DataExchange
src/Libraries/SmartStore.Services/Localization src/Libraries/SmartStore.Services/Messages src/Libraries/SmartStore.Services/Orders
src/Libraries/SmartStore.Services/Payments src/Libraries/SmartStore.Services/Shipping src/Libraries/SmartStore.Services/Tasks
src/Libraries/SmartStore.Services/Customers src/Libraries/SmartStore.Services/Configuration src/Libraries/SmartStore.Core/Utilities
src/Libraries/SmartStore.Core/Logging src/Libraries/SmartStore.Core/Extensions src/Libraries/SmartStore.Core/Domain
src/Tests/SmartStore.Services.Tests src/Tests/SmartStore.Web.MVC.Tests src/Presentation/SmartStore.Web
src/Presentation/SmartStore.Web.Framework
Code maat – module ownership core
14266
10053
7040
1097
234
535
699
2449
23
5956
90351
3747
1604
1138
723
472
396
226
200
1443662 32 0 0
44
0 6 6 0 22
Marcus Gesing Murat Cakir Michael Herzog
Code maat – code relations
A B C
Functional code Tests code
Other tools
■FxCop
■StyleCop
■R#
■SonarQube
■CodeCity
Arguments for boss
Hard data
provided by
engineering
tools speaks for
itself
Key outcome
■Everything can be measured
■Use suitable tools
■Provide hard data
■Programming triangle: correctness,
readability, performance
References
■ NDepend http://www.ndepend.com/
■ Code Maat https://github.com/adamtornhill/code-maat
■ Book https://pragprog.com/book/atcrime/your-code-as-a-
crime-scene
■ FxCop https://msdn.microsoft.com/en-
us/library/bb429476(v=vs.80).aspx
■ R# https://www.jetbrains.com/resharper/ (and other
similarVS plugins)
Thank you!
Blog: http://blog.klimczyk.pl
Contact:
Twitter: @pwlklm
Mail: pawel@klimczyk.pl

More Related Content

Viewers also liked

Product Roadmap vs Development
Product Roadmap vs DevelopmentProduct Roadmap vs Development
Product Roadmap vs DevelopmentPawel Klimczyk
 
ADJECTIVES ENDING IN ED & ING 1
ADJECTIVES ENDING IN ED & ING 1ADJECTIVES ENDING IN ED & ING 1
ADJECTIVES ENDING IN ED & ING 1Vanesa
 
Adjectives ending in ed and ing
Adjectives ending in ed and ingAdjectives ending in ed and ing
Adjectives ending in ed and ingdhiano
 
Beyond the walled garden - the story of how one learner used social media for...
Beyond the walled garden - the story of how one learner used social media for...Beyond the walled garden - the story of how one learner used social media for...
Beyond the walled garden - the story of how one learner used social media for...Helen Crump
 
Crime Story - Narrative Task
Crime Story - Narrative TaskCrime Story - Narrative Task
Crime Story - Narrative TaskHayley_Wilson
 
DESCRIBING PEOPLE 1
DESCRIBING PEOPLE 1DESCRIBING PEOPLE 1
DESCRIBING PEOPLE 1Vanesa
 
Headline Writing
Headline WritingHeadline Writing
Headline Writingmrarmknecht
 
Ed and ing adjectives
Ed and ing adjectivesEd and ing adjectives
Ed and ing adjectiveslovinglondon
 
THE USE OF PRESENT PERFECT
THE USE OF PRESENT PERFECTTHE USE OF PRESENT PERFECT
THE USE OF PRESENT PERFECTTEDDYBEAR2621
 
Picture description
Picture descriptionPicture description
Picture descriptionMonica Reig
 
Adjectives on -ed or -ing (excited/exciting)
Adjectives on -ed or -ing (excited/exciting)Adjectives on -ed or -ing (excited/exciting)
Adjectives on -ed or -ing (excited/exciting)Caroline Declerck
 

Viewers also liked (20)

Product Roadmap vs Development
Product Roadmap vs DevelopmentProduct Roadmap vs Development
Product Roadmap vs Development
 
ADJECTIVES ENDING IN ED & ING 1
ADJECTIVES ENDING IN ED & ING 1ADJECTIVES ENDING IN ED & ING 1
ADJECTIVES ENDING IN ED & ING 1
 
Time expressions
Time expressionsTime expressions
Time expressions
 
Inspiring films
Inspiring filmsInspiring films
Inspiring films
 
Adjectives ending in ed and ing
Adjectives ending in ed and ingAdjectives ending in ed and ing
Adjectives ending in ed and ing
 
Crime vocabulary
Crime vocabularyCrime vocabulary
Crime vocabulary
 
Vocabulary crime
Vocabulary crimeVocabulary crime
Vocabulary crime
 
Beyond the walled garden - the story of how one learner used social media for...
Beyond the walled garden - the story of how one learner used social media for...Beyond the walled garden - the story of how one learner used social media for...
Beyond the walled garden - the story of how one learner used social media for...
 
Crime Story - Narrative Task
Crime Story - Narrative TaskCrime Story - Narrative Task
Crime Story - Narrative Task
 
Adverbs
AdverbsAdverbs
Adverbs
 
DESCRIBING PEOPLE 1
DESCRIBING PEOPLE 1DESCRIBING PEOPLE 1
DESCRIBING PEOPLE 1
 
Vocabulary crime
Vocabulary crimeVocabulary crime
Vocabulary crime
 
Headline Writing
Headline WritingHeadline Writing
Headline Writing
 
Adjectives ending in ed or -ing
Adjectives ending in  ed or -ingAdjectives ending in  ed or -ing
Adjectives ending in ed or -ing
 
Expressions of Time (Part 1)
Expressions of Time (Part 1) Expressions of Time (Part 1)
Expressions of Time (Part 1)
 
Ed and ing adjectives
Ed and ing adjectivesEd and ing adjectives
Ed and ing adjectives
 
THE USE OF PRESENT PERFECT
THE USE OF PRESENT PERFECTTHE USE OF PRESENT PERFECT
THE USE OF PRESENT PERFECT
 
Adverbs
AdverbsAdverbs
Adverbs
 
Picture description
Picture descriptionPicture description
Picture description
 
Adjectives on -ed or -ing (excited/exciting)
Adjectives on -ed or -ing (excited/exciting)Adjectives on -ed or -ing (excited/exciting)
Adjectives on -ed or -ing (excited/exciting)
 

Similar to Code Crime Scene

Proactive monitoring tools or services - Open Source
Proactive monitoring tools or services - Open Source Proactive monitoring tools or services - Open Source
Proactive monitoring tools or services - Open Source B.A.
 
Shall we play a game?
Shall we play a game?Shall we play a game?
Shall we play a game?Maciej Lasyk
 
Next Generation Vulnerability Assessment Using Datadog and Snyk
Next Generation Vulnerability Assessment Using Datadog and SnykNext Generation Vulnerability Assessment Using Datadog and Snyk
Next Generation Vulnerability Assessment Using Datadog and SnykDevOps.com
 
Automated Malware Analysis and Cyber Security Intelligence
Automated Malware Analysis and Cyber Security IntelligenceAutomated Malware Analysis and Cyber Security Intelligence
Automated Malware Analysis and Cyber Security IntelligenceJason Choi
 
Sandbox kiev
Sandbox kievSandbox kiev
Sandbox kievuisgslide
 
Hacker Halted 2014 - Why Botnet Takedowns Never Work, Unless It’s a SmackDown!
Hacker Halted 2014 - Why Botnet Takedowns Never Work, Unless It’s a SmackDown!Hacker Halted 2014 - Why Botnet Takedowns Never Work, Unless It’s a SmackDown!
Hacker Halted 2014 - Why Botnet Takedowns Never Work, Unless It’s a SmackDown!EC-Council
 
Go Is Your Next Language — Sergii Shapoval
Go Is Your Next Language — Sergii ShapovalGo Is Your Next Language — Sergii Shapoval
Go Is Your Next Language — Sergii ShapovalGlobalLogic Ukraine
 
I got 99 trends and a # is all of them
I got 99 trends and a # is all of themI got 99 trends and a # is all of them
I got 99 trends and a # is all of themRoberto Suggi Liverani
 
Application Server-less Web Applications - Serverless Toronto Meetup Intro
Application Server-less Web Applications - Serverless Toronto Meetup IntroApplication Server-less Web Applications - Serverless Toronto Meetup Intro
Application Server-less Web Applications - Serverless Toronto Meetup IntroDaniel Zivkovic
 
Container con toronto
Container con torontoContainer con toronto
Container con torontoDan Lambright
 
YOW2018 Cloud Performance Root Cause Analysis at Netflix
YOW2018 Cloud Performance Root Cause Analysis at NetflixYOW2018 Cloud Performance Root Cause Analysis at Netflix
YOW2018 Cloud Performance Root Cause Analysis at NetflixBrendan Gregg
 
Monitoring as Code: Getting to Monitoring-Driven Development - DEV314 - re:In...
Monitoring as Code: Getting to Monitoring-Driven Development - DEV314 - re:In...Monitoring as Code: Getting to Monitoring-Driven Development - DEV314 - re:In...
Monitoring as Code: Getting to Monitoring-Driven Development - DEV314 - re:In...Amazon Web Services
 
Building a data pipeline to ingest data into Hadoop in minutes using Streamse...
Building a data pipeline to ingest data into Hadoop in minutes using Streamse...Building a data pipeline to ingest data into Hadoop in minutes using Streamse...
Building a data pipeline to ingest data into Hadoop in minutes using Streamse...Guglielmo Iozzia
 
Cloud native IPC for Microservices Workshop @ Containerdays 2022
Cloud native IPC for Microservices Workshop @ Containerdays 2022Cloud native IPC for Microservices Workshop @ Containerdays 2022
Cloud native IPC for Microservices Workshop @ Containerdays 2022QAware GmbH
 
AktaionPPTv5_JZedits
AktaionPPTv5_JZeditsAktaionPPTv5_JZedits
AktaionPPTv5_JZeditsRod Soto
 
HTTP(S)-Based Clustering for Assisted Cybercrime Investigations
 HTTP(S)-Based Clustering for Assisted Cybercrime Investigations HTTP(S)-Based Clustering for Assisted Cybercrime Investigations
HTTP(S)-Based Clustering for Assisted Cybercrime InvestigationsMarco Balduzzi
 
Building next gen malware behavioural analysis environment
Building next gen malware behavioural analysis environment Building next gen malware behavioural analysis environment
Building next gen malware behavioural analysis environment isc2-hellenic
 
Detecting Hacks: Anomaly Detection on Networking Data
Detecting Hacks: Anomaly Detection on Networking DataDetecting Hacks: Anomaly Detection on Networking Data
Detecting Hacks: Anomaly Detection on Networking DataJames Sirota
 
Timing attacks against web applications: Are they still practical?
Timing attacks against web applications: Are they still practical?Timing attacks against web applications: Are they still practical?
Timing attacks against web applications: Are they still practical?DefCamp
 

Similar to Code Crime Scene (20)

Proactive monitoring tools or services - Open Source
Proactive monitoring tools or services - Open Source Proactive monitoring tools or services - Open Source
Proactive monitoring tools or services - Open Source
 
Shall we play a game?
Shall we play a game?Shall we play a game?
Shall we play a game?
 
Next Generation Vulnerability Assessment Using Datadog and Snyk
Next Generation Vulnerability Assessment Using Datadog and SnykNext Generation Vulnerability Assessment Using Datadog and Snyk
Next Generation Vulnerability Assessment Using Datadog and Snyk
 
Automated Malware Analysis and Cyber Security Intelligence
Automated Malware Analysis and Cyber Security IntelligenceAutomated Malware Analysis and Cyber Security Intelligence
Automated Malware Analysis and Cyber Security Intelligence
 
Sandbox kiev
Sandbox kievSandbox kiev
Sandbox kiev
 
Hacker Halted 2014 - Why Botnet Takedowns Never Work, Unless It’s a SmackDown!
Hacker Halted 2014 - Why Botnet Takedowns Never Work, Unless It’s a SmackDown!Hacker Halted 2014 - Why Botnet Takedowns Never Work, Unless It’s a SmackDown!
Hacker Halted 2014 - Why Botnet Takedowns Never Work, Unless It’s a SmackDown!
 
Go Is Your Next Language — Sergii Shapoval
Go Is Your Next Language — Sergii ShapovalGo Is Your Next Language — Sergii Shapoval
Go Is Your Next Language — Sergii Shapoval
 
I got 99 trends and a # is all of them
I got 99 trends and a # is all of themI got 99 trends and a # is all of them
I got 99 trends and a # is all of them
 
Application Server-less Web Applications - Serverless Toronto Meetup Intro
Application Server-less Web Applications - Serverless Toronto Meetup IntroApplication Server-less Web Applications - Serverless Toronto Meetup Intro
Application Server-less Web Applications - Serverless Toronto Meetup Intro
 
Container con toronto
Container con torontoContainer con toronto
Container con toronto
 
YOW2018 Cloud Performance Root Cause Analysis at Netflix
YOW2018 Cloud Performance Root Cause Analysis at NetflixYOW2018 Cloud Performance Root Cause Analysis at Netflix
YOW2018 Cloud Performance Root Cause Analysis at Netflix
 
Monitoring as Code: Getting to Monitoring-Driven Development - DEV314 - re:In...
Monitoring as Code: Getting to Monitoring-Driven Development - DEV314 - re:In...Monitoring as Code: Getting to Monitoring-Driven Development - DEV314 - re:In...
Monitoring as Code: Getting to Monitoring-Driven Development - DEV314 - re:In...
 
Building a data pipeline to ingest data into Hadoop in minutes using Streamse...
Building a data pipeline to ingest data into Hadoop in minutes using Streamse...Building a data pipeline to ingest data into Hadoop in minutes using Streamse...
Building a data pipeline to ingest data into Hadoop in minutes using Streamse...
 
Cloud native IPC for Microservices Workshop @ Containerdays 2022
Cloud native IPC for Microservices Workshop @ Containerdays 2022Cloud native IPC for Microservices Workshop @ Containerdays 2022
Cloud native IPC for Microservices Workshop @ Containerdays 2022
 
Monitoring in 2017 - TIAD Camp Docker
Monitoring in 2017 - TIAD Camp DockerMonitoring in 2017 - TIAD Camp Docker
Monitoring in 2017 - TIAD Camp Docker
 
AktaionPPTv5_JZedits
AktaionPPTv5_JZeditsAktaionPPTv5_JZedits
AktaionPPTv5_JZedits
 
HTTP(S)-Based Clustering for Assisted Cybercrime Investigations
 HTTP(S)-Based Clustering for Assisted Cybercrime Investigations HTTP(S)-Based Clustering for Assisted Cybercrime Investigations
HTTP(S)-Based Clustering for Assisted Cybercrime Investigations
 
Building next gen malware behavioural analysis environment
Building next gen malware behavioural analysis environment Building next gen malware behavioural analysis environment
Building next gen malware behavioural analysis environment
 
Detecting Hacks: Anomaly Detection on Networking Data
Detecting Hacks: Anomaly Detection on Networking DataDetecting Hacks: Anomaly Detection on Networking Data
Detecting Hacks: Anomaly Detection on Networking Data
 
Timing attacks against web applications: Are they still practical?
Timing attacks against web applications: Are they still practical?Timing attacks against web applications: Are they still practical?
Timing attacks against web applications: Are they still practical?
 

More from Pawel Klimczyk

More from Pawel Klimczyk (11)

Wrocnet.meeting.info.20180515.109
Wrocnet.meeting.info.20180515.109Wrocnet.meeting.info.20180515.109
Wrocnet.meeting.info.20180515.109
 
Wrocnet.meeting.info.20180320.107
Wrocnet.meeting.info.20180320.107Wrocnet.meeting.info.20180320.107
Wrocnet.meeting.info.20180320.107
 
Software Quality for Programmers
Software Quality for ProgrammersSoftware Quality for Programmers
Software Quality for Programmers
 
Solid as OOP abstraction
Solid as OOP abstractionSolid as OOP abstraction
Solid as OOP abstraction
 
SOLID for Adults
SOLID for AdultsSOLID for Adults
SOLID for Adults
 
Wrocnet #88
Wrocnet #88Wrocnet #88
Wrocnet #88
 
GeekWeekWro TechSaturdays
GeekWeekWro TechSaturdaysGeekWeekWro TechSaturdays
GeekWeekWro TechSaturdays
 
GeekWeekWro hack4culture
GeekWeekWro hack4cultureGeekWeekWro hack4culture
GeekWeekWro hack4culture
 
Wrocnet #87
Wrocnet #87Wrocnet #87
Wrocnet #87
 
Wrocnet 86
Wrocnet 86Wrocnet 86
Wrocnet 86
 
Wrocnet spotkanie 85
Wrocnet spotkanie 85Wrocnet spotkanie 85
Wrocnet spotkanie 85
 

Recently uploaded

Intelligent Gimbal FINAL PAPER Engineering.pdf
Intelligent Gimbal FINAL PAPER Engineering.pdfIntelligent Gimbal FINAL PAPER Engineering.pdf
Intelligent Gimbal FINAL PAPER Engineering.pdfAnthony Lucente
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka DoktorováCzechDreamin
 
Motion for AI: Creating Empathy in Technology
Motion for AI: Creating Empathy in TechnologyMotion for AI: Creating Empathy in Technology
Motion for AI: Creating Empathy in TechnologyUXDXConf
 
Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKUXDXConf
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekCzechDreamin
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessUXDXConf
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsStefano
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty SecureFemke de Vroome
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1DianaGray10
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomCzechDreamin
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀DianaGray10
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaCzechDreamin
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeCzechDreamin
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsUXDXConf
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...CzechDreamin
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor TurskyiFwdays
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlPeter Udo Diehl
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyUXDXConf
 

Recently uploaded (20)

Intelligent Gimbal FINAL PAPER Engineering.pdf
Intelligent Gimbal FINAL PAPER Engineering.pdfIntelligent Gimbal FINAL PAPER Engineering.pdf
Intelligent Gimbal FINAL PAPER Engineering.pdf
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
Motion for AI: Creating Empathy in Technology
Motion for AI: Creating Empathy in TechnologyMotion for AI: Creating Empathy in Technology
Motion for AI: Creating Empathy in Technology
 
Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAK
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering Teams
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 

Code Crime Scene

  • 1. CODE CRIME SCENEVERSION 1.2 Paweł Klimczyk Gemotial 2017
  • 2. About me ■ Software engineer ■ Running Gemotial Software Studio ■ Co-organizer of WrocNET ■ Blog: http://blog.klimczyk.pl ■ Contact: – Twitter: @pwlklm – Mail: pawel@klimczyk.pl
  • 3. What is a crime scene? (1) ■ Duplicate Code ■ Long Method ■ Comments ■ Long Parameter List ■ Large Class ■ Switch Statements ■ Parallel Inheritance Hierarchies ■ Conditional Complexity ■ Combinitorial Explosion ■ Uncommunicative Name ■ Dead Code ■ Inconsistent Names ■ Temporary Field
  • 4. What is a crime scene? (2) ■ AlternativeClasses with Different Interfaces ■ Primitive ObsessionData Class ■ Data Clumps ■ Refused Bequest ■ Inappropriate Intimacy ■ Indecent Exposure ■ Feature Envy ■ Lazy Class ■ Message Chains ■ Middle Man ■ DivergentChange ■ Shotgun Surgery ■ Parallel Inheritance Hierarchies ■ Incomplete Library Class ■ Solution Sprawl
  • 5. Crime scene samples – code level
  • 6. Crime scene samples – class level
  • 7. Crime scene samples – SOLID violation
  • 8. Crime scene samples – multiple test assertions
  • 9. SmartStore.NET introduction https://github.com/smartstoreag/SmartStoreNET SmartStore.NET is a free, open source, full-featured e-commerce solution for companies of any size. It is web standards compliant and incorporates the newest Microsoft web technology stack. SmartStore.NET includes all essential features to create multilingual and multi- currency stores targeting desktop or mobile devices and enabling SEO optimized rich product catalogs with support for an unlimited number of products and categories, variants, bundles, datasheets, ESD, discounts, coupons and many more. The state-of-the-art architecture of SmartStore.NET - with ASP.NET 4.5 + MVC 5, Entity Framework 6 and Domain Driven Design approach - makes it easy to extend, extremely flexible and essentially fun to work with ;-)
  • 10. SmartStore.NET production deployments ■ http://2stonedshop.de/ ■ http://indo-divers.de/ ■ http://www.adr-shop.com/ ■ http://www.mobilesat.co.uk/ trendspro.builtwith.com +500 online stores
  • 15. Finding the crime How to find code crime in project ?
  • 16. Code crime scene (Ndepend) •Dependency graph •Dependency matrix •LINQ queries •Code quality metrics (+custom) •More…
  • 22. NDepend – SOLID violation (S)
  • 23. NDepend – SOLID violation (I)
  • 24. NDepend – Code coverage
  • 27. June – October 2016 compare
  • 28. Source control systems – measure behavior * 1a660f0 | (HEAD -> master, origin/master, origin/HEAD) dd (Fri May 13 17:03:40 2016) [User1] * dfcd431 | screenshots attepmt 2 (Fri May 13 16:59:35 2016) [User1] * f29f63e | Apropriate screenshotting added (Fri May 13 16:54:46 2016) [User1] * 9203bdb | disabled native events for IE (Fri May 13 16:38:44 2016) [User1] * 45a6f12 | More setting for screenshots (Fri May 13 15:13:36 2016) [User1] * 690180c | IE only (Fri May 13 15:01:22 2016) [User1] * b687d21 | ScreenShots added (Fri May 13 15:00:51 2016) [User1] * f98748f | Added waiting for page fully loaded (Fri May 13 14:44:48 2016) [User1] * 2f15015 | Wait till page fully loaded for IE (Fri May 13 11:46:25 2016) [User1] * 46dafc1 | Enabled IE and Chrome (Fri May 13 11:23:21 2016) [User1] * 4faa96c | eliminated reposting form twice (Fri May 13 11:13:15 2016) [User1] * ea6e879 | Improved user profile edit tests (Fri May 13 10:53:38 2016) [User1] * 83f2f28 | removed retry forTestLauncher (Fri May 13 10:32:31 2016) [User1] * ff0e1ff | Changed retry count and added message text for asserts (Fri May 13 10:25:13 2016) [User1] * 2f27e2a |Temporary disabled most of the tests to (Fri May 13 10:08:46 2016) [User1] * b6dcb02 | FireFox enabled for tests (Thu May 12 14:02:29 2016) [User1]
  • 29. Code maat - introduction Features: ■ Analize GIT/SVN history ■ Command line tool ■ Various analizers ■ CSV output ■ Open source Work flow: Git log…. Parse log with code maat Generate graph from csv
  • 30. Code maat – sample entity,n-authors,n-revs src/Presentation/SmartStore.Web/Controllers/ShoppingCartController.cs,4,14 src/Plugins/SmartStore.PayPal/Providers/PayPalExpressProvider.cs,4,6 src/Libraries/SmartStore.Services/Catalog/Importer/ProductImporter.cs,3,48 src/Presentation/SmartStore.Web/Administration/Controllers/ImportController.cs,3,38 src/Libraries/SmartStore.Services/Catalog/Importer/CategoryImporter.cs,3,35 src/Presentation/SmartStore.Web/Administration/Controllers/ExportController.cs,3,31 src/Libraries/SmartStore.Data/Migrations/201601262000441_ImportFramework1.cs,3,30 src/Libraries/SmartStore.Services/Customers/Importer/CustomerImporter.cs,3,29 java -jar code-maat-0.8.5-standalone.jar -l log_file.log -c git -a authors
  • 31. Code maat – hot files entity n.authors n.revs src/Libraries/SmartStore.Services/Catalog/Importer/ProductImporter.cs 3 48 src/Presentation/SmartStore.Web/Administration/Controllers/ImportController.cs 3 38 src/Libraries/SmartStore.Services/Catalog/Importer/CategoryImporter.cs 3 35 src/Presentation/SmartStore.Web/Administration/Controllers/ExportController.cs 3 31 src/Libraries/SmartStore.Data/Migrations/201601262000441_ImportFramework1.cs 3 30 src/Libraries/SmartStore.Services/Customers/Importer/CustomerImporter.cs 3 29 src/Libraries/SmartStore.Data/Migrations/201512151526290_ImportFramework.cs 2 28 src/Libraries/SmartStore.Data/Migrations/201603121451066_ThirdPartyEmailHandOver.cs 2 21 src/Plugins/SmartStore.PayPal/Localization/resources.en-us.xml 3 20 src/Plugins/SmartStore.PayPal/Localization/resources.de-de.xml 3 20 src/Plugins/SmartStore.PayPal/Services/PayPalService.cs 1 20 src/Libraries/SmartStore.Services/DataExchange/Export/DataExporter.cs 3 19 src/Libraries/SmartStore.Services/DataExchange/Import/DataImporter.cs 3 19 src/Libraries/SmartStore.Services/DataExchange/Import/ImportRow.cs 3 18 src/Presentation/SmartStore.Web/Administration/Views/Import/_ColumnMappings.cshtml 3 18 src/Presentation/SmartStore.Web/Administration/Views/Import/_CreateOrUpdate.cshtml 1 18 src/Presentation/SmartStore.Web/Administration/Controllers/ProductController.cs 2 16 src/Presentation/SmartStore.Web/Administration/Models/DataExchange/ImportProfileModel.cs 2 16 src/Presentation/SmartStore.Web/Controllers/CommonController.cs 2 15 src/Presentation/SmartStore.Web/Scripts/smartstore.entityPicker.js 2 15
  • 32. Code maat – Author importance 0 20000 40000 60000 80000 100000 120000 Christian Oliff James Bright Marcus Gesing Michael Herzog Murat Cakir Authors importance 2016 added deleted diff
  • 33. Code maat – module ownership 5956 2449 226 6 10053 3747 32 7040 1604 0 90351 3662 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% Marcus Gesing Murat Cakir Michael Herzog src/Plugins/SmartStore.AmazonPay src/Plugins/SmartStore.Clickatell src/Plugins/SmartStore.DevTools src/Plugins/SmartStore.DiscountRules src/Plugins/SmartStore.FacebookAuth src/Plugins/SmartStore.GoogleAnalytics src/Plugins/SmartStore.GoogleMerchantCenter src/Plugins/SmartStore.OfflinePayment src/Plugins/SmartStore.Shipping src/Plugins/SmartStore.ShippingByWeight src/Plugins/SmartStore.Tax src/Plugins/SmartStore.WebApi src/Libraries/SmartStore.Core src/Libraries/SmartStore.Data src/Libraries/SmartStore.Services src/Libraries/SmartStore.Services/Catalog src/Libraries/SmartStore.Services/Common src/Libraries/SmartStore.Services/DataExchange src/Libraries/SmartStore.Services/Localization src/Libraries/SmartStore.Services/Messages src/Libraries/SmartStore.Services/Orders src/Libraries/SmartStore.Services/Payments src/Libraries/SmartStore.Services/Shipping src/Libraries/SmartStore.Services/Tasks src/Libraries/SmartStore.Services/Customers src/Libraries/SmartStore.Services/Configuration src/Libraries/SmartStore.Core/Utilities src/Libraries/SmartStore.Core/Logging src/Libraries/SmartStore.Core/Extensions src/Libraries/SmartStore.Core/Domain src/Tests/SmartStore.Services.Tests src/Tests/SmartStore.Web.MVC.Tests src/Presentation/SmartStore.Web src/Presentation/SmartStore.Web.Framework
  • 34. Code maat – module ownership core 14266 10053 7040 1097 234 535 699 2449 23 5956 90351 3747 1604 1138 723 472 396 226 200 1443662 32 0 0 44 0 6 6 0 22 Marcus Gesing Murat Cakir Michael Herzog
  • 35. Code maat – code relations A B C Functional code Tests code
  • 37. Arguments for boss Hard data provided by engineering tools speaks for itself
  • 38. Key outcome ■Everything can be measured ■Use suitable tools ■Provide hard data ■Programming triangle: correctness, readability, performance
  • 39. References ■ NDepend http://www.ndepend.com/ ■ Code Maat https://github.com/adamtornhill/code-maat ■ Book https://pragprog.com/book/atcrime/your-code-as-a- crime-scene ■ FxCop https://msdn.microsoft.com/en- us/library/bb429476(v=vs.80).aspx ■ R# https://www.jetbrains.com/resharper/ (and other similarVS plugins)