SlideShare a Scribd company logo
OO Design 
Part Deux
About Me 
● Bryan Warner - Engineer @ Traackr 
● 10 years of programming experience 
● Currently working with Java/Spring/MongoDB, ElasticSearch/Lucene, and 
Scala/Spray.io 
● Email: bwarner@traackr.com
About You 
● Programming experience outside of B.S.S. 
● What are you hoping to learn in this session 
● Ruby vs. Java
Object-Oriented Design
What is OO Design* 
● Single Responsibility Principle 
● Open / Closed Principle 
● Data encapsulation 
○ The mighty DOT (.) 
● Data Abstraction / Loose Coupling 
● Modularization => Architectural OO 
* Impossible to follow 100%
Why OO Design 
● Better code maintainability 
● Promote code reusability (DRY) 
● Less feeling like this...
When to OO Design 
● Is it worth it? ... depends 
● Cost of good design vs. cost of quick-and-dirty 
design 
● Too much design (i.e. over-architecting) just as 
bad as no design 
● What are you building? 
● The future is uncertain
Bird's Eye View 
To begin, 
Let's ask the question: Where does Code live? 
Hint: It's not the cloud...
MVC Architecture 
RAILS APP 
MODULE 
CONTROLLER CONTROLLER 
MODEL MODEL
MVC - 1 Year Later 
RAILS APP 
MODULE 
CONTROLLER CONTROLLER 
CONTROLLER CONTROLLER 
MODEL MODEL 
EMAIL UTILS 
MODEL 
MODEL MODEL MODEL
MVC - 2 Years Later 
RAILS APP 
MODULE 
CONTROLLER 
MODEL 
MODEL MODEL 
MODEL MODEL 
MODEL 
EMAIL UTILS 
ANALYTICS 
UTILS 
REPORTING 
UTILS 
MODEL 
MODEL 
CONTROLLER 
CONTROLLER 
CONTROLLER 
CONTROLLER 
CONTROLLER 
CONTROLLER 
CONTROLLER 
CONTROLLER 
MODEL 
MODEL 
MODEL MODEL MODEL MODEL 
CRON JOB 
UTILS 
EMAIL UTILS 
WEB UTILS
Bloat 
● Classes => Single Responsibility Principle 
○ Failure to adhere = Non-reusable code 
● Applications => Single Purpose Principle 
○ Failure to adhere = One monolithic application
Who Cares, right? 
● Tougher to scale performance with one, giant application 
● As the application grows, tougher to add features to it 
○ No matter how well you structure your code, it's just increasingly 
difficult to keep the bloat under control without modularization 
● Unit testing performance suffers => Less likely to add more tests (or even 
run the ones you have!) 
● So what's the answer?
Software Modularization
What is a module? 
● A grouping of classes that share a common purpose 
● A module should have a specification file that describes the module 
○ Name, summary, etc. 
○ Version number 
○ External dependencies (if any) 
● Ruby: Gemspec File (http://docs.rubygems.org/read/chapter/20) 
○ http://rubygems.org/gems/twitter 
● Java: Maven => POM File 
○ http://search.maven.org/#browse%7C-120342089 
● Provides its own set of unit tests (hopefully!) 
● A module can (and usually does) extend the functionality of another 
module
Modules ~ Legos 
Modules are the building blocks of your applications!
Modular Architecture 
APPLICATION 
MODULES MODULES MODULES 
CLASSES 
CLASSES 
CLASSES 
CLASSES 
CLASSES 
CLASSES 
CLASSES 
CLASSES 
CLASSES
Modules <-> OO Design 
● Efficient software modularization can't be achieved without following good 
OO design principles 
● The functionality a module offers is only available through the classes it 
provides. Think about: 
○ What methods (i.e. APIs) do you want to expose in your classes? 
○ How could one extend the functionality you provide (e.g. inheritance 
structures, interfaces, mixins, etc.) 
● A module's classes should only do what they are designed to do (SRP) 
○ Classes that make behavioral assumptions are less reusable by 
others 
● Classes bloat = Module bloat
Coding Exercise I 
● Let's create a software module! 
● Identify a reusable software component that can be leveraged in your own 
personal projects 
○ Can we brainstorm ideas in class and break into teams? 
○ -OR- 
○ Program against the use-case in the next slide 
● Properly structure your module according to Ruby Gem standards 
○ For instance, I can demonstrate how Java Maven modules are 
structured 
● Unit tests for your module! 
● Extra Credit => Create a Ruby Gem for your module
Module Description 
1. Exposes one method to take in a social profile URL and return a social 
profile response 
2. The supported URLs will be facebook and twitter. Non-supported URLs 
should throw an exception 
3. Use a ruby HTML parser to scrap the data from the page and extract the 
person's bio, picture URL, etc. 
4. Create a class to encapsulate the response info
Coding Exercise II 
● Import our social profile retrieval module into an existing Rails App or we 
can create a new one 
● Let's add some properties to a Contact model 
○ Social Profile URL 
○ Bio 
○ Image URL 
○ Etc. 
● When we create a Contact 
○ Hook into our module to automatically fetch a contact's social profile 
info 
○ Store this information on the contact
Data Abstraction 
● Loosely-coupled vs. highly-coupled classes 
● Dependency inversion 
○ High-level components should not depend directly on low-level 
components. They should both depend on abstractions 
○ Abstractions should not depend on details. Details should depend 
upon abstractions 
● Hides implementation details from caller 
● Allows us to switch out low-level components on the fly 
○ Which is terrific for unit testing, 
○ Allows us to utilize a concept known as mock objects
Data Abstraction 
● Java => Interfaces 
○ Interface methods can not provide any implementation details 
● Scala => Traits 
○ Similar to interfaces, but a trait method can provide a default 
implementation 
● Ruby => "duck-typing" ... no such thing as a "design by contract" due to the 
lack of static typing 
Dependency injection frameworks can help "wire" classes together that utilize 
an abstraction layer 
○ Java => Spring Framework, Google Guice
Coding Exercise III 
● Let's re-examine our social profile retrieval module 
○ Let's create an inheritance structure for our retrieval component so it 
can support multiple, different implementations 
○ Have our existing class extend this inheritance structure and re-name 
the class to reflect what type of implementation it is (e.g. 
SocialProfilePageScrapper) 
○ Create a new implementation for social profile retrieval that will mock 
(i.e. fake) a response instead of actually making an HTTP call, and 
name it appropriately
Coding Exercise IV 
● Let's apply the principles of data inversion to our application's dependency 
on the module 
○ In our Ruby on Rails app, where we create the contact, abstract the 
usage of the social profile retrieval component so it can be easily be 
"switched out" for different implementations 
■ Hint: the component should be a property of the class it lives in 
○ Extra Credit: Write a unit test for creating a contact that will "wire in" 
the mock social profile implementation so we can assert for known 
expected values

More Related Content

What's hot

Php OOP interview questions
Php OOP interview questionsPhp OOP interview questions
Php OOP interview questions
Harsiddhi Thakkar
 
Java Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | EdurekaJava Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | Edureka
Edureka!
 
CV-Kapranov-eng-2015
CV-Kapranov-eng-2015CV-Kapranov-eng-2015
CV-Kapranov-eng-2015Oleg Kapranov
 
Introduction to Angular for .NET Developers
Introduction to Angular for .NET DevelopersIntroduction to Angular for .NET Developers
Introduction to Angular for .NET Developers
Laurent Duveau
 
Core Java interview questions-ppt
Core Java interview questions-pptCore Java interview questions-ppt
Core Java interview questions-ppt
Mayank Kumar
 
CLEAN CODE
CLEAN CODECLEAN CODE
CLEAN CODE
Knoldus Inc.
 
What is design pattern
What is design patternWhat is design pattern
Introduction to Angular for .NET Developers
Introduction to Angular for .NET DevelopersIntroduction to Angular for .NET Developers
Introduction to Angular for .NET Developers
Laurent Duveau
 
TypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret WeaponTypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret Weapon
Laurent Duveau
 
TypeScript Overview
TypeScript OverviewTypeScript Overview
TypeScript Overview
Aniruddha Chakrabarti
 
Java OOP s concepts and buzzwords
Java OOP s concepts and buzzwordsJava OOP s concepts and buzzwords
Java OOP s concepts and buzzwords
Raja Sekhar
 
Java interface
Java interface Java interface
Java interface
HoneyChintal
 
Design Pattern - Introduction
Design Pattern - IntroductionDesign Pattern - Introduction
Design Pattern - Introduction
Mudasir Qazi
 
The OO Design Principles
The OO Design PrinciplesThe OO Design Principles
The OO Design Principles
Steve Zhang
 
Interview Questions and Answers for Java
Interview Questions and Answers for JavaInterview Questions and Answers for Java
Interview Questions and Answers for Java
Garuda Trainings
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
talha ijaz
 
Clean code coding like a professional
Clean code   coding like a professionalClean code   coding like a professional
Clean code coding like a professional
Nhật Nguyễn Khắc
 
Clean code, Feb 2012
Clean code, Feb 2012Clean code, Feb 2012
Clean code, Feb 2012cobyst
 
Design Patterns - Factory Method & Abstract Factory
Design Patterns - Factory Method & Abstract FactoryDesign Patterns - Factory Method & Abstract Factory
Design Patterns - Factory Method & Abstract Factory
Guillermo Daniel Salazar
 

What's hot (20)

Php OOP interview questions
Php OOP interview questionsPhp OOP interview questions
Php OOP interview questions
 
Java Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | EdurekaJava Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | Edureka
 
CV-Kapranov-eng-2015
CV-Kapranov-eng-2015CV-Kapranov-eng-2015
CV-Kapranov-eng-2015
 
Introduction to Angular for .NET Developers
Introduction to Angular for .NET DevelopersIntroduction to Angular for .NET Developers
Introduction to Angular for .NET Developers
 
Core Java interview questions-ppt
Core Java interview questions-pptCore Java interview questions-ppt
Core Java interview questions-ppt
 
CLEAN CODE
CLEAN CODECLEAN CODE
CLEAN CODE
 
What is design pattern
What is design patternWhat is design pattern
What is design pattern
 
Introduction to Angular for .NET Developers
Introduction to Angular for .NET DevelopersIntroduction to Angular for .NET Developers
Introduction to Angular for .NET Developers
 
TypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret WeaponTypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret Weapon
 
TypeScript Overview
TypeScript OverviewTypeScript Overview
TypeScript Overview
 
Java OOP s concepts and buzzwords
Java OOP s concepts and buzzwordsJava OOP s concepts and buzzwords
Java OOP s concepts and buzzwords
 
Java interface
Java interface Java interface
Java interface
 
Design Pattern - Introduction
Design Pattern - IntroductionDesign Pattern - Introduction
Design Pattern - Introduction
 
The OO Design Principles
The OO Design PrinciplesThe OO Design Principles
The OO Design Principles
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
Interview Questions and Answers for Java
Interview Questions and Answers for JavaInterview Questions and Answers for Java
Interview Questions and Answers for Java
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
 
Clean code coding like a professional
Clean code   coding like a professionalClean code   coding like a professional
Clean code coding like a professional
 
Clean code, Feb 2012
Clean code, Feb 2012Clean code, Feb 2012
Clean code, Feb 2012
 
Design Patterns - Factory Method & Abstract Factory
Design Patterns - Factory Method & Abstract FactoryDesign Patterns - Factory Method & Abstract Factory
Design Patterns - Factory Method & Abstract Factory
 

Similar to Boston Startup School - OO Design

Single Responsibility Principle
Single Responsibility PrincipleSingle Responsibility Principle
Single Responsibility Principle
BADR
 
Object Oriented, Design patterns and data modelling worshop
Object Oriented, Design patterns and data modelling worshopObject Oriented, Design patterns and data modelling worshop
Object Oriented, Design patterns and data modelling worshop
Mohammad Shawahneh
 
Create first android app with MVVM Architecture
Create first android app with MVVM ArchitectureCreate first android app with MVVM Architecture
Create first android app with MVVM Architecture
khushbu thakker
 
Foster - Getting started with Angular
Foster - Getting started with AngularFoster - Getting started with Angular
Foster - Getting started with Angular
MukundSonaiya1
 
Dependency injection using Google guice
Dependency injection using Google guiceDependency injection using Google guice
Dependency injection using Google guice
Aman Verma
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
sharmisivarajah
 
Unit Testing Full@
Unit Testing Full@Unit Testing Full@
Unit Testing Full@Alex Borsuk
 
Better java with design
Better java with designBetter java with design
Better java with design
Narayann Swaami
 
Tests immutable when refactoring - SegFault Unconference Cracow 2019
Tests immutable when refactoring - SegFault Unconference Cracow 2019Tests immutable when refactoring - SegFault Unconference Cracow 2019
Tests immutable when refactoring - SegFault Unconference Cracow 2019
Grzegorz Miejski
 
Prototyping Workshop - Wireframes, Mockups, Prototypes
Prototyping Workshop - Wireframes, Mockups, PrototypesPrototyping Workshop - Wireframes, Mockups, Prototypes
Prototyping Workshop - Wireframes, Mockups, Prototypes
Marta Soncodi
 
Design Patterns Part1
Design Patterns  Part1Design Patterns  Part1
Design Patterns Part1
Tom Chen
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
Muhammad Jahanzaib
 
Usable Software Design
Usable Software DesignUsable Software Design
Usable Software Design
Alexandru Bolboaca
 
Software Engineering Primer
Software Engineering PrimerSoftware Engineering Primer
Software Engineering Primer
Georg Buske
 
UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptx
anguraju1
 
OOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdfOOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdf
HouseMusica
 
Keeping code clean
Keeping code cleanKeeping code clean
Keeping code clean
Brett Child
 
4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT
Ajay Chimmani
 
Cs690 object oriented_software_engineering_team01_ report
Cs690 object oriented_software_engineering_team01_ reportCs690 object oriented_software_engineering_team01_ report
Cs690 object oriented_software_engineering_team01_ report
Khushboo Wadhwani
 
RealDay: Angular.js
RealDay: Angular.jsRealDay: Angular.js
RealDay: Angular.js
Miguel Schmitz Grazziotin
 

Similar to Boston Startup School - OO Design (20)

Single Responsibility Principle
Single Responsibility PrincipleSingle Responsibility Principle
Single Responsibility Principle
 
Object Oriented, Design patterns and data modelling worshop
Object Oriented, Design patterns and data modelling worshopObject Oriented, Design patterns and data modelling worshop
Object Oriented, Design patterns and data modelling worshop
 
Create first android app with MVVM Architecture
Create first android app with MVVM ArchitectureCreate first android app with MVVM Architecture
Create first android app with MVVM Architecture
 
Foster - Getting started with Angular
Foster - Getting started with AngularFoster - Getting started with Angular
Foster - Getting started with Angular
 
Dependency injection using Google guice
Dependency injection using Google guiceDependency injection using Google guice
Dependency injection using Google guice
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Unit Testing Full@
Unit Testing Full@Unit Testing Full@
Unit Testing Full@
 
Better java with design
Better java with designBetter java with design
Better java with design
 
Tests immutable when refactoring - SegFault Unconference Cracow 2019
Tests immutable when refactoring - SegFault Unconference Cracow 2019Tests immutable when refactoring - SegFault Unconference Cracow 2019
Tests immutable when refactoring - SegFault Unconference Cracow 2019
 
Prototyping Workshop - Wireframes, Mockups, Prototypes
Prototyping Workshop - Wireframes, Mockups, PrototypesPrototyping Workshop - Wireframes, Mockups, Prototypes
Prototyping Workshop - Wireframes, Mockups, Prototypes
 
Design Patterns Part1
Design Patterns  Part1Design Patterns  Part1
Design Patterns Part1
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Usable Software Design
Usable Software DesignUsable Software Design
Usable Software Design
 
Software Engineering Primer
Software Engineering PrimerSoftware Engineering Primer
Software Engineering Primer
 
UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptx
 
OOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdfOOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdf
 
Keeping code clean
Keeping code cleanKeeping code clean
Keeping code clean
 
4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT
 
Cs690 object oriented_software_engineering_team01_ report
Cs690 object oriented_software_engineering_team01_ reportCs690 object oriented_software_engineering_team01_ report
Cs690 object oriented_software_engineering_team01_ report
 
RealDay: Angular.js
RealDay: Angular.jsRealDay: Angular.js
RealDay: Angular.js
 

Recently uploaded

FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
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
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
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...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 

Boston Startup School - OO Design

  • 2. About Me ● Bryan Warner - Engineer @ Traackr ● 10 years of programming experience ● Currently working with Java/Spring/MongoDB, ElasticSearch/Lucene, and Scala/Spray.io ● Email: bwarner@traackr.com
  • 3. About You ● Programming experience outside of B.S.S. ● What are you hoping to learn in this session ● Ruby vs. Java
  • 5. What is OO Design* ● Single Responsibility Principle ● Open / Closed Principle ● Data encapsulation ○ The mighty DOT (.) ● Data Abstraction / Loose Coupling ● Modularization => Architectural OO * Impossible to follow 100%
  • 6. Why OO Design ● Better code maintainability ● Promote code reusability (DRY) ● Less feeling like this...
  • 7. When to OO Design ● Is it worth it? ... depends ● Cost of good design vs. cost of quick-and-dirty design ● Too much design (i.e. over-architecting) just as bad as no design ● What are you building? ● The future is uncertain
  • 8. Bird's Eye View To begin, Let's ask the question: Where does Code live? Hint: It's not the cloud...
  • 9. MVC Architecture RAILS APP MODULE CONTROLLER CONTROLLER MODEL MODEL
  • 10. MVC - 1 Year Later RAILS APP MODULE CONTROLLER CONTROLLER CONTROLLER CONTROLLER MODEL MODEL EMAIL UTILS MODEL MODEL MODEL MODEL
  • 11. MVC - 2 Years Later RAILS APP MODULE CONTROLLER MODEL MODEL MODEL MODEL MODEL MODEL EMAIL UTILS ANALYTICS UTILS REPORTING UTILS MODEL MODEL CONTROLLER CONTROLLER CONTROLLER CONTROLLER CONTROLLER CONTROLLER CONTROLLER CONTROLLER MODEL MODEL MODEL MODEL MODEL MODEL CRON JOB UTILS EMAIL UTILS WEB UTILS
  • 12. Bloat ● Classes => Single Responsibility Principle ○ Failure to adhere = Non-reusable code ● Applications => Single Purpose Principle ○ Failure to adhere = One monolithic application
  • 13. Who Cares, right? ● Tougher to scale performance with one, giant application ● As the application grows, tougher to add features to it ○ No matter how well you structure your code, it's just increasingly difficult to keep the bloat under control without modularization ● Unit testing performance suffers => Less likely to add more tests (or even run the ones you have!) ● So what's the answer?
  • 15. What is a module? ● A grouping of classes that share a common purpose ● A module should have a specification file that describes the module ○ Name, summary, etc. ○ Version number ○ External dependencies (if any) ● Ruby: Gemspec File (http://docs.rubygems.org/read/chapter/20) ○ http://rubygems.org/gems/twitter ● Java: Maven => POM File ○ http://search.maven.org/#browse%7C-120342089 ● Provides its own set of unit tests (hopefully!) ● A module can (and usually does) extend the functionality of another module
  • 16. Modules ~ Legos Modules are the building blocks of your applications!
  • 17. Modular Architecture APPLICATION MODULES MODULES MODULES CLASSES CLASSES CLASSES CLASSES CLASSES CLASSES CLASSES CLASSES CLASSES
  • 18. Modules <-> OO Design ● Efficient software modularization can't be achieved without following good OO design principles ● The functionality a module offers is only available through the classes it provides. Think about: ○ What methods (i.e. APIs) do you want to expose in your classes? ○ How could one extend the functionality you provide (e.g. inheritance structures, interfaces, mixins, etc.) ● A module's classes should only do what they are designed to do (SRP) ○ Classes that make behavioral assumptions are less reusable by others ● Classes bloat = Module bloat
  • 19. Coding Exercise I ● Let's create a software module! ● Identify a reusable software component that can be leveraged in your own personal projects ○ Can we brainstorm ideas in class and break into teams? ○ -OR- ○ Program against the use-case in the next slide ● Properly structure your module according to Ruby Gem standards ○ For instance, I can demonstrate how Java Maven modules are structured ● Unit tests for your module! ● Extra Credit => Create a Ruby Gem for your module
  • 20. Module Description 1. Exposes one method to take in a social profile URL and return a social profile response 2. The supported URLs will be facebook and twitter. Non-supported URLs should throw an exception 3. Use a ruby HTML parser to scrap the data from the page and extract the person's bio, picture URL, etc. 4. Create a class to encapsulate the response info
  • 21. Coding Exercise II ● Import our social profile retrieval module into an existing Rails App or we can create a new one ● Let's add some properties to a Contact model ○ Social Profile URL ○ Bio ○ Image URL ○ Etc. ● When we create a Contact ○ Hook into our module to automatically fetch a contact's social profile info ○ Store this information on the contact
  • 22. Data Abstraction ● Loosely-coupled vs. highly-coupled classes ● Dependency inversion ○ High-level components should not depend directly on low-level components. They should both depend on abstractions ○ Abstractions should not depend on details. Details should depend upon abstractions ● Hides implementation details from caller ● Allows us to switch out low-level components on the fly ○ Which is terrific for unit testing, ○ Allows us to utilize a concept known as mock objects
  • 23. Data Abstraction ● Java => Interfaces ○ Interface methods can not provide any implementation details ● Scala => Traits ○ Similar to interfaces, but a trait method can provide a default implementation ● Ruby => "duck-typing" ... no such thing as a "design by contract" due to the lack of static typing Dependency injection frameworks can help "wire" classes together that utilize an abstraction layer ○ Java => Spring Framework, Google Guice
  • 24. Coding Exercise III ● Let's re-examine our social profile retrieval module ○ Let's create an inheritance structure for our retrieval component so it can support multiple, different implementations ○ Have our existing class extend this inheritance structure and re-name the class to reflect what type of implementation it is (e.g. SocialProfilePageScrapper) ○ Create a new implementation for social profile retrieval that will mock (i.e. fake) a response instead of actually making an HTTP call, and name it appropriately
  • 25. Coding Exercise IV ● Let's apply the principles of data inversion to our application's dependency on the module ○ In our Ruby on Rails app, where we create the contact, abstract the usage of the social profile retrieval component so it can be easily be "switched out" for different implementations ■ Hint: the component should be a property of the class it lives in ○ Extra Credit: Write a unit test for creating a contact that will "wire in" the mock social profile implementation so we can assert for known expected values