SlideShare a Scribd company logo
1 of 20
(c) kevin rutherford 2012
describing the internal quality of software
@kevinrutherford
(c) kevin rutherford 2012
code smells
Primitive Obsession
Feature Envy
Sim
ulated
Polym
orphismLazy Class
Temporary Field
Inappropriate Intimacy
ShotgunSurgery
Data Clump
Long
M
ethod
Large Class
RefusedBequest
(c) kevin rutherford 2012
code smells
Primitive Obsession
Feature Envy
Sim
ulated
Polym
orphismLazy Class
Temporary Field
Inappropriate Intimacy
ShotgunSurgery
Data Clump
Long
M
ethod
Large Class
???
??? ???
???
???
???
???
RefusedBequest
(c) kevin rutherford 2012
connascence
Two software components are connascent
if a change in one would require the other to be modified
in order to maintain the overall correctness of the system.
(c) kevin rutherford 2012
connascence
Connascence of Name
Connascence of Type
Connascence of Meaning
Connascence of Algorithm
Connascence of Position
Connascence of Execution order
Connascence of Timing
Connascence of Value
Connascence of Identity
(c) kevin rutherford 2012
connascence
Connascence of Name
Connascence of Type
Connascence of Meaning
Connascence of Algorithm
Connascence of Position
Connascence of Execution order
Connascence of Timing
Connascence of Value
Connascence of Identity
refactoring should
take the code in
this direction
static code
properties
properties of
running code
(c) kevin rutherford 2012
connascence of name
Two components must agree on the name of something
int count;
count = 10;
public enum Deck {
  SPADES, HEARTS, CLUBS, DIAMONDS
};
card = new Card(3, Deck.HEARTS);
@Override
public String toString() {
  ...
};
(c) kevin rutherford 2012
connascence of type
Two components must agree on the type of something
String var;
var = 10;   // oops!
Writer out = new PrintWriter(f);
@Override
public String toString() {
  ...
};
(c) kevin rutherford 2012
connascence of meaning
Two components must agree on the interpretation of a value
String getSSN() {
  if (ssnIsMissing) {
    return "999­99­9999";
  } else {
    return blah_blah_blah;
  }
}
ssn = getSSN();
if (ssn.equals("999­99­9999")) {
  // handle missing ssn
}
switch (message.getType()) {
case 1:
  return message.sendToAll();
case 2:
  return message.cancel();
default:
  return null;
}
(c) kevin rutherford 2012
connascence of meaning
Two components must agree on the interpretation of a value
String getSSN() {
  if (ssnIsMissing) {
    return "999­99­9999";
  } else {
    return blah_blah_blah;
  }
}
ssn = getSSN();
if (ssn.equals("999­99­9999")) {
  // handle missing ssn
}
switch (message.getType()) {
case 1:
  return message.sendToAll();
case 2:
  return message.cancel();
default:
  return null;
}
(c) kevin rutherford 2012
connascence of algorithm
Two components must agree on a particular algorithm
@Test
public void testFingerprint() {
  String actual = myObj.getFingerprint();
  String expected = DigestUtils.md5Hex(myObj.name);
  assertEquals(expected, actual);
}
(c) kevin rutherford 2012
connascence of position
Two components must be adjacent or occur in a particular order
String names[] = { "Jim", "Helen", "Jenny" };
...
System.out.println("Father: " + names[0]);
System.out.println("Mother: " + names[1]);
System.out.println("Child:  " + names[2]);
Rectangle rect = new Rectangle(23.0, 15.5);
(c) kevin rutherford 2012
connascence of execution order
The order of execution of two components is important
Email email = new Email();
email.setSender(“joe.bloggs”);
//. . .
email.deliver();
(c) kevin rutherford 2012
connascence of timing
Two components must agree on the timing of execution
timeout = 200; // Milliseconds
socket.writeRequest(data);
answer = socket.readResponse(timeout);
(c) kevin rutherford 2012
connascence of value
The values of two components are related
class CircularBuffer {
    private int myHead;
    private int myTail;
    // myHead == myTail    =>  buffer empty
    // myHead+1 == myTail  =>  buffer full
}
(c) kevin rutherford 2012
connascence of identity
Two components must reference the same object
class Producer implements Runnable {
  public static Queue myQueue;
  public void run() {
    myQueue.put(37);
  }
}
class Consumer implements Runnable {
  public void run() {
    int item = Producer.myQueue.get();
    processItem(item);
  }
}
(c) kevin rutherford 2012
connascence of identity
Two components must reference the same object
class Producer implements Runnable {
  public static Queue myQueue;
  public void run() {
    myQueue.put(37);
  }
}
class Consumer implements Runnable {
  public void run() {
    int item = Producer.myQueue.get();
    processItem(item);
  }
}
also connascence
of timing
...and connascence
of type
(c) kevin rutherford 2012
connascence
Connascence of Name
Connascence of Type
Connascence of Meaning
Connascence of Algorithm
Connascence of Position
Connascence of Execution order
Connascence of Timing
Connascence of Value
Connascence of Identity
refactoring should
take the code in
this direction
static code
properties
properties of
running code
(c) kevin rutherford 2012
connascence
Two software components are connascent
if a change in one would require the other to be modified
in order to maintain the overall correctness of the system.
What Every Programmer Should Know About Object Oriented Design,
Meilir Page-Jones, Dorset House Publishing, 1996
Fundamentals of Object-Oriented Design in UML,
Meilir Page-Jones, Addison-Wesley, 1999
(c) kevin rutherford 2012
connascence
Two software components are connascent
if a change in one would require the other to be modified
in order to maintain the overall correctness of the system.
http://onestepback.org/articles/connascence/index.html
Jim Weirich
Connascence as a software design metric
http://blog.rubybestpractices.com/posts/gregory/056-issue-24-connascence.html
Gregory Brown
Grand unified theory of software design,
http://vimeo.com/10837903
Jim Weirich

