SlideShare a Scribd company logo
Refactoring the BlackBerry’s
GaugeField component
Mohammad Talha Khalid
All respective BlackBerry images and logos are the property of BlackBerry (Research In Motion)
Presentation Background
I originally created this presentation for my SE 464 Software
Architecture class, based on my co-op experience at BlackBerry.
I subsequently entered it into the SFF Technical Speaking
Competition (2nd Place Award).
GaugeField component
• UI Components team
– Makes UI Components
for the BlackBerry
Project Overview
• Refactor the GaugeField component to
adhere to the MVC pattern
– Restructure & Rearrange the code
– Splitting up into M, V, C
• SE 464 Relevance
– Refactoring
– MVC Design Pattern
Why refactor the GaugeField?
• Code will be easier to understand
– All the code was in one class... messy
• MVC makes sense for a UI component
– Easier to modify the component
– Add more input controllers
• Support touch-screen devices
– Add more Views
Refactoring Process
Applying behavior-preserving transformations
1) Adding new classes
– Controller & View
2) Method extraction
– Identify all the code relevant to M, V, C
– Extract code
– Put it in the View and Controller classes
1
2
#1: Adding Classes
Original GaugeField class
#1: Adding Classes
• Adding 2 aggregate classes
– GaugeField “has a” GaugeFieldView
#2: Method Extraction
1. Select code
2. Place it in a new (private) method
3. Call the new method
private void clone(){
}
#2: Method Extraction
GaugeField(){
//constructor…
}
TrackBall_Input (){
//handle trackball events…..
}
Paint_ProgressBar(){
//paint the progress bar…
}
Controller
View
GaugeField(){
GaugeFieldController _controller;
GaugeFieldView _view;
}
TrackBall_Input (){
_controller.TrackBall_Input()
}
Paint_ProgressBar(){
_view.Paint_ProgressBar()
}
GaugeFieldController
TrackBall_Input(){
//handle trackball events…..
}
GaugeFieldView
Paint_ProgressBar(){
//paint the progress bar…
}
GaugeField(){
GaugeFieldController _controller;
GaugeFieldView _view;
}
TrackBallInput (){
_controller.TrackBallInput()
}
PaintProgressBar(){
_view.PaintProgressBar()
}
GaugeFieldController
FooTrackBallInput(){
//handle trackball events…..
}
GaugeFieldView
PaintProgressBar(){
//paint the progress bar…
}
Adding Classes
GaugeField has a
Controller and View
1
GaugeField(){
GaugeFieldController _controller;
GaugeFieldView _view;
}
TrackBallInput (){
_controller.TrackBallInput()
}
GaugeFieldController
TrackBallInput(){
//handle trackball events…..
}
Method Extraction
Redirecting to the Controller
2
A note about re-directing
• Cannot destroy current
methods
– Developers rely on the API
• But old methods can
redirect to the new
methods
Just re-directing?
• Many methods were self-contained
– Extraction
– Re-direction
• There was code that was not self-contained
Benefits
• Code is neatly organized
– Split up into M, V, C
• Beneficial for the Controller & View
– Easier to add more methods in the future
1
2
Beneficial for the View
Progress Bar View Pyramid View
Beneficial for the Controller
Trackball Trackpad Touch-screen
Beneficial for the Controller
GaugeFieldController
TrackBall_Input(){
//handle trackball events…..
}
TouchEvents(){
//handle touchscreen events…
}
Trackpad(){
//handle trackpad…
}
Beneficial for BlackBerry?
Summary
• Restructured the GaugeField code
• Added Classes
• Method Extraction
– Old methods re-directed to the new
methods
– Helped preserve the API
• MVC allows you to enhance the
View & Controller with more
functionality
1
2
The End
All respective BlackBerry images and logos are the property of BlackBerry (Research In Motion)
Image References
Images in this presentation were extracted from the Internet, and are the property of
their respective owners, including BlackBerry.
A non-exhaustive list of miscellaneous image references follows. Caveat: Some of the
labels in the domain names are a bit peculiar.
Peculiar URL References:
• http://2.bp.blogspot.com/_xhI2QKKA6cY/ScFMZdFhxMI/AAAAAAAAAWI/YsmJKn7
Doz4/s400/image.axd+%281%29.png
• http://www.stopgettingcheated.com/images/easy-button.jpg
• http://www.stop-age.com/userfiles/image/syringe2.jpg
• http://www.code-magazine.com/article.aspx?quickid=0401071&page=2
• http://www.dreamstime.com/doctor-with-syringe-needle-image5290308

