SlideShare a Scribd company logo
Buliding Object-Oriented Applications in PowerBuilder  Module 7: Encapsulation
Objectives Define encapsulation Describe the techniques associated with encapsulation Encapsulate properties, methods, functions, and window controls
Topics In troduction Information Hiding Encapsulating Properties Encapsulating Methods Window Controls and User Object Controls Encapsulation Read / Write Access
Encapsulation  Encapsulation is the process of defining a class of  objects that: Perform behavior upon request using input data Provide the results of that behavior as output data Require no external knowledge of the internal methods
Encapsulation 1. Clicked! 2. Send message to DataWindow control: "Scroll to next page"
Encapsulation — Information Hiding No direct access to manipulate properties (data) Properties accessed only via methods Object controls access to its data "Published" functional interface to make use of the object's behavior
Encapsulation in PowerBuilder Instance variables declared private for the object Data can be manipulated outside the object only through user-defined functions Communication with the object occurs via user-defined events or user-defined functions
Encapsulation — Benefits Prevents unexpected and undesirable changes from external sources No external impact from internal implementation changes
Encapsulating Properties — Implementation Encapsulate instance variables by defining their access as private or protected Declare "Get" and "Set" functions for access To make a property read-only, declare "Get" functions only
Encapsulating Properties Define access rights for instance variables: Public – Any scripts in the application (default) Private – Scripts for the object for which the variable was declared Protected – Scripts for the object and descendants of the object
Encapsulating Properties
Encapsulating Properties — Access and Scope Instance variables default to public — can make private or protected Global variables are always public Shared variables are always private PowerBuilder-defined properties are always public (for example, Window.X)
Encapsulating Properties  Access to PowerBuilder-defined properties cannot be modified; they are always public For example: x and y are properties of a window Using Move(300, 200) sets their values and does not require knowledge of property names But, x and y values can be directly set for a window: x = 300 y = 200
Encapsulating Methods Some user-defined methods should not be open to public access Events are always public Object functions can be made private or protected Specify access rights in the object Function painter definition window
Encapsulating Methods  —  Function Access
Encapsulating Methods — Function Access Menu, window, and user-object functions can be private, protected, or public (default) All PowerBuilder functions are public — no access modifiers Globally defined user functions are always public — no access modifiers Private functions are meaningful only to the internal behavior of objects; protected functions may need to be called from descendants
Encapsulating Methods Benefits Implementation of behavior can be changed or enhanced without affecting "clients" Platform-dependent behavior is implemented through "plug and play" Using encapsulated behavior does not require external knowledge of implementation
Encapsulation — Controls Window controls or user object controls are secondary classes Secondary classes can: Be accessed only through the primary class, for example:  w_cust.cb_ok.Hide( ) Access private and protected  instance  variables of the primary class Access private and protected  functions  of the primary class
Read / Write Access Keyword restricting ability of scripts to read / write a variable's value — called operational access Fine-tunes access rights Declared with the instance variable declaration Used for variables only,  not functions
Read Access ProtectedRead  Only scripts in object and descendants can read Only valid if access right is public public ProtectedRead integer ii_count PrivateRead  Only scripts in object can read Only valid if access right is public or protected protected PrivateRead integer ii_maxcount
Write Access ProtectedWrite  Only scripts in object and descendants can write Only valid if access right is public public ProtectedWrite int ii_count PrivateWrite  Only scripts in object can write Only valid if access right is public or protected protected PrivateWrite int ii_maxcount
Read / Write Access Can be combined in declaration public PrivateRead PrivateWrite int ii_count Net effect:  Compiler generates warning if there is an attempt to redefine access in the descendant
Summary Encapsulation is the process of incorporating properties and methods together in an object. Information hiding limits access to an object's properties and implementation of its behavior. PowerBuilder allows encapsulation, but it does not enforce it. Access rights can be assigned to user functions and instance variables.
Summary Events are always public.  Operational access rights are used to fine-tune access to instance variables (for example, make instance variables public, but read-only).
Summary Questions
Lab Setup What you will need to do the lab: · Define a custom visual user class · Encapsulate methods and properties in a custom visual user class · Restrict access to properties
Lab Debriefing Initialize the DataWindow control reference Then use it. idw_control.ScrollToRow(1)
Lab Debriefing The report window uses the control uo_scroller.of_initdw( this) ue_postconstructor of  Datawindow control
Lab Debriefing Discuss – what kinds of additional things could you have done in the of_initDW( )  Could you have been assured that these were done if the variable idw_control had not been declared private?
Lab Debriefing Some Examples: Debugging – you can put a breakpoint on the of_initDW() Logging – you could add code to log to a file Validation – you could add code to validate  In Version 2 of your application, you could add an array of DataWindow controls If you had not declared your variable private, you could not be assured that some client was using the of_initDW() to initialize the reference.

