1 - Service Orientation
1 - Service Orientation
1. Service Orientation
Companies like Airbnb often start out as monolithic applications — a kind of swiss army knife which Travis-CI
Linux Integrated Testing Continuous
performs all of the functions of the organization. As traffic (and the number of engineers working on the Unix Environment Integration
product) grows, this approach doesn’t scale. The code base becomes too complicated, concerns are not Codeship
cleanly separated, changes from many engineers touching many different parts of the codebase go out Adaptable, scalable services Test behavior, simulate user experience Open Source RubyGems Integrated Deployment Continuous
together, and performance is determined by the worst-performing sections in the application. Service design patterns Behavior Driven Development Development Package Management
Deployment
Continuous Integration, Deployment Continuous Integration, Deployment Heroku
Automated Acceptance tests Automated Acceptance tests Ruby
Monolith Architecture Technical Difficulties: Modern Programming
Cloud Deployment
Large, single, block of stone Hard to add new features Code for humans, not machines Respond to needs, react to changes Sqlite
Cannot change tools/languages Open Source Development Responsive user interfaces GitHub Local SQL Database
Cannot scale beyond ~5000 users Collaborative Development Message Queues Collaborative Development
Conventions, Patterns, Frameworks Asynchronous Jobs PostGres Distributed
Collaborative Git Hosted SQL Database Data Storage
Development Version Control
Human problems: Redis
Developers are constantly “firefighting” CDN Web Sockets Slack Key-value Datastore
Hard to onboard new employees Parallel Group Communication
Worker
queue
Developers skills are out of date HTTP SQS
JS client
ActiveRecord Message Queues
Message
Web External Programming Object-Relational Mapping
SNS Queues
HTTP HTTP HTTP
Web API
Business Problems: Application Web API Frameworks
Hard to change business rules
gem
Sinatra Notification Service
Scheduled Microservice Framework
queue Worker
Cannot innovate
Costs lots of money to maintain Minitest IronWorker Asynchronous
PostGres Testing Framework Background Tasks
Jobs
1
⼤家好!
I am: Soumya Ray
Distinguished Professor
Institute of Service Science
College of Technology Management
[email protected]
https://www.facebook.com/soumya.ray.prof
.com
I’m also: /
soumyaray
@ @gmail.com
2
Communicate: Canvas and Teams
Canvas: courseware
- handouts
- assignments
- readings
Teams: groupware
- weekly discussions
- private team channels
- weekly livestream
3
Canvas
See guide on how to apply/activate your Office 365 account
Link to our MS Teams space to discuss/watch livestream
4
MS Teams
We will use MS Teams for all discussion and livestreams
5
To do all this, we will make extensive use Amazon’s AWS and other cloud services. The tools and methods
used in this class closely mirror those favored by cutting-edge startups and the open-source movement.
After this class, you will be fully prepared to be an IT entrepreneur and open-source contributor.
This class is ideal for students who wish to pursue careers in the following areas.
- Software engineering: discover advanced software design and development tools You should
used be able to
by professionals
- IT project management: manage a sophisticated system with versioning and distributed
write ancoding
application
- Data science: extract and transform data from web sources and store it in cloud-basedbydatastores
yourself.
What will we read?
The Internet is our textbook. Every week, you will be given current online resources that software
developers regularly use to solve problems and expand their knowledge (tutorials, blogs, articls, Q&A
forums, code repositories). We will communicate and collaborate with each other entirely through modern
teamware such as Github and Slack.
You are graded
How will we be graded? solely on your
Students will be graded on class and online discussion, individual assignments, and group
ownassignments.
effort
- Individual Development Effort: 70% (from your recorded activity on code repositories, tutorials, etc.)
- Class and Online Discussion: 30% (you must communicate to get a good grade)
6
Must Know How to Make an Application
12
10
8
6
4
2
0
Data Science Front−end Terminal Back−end Mobile Database−driven IoT Desktop Firmware Server
"Web"
7
Techniques
15
10
5
0
Git VCS OOP basics Command line Database Design HTML/CSS Regex Cloud Deploy Containerization UML Testing OOP advanced
8
We are the Service Providers
9
Why do Software Projects Fail?
https://www.computerworld.com/article/2486426/healthcare-it/healthcare-gov-website--didn-t-have-a-chance-in-hell-
.html
https://www.theguardian.com/society/2013/sep/18/nhs-records-system-10bn
https://www.computerweekly.com/news/2240185166/Universal-Credit-will-cost-taxpayers-128bn
10
Why do Software Projects Fail?
Healthcare.gov website 'didn't have a chance in hell
https://www.computerworld.com/article/2486426/healthcare-it/healthcare-gov-website--didn-t-have-a-chance-in-hell-.html
Of 3,555 projects from 2003 to 2012 that had labor costs of at least $10 million, only 6.4% were successful.
The Standish data showed that 52% of the large projects were "challenged," meaning they were over
budget, behind schedule or didn't meet user expectations.
The remaining 41.4% were failures -- they were either abandoned or started anew from scratch.
Software development experts and analysts point to multiple issues as the potential cause of such problems.
https://www.bloomberg.com/opinion/articles/2021-06-04/how-micro
12
https://www.theverge.com/2020/3/31/21200844/microsoft-skype-zoom-
houseparty-coronavirus-pandemic-usage-growth-competition
Change is a Challenge
Success…
brings change…
complicating systems.
Customers/Managers want new features Quickly Add More Code all the time
design and policies keeps changing old features break; starting debugging
v1.3
v1.2
Features
v1.1
Time
What can we do in the beginning to ensure our What should we do later if we find that
system can keep innovating later? our system is too hard to change?
15
How can Architecture Help?
Which system would you rather have to fix?
or
Representers
Values
Controllers
Service Objects
Entities + Values
Repositories + DataMappers
Object-Relational
Gateways
Mappers
API
year : int
track : String
…
…
String getTrack()
changeTrack(String)
…
16
Airbnb Engineering: http://nerds.airbnb.com/smartstack-service-discovery-cloud/
Companies like Airbnb often start out as monolithic applications — a kind of swiss army knife which
performs all of the functions of the organization. As traffic (and the number of engineers working on
the product) grows, this approach doesn’t scale. The code base becomes too complicated, concerns are
not cleanly separated, changes from many engineers touching many different parts of the codebase go
out together, and performance is determined by the worst-performing sections in the application.
Human problems:
Developers are constantly “firefighting” bugs
Hard to onboard new employees
Developers skills are out of date
Business Problems:
Hard to change business rules to market needs
Cannot innovate
Costs lots of money to maintain
17
Airbnb Engineering: http://nerds.airbnb.com/smartstack-service-discovery-cloud/
The solution to this problem is services: individual, smaller code bases, running on separate machines
with separate deployment cycles, that more cleanly address more targeted problem domains.
This is called a services-oriented architecture: SOA.
Happy people
Focus and learn what you need
Choose your own tools
18
Our SOA Approach
There are many ways of doing SOA -- we will explore a a best of breed approach
HTML / Json
Controllers
Representers
Code for humans, not machines
Services
Domain Driven Design
Domain: Entities + Values
Repositories + DataMappers
Conventions, Patterns, Frameworks "readable"
Coding Metrics
ORM Gateways
Database
External …
API
Parallel
Worker queue
Extensible, Scalable Services
"scalable"
HTTP
JS client
HTTP Web
Application
HTTP
Web API
gem
HTTP External
Web API
Service Architecture
queue Scheduled
Worker
Message Queues
PostGres
Concurrent Workers
19
Code for Humans, Not Machines
Conventions and Patterns Domain Driven Design
Get feedback on your coding style using automated tools Structure your code into single responsibilities
HTML / Json
Representers
$ gem install rubocop
Services
Repositories + DataMappers
Quality Metrics
Quantitatively measure the complexity of your code ORM Gateways
Code metrics: quantifying code quality using crowd-sourced wisdom
ABC Metric: Flog Metric:
External …
ABC is an example of code size metric Specific to Ruby: aware of bad Ruby habits Database API
Counts number of assignments, branches, conditions Extends ABC to weight method calls
Assignment: explicit transfer of data into a variable “The more painful the code, the higher the score.
(= *= /= %= += << , etc.) The higher the score, the harder it is to test.”
Branch: explicit program branch Flog score Means
(method call, new object) 0-10 Awesome
Condition: logical/boolean test 11-20 Good enough
(if-else logic, == != <= >= < > else case , etc.) 21-40 Might need refactoring
41-60 Possible to justify
61-100 Danger
High ABC is bad: code is hard to understand and test
100-200 Whoop, whoop, whoop
Generic metric: ABC applies to any programming language 200+ Someone please think of the children
20
Test Your Confidence
Test Driven Development Automated Acceptance tests
Use automated tests to guide your coding Simulate and test user experience
We must be confident all our code will really work. We must be confident our code is
We must publish all tested changes
always ready for end users.
without any delay.
21
Collaboration and Community
Open-Source Development Collaborative Workflow
Use Git/Github to share and collaborate Fork, merge, and pull requests for formal collaboration
Parallel
Worker queue
HTTP
JS client
HTTP Web HTTP HTTP External
Web API
Application Web API
gem
Scheduled
queue Worker
PostGres
23
Which Road to Take?
25
Our Development Platform
or or
26
Why are there so many programming languag
How are they different?
27
http://redmonk.com/sogrady/2017/06/08/language-rankings-6-17/
What we Code in Today
python javascript c++ java c# c php ruby swift kotlin r typescript go lua pyspark. sas sass scheme
28
Growing as a Developer
The safe ALGOL line Ruby: a window to new things
for i := 1 step 1 until 10 do SmallTalk Perl Python
if i MOD 2 :=: 0 then
ALGOL begin print((i, newline))
Object Oriented Flexibility Readability
(1960) end
od
std::stringstream ss;
for (int i = 1; i < 10; i = i + 1) {
Ruby
if (i % 2 == 0) {
C/C++ ss << i << endl;
}
} 10.times { |i| puts i if i.even? }
for (int i = 1; i < 10; i++) {
if (i % 2 == 0) {
Java System.out.println(i); Discover new languages in programming
}
} Return to your favorite language with new eyes
for i in range(1,10):
Python if (i % 2 == 0): print i;
Modern Programming
Sqlite
Local SQL Database
GitHub
Collaborative Development PostGres Distributed
Hosted SQL Database Data Storage
Collaborative Git
Development Version Control Redis
Key-value Datastore
Trello
Group Communication
SQS Asynchronous
Message Queues Communication
Sequel
Object-Relational Mapping
Programming
Docker
Roda Containers
Frameworks Microservice Framework Containers
DockerHub
Minitest Container Registry
Testing Framework
30