More Related Content

Viewers also liked

Excursión Atalaya
Excursión AtalayaExcursión Atalaya
Excursión Atalaya
gelfling333
 
Mercedes Benz - Story of a thousand hours
Mercedes Benz - Story of a thousand hoursMercedes Benz - Story of a thousand hours
Mercedes Benz - Story of a thousand hours
Zeeshan Ali Contractor
 
Technical Seminar PPT
Technical Seminar PPTTechnical Seminar PPT
Technical Seminar PPT
Kshitiz_Vj
 
Download presentation
Download presentationDownload presentation
Download presentation
webhostingguy
 
Free Download Powerpoint Slides
Free Download Powerpoint SlidesFree Download Powerpoint Slides
Free Download Powerpoint Slides
George
 
Technology powerpoint presentations
Technology powerpoint presentationsTechnology powerpoint presentations
Technology powerpoint presentations
ismailraesha
 

Viewers also liked (6)

Excursión Atalaya
Excursión AtalayaExcursión Atalaya
Excursión Atalaya
 
Mercedes Benz - Story of a thousand hours
Mercedes Benz - Story of a thousand hoursMercedes Benz - Story of a thousand hours
Mercedes Benz - Story of a thousand hours
 
Technical Seminar PPT
Technical Seminar PPTTechnical Seminar PPT
Technical Seminar PPT
 
Download presentation
Download presentationDownload presentation
Download presentation
 
Free Download Powerpoint Slides
Free Download Powerpoint SlidesFree Download Powerpoint Slides
Free Download Powerpoint Slides
 
Technology powerpoint presentations
Technology powerpoint presentationsTechnology powerpoint presentations
Technology powerpoint presentations
 

Similar to Technical Presentation - BlackBerry - Refactoring the Gaugefield Component - University of Waterloo

angular fundamentals.pdf angular fundamentals.pdf
angular fundamentals.pdf angular fundamentals.pdfangular fundamentals.pdf angular fundamentals.pdf
angular fundamentals.pdf angular fundamentals.pdf
NuttavutThongjor1
 
Protocol-Oriented Programming in Swift
Protocol-Oriented Programming in SwiftProtocol-Oriented Programming in Swift
Protocol-Oriented Programming in Swift
Oleksandr Stepanov
 
Android development 1july
Android development 1julyAndroid development 1july
Android development 1july
Edureka!
 
Angular 2 Migration - JHipster Meetup 6
Angular 2 Migration - JHipster Meetup 6Angular 2 Migration - JHipster Meetup 6
Angular 2 Migration - JHipster Meetup 6
William Marques
 
Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)
Oro Inc.
 
Building an Angular 2 App
Building an Angular 2 AppBuilding an Angular 2 App
Building an Angular 2 App
Felix Gessert
 
Develop Mobile App Using Android Lollipop
Develop Mobile App Using Android LollipopDevelop Mobile App Using Android Lollipop
Develop Mobile App Using Android Lollipop
Edureka!
 
What is your money doing?
What is your money doing?What is your money doing?
What is your money doing?
Alfonso Fernández
 
Nagios Conference 2013 - Jake Omann - Developing Nagios XI Components and Wiz...
Nagios Conference 2013 - Jake Omann - Developing Nagios XI Components and Wiz...Nagios Conference 2013 - Jake Omann - Developing Nagios XI Components and Wiz...
Nagios Conference 2013 - Jake Omann - Developing Nagios XI Components and Wiz...
Nagios
 
Angular 2 at solutions.hamburg
Angular 2 at solutions.hamburgAngular 2 at solutions.hamburg
Angular 2 at solutions.hamburg
Baqend
 
Lightning salesforce
Lightning salesforceLightning salesforce
Lightning salesforce
mounikadv
 
angular fundamentals.pdf
angular fundamentals.pdfangular fundamentals.pdf
angular fundamentals.pdf
NuttavutThongjor1
 
Jan 2017 - a web of applications (angular 2)
Jan 2017 - a web of applications (angular 2)Jan 2017 - a web of applications (angular 2)
Jan 2017 - a web of applications (angular 2)
Kasper Reijnders
 