More Related Content

What's hot

12 encapsulation
12   encapsulation12   encapsulation
12 encapsulation
dhrubo kayal
 
Java Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepJava Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By Step
Guo Albert
 
Entity Persistence with JPA
Entity Persistence with JPAEntity Persistence with JPA
Entity Persistence with JPA
Subin Sugunan
 
JPA For Beginner's
JPA For Beginner'sJPA For Beginner's
JPA For Beginner's
NarayanaMurthy Ganashree
 
Java persistence api 2.1
Java persistence api 2.1Java persistence api 2.1
Java persistence api 2.1
Rakesh K. Cherukuri
 
hibernate with JPA
hibernate with JPAhibernate with JPA
hibernate with JPA
Mohammad Faizan
 
Introduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examplesIntroduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examples
ecosio GmbH
 
Db locking
Db lockingDb locking
Db locking
Marek Hudyma
 
Abstraction file
Abstraction fileAbstraction file
Abstraction file
Hoang Nguyen
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentation
guest11106b
 
Pavel_Kravchenko_Mobile Development
Pavel_Kravchenko_Mobile DevelopmentPavel_Kravchenko_Mobile Development
Pavel_Kravchenko_Mobile Development
Ciklum
 

What's hot (11)

12 encapsulation
12   encapsulation12   encapsulation
12 encapsulation
 
Java Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepJava Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By Step
 
Entity Persistence with JPA
Entity Persistence with JPAEntity Persistence with JPA
Entity Persistence with JPA
 
JPA For Beginner's
JPA For Beginner'sJPA For Beginner's
JPA For Beginner's
 
Java persistence api 2.1
Java persistence api 2.1Java persistence api 2.1
Java persistence api 2.1
 
hibernate with JPA
hibernate with JPAhibernate with JPA
hibernate with JPA
 
Introduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examplesIntroduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examples
 
Db locking
Db lockingDb locking
Db locking
 
Abstraction file
Abstraction fileAbstraction file
Abstraction file
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentation
 
Pavel_Kravchenko_Mobile Development
Pavel_Kravchenko_Mobile DevelopmentPavel_Kravchenko_Mobile Development
Pavel_Kravchenko_Mobile Development
 

Viewers also liked

Booa8 Slide 03
Booa8 Slide 03Booa8 Slide 03
Booa8 Slide 03
oswchavez
 
Booa8 Slide 02
Booa8 Slide 02Booa8 Slide 02
Booa8 Slide 02
oswchavez
 
Powerbuilder tutorial
Powerbuilder tutorialPowerbuilder tutorial
Powerbuilder tutorial
dzas42
 
Booa8 Slide 01
Booa8 Slide 01Booa8 Slide 01
Booa8 Slide 01
oswchavez
 
Booa8 Slide 04
Booa8 Slide 04Booa8 Slide 04
Booa8 Slide 04
oswchavez
 
Booa8 Slide 09
Booa8 Slide 09Booa8 Slide 09
Booa8 Slide 09
oswchavez
 

Viewers also liked (6)

Booa8 Slide 03
Booa8 Slide 03Booa8 Slide 03
Booa8 Slide 03
 
Booa8 Slide 02
Booa8 Slide 02Booa8 Slide 02
Booa8 Slide 02
 
Powerbuilder tutorial
Powerbuilder tutorialPowerbuilder tutorial
Powerbuilder tutorial
 
Booa8 Slide 01
Booa8 Slide 01Booa8 Slide 01
Booa8 Slide 01
 
Booa8 Slide 04
Booa8 Slide 04Booa8 Slide 04
Booa8 Slide 04
 
Booa8 Slide 09
Booa8 Slide 09Booa8 Slide 09
Booa8 Slide 09
 

Similar to Booa8 Slide 07

Encapsulation C++ Piller of OOP it is the important piller
Encapsulation C++ Piller of OOP it is the important pillerEncapsulation C++ Piller of OOP it is the important piller
Encapsulation C++ Piller of OOP it is the important piller
an7539661
 