More Related Content

Viewers also liked

Puppet Camp Sydney 2015: The (Im)perfect Puppet Module
Puppet Camp Sydney 2015: The (Im)perfect Puppet ModulePuppet Camp Sydney 2015: The (Im)perfect Puppet Module
Puppet Camp Sydney 2015: The (Im)perfect Puppet ModulePuppet
 
Using Vagrant, Puppet, Testing & Hadoop
Using Vagrant, Puppet, Testing & HadoopUsing Vagrant, Puppet, Testing & Hadoop
Using Vagrant, Puppet, Testing & HadoopPuppet
 
Puppet Development Workflow
Puppet Development WorkflowPuppet Development Workflow
Puppet Development WorkflowJeffery Smith
 
Devops, Dungeons & Dragons
Devops, Dungeons & Dragons Devops, Dungeons & Dragons
Devops, Dungeons & Dragons David Lutz
 
Puppet - Configuration Management Made Eas(ier)
Puppet - Configuration Management Made Eas(ier)Puppet - Configuration Management Made Eas(ier)
Puppet - Configuration Management Made Eas(ier)Aaron Bernstein
 
Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014Puppet
 
A Introduction of Packer
A Introduction of PackerA Introduction of Packer
A Introduction of PackerFreyr Lin
 
Designing with capabilities (DDD-EU 2017)
Designing with capabilities (DDD-EU 2017)Designing with capabilities (DDD-EU 2017)
Designing with capabilities (DDD-EU 2017)Scott Wlaschin
 
Contagious Messages
Contagious MessagesContagious Messages
Contagious MessageskarenMoyse
 
Compresent pyramid by coon
Compresent pyramid by coonCompresent pyramid by coon
Compresent pyramid by coonCoon Chaiyapruk
 
Recommendation From ABC Industries 2014
Recommendation From ABC Industries 2014Recommendation From ABC Industries 2014
Recommendation From ABC Industries 2014Boyd Breeding
 

Viewers also liked (17)

Puppet Camp Sydney 2015: The (Im)perfect Puppet Module
Puppet Camp Sydney 2015: The (Im)perfect Puppet ModulePuppet Camp Sydney 2015: The (Im)perfect Puppet Module
Puppet Camp Sydney 2015: The (Im)perfect Puppet Module
 
Using Vagrant, Puppet, Testing & Hadoop
Using Vagrant, Puppet, Testing & HadoopUsing Vagrant, Puppet, Testing & Hadoop
Using Vagrant, Puppet, Testing & Hadoop
 
Puppet Development Workflow
Puppet Development WorkflowPuppet Development Workflow
Puppet Development Workflow
 
Devops, Dungeons & Dragons
Devops, Dungeons & Dragons Devops, Dungeons & Dragons
Devops, Dungeons & Dragons
 
Puppet - Configuration Management Made Eas(ier)
Puppet - Configuration Management Made Eas(ier)Puppet - Configuration Management Made Eas(ier)
Puppet - Configuration Management Made Eas(ier)
 
Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014
 
Docker
Docker Docker
Docker
 