Implementing one feature set in two JavaScript engines (Web Engines Hackfest ...
Implementing one feature set in two JavaScript engines (Web Engines Hackfest ...Implementing one feature set in two JavaScript engines (Web Engines Hackfest ...
Implementing one feature set in two JavaScript engines (Web Engines Hackfest ...
Igalia
 
Builder Design Pattern (Generic Construction -Different Representation)
Builder Design Pattern (Generic Construction -Different Representation)Builder Design Pattern (Generic Construction -Different Representation)
Builder Design Pattern (Generic Construction -Different Representation)
Sameer Rathoud
 
Jsf intro
Jsf introJsf intro
Jsf intro
vantinhkhuc
 
Gutenberg sous le capot, modules réutilisables
Gutenberg sous le capot, modules réutilisablesGutenberg sous le capot, modules réutilisables
Gutenberg sous le capot, modules réutilisables
Riad Benguella
 
Hidden Docs in Angular
Hidden Docs in AngularHidden Docs in Angular
Hidden Docs in Angular
Yadong Xie
 
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia InstituteMVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
Ravi Bhadauria
 
[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM pattern[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM pattern
NAVER Engineering
 

Similar to Technical Presentation - BlackBerry - Refactoring the Gaugefield Component - University of Waterloo (20)

angular fundamentals.pdf angular fundamentals.pdf
angular fundamentals.pdf angular fundamentals.pdfangular fundamentals.pdf angular fundamentals.pdf
angular fundamentals.pdf angular fundamentals.pdf
 
Protocol-Oriented Programming in Swift
Protocol-Oriented Programming in SwiftProtocol-Oriented Programming in Swift
Protocol-Oriented Programming in Swift
 
Android development 1july
Android development 1julyAndroid development 1july
Android development 1july
 
Angular 2 Migration - JHipster Meetup 6
Angular 2 Migration - JHipster Meetup 6Angular 2 Migration - JHipster Meetup 6
Angular 2 Migration - JHipster Meetup 6
 
Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)
 
Building an Angular 2 App
Building an Angular 2 AppBuilding an Angular 2 App
Building an Angular 2 App
 
Develop Mobile App Using Android Lollipop
Develop Mobile App Using Android LollipopDevelop Mobile App Using Android Lollipop
Develop Mobile App Using Android Lollipop
 
What is your money doing?
What is your money doing?What is your money doing?
What is your money doing?
 
Nagios Conference 2013 - Jake Omann - Developing Nagios XI Components and Wiz...
Nagios Conference 2013 - Jake Omann - Developing Nagios XI Components and Wiz...Nagios Conference 2013 - Jake Omann - Developing Nagios XI Components and Wiz...
Nagios Conference 2013 - Jake Omann - Developing Nagios XI Components and Wiz...
 
Angular 2 at solutions.hamburg
Angular 2 at solutions.hamburgAngular 2 at solutions.hamburg
Angular 2 at solutions.hamburg
 
Lightning salesforce
Lightning salesforceLightning salesforce
Lightning salesforce
 
angular fundamentals.pdf
angular fundamentals.pdfangular fundamentals.pdf
angular fundamentals.pdf
 
Jan 2017 - a web of applications (angular 2)
Jan 2017 - a web of applications (angular 2)Jan 2017 - a web of applications (angular 2)
Jan 2017 - a web of applications (angular 2)
 
Implementing one feature set in two JavaScript engines (Web Engines Hackfest ...
Implementing one feature set in two JavaScript engines (Web Engines Hackfest ...Implementing one feature set in two JavaScript engines (Web Engines Hackfest ...
Implementing one feature set in two JavaScript engines (Web Engines Hackfest ...
 
Builder Design Pattern (Generic Construction -Different Representation)
Builder Design Pattern (Generic Construction -Different Representation)Builder Design Pattern (Generic Construction -Different Representation)
Builder Design Pattern (Generic Construction -Different Representation)
 
Jsf intro
Jsf introJsf intro
Jsf intro
 
Gutenberg sous le capot, modules réutilisables
Gutenberg sous le capot, modules réutilisablesGutenberg sous le capot, modules réutilisables
Gutenberg sous le capot, modules réutilisables
 
Hidden Docs in Angular
Hidden Docs in AngularHidden Docs in Angular
Hidden Docs in Angular
 
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia InstituteMVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
 
[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM pattern[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM pattern
 

Recently uploaded

Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Undress Baby
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
Remote DBA Services
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
Yara Milbes
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Envertis Software Solutions
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
Quickdice ERP
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
lorraineandreiamcidl
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 

Recently uploaded (20)

Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 

Technical Presentation - BlackBerry - Refactoring the Gaugefield Component - University of Waterloo

  • 1. Refactoring the BlackBerry’s GaugeField component Mohammad Talha Khalid All respective BlackBerry images and logos are the property of BlackBerry (Research In Motion)
  • 2. Presentation Background I originally created this presentation for my SE 464 Software Architecture class, based on my co-op experience at BlackBerry. I subsequently entered it into the SFF Technical Speaking Competition (2nd Place Award).
  • 3. GaugeField component • UI Components team – Makes UI Components for the BlackBerry
  • 4. Project Overview • Refactor the GaugeField component to adhere to the MVC pattern – Restructure & Rearrange the code – Splitting up into M, V, C • SE 464 Relevance – Refactoring – MVC Design Pattern
  • 5. Why refactor the GaugeField? • Code will be easier to understand – All the code was in one class... messy • MVC makes sense for a UI component – Easier to modify the component – Add more input controllers • Support touch-screen devices – Add more Views
  • 6. Refactoring Process Applying behavior-preserving transformations 1) Adding new classes – Controller & View 2) Method extraction – Identify all the code relevant to M, V, C – Extract code – Put it in the View and Controller classes 1 2
  • 7. #1: Adding Classes Original GaugeField class
  • 8. #1: Adding Classes • Adding 2 aggregate classes – GaugeField “has a” GaugeFieldView
  • 9. #2: Method Extraction 1. Select code 2. Place it in a new (private) method 3. Call the new method private void clone(){ }
  • 10. #2: Method Extraction GaugeField(){ //constructor… } TrackBall_Input (){ //handle trackball events….. } Paint_ProgressBar(){ //paint the progress bar… } Controller View
  • 11. GaugeField(){ GaugeFieldController _controller; GaugeFieldView _view; } TrackBall_Input (){ _controller.TrackBall_Input() } Paint_ProgressBar(){ _view.Paint_ProgressBar() } GaugeFieldController TrackBall_Input(){ //handle trackball events….. } GaugeFieldView Paint_ProgressBar(){ //paint the progress bar… }
  • 12. GaugeField(){ GaugeFieldController _controller; GaugeFieldView _view; } TrackBallInput (){ _controller.TrackBallInput() } PaintProgressBar(){ _view.PaintProgressBar() } GaugeFieldController FooTrackBallInput(){ //handle trackball events….. } GaugeFieldView PaintProgressBar(){ //paint the progress bar… } Adding Classes GaugeField has a Controller and View 1
  • 13. GaugeField(){ GaugeFieldController _controller; GaugeFieldView _view; } TrackBallInput (){ _controller.TrackBallInput() } GaugeFieldController TrackBallInput(){ //handle trackball events….. } Method Extraction Redirecting to the Controller 2
  • 14. A note about re-directing • Cannot destroy current methods – Developers rely on the API • But old methods can redirect to the new methods
  • 15. Just re-directing? • Many methods were self-contained – Extraction – Re-direction • There was code that was not self-contained
  • 16. Benefits • Code is neatly organized – Split up into M, V, C • Beneficial for the Controller & View – Easier to add more methods in the future 1 2
  • 17. Beneficial for the View Progress Bar View Pyramid View
  • 18. Beneficial for the Controller Trackball Trackpad Touch-screen
  • 19. Beneficial for the Controller GaugeFieldController TrackBall_Input(){ //handle trackball events….. } TouchEvents(){ //handle touchscreen events… } Trackpad(){ //handle trackpad… }
  • 21. Summary • Restructured the GaugeField code • Added Classes • Method Extraction – Old methods re-directed to the new methods – Helped preserve the API • MVC allows you to enhance the View & Controller with more functionality 1 2
  • 22. The End All respective BlackBerry images and logos are the property of BlackBerry (Research In Motion)
  • 23. Image References Images in this presentation were extracted from the Internet, and are the property of their respective owners, including BlackBerry. A non-exhaustive list of miscellaneous image references follows. Caveat: Some of the labels in the domain names are a bit peculiar. Peculiar URL References: • http://2.bp.blogspot.com/_xhI2QKKA6cY/ScFMZdFhxMI/AAAAAAAAAWI/YsmJKn7 Doz4/s400/image.axd+%281%29.png • http://www.stopgettingcheated.com/images/easy-button.jpg • http://www.stop-age.com/userfiles/image/syringe2.jpg • http://www.code-magazine.com/article.aspx?quickid=0401071&page=2 • http://www.dreamstime.com/doctor-with-syringe-needle-image5290308