Encapsulation C++ Piller of OOP it is the important piller
Encapsulation C++ Piller of OOP it is the important pillerEncapsulation C++ Piller of OOP it is the important piller
Encapsulation C++ Piller of OOP it is the important piller
an7539661
 
Context and Dependency Injection 2.0
Context and Dependency Injection 2.0Context and Dependency Injection 2.0
Context and Dependency Injection 2.0
Brian S. Paskin
 
Intro to iOS Development • Made by Many
Intro to iOS Development • Made by ManyIntro to iOS Development • Made by Many
Intro to iOS Development • Made by Many
kenatmxm
 
C++Presentation 2.PPT
C++Presentation 2.PPTC++Presentation 2.PPT
C++Presentation 2.PPT
VENARATEKANHURU
 
Object-oriented programming
Object-oriented programmingObject-oriented programming
Object-oriented programming
Neelesh Shukla
 
Mca 504 dotnet_unit3
Mca 504 dotnet_unit3Mca 504 dotnet_unit3
Configuring CQ Security
Configuring CQ SecurityConfiguring CQ Security
Configuring CQ Security
connectwebex
 
Chapter2 Encapsulation (Java)
Chapter2 Encapsulation (Java)Chapter2 Encapsulation (Java)
Chapter2 Encapsulation (Java)
Dyah Fajar Nur Rohmah
 
Lecture09a computer applicationsie1_dratifshahzad
Lecture09a computer applicationsie1_dratifshahzadLecture09a computer applicationsie1_dratifshahzad
Lecture09a computer applicationsie1_dratifshahzad
Atif Shahzad
 
4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT
Ajay Chimmani
 
Diving into OOP (Day 5): All About C# Access Modifiers (Public/Private/Protec...
Diving into OOP (Day 5): All About C# Access Modifiers (Public/Private/Protec...Diving into OOP (Day 5): All About C# Access Modifiers (Public/Private/Protec...
Diving into OOP (Day 5): All About C# Access Modifiers (Public/Private/Protec...
Akhil Mittal
 
Opp concept in c++
Opp concept in c++Opp concept in c++
Opp concept in c++
SadiqullahGhani1
 
Beginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHPBeginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHP
Rick Ogden
 
Dcp'15
Dcp'15Dcp'15
Unit Testing Documentum Foundation Classes Code
Unit Testing Documentum Foundation Classes CodeUnit Testing Documentum Foundation Classes Code
Unit Testing Documentum Foundation Classes Code
BlueFish
 
Unit Testing DFC
Unit Testing DFCUnit Testing DFC
Unit Testing DFC
BlueFish
 
PHP - Introduction to Object Oriented Programming with PHP
PHP -  Introduction to  Object Oriented Programming with PHPPHP -  Introduction to  Object Oriented Programming with PHP
PHP - Introduction to Object Oriented Programming with PHP
Vibrant Technologies & Computers
 
Implement custom iprincipal in mvc
Implement custom iprincipal in mvcImplement custom iprincipal in mvc
Implement custom iprincipal in mvc
LearningTech
 
08ui.pptx
08ui.pptx08ui.pptx
08ui.pptx
KabadaSori
 

Similar to Booa8 Slide 07 (20)

Encapsulation C++ Piller of OOP it is the important piller
Encapsulation C++ Piller of OOP it is the important pillerEncapsulation C++ Piller of OOP it is the important piller
Encapsulation C++ Piller of OOP it is the important piller
 
Encapsulation C++ Piller of OOP it is the important piller
Encapsulation C++ Piller of OOP it is the important pillerEncapsulation C++ Piller of OOP it is the important piller
Encapsulation C++ Piller of OOP it is the important piller
 
Context and Dependency Injection 2.0
Context and Dependency Injection 2.0Context and Dependency Injection 2.0
Context and Dependency Injection 2.0
 
Intro to iOS Development • Made by Many
Intro to iOS Development • Made by ManyIntro to iOS Development • Made by Many
Intro to iOS Development • Made by Many
 
C++Presentation 2.PPT
C++Presentation 2.PPTC++Presentation 2.PPT
C++Presentation 2.PPT
 
Object-oriented programming
Object-oriented programmingObject-oriented programming
Object-oriented programming
 
Mca 504 dotnet_unit3
Mca 504 dotnet_unit3Mca 504 dotnet_unit3
Mca 504 dotnet_unit3
 