A Introduction of Packer
A Introduction of PackerA Introduction of Packer
A Introduction of Packer
 
Docker internals
Docker internalsDocker internals
Docker internals
 
Designing with capabilities (DDD-EU 2017)
Designing with capabilities (DDD-EU 2017)Designing with capabilities (DDD-EU 2017)
Designing with capabilities (DDD-EU 2017)
 
Penal especial
Penal especialPenal especial
Penal especial
 
Contagious Messages
Contagious MessagesContagious Messages
Contagious Messages
 
Compresent pyramid by coon
Compresent pyramid by coonCompresent pyramid by coon
Compresent pyramid by coon
 
Recommendation From ABC Industries 2014
Recommendation From ABC Industries 2014Recommendation From ABC Industries 2014
Recommendation From ABC Industries 2014
 
insect legs
insect legsinsect legs
insect legs
 
Dubrovnik Pres
Dubrovnik PresDubrovnik Pres
Dubrovnik Pres
 
conicoid
conicoidconicoid
conicoid
 

Similar to Software Quality Code Smells

Cleaning your architecture with android architecture components
Cleaning your architecture with android architecture componentsCleaning your architecture with android architecture components
Cleaning your architecture with android architecture componentsDebora Gomez Bertoli
 
Make A Shoot ‘Em Up Game with Amethyst Framework
Make A Shoot ‘Em Up Game with Amethyst FrameworkMake A Shoot ‘Em Up Game with Amethyst Framework
Make A Shoot ‘Em Up Game with Amethyst FrameworkYodalee
 
An Introduction To CQRS
An Introduction To CQRSAn Introduction To CQRS
An Introduction To CQRSNeil Robbins
 
1z0 804 exam-java se 7 programmer ii
1z0 804 exam-java se 7 programmer ii1z0 804 exam-java se 7 programmer ii
1z0 804 exam-java se 7 programmer iiIsabella789
 
Java level 1 Quizzes
Java level 1 QuizzesJava level 1 Quizzes
Java level 1 QuizzesSteven Luo
 
Legacy projects: how to win the race
Legacy projects: how to win the raceLegacy projects: how to win the race
Legacy projects: how to win the raceVictor_Cr
 
Deterministic simulation testing
Deterministic simulation testingDeterministic simulation testing
Deterministic simulation testingFoundationDB
 
Navigating the xDD Alphabet Soup
Navigating the xDD Alphabet SoupNavigating the xDD Alphabet Soup
Navigating the xDD Alphabet SoupDror Helper
 
a data driven game object system
a data driven game object systema data driven game object system
a data driven game object systemmaa77
 
Refactoring & Restructuring - Improving the Code and Structure of Software
Refactoring & Restructuring - Improving the Code and Structure of SoftwareRefactoring & Restructuring - Improving the Code and Structure of Software
Refactoring & Restructuring - Improving the Code and Structure of SoftwareCodeOps Technologies LLP
 
Clean Software Design: The Practices to Make The Design Simple
Clean Software Design: The Practices to Make The Design SimpleClean Software Design: The Practices to Make The Design Simple
Clean Software Design: The Practices to Make The Design SimpleLemi Orhan Ergin
 
Java 스터디 강의자료 - 1차시
Java 스터디 강의자료 - 1차시Java 스터디 강의자료 - 1차시
Java 스터디 강의자료 - 1차시Junha Jang
 
Unit test candidate solutions
Unit test candidate solutionsUnit test candidate solutions
Unit test candidate solutionsbenewu
 

Similar to Software Quality Code Smells (16)

Cleaning your architecture with android architecture components
Cleaning your architecture with android architecture componentsCleaning your architecture with android architecture components
Cleaning your architecture with android architecture components
 
Make A Shoot ‘Em Up Game with Amethyst Framework
Make A Shoot ‘Em Up Game with Amethyst FrameworkMake A Shoot ‘Em Up Game with Amethyst Framework
Make A Shoot ‘Em Up Game with Amethyst Framework
 
An Introduction To CQRS
An Introduction To CQRSAn Introduction To CQRS
An Introduction To CQRS
 
JAVASCRIPT CHEAT SHEET PDF
JAVASCRIPT CHEAT SHEET PDFJAVASCRIPT CHEAT SHEET PDF
JAVASCRIPT CHEAT SHEET PDF
 
Object discovery
Object discoveryObject discovery
Object discovery
 
1z0 804 exam-java se 7 programmer ii
1z0 804 exam-java se 7 programmer ii1z0 804 exam-java se 7 programmer ii
1z0 804 exam-java se 7 programmer ii
 
