SlideShare a Scribd company logo
1 of 28
Download to read offline
我的 Julia 軟體架構演進之旅
Yueh-Hua Tu Ph.D.
ML Engineer@Taiwan AI Labs
Saturday 29th July, 2023
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 1 / 28
Projects
Open source projects
FluxML/GeometricFlux.jl
yuehhua/GraphSignals.jl
yuehhua/CDGRNs.jl
JuliaSingleCellOmics/SnowyOwl.jl
Current work
Federated learning system architecture
Bioinformatics analysis tool development
(e.g. GWAS, linkage disequilibrium and
statistics)
Program optimization for execution
performance
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 2 / 28
Outline
1. Prototyping-Development Iteration
2. TDD and Test Coverage
3. Evolutionary Design
4. Principles of Software Engineering
5. Development Mindset
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 3 / 28
Developing from scratch
If we want a project for statistical analysis, where could we start?
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 4 / 28
Prototyping linear regression
Inference
y = Xβ
1 julia> predict(X, β)=X∗β
Fitting
β = (XT
X)−1
XT
y
1 julia> fit(X, y) = inv(X'*X) * X'*y
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 5 / 28
Prototyping-Development Iteration
Prototyping-Development Iteration
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 6 / 28
Prototyping-Development Iteration
Prototyping-Development Iteration (PDI)
Prototyping first then develop for flexibility and performance!
For prototyping and researching
Figure: Scripts
⇒
For development
Figure: Codebase
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 7 / 28
Prototyping-Development Iteration
Prototyping
Figure: Scripts
Implement a simple and standalone feature in a script
to ensure correctness.
1 julia> predict(X, β)=X∗β
2
3 julia> fit(X, y) = inv(X'*X) * X'*y
And try to wrap these features into functions.
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 8 / 28
Prototyping-Development Iteration
Development
Figure: Codebase
Puts functions or components into your codebase and design for
reusablility and flexibility.
1 struct LinearRegressionModel
2 β
3 end
4
5 coefs(m::LinearRegressionModel) = m.β
6
7 predict(m::LinearRegressionModel, X) = X*coefs(m)
8
9 fit(::Type{LinearRegressionModel}, X, y) =
LinearRegressionModel(inv(X'*X) * X'*y)
,
→
After putting components into codebase, ensure your scripts still work for you. Don't put to
much specifics into codebase (e.g. data, configs).
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 9 / 28
TDD and Test Coverage
TDD and Test Coverage
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 10 / 28
TDD and Test Coverage
Test-Driven Development (TDD)
Actually, PDI is a kind of TDD process.
We still need to add some test cases and ensure tests are passed.
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 11 / 28
TDD and Test Coverage
TDD in Julia
TDD is very simple in Julia.
test/runtests.jl
1 @testset "MyProject.jl" begin
2 @test coefs(model) == β
3 ...
4 end
1 (@v1.9) pkg> test
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 12 / 28
TDD and Test Coverage
Develop for flexibility
src/stats.jl
1 cov(X, Y) = innerprod(X, Y)
src/linalg.jl
1 innerprod(x, y) = x'*y
src/regression.jl
fit(::Type{LinearRegressionModel}, X, y) = LinearRegressionModel(inv(innerprod(X, X)) *
innerprod(X, y))
,
→
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 13 / 28
TDD and Test Coverage
Develop for performance
src/linalg.jl
function innerprod(X::AbstractMatrix, y::AbstractVector)
# acceleration techniques: SIMD, GPU...
end
function innerprod(X::AbstractMatrix, Y::AbstractMatrix)
# acceleration techniques: SIMD, GPU...
end
Specification for optimization and keep consistent interfaces.
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 14 / 28
TDD and Test Coverage
Test coverage
Keep high test coverage as possible to ensure your codebase provides desired features.
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 15 / 28
Evolutionary Design
Evolutionary Design
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 16 / 28
Evolutionary Design
Adding new features
If we want to add new approach to solve a linear system, how can we do?
Ax = b
1 using LinearSolve
2
3 A = rand(4, 4)
4 b = rand(4)
5 prob = LinearProblem(A, b)
6 sol = solve(prob)
Adding new features could be prototyped by
Adding types
Extending existing functions
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 17 / 28
Evolutionary Design
Adding types
Original
struct RegularSolver end
solve(m::RegularSolver, A, b) =
solve(LinearProblem(A, b))
,
→
⇒
Adding CholeskySolver
1 abstract type LinearSolver end
2
3 struct RegularSolver <: LinearSolver end
4 struct CholeskySolver <: LinearSolver end
5
6 solve(m::RegularSolver, A, b) =
solve(LinearProblem(A, b))
,
→
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 18 / 28
Evolutionary Design
Extending functions/methods
Original
abstract type LinearSolver end
struct RegularSolver <:
LinearSolver end
,
→
struct CholeskySolver <:
LinearSolver end
,
→
solve(m::RegularSolver, A, b) =
solve(LinearProblem(A, b))
,
→
⇒
Extending solve to CholeskySolver.
1 abstract type LinearSolver end
2
3 struct RegularSolver <: LinearSolver end
4 struct CholeskySolver <: LinearSolver end
5
6 solve(m::RegularSolver, A, b) =
solve(LinearProblem(A, b))
,
→
7 solve(m::CholeskySolver, A, b) = #
Cholesky decomposition...
,
→
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 19 / 28
Principles of Software Engineering
Principles of Software Engineering
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 20 / 28
Principles of Software Engineering
Single Responsibility Principle
A class or function should be responsible to only one actor.
LinearModel: represent a linear model
coefs: returns model coefficients
fit: fitting model
LinearSolver: approach to solve a linear system
solve: determines how to solve a linear system
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 21 / 28
Principles of Software Engineering
Open-Closed Principle
A module will be said to be open for extension and be said to be closed for modification.
struct LinearRegressionModel
β
end
coefs(m::LinearRegressionModel) =
m.β
⇒
1 abstract type LinearModel end
2
3 struct LinearRegressionModel <:
LinearModel
,
→
4 β
5 end
6
7 struct LogisticRegressionModel <:
LinearModel
,
→
8 β
9 end
10
11 coefs(m::LinearRegressionModel) = m.β
12 coefs(m::LogisticRegressionModel) = m.β
Benefitial from Julia's features of type and method separation, it's easy to add new types or
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 22 / 28
Principles of Software Engineering
Liskov Substitution Principle
Derived class can be able to replace its base class.
abstract type LinearModel end
struct LinearRegressionModel <: LinearModel
β
end
struct LogisticRegressionModel <: LinearModel
β
end
Since Julia's subtyping system doesn't allow composite types as super types, Julia always run
composite types in practice.
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 23 / 28
Principles of Software Engineering
Interface Segregation Principle
No code should be forced to depend on methods it does not use.
1 julia> model = fit(LinearRegressionModel,
X, y)
,
→
2
3 julia> coefs(model)
4
5 julia> model =
fit(LogisticRegressionModel, X, y)
,
→
6
7 julia> coefs(model)
User just need to know interfaces.
1 module MyPackage
2 abstract type LinearModel end
3 struct LinearRegressionModel <:
LinearModel
,
→
4 β
5 end
6 struct LogisticRegressionModel <:
LinearModel
,
→
7 β
8 end
9 coefs(m::LinearRegressionModel) = m.β
10 coefs(m::LogisticRegressionModel) =
m.β
11 end
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 24 / 28
Principles of Software Engineering
Dependency Inversion Principle
Dependency injection
1 abstract type LinearSolver end
2
3 struct RegularSolver <: LinearSolver end
4 struct CholeskySolver <: LinearSolver end
5 struct QRSolver <: LinearSolver end
1 abstract type LinearModel end
2
3 struct LinearRegressionModel <:
LinearModel end
,
→
4 struct LogisticRegressionModel <:
LinearModel end
,
→
5
6 fit(::Type{LinearRegressionModel}, X, y;
algo=CholeskySolver())
,
→
7 fit(::Type{LogisticRegressionModel}, X, y;
algo=CholeskySolver())
,
→
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 25 / 28
Development Mindset
Development Mindset
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 26 / 28
Development Mindset
Issues and Pull Requests
貢獻者
遇到善於給建議(機車)的人
如何主持跟維護專案
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 27 / 28
Development Mindset
Thank you for attention
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 28 / 28

More Related Content

Similar to [COSCUP 2023] 我的Julia軟體架構演進之旅

9781111530532 ppt ch08
9781111530532 ppt ch089781111530532 ppt ch08
9781111530532 ppt ch08Terry Yoast
 
Feature Bits at LSSC10
Feature  Bits at LSSC10Feature  Bits at LSSC10
Feature Bits at LSSC10Erik Sowa
 
Generation of Testcases from UML Sequence Diagram and Detecting Deadlocks usi...
Generation of Testcases from UML Sequence Diagram and Detecting Deadlocks usi...Generation of Testcases from UML Sequence Diagram and Detecting Deadlocks usi...
Generation of Testcases from UML Sequence Diagram and Detecting Deadlocks usi...KIIT
 
J unit presentation
J unit presentationJ unit presentation
J unit presentationPriya Sharma
 
Ujjwalreverseengineeringppptfinal
UjjwalreverseengineeringppptfinalUjjwalreverseengineeringppptfinal
Ujjwalreverseengineeringppptfinalujjwalchauhan87
 
Benchmarking the Parallel 1D Heat Equation Solver in Chapel, Charm++, C++, HP...
Benchmarking the Parallel 1D Heat Equation Solver in Chapel, Charm++, C++, HP...Benchmarking the Parallel 1D Heat Equation Solver in Chapel, Charm++, C++, HP...
Benchmarking the Parallel 1D Heat Equation Solver in Chapel, Charm++, C++, HP...Patrick Diehl
 
Poster on Automated Refactoring of Legacy Java Software to Default Methods
Poster on Automated Refactoring of Legacy Java Software to Default MethodsPoster on Automated Refactoring of Legacy Java Software to Default Methods
Poster on Automated Refactoring of Legacy Java Software to Default MethodsRaffi Khatchadourian
 
OOAD-Unit1.ppt
OOAD-Unit1.pptOOAD-Unit1.ppt
OOAD-Unit1.pptrituah
 
Julia: A modern language for software 2.0
Julia: A modern language for software 2.0Julia: A modern language for software 2.0
Julia: A modern language for software 2.0Viral Shah
 
Future Programming Language
Future Programming LanguageFuture Programming Language
Future Programming LanguageYLTO
 
Ptidej Architecture, Design, and Implementation in Action v2.1
Ptidej Architecture, Design, and Implementation in Action v2.1Ptidej Architecture, Design, and Implementation in Action v2.1
Ptidej Architecture, Design, and Implementation in Action v2.1Yann-Gaël Guéhéneuc
 
IRJET- Unabridged Review of Supervised Machine Learning Regression and Classi...
IRJET- Unabridged Review of Supervised Machine Learning Regression and Classi...IRJET- Unabridged Review of Supervised Machine Learning Regression and Classi...
IRJET- Unabridged Review of Supervised Machine Learning Regression and Classi...IRJET Journal
 
Value objects in JS - an ES7 work in progress
Value objects in JS - an ES7 work in progressValue objects in JS - an ES7 work in progress
Value objects in JS - an ES7 work in progressBrendan Eich
 
Unit Testing Frameworks: A comparative study
Unit Testing Frameworks: A comparative studyUnit Testing Frameworks: A comparative study
Unit Testing Frameworks: A comparative studyIRJET Journal
 
Devry CIS 355A Full Course Latest
Devry CIS 355A Full Course LatestDevry CIS 355A Full Course Latest
Devry CIS 355A Full Course LatestAtifkhilji
 

Similar to [COSCUP 2023] 我的Julia軟體架構演進之旅 (20)

9781111530532 ppt ch08
9781111530532 ppt ch089781111530532 ppt ch08
9781111530532 ppt ch08
 
Feature Bits at LSSC10
Feature  Bits at LSSC10Feature  Bits at LSSC10
Feature Bits at LSSC10
 
Generation of Testcases from UML Sequence Diagram and Detecting Deadlocks usi...
Generation of Testcases from UML Sequence Diagram and Detecting Deadlocks usi...Generation of Testcases from UML Sequence Diagram and Detecting Deadlocks usi...
Generation of Testcases from UML Sequence Diagram and Detecting Deadlocks usi...
 
J unit presentation
J unit presentationJ unit presentation
J unit presentation
 
JUnit Presentation
JUnit PresentationJUnit Presentation
JUnit Presentation
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Ujjwalreverseengineeringppptfinal
UjjwalreverseengineeringppptfinalUjjwalreverseengineeringppptfinal
Ujjwalreverseengineeringppptfinal
 
Benchmarking the Parallel 1D Heat Equation Solver in Chapel, Charm++, C++, HP...
Benchmarking the Parallel 1D Heat Equation Solver in Chapel, Charm++, C++, HP...Benchmarking the Parallel 1D Heat Equation Solver in Chapel, Charm++, C++, HP...
Benchmarking the Parallel 1D Heat Equation Solver in Chapel, Charm++, C++, HP...
 
Poster on Automated Refactoring of Legacy Java Software to Default Methods
Poster on Automated Refactoring of Legacy Java Software to Default MethodsPoster on Automated Refactoring of Legacy Java Software to Default Methods
Poster on Automated Refactoring of Legacy Java Software to Default Methods
 
OOAD-Unit1.ppt
OOAD-Unit1.pptOOAD-Unit1.ppt
OOAD-Unit1.ppt
 
Julia: A modern language for software 2.0
Julia: A modern language for software 2.0Julia: A modern language for software 2.0
Julia: A modern language for software 2.0
 
Future Programming Language
Future Programming LanguageFuture Programming Language
Future Programming Language
 
Ptidej Architecture, Design, and Implementation in Action v2.1
Ptidej Architecture, Design, and Implementation in Action v2.1Ptidej Architecture, Design, and Implementation in Action v2.1
Ptidej Architecture, Design, and Implementation in Action v2.1
 
Oops ppt
Oops pptOops ppt
Oops ppt
 
opps.pptx
opps.pptxopps.pptx
opps.pptx
 
IRJET- Unabridged Review of Supervised Machine Learning Regression and Classi...
IRJET- Unabridged Review of Supervised Machine Learning Regression and Classi...IRJET- Unabridged Review of Supervised Machine Learning Regression and Classi...
IRJET- Unabridged Review of Supervised Machine Learning Regression and Classi...
 
Value objects in JS - an ES7 work in progress
Value objects in JS - an ES7 work in progressValue objects in JS - an ES7 work in progress
Value objects in JS - an ES7 work in progress
 
Unit Testing Frameworks: A comparative study
Unit Testing Frameworks: A comparative studyUnit Testing Frameworks: A comparative study
Unit Testing Frameworks: A comparative study
 
Devry CIS 355A Full Course Latest
Devry CIS 355A Full Course LatestDevry CIS 355A Full Course Latest
Devry CIS 355A Full Course Latest
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 

More from 岳華 杜

Julia: The language for future
Julia: The language for futureJulia: The language for future
Julia: The language for future岳華 杜
 
The Language for future-julia
The Language for future-juliaThe Language for future-julia
The Language for future-julia岳華 杜
 
20190907 Julia the language for future
20190907 Julia the language for future20190907 Julia the language for future
20190907 Julia the language for future岳華 杜
 
Metaprogramming in julia
Metaprogramming in juliaMetaprogramming in julia
Metaprogramming in julia岳華 杜
 
Introduction to julia
Introduction to juliaIntroduction to julia
Introduction to julia岳華 杜
 
自然語言處理概覽
自然語言處理概覽自然語言處理概覽
自然語言處理概覽岳華 杜
 
Introduction to machine learning
Introduction to machine learningIntroduction to machine learning
Introduction to machine learning岳華 杜
 
Semantic Segmentation - Fully Convolutional Networks for Semantic Segmentation
Semantic Segmentation - Fully Convolutional Networks for Semantic SegmentationSemantic Segmentation - Fully Convolutional Networks for Semantic Segmentation
Semantic Segmentation - Fully Convolutional Networks for Semantic Segmentation岳華 杜
 
Batch normalization 與他愉快的小伙伴
Batch normalization 與他愉快的小伙伴Batch normalization 與他愉快的小伙伴
Batch normalization 與他愉快的小伙伴岳華 杜
 
從 VAE 走向深度學習新理論
從 VAE 走向深度學習新理論從 VAE 走向深度學習新理論
從 VAE 走向深度學習新理論岳華 杜
 
COSCUP: Foreign Function Call in Julia
COSCUP: Foreign Function Call in JuliaCOSCUP: Foreign Function Call in Julia
COSCUP: Foreign Function Call in Julia岳華 杜
 
COSCUP: Metaprogramming in Julia
COSCUP: Metaprogramming in JuliaCOSCUP: Metaprogramming in Julia
COSCUP: Metaprogramming in Julia岳華 杜
 
COSCUP: Introduction to Julia
COSCUP: Introduction to JuliaCOSCUP: Introduction to Julia
COSCUP: Introduction to Julia岳華 杜
 
Introduction to Julia
Introduction to JuliaIntroduction to Julia
Introduction to Julia岳華 杜
 
20180506 Introduction to machine learning
20180506 Introduction to machine learning20180506 Introduction to machine learning
20180506 Introduction to machine learning岳華 杜
 
20171127 當julia遇上資料科學
20171127 當julia遇上資料科學20171127 當julia遇上資料科學
20171127 當julia遇上資料科學岳華 杜
 
20171117 oop and design patterns in julia
20171117 oop and design patterns in julia20171117 oop and design patterns in julia
20171117 oop and design patterns in julia岳華 杜
 
20171014 tips for manipulating filesystem in julia
20171014 tips for manipulating filesystem in julia20171014 tips for manipulating filesystem in julia
20171014 tips for manipulating filesystem in julia岳華 杜
 
20170807 julia的簡單而高效資料處理
20170807 julia的簡單而高效資料處理20170807 julia的簡單而高效資料處理
20170807 julia的簡單而高效資料處理岳華 杜
 
20170715 北Bio meetup
20170715 北Bio meetup20170715 北Bio meetup
20170715 北Bio meetup岳華 杜
 

More from 岳華 杜 (20)

Julia: The language for future
Julia: The language for futureJulia: The language for future
Julia: The language for future
 
The Language for future-julia
The Language for future-juliaThe Language for future-julia
The Language for future-julia
 
20190907 Julia the language for future
20190907 Julia the language for future20190907 Julia the language for future
20190907 Julia the language for future
 
Metaprogramming in julia
Metaprogramming in juliaMetaprogramming in julia
Metaprogramming in julia
 
Introduction to julia
Introduction to juliaIntroduction to julia
Introduction to julia
 
自然語言處理概覽
自然語言處理概覽自然語言處理概覽
自然語言處理概覽
 
Introduction to machine learning
Introduction to machine learningIntroduction to machine learning
Introduction to machine learning
 
Semantic Segmentation - Fully Convolutional Networks for Semantic Segmentation
Semantic Segmentation - Fully Convolutional Networks for Semantic SegmentationSemantic Segmentation - Fully Convolutional Networks for Semantic Segmentation
Semantic Segmentation - Fully Convolutional Networks for Semantic Segmentation
 
Batch normalization 與他愉快的小伙伴
Batch normalization 與他愉快的小伙伴Batch normalization 與他愉快的小伙伴
Batch normalization 與他愉快的小伙伴
 
從 VAE 走向深度學習新理論
從 VAE 走向深度學習新理論從 VAE 走向深度學習新理論
從 VAE 走向深度學習新理論
 
COSCUP: Foreign Function Call in Julia
COSCUP: Foreign Function Call in JuliaCOSCUP: Foreign Function Call in Julia
COSCUP: Foreign Function Call in Julia
 
COSCUP: Metaprogramming in Julia
COSCUP: Metaprogramming in JuliaCOSCUP: Metaprogramming in Julia
COSCUP: Metaprogramming in Julia
 
COSCUP: Introduction to Julia
COSCUP: Introduction to JuliaCOSCUP: Introduction to Julia
COSCUP: Introduction to Julia
 
Introduction to Julia
Introduction to JuliaIntroduction to Julia
Introduction to Julia
 
20180506 Introduction to machine learning
20180506 Introduction to machine learning20180506 Introduction to machine learning
20180506 Introduction to machine learning
 
20171127 當julia遇上資料科學
20171127 當julia遇上資料科學20171127 當julia遇上資料科學
20171127 當julia遇上資料科學
 
20171117 oop and design patterns in julia
20171117 oop and design patterns in julia20171117 oop and design patterns in julia
20171117 oop and design patterns in julia
 
20171014 tips for manipulating filesystem in julia
20171014 tips for manipulating filesystem in julia20171014 tips for manipulating filesystem in julia
20171014 tips for manipulating filesystem in julia
 
20170807 julia的簡單而高效資料處理
20170807 julia的簡單而高效資料處理20170807 julia的簡單而高效資料處理
20170807 julia的簡單而高效資料處理
 
20170715 北Bio meetup
20170715 北Bio meetup20170715 北Bio meetup
20170715 北Bio meetup
 

Recently uploaded

ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxnada99848
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 

Recently uploaded (20)

ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptx
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 

[COSCUP 2023] 我的Julia軟體架構演進之旅

  • 1. 我的 Julia 軟體架構演進之旅 Yueh-Hua Tu Ph.D. ML Engineer@Taiwan AI Labs Saturday 29th July, 2023 Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 1 / 28
  • 2. Projects Open source projects FluxML/GeometricFlux.jl yuehhua/GraphSignals.jl yuehhua/CDGRNs.jl JuliaSingleCellOmics/SnowyOwl.jl Current work Federated learning system architecture Bioinformatics analysis tool development (e.g. GWAS, linkage disequilibrium and statistics) Program optimization for execution performance Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 2 / 28
  • 3. Outline 1. Prototyping-Development Iteration 2. TDD and Test Coverage 3. Evolutionary Design 4. Principles of Software Engineering 5. Development Mindset Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 3 / 28
  • 4. Developing from scratch If we want a project for statistical analysis, where could we start? Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 4 / 28
  • 5. Prototyping linear regression Inference y = Xβ 1 julia> predict(X, β)=X∗β Fitting β = (XT X)−1 XT y 1 julia> fit(X, y) = inv(X'*X) * X'*y Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 5 / 28
  • 6. Prototyping-Development Iteration Prototyping-Development Iteration Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 6 / 28
  • 7. Prototyping-Development Iteration Prototyping-Development Iteration (PDI) Prototyping first then develop for flexibility and performance! For prototyping and researching Figure: Scripts ⇒ For development Figure: Codebase Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 7 / 28
  • 8. Prototyping-Development Iteration Prototyping Figure: Scripts Implement a simple and standalone feature in a script to ensure correctness. 1 julia> predict(X, β)=X∗β 2 3 julia> fit(X, y) = inv(X'*X) * X'*y And try to wrap these features into functions. Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 8 / 28
  • 9. Prototyping-Development Iteration Development Figure: Codebase Puts functions or components into your codebase and design for reusablility and flexibility. 1 struct LinearRegressionModel 2 β 3 end 4 5 coefs(m::LinearRegressionModel) = m.β 6 7 predict(m::LinearRegressionModel, X) = X*coefs(m) 8 9 fit(::Type{LinearRegressionModel}, X, y) = LinearRegressionModel(inv(X'*X) * X'*y) , → After putting components into codebase, ensure your scripts still work for you. Don't put to much specifics into codebase (e.g. data, configs). Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 9 / 28
  • 10. TDD and Test Coverage TDD and Test Coverage Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 10 / 28
  • 11. TDD and Test Coverage Test-Driven Development (TDD) Actually, PDI is a kind of TDD process. We still need to add some test cases and ensure tests are passed. Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 11 / 28
  • 12. TDD and Test Coverage TDD in Julia TDD is very simple in Julia. test/runtests.jl 1 @testset "MyProject.jl" begin 2 @test coefs(model) == β 3 ... 4 end 1 (@v1.9) pkg> test Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 12 / 28
  • 13. TDD and Test Coverage Develop for flexibility src/stats.jl 1 cov(X, Y) = innerprod(X, Y) src/linalg.jl 1 innerprod(x, y) = x'*y src/regression.jl fit(::Type{LinearRegressionModel}, X, y) = LinearRegressionModel(inv(innerprod(X, X)) * innerprod(X, y)) , → Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 13 / 28
  • 14. TDD and Test Coverage Develop for performance src/linalg.jl function innerprod(X::AbstractMatrix, y::AbstractVector) # acceleration techniques: SIMD, GPU... end function innerprod(X::AbstractMatrix, Y::AbstractMatrix) # acceleration techniques: SIMD, GPU... end Specification for optimization and keep consistent interfaces. Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 14 / 28
  • 15. TDD and Test Coverage Test coverage Keep high test coverage as possible to ensure your codebase provides desired features. Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 15 / 28
  • 16. Evolutionary Design Evolutionary Design Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 16 / 28
  • 17. Evolutionary Design Adding new features If we want to add new approach to solve a linear system, how can we do? Ax = b 1 using LinearSolve 2 3 A = rand(4, 4) 4 b = rand(4) 5 prob = LinearProblem(A, b) 6 sol = solve(prob) Adding new features could be prototyped by Adding types Extending existing functions Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 17 / 28
  • 18. Evolutionary Design Adding types Original struct RegularSolver end solve(m::RegularSolver, A, b) = solve(LinearProblem(A, b)) , → ⇒ Adding CholeskySolver 1 abstract type LinearSolver end 2 3 struct RegularSolver <: LinearSolver end 4 struct CholeskySolver <: LinearSolver end 5 6 solve(m::RegularSolver, A, b) = solve(LinearProblem(A, b)) , → Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 18 / 28
  • 19. Evolutionary Design Extending functions/methods Original abstract type LinearSolver end struct RegularSolver <: LinearSolver end , → struct CholeskySolver <: LinearSolver end , → solve(m::RegularSolver, A, b) = solve(LinearProblem(A, b)) , → ⇒ Extending solve to CholeskySolver. 1 abstract type LinearSolver end 2 3 struct RegularSolver <: LinearSolver end 4 struct CholeskySolver <: LinearSolver end 5 6 solve(m::RegularSolver, A, b) = solve(LinearProblem(A, b)) , → 7 solve(m::CholeskySolver, A, b) = # Cholesky decomposition... , → Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 19 / 28
  • 20. Principles of Software Engineering Principles of Software Engineering Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 20 / 28
  • 21. Principles of Software Engineering Single Responsibility Principle A class or function should be responsible to only one actor. LinearModel: represent a linear model coefs: returns model coefficients fit: fitting model LinearSolver: approach to solve a linear system solve: determines how to solve a linear system Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 21 / 28
  • 22. Principles of Software Engineering Open-Closed Principle A module will be said to be open for extension and be said to be closed for modification. struct LinearRegressionModel β end coefs(m::LinearRegressionModel) = m.β ⇒ 1 abstract type LinearModel end 2 3 struct LinearRegressionModel <: LinearModel , → 4 β 5 end 6 7 struct LogisticRegressionModel <: LinearModel , → 8 β 9 end 10 11 coefs(m::LinearRegressionModel) = m.β 12 coefs(m::LogisticRegressionModel) = m.β Benefitial from Julia's features of type and method separation, it's easy to add new types or Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 22 / 28
  • 23. Principles of Software Engineering Liskov Substitution Principle Derived class can be able to replace its base class. abstract type LinearModel end struct LinearRegressionModel <: LinearModel β end struct LogisticRegressionModel <: LinearModel β end Since Julia's subtyping system doesn't allow composite types as super types, Julia always run composite types in practice. Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 23 / 28
  • 24. Principles of Software Engineering Interface Segregation Principle No code should be forced to depend on methods it does not use. 1 julia> model = fit(LinearRegressionModel, X, y) , → 2 3 julia> coefs(model) 4 5 julia> model = fit(LogisticRegressionModel, X, y) , → 6 7 julia> coefs(model) User just need to know interfaces. 1 module MyPackage 2 abstract type LinearModel end 3 struct LinearRegressionModel <: LinearModel , → 4 β 5 end 6 struct LogisticRegressionModel <: LinearModel , → 7 β 8 end 9 coefs(m::LinearRegressionModel) = m.β 10 coefs(m::LogisticRegressionModel) = m.β 11 end Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 24 / 28
  • 25. Principles of Software Engineering Dependency Inversion Principle Dependency injection 1 abstract type LinearSolver end 2 3 struct RegularSolver <: LinearSolver end 4 struct CholeskySolver <: LinearSolver end 5 struct QRSolver <: LinearSolver end 1 abstract type LinearModel end 2 3 struct LinearRegressionModel <: LinearModel end , → 4 struct LogisticRegressionModel <: LinearModel end , → 5 6 fit(::Type{LinearRegressionModel}, X, y; algo=CholeskySolver()) , → 7 fit(::Type{LogisticRegressionModel}, X, y; algo=CholeskySolver()) , → Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 25 / 28
  • 26. Development Mindset Development Mindset Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 26 / 28
  • 27. Development Mindset Issues and Pull Requests 貢獻者 遇到善於給建議(機車)的人 如何主持跟維護專案 Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 27 / 28
  • 28. Development Mindset Thank you for attention Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 28 / 28