Configuring CQ Security
Configuring CQ SecurityConfiguring CQ Security
Configuring CQ Security
 
Chapter2 Encapsulation (Java)
Chapter2 Encapsulation (Java)Chapter2 Encapsulation (Java)
Chapter2 Encapsulation (Java)
 
Lecture09a computer applicationsie1_dratifshahzad
Lecture09a computer applicationsie1_dratifshahzadLecture09a computer applicationsie1_dratifshahzad
Lecture09a computer applicationsie1_dratifshahzad
 
4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT
 
Diving into OOP (Day 5): All About C# Access Modifiers (Public/Private/Protec...
Diving into OOP (Day 5): All About C# Access Modifiers (Public/Private/Protec...Diving into OOP (Day 5): All About C# Access Modifiers (Public/Private/Protec...
Diving into OOP (Day 5): All About C# Access Modifiers (Public/Private/Protec...
 
Opp concept in c++
Opp concept in c++Opp concept in c++
Opp concept in c++
 
Beginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHPBeginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHP
 
Dcp'15
Dcp'15Dcp'15
Dcp'15
 
Unit Testing Documentum Foundation Classes Code
Unit Testing Documentum Foundation Classes CodeUnit Testing Documentum Foundation Classes Code
Unit Testing Documentum Foundation Classes Code
 
Unit Testing DFC
Unit Testing DFCUnit Testing DFC
Unit Testing DFC
 
PHP - Introduction to Object Oriented Programming with PHP
PHP -  Introduction to  Object Oriented Programming with PHPPHP -  Introduction to  Object Oriented Programming with PHP
PHP - Introduction to Object Oriented Programming with PHP
 
Implement custom iprincipal in mvc
Implement custom iprincipal in mvcImplement custom iprincipal in mvc
Implement custom iprincipal in mvc
 
08ui.pptx
08ui.pptx08ui.pptx
08ui.pptx
 

More from oswchavez

Html Y Javascript
Html Y JavascriptHtml Y Javascript
Html Y Javascript
oswchavez
 
Booa8 Slide 12
Booa8 Slide 12Booa8 Slide 12
Booa8 Slide 12
oswchavez
 
Asp .Net Parte 1
Asp .Net Parte 1Asp .Net Parte 1
Asp .Net Parte 1
oswchavez
 
Html Y Javascript
Html Y JavascriptHtml Y Javascript
Html Y Javascript
oswchavez
 
Booa8 Slide 11
Booa8 Slide 11Booa8 Slide 11
Booa8 Slide 11
oswchavez
 
Booa8 Slide 03
Booa8 Slide 03Booa8 Slide 03
Booa8 Slide 03
oswchavez
 
Pb11 002 1 Metodologia
Pb11 002 1 MetodologiaPb11 002 1 Metodologia
Pb11 002 1 Metodologia
oswchavez
 
Pb11 002 0 Problematica
Pb11 002 0 ProblematicaPb11 002 0 Problematica
Pb11 002 0 Problematica
oswchavez
 
Pb11 003 Overview
Pb11 003 OverviewPb11 003 Overview
Pb11 003 Overview
oswchavez
 
P B11 001 Intro
P B11 001  IntroP B11 001  Intro
P B11 001 Intro
oswchavez
 
Pb110021 Metodologia
Pb110021 MetodologiaPb110021 Metodologia
Pb110021 Metodologia
oswchavez
 
Pb11002 Problematica
Pb11002 ProblematicaPb11002 Problematica
Pb11002 Problematica
oswchavez
 
IntroduccióN A Visual C
IntroduccióN A  Visual  CIntroduccióN A  Visual  C
IntroduccióN A Visual C
oswchavez
 
Net Windows Developer Parte 1
Net  Windows  Developer  Parte 1Net  Windows  Developer  Parte 1
Net Windows Developer Parte 1
oswchavez
 
Clase01 Generalidades De Las Estructuras
Clase01   Generalidades De Las EstructurasClase01   Generalidades De Las Estructuras
Clase01 Generalidades De Las Estructuras
oswchavez
 
Microsoft Ado
Microsoft AdoMicrosoft Ado
Microsoft Ado
oswchavez
 
IntroduccióN A Sql Server 2005
IntroduccióN A Sql Server 2005IntroduccióN A Sql Server 2005
IntroduccióN A Sql Server 2005
oswchavez
 
IntroduccióN A Visual C
IntroduccióN A Visual CIntroduccióN A Visual C
IntroduccióN A Visual C
oswchavez
 