Java level 1 Quizzes
Java level 1 QuizzesJava level 1 Quizzes
Java level 1 Quizzes
 
Legacy projects: how to win the race
Legacy projects: how to win the raceLegacy projects: how to win the race
Legacy projects: how to win the race
 
Deterministic simulation testing
Deterministic simulation testingDeterministic simulation testing
Deterministic simulation testing
 
Navigating the xDD Alphabet Soup
Navigating the xDD Alphabet SoupNavigating the xDD Alphabet Soup
Navigating the xDD Alphabet Soup
 
a data driven game object system
a data driven game object systema data driven game object system
a data driven game object system
 
Refactoring & Restructuring - Improving the Code and Structure of Software
Refactoring & Restructuring - Improving the Code and Structure of SoftwareRefactoring & Restructuring - Improving the Code and Structure of Software
Refactoring & Restructuring - Improving the Code and Structure of Software
 
Clean Software Design: The Practices to Make The Design Simple
Clean Software Design: The Practices to Make The Design SimpleClean Software Design: The Practices to Make The Design Simple
Clean Software Design: The Practices to Make The Design Simple
 
Java 스터디 강의자료 - 1차시
Java 스터디 강의자료 - 1차시Java 스터디 강의자료 - 1차시
Java 스터디 강의자료 - 1차시
 
Unit test candidate solutions
Unit test candidate solutionsUnit test candidate solutions
Unit test candidate solutions
 
Import java
Import javaImport java
Import java
 

More from Kevin Rutherford (20)

Making the most of autism
Making the most of autismMaking the most of autism
Making the most of autism
 
Evolving the Kanban Board
Evolving the Kanban BoardEvolving the Kanban Board
Evolving the Kanban Board
 
Don't forget the developers!
Don't forget the developers!Don't forget the developers!
Don't forget the developers!
 
Love and death
Love and deathLove and death
Love and death
 
The 5-day challenge
The 5-day challengeThe 5-day challenge
The 5-day challenge
 
Red, green, ... what now?!
Red, green, ... what now?!Red, green, ... what now?!
Red, green, ... what now?!
 
Pair programming
Pair programmingPair programming
Pair programming
 
Tdd is dead
Tdd is deadTdd is dead
Tdd is dead
 
Hex arch
Hex archHex arch
Hex arch
 
Shepherding antipatterns
Shepherding antipatternsShepherding antipatterns
Shepherding antipatterns
 
Kata rules
Kata rulesKata rules
Kata rules
 
Movie app kata
Movie app kataMovie app kata
Movie app kata
 
OCP Checkout kata
OCP Checkout kataOCP Checkout kata
OCP Checkout kata
 
OCP bowling kata
OCP bowling kataOCP bowling kata
OCP bowling kata
 
OCP String Calculator kata
OCP String Calculator kataOCP String Calculator kata
OCP String Calculator kata
 
OCP kata overview
OCP kata overviewOCP kata overview
OCP kata overview
 
Telling not-asking
Telling not-askingTelling not-asking
Telling not-asking
 
Uml
UmlUml
Uml
 
Agile principles
Agile principlesAgile principles
Agile principles
 
Flow
FlowFlow
Flow
 

Recently uploaded

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 

Recently uploaded (20)

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 

Software Quality Code Smells

  • 1. (c) kevin rutherford 2012 describing the internal quality of software @kevinrutherford
  • 2. (c) kevin rutherford 2012 code smells Primitive Obsession Feature Envy Sim ulated Polym orphismLazy Class Temporary Field Inappropriate Intimacy ShotgunSurgery Data Clump Long M ethod Large Class RefusedBequest
  • 3. (c) kevin rutherford 2012 code smells Primitive Obsession Feature Envy Sim ulated Polym orphismLazy Class Temporary Field Inappropriate Intimacy ShotgunSurgery Data Clump Long M ethod Large Class ??? ??? ??? ??? ??? ??? ??? RefusedBequest
  • 4. (c) kevin rutherford 2012 connascence Two software components are connascent if a change in one would require the other to be modified in order to maintain the overall correctness of the system.
  • 5. (c) kevin rutherford 2012 connascence Connascence of Name Connascence of Type Connascence of Meaning Connascence of Algorithm Connascence of Position Connascence of Execution order Connascence of Timing Connascence of Value Connascence of Identity
  • 6. (c) kevin rutherford 2012 connascence Connascence of Name Connascence of Type Connascence of Meaning Connascence of Algorithm Connascence of Position Connascence of Execution order Connascence of Timing Connascence of Value Connascence of Identity refactoring should take the code in this direction static code properties properties of running code
  • 7. (c) kevin rutherford 2012 connascence of name Two components must agree on the name of something int count; count = 10; public enum Deck {   SPADES, HEARTS, CLUBS, DIAMONDS }; card = new Card(3, Deck.HEARTS); @Override public String toString() {   ... };
  • 8. (c) kevin rutherford 2012 connascence of type Two components must agree on the type of something String var; var = 10;   // oops! Writer out = new PrintWriter(f); @Override public String toString() {   ... };
  • 9. (c) kevin rutherford 2012 connascence of meaning Two components must agree on the interpretation of a value String getSSN() {   if (ssnIsMissing) {     return "999­99­9999";   } else {     return blah_blah_blah;   } } ssn = getSSN(); if (ssn.equals("999­99­9999")) {   // handle missing ssn } switch (message.getType()) { case 1:   return message.sendToAll(); case 2:   return message.cancel(); default:   return null; }
  • 10. (c) kevin rutherford 2012 connascence of meaning Two components must agree on the interpretation of a value String getSSN() {   if (ssnIsMissing) {     return "999­99­9999";   } else {     return blah_blah_blah;   } } ssn = getSSN(); if (ssn.equals("999­99­9999")) {   // handle missing ssn } switch (message.getType()) { case 1:   return message.sendToAll(); case 2:   return message.cancel(); default:   return null; }
  • 11. (c) kevin rutherford 2012 connascence of algorithm Two components must agree on a particular algorithm @Test public void testFingerprint() {   String actual = myObj.getFingerprint();   String expected = DigestUtils.md5Hex(myObj.name);   assertEquals(expected, actual); }
  • 12. (c) kevin rutherford 2012 connascence of position Two components must be adjacent or occur in a particular order String names[] = { "Jim", "Helen", "Jenny" }; ... System.out.println("Father: " + names[0]); System.out.println("Mother: " + names[1]); System.out.println("Child:  " + names[2]); Rectangle rect = new Rectangle(23.0, 15.5);
  • 13. (c) kevin rutherford 2012 connascence of execution order The order of execution of two components is important Email email = new Email(); email.setSender(“joe.bloggs”); //. . . email.deliver();
  • 14. (c) kevin rutherford 2012 connascence of timing Two components must agree on the timing of execution timeout = 200; // Milliseconds socket.writeRequest(data); answer = socket.readResponse(timeout);
  • 15. (c) kevin rutherford 2012 connascence of value The values of two components are related class CircularBuffer {     private int myHead;     private int myTail;     // myHead == myTail    =>  buffer empty     // myHead+1 == myTail  =>  buffer full }
  • 16. (c) kevin rutherford 2012 connascence of identity Two components must reference the same object class Producer implements Runnable {   public static Queue myQueue;   public void run() {     myQueue.put(37);   } } class Consumer implements Runnable {   public void run() {     int item = Producer.myQueue.get();     processItem(item);   } }
  • 17. (c) kevin rutherford 2012 connascence of identity Two components must reference the same object class Producer implements Runnable {   public static Queue myQueue;   public void run() {     myQueue.put(37);   } } class Consumer implements Runnable {   public void run() {     int item = Producer.myQueue.get();     processItem(item);   } } also connascence of timing ...and connascence of type
  • 18. (c) kevin rutherford 2012 connascence Connascence of Name Connascence of Type Connascence of Meaning Connascence of Algorithm Connascence of Position Connascence of Execution order Connascence of Timing Connascence of Value Connascence of Identity refactoring should take the code in this direction static code properties properties of running code
  • 19. (c) kevin rutherford 2012 connascence Two software components are connascent if a change in one would require the other to be modified in order to maintain the overall correctness of the system. What Every Programmer Should Know About Object Oriented Design, Meilir Page-Jones, Dorset House Publishing, 1996 Fundamentals of Object-Oriented Design in UML, Meilir Page-Jones, Addison-Wesley, 1999
  • 20. (c) kevin rutherford 2012 connascence Two software components are connascent if a change in one would require the other to be modified in order to maintain the overall correctness of the system. http://onestepback.org/articles/connascence/index.html Jim Weirich Connascence as a software design metric http://blog.rubybestpractices.com/posts/gregory/056-issue-24-connascence.html Gregory Brown Grand unified theory of software design, http://vimeo.com/10837903 Jim Weirich