Net Windows Developer Part 1
Net  Windows  Developer    Part 1Net  Windows  Developer    Part 1
Net Windows Developer Part 1
oswchavez
 
Expo Adrenalinux
Expo AdrenalinuxExpo Adrenalinux
Expo Adrenalinux
oswchavez
 

More from oswchavez (20)

Html Y Javascript
Html Y JavascriptHtml Y Javascript
Html Y Javascript
 
Booa8 Slide 12
Booa8 Slide 12Booa8 Slide 12
Booa8 Slide 12
 
Asp .Net Parte 1
Asp .Net Parte 1Asp .Net Parte 1
Asp .Net Parte 1
 
Html Y Javascript
Html Y JavascriptHtml Y Javascript
Html Y Javascript
 
Booa8 Slide 11
Booa8 Slide 11Booa8 Slide 11
Booa8 Slide 11
 
Booa8 Slide 03
Booa8 Slide 03Booa8 Slide 03
Booa8 Slide 03
 
Pb11 002 1 Metodologia
Pb11 002 1 MetodologiaPb11 002 1 Metodologia
Pb11 002 1 Metodologia
 
Pb11 002 0 Problematica
Pb11 002 0 ProblematicaPb11 002 0 Problematica
Pb11 002 0 Problematica
 
Pb11 003 Overview
Pb11 003 OverviewPb11 003 Overview
Pb11 003 Overview
 
P B11 001 Intro
P B11 001  IntroP B11 001  Intro
P B11 001 Intro
 
Pb110021 Metodologia
Pb110021 MetodologiaPb110021 Metodologia
Pb110021 Metodologia
 
Pb11002 Problematica
Pb11002 ProblematicaPb11002 Problematica
Pb11002 Problematica
 
IntroduccióN A Visual C
IntroduccióN A  Visual  CIntroduccióN A  Visual  C
IntroduccióN A Visual C
 
Net Windows Developer Parte 1
Net  Windows  Developer  Parte 1Net  Windows  Developer  Parte 1
Net Windows Developer Parte 1
 
Clase01 Generalidades De Las Estructuras
Clase01   Generalidades De Las EstructurasClase01   Generalidades De Las Estructuras
Clase01 Generalidades De Las Estructuras
 
Microsoft Ado
Microsoft AdoMicrosoft Ado
Microsoft Ado
 
IntroduccióN A Sql Server 2005
IntroduccióN A Sql Server 2005IntroduccióN A Sql Server 2005
IntroduccióN A Sql Server 2005
 
IntroduccióN A Visual C
IntroduccióN A Visual CIntroduccióN A Visual C
IntroduccióN A Visual C
 
Net Windows Developer Part 1
Net  Windows  Developer    Part 1Net  Windows  Developer    Part 1
Net Windows Developer Part 1
 
Expo Adrenalinux
Expo AdrenalinuxExpo Adrenalinux
Expo Adrenalinux
 

Recently uploaded

Overview of Enterprise-scale landing zones using Cloud Adoption Framework Rea...
Overview of Enterprise-scale landing zones using Cloud Adoption Framework Rea...Overview of Enterprise-scale landing zones using Cloud Adoption Framework Rea...
Overview of Enterprise-scale landing zones using Cloud Adoption Framework Rea...
MarceloMiranda38200
 
Amul milk launches in US: Key details of its new products ...
Amul milk launches in US: Key details of its new products ...Amul milk launches in US: Key details of its new products ...
Amul milk launches in US: Key details of its new products ...
chetankumar9855
 
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptxRPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
SynapseIndia
 
BLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALL
BLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALLBLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALL
BLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALL
Liveplex
 
Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024
aakash malhotra
 
Comparison Table of DiskWarrior Alternatives.pdf
Comparison Table of DiskWarrior Alternatives.pdfComparison Table of DiskWarrior Alternatives.pdf
Comparison Table of DiskWarrior Alternatives.pdf
Andrey Yasko
 
How Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdfHow Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdf
HackersList
 
7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf
Enterprise Wired
 
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
Kief Morris
 
The Role of Technology in Payroll Statutory Compliance (1).pdf
The Role of Technology in Payroll Statutory Compliance (1).pdfThe Role of Technology in Payroll Statutory Compliance (1).pdf
The Role of Technology in Payroll Statutory Compliance (1).pdf
paysquare consultancy
 
Calgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptxCalgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptx
ishalveerrandhawa1
 
Empowering Businesses in the Digital Age
Empowering Businesses in the Digital AgeEmpowering Businesses in the Digital Age
Empowering Businesses in the Digital Age
Bert Blevins
 
Best Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdfBest Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdf
Tatiana Al-Chueyr
 
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
Toru Tamaki
 
How RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptxHow RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptx
SynapseIndia
 
ScrumGathering New Orleans 2024 Catherine Louis.pdf
ScrumGathering New Orleans 2024  Catherine Louis.pdfScrumGathering New Orleans 2024  Catherine Louis.pdf
ScrumGathering New Orleans 2024 Catherine Louis.pdf
Global Agile Consulting- CLL-Group, LLC
 
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Bert Blevins
 
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Chris Swan
 
Advanced Techniques for Cyber Security Analysis and Anomaly Detection
Advanced Techniques for Cyber Security Analysis and Anomaly DetectionAdvanced Techniques for Cyber Security Analysis and Anomaly Detection
Advanced Techniques for Cyber Security Analysis and Anomaly Detection
Bert Blevins
 
IPLOOK Remote-Sensing Satellite Solution
IPLOOK Remote-Sensing Satellite SolutionIPLOOK Remote-Sensing Satellite Solution
IPLOOK Remote-Sensing Satellite Solution
IPLOOK Networks
 

Recently uploaded (20)

Overview of Enterprise-scale landing zones using Cloud Adoption Framework Rea...
Overview of Enterprise-scale landing zones using Cloud Adoption Framework Rea...Overview of Enterprise-scale landing zones using Cloud Adoption Framework Rea...
Overview of Enterprise-scale landing zones using Cloud Adoption Framework Rea...
 
Amul milk launches in US: Key details of its new products ...
Amul milk launches in US: Key details of its new products ...Amul milk launches in US: Key details of its new products ...
Amul milk launches in US: Key details of its new products ...
 
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptxRPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
 
BLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALL
BLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALLBLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALL
BLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALL
 
Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024
 
Comparison Table of DiskWarrior Alternatives.pdf
Comparison Table of DiskWarrior Alternatives.pdfComparison Table of DiskWarrior Alternatives.pdf
Comparison Table of DiskWarrior Alternatives.pdf
 
How Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdfHow Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdf
 
7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf
 
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
 
The Role of Technology in Payroll Statutory Compliance (1).pdf
The Role of Technology in Payroll Statutory Compliance (1).pdfThe Role of Technology in Payroll Statutory Compliance (1).pdf
The Role of Technology in Payroll Statutory Compliance (1).pdf
 
Calgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptxCalgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptx
 
Empowering Businesses in the Digital Age
Empowering Businesses in the Digital AgeEmpowering Businesses in the Digital Age
Empowering Businesses in the Digital Age
 
Best Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdfBest Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdf
 
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
 
How RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptxHow RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptx
 
ScrumGathering New Orleans 2024 Catherine Louis.pdf
ScrumGathering New Orleans 2024  Catherine Louis.pdfScrumGathering New Orleans 2024  Catherine Louis.pdf
ScrumGathering New Orleans 2024 Catherine Louis.pdf
 
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
 
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
 
Advanced Techniques for Cyber Security Analysis and Anomaly Detection
Advanced Techniques for Cyber Security Analysis and Anomaly DetectionAdvanced Techniques for Cyber Security Analysis and Anomaly Detection
Advanced Techniques for Cyber Security Analysis and Anomaly Detection
 
IPLOOK Remote-Sensing Satellite Solution
IPLOOK Remote-Sensing Satellite SolutionIPLOOK Remote-Sensing Satellite Solution
IPLOOK Remote-Sensing Satellite Solution
 

Booa8 Slide 07

  • 1. Buliding Object-Oriented Applications in PowerBuilder Module 7: Encapsulation
  • 2. Objectives Define encapsulation Describe the techniques associated with encapsulation Encapsulate properties, methods, functions, and window controls
  • 3. Topics In troduction Information Hiding Encapsulating Properties Encapsulating Methods Window Controls and User Object Controls Encapsulation Read / Write Access
  • 4. Encapsulation Encapsulation is the process of defining a class of objects that: Perform behavior upon request using input data Provide the results of that behavior as output data Require no external knowledge of the internal methods
  • 5. Encapsulation 1. Clicked! 2. Send message to DataWindow control: "Scroll to next page"
  • 6. Encapsulation — Information Hiding No direct access to manipulate properties (data) Properties accessed only via methods Object controls access to its data "Published" functional interface to make use of the object's behavior
  • 7. Encapsulation in PowerBuilder Instance variables declared private for the object Data can be manipulated outside the object only through user-defined functions Communication with the object occurs via user-defined events or user-defined functions
  • 8. Encapsulation — Benefits Prevents unexpected and undesirable changes from external sources No external impact from internal implementation changes
  • 9. Encapsulating Properties — Implementation Encapsulate instance variables by defining their access as private or protected Declare "Get" and "Set" functions for access To make a property read-only, declare "Get" functions only
  • 10. Encapsulating Properties Define access rights for instance variables: Public – Any scripts in the application (default) Private – Scripts for the object for which the variable was declared Protected – Scripts for the object and descendants of the object
  • 12. Encapsulating Properties — Access and Scope Instance variables default to public — can make private or protected Global variables are always public Shared variables are always private PowerBuilder-defined properties are always public (for example, Window.X)
  • 13. Encapsulating Properties Access to PowerBuilder-defined properties cannot be modified; they are always public For example: x and y are properties of a window Using Move(300, 200) sets their values and does not require knowledge of property names But, x and y values can be directly set for a window: x = 300 y = 200
  • 14. Encapsulating Methods Some user-defined methods should not be open to public access Events are always public Object functions can be made private or protected Specify access rights in the object Function painter definition window
  • 15. Encapsulating Methods — Function Access
  • 16. Encapsulating Methods — Function Access Menu, window, and user-object functions can be private, protected, or public (default) All PowerBuilder functions are public — no access modifiers Globally defined user functions are always public — no access modifiers Private functions are meaningful only to the internal behavior of objects; protected functions may need to be called from descendants
  • 17. Encapsulating Methods Benefits Implementation of behavior can be changed or enhanced without affecting "clients" Platform-dependent behavior is implemented through "plug and play" Using encapsulated behavior does not require external knowledge of implementation
  • 18. Encapsulation — Controls Window controls or user object controls are secondary classes Secondary classes can: Be accessed only through the primary class, for example: w_cust.cb_ok.Hide( ) Access private and protected instance variables of the primary class Access private and protected functions of the primary class
  • 19. Read / Write Access Keyword restricting ability of scripts to read / write a variable's value — called operational access Fine-tunes access rights Declared with the instance variable declaration Used for variables only, not functions
  • 20. Read Access ProtectedRead Only scripts in object and descendants can read Only valid if access right is public public ProtectedRead integer ii_count PrivateRead Only scripts in object can read Only valid if access right is public or protected protected PrivateRead integer ii_maxcount
  • 21. Write Access ProtectedWrite Only scripts in object and descendants can write Only valid if access right is public public ProtectedWrite int ii_count PrivateWrite Only scripts in object can write Only valid if access right is public or protected protected PrivateWrite int ii_maxcount
  • 22. Read / Write Access Can be combined in declaration public PrivateRead PrivateWrite int ii_count Net effect: Compiler generates warning if there is an attempt to redefine access in the descendant
  • 23. Summary Encapsulation is the process of incorporating properties and methods together in an object. Information hiding limits access to an object's properties and implementation of its behavior. PowerBuilder allows encapsulation, but it does not enforce it. Access rights can be assigned to user functions and instance variables.
  • 24. Summary Events are always public. Operational access rights are used to fine-tune access to instance variables (for example, make instance variables public, but read-only).
  • 26. Lab Setup What you will need to do the lab: · Define a custom visual user class · Encapsulate methods and properties in a custom visual user class · Restrict access to properties
  • 27. Lab Debriefing Initialize the DataWindow control reference Then use it. idw_control.ScrollToRow(1)
  • 28. Lab Debriefing The report window uses the control uo_scroller.of_initdw( this) ue_postconstructor of Datawindow control
  • 29. Lab Debriefing Discuss – what kinds of additional things could you have done in the of_initDW( ) Could you have been assured that these were done if the variable idw_control had not been declared private?
  • 30. Lab Debriefing Some Examples: Debugging – you can put a breakpoint on the of_initDW() Logging – you could add code to log to a file Validation – you could add code to validate In Version 2 of your application, you could add an array of DataWindow controls If you had not declared your variable private, you could not be assured that some client was using the of_initDW() to initialize the reference.