This document contains lecture slides on object-oriented programming concepts in Java like classes, objects, inheritance, polymorphism, abstraction and interfaces. It also discusses design patterns like context, adapter and separation of concerns (MVC). The slides provide examples of different OOP concepts like nested classes (static, inner, local and anonymous), method overriding and abstract classes vs interfaces. It also summarizes packages, annotations and javadocs. The context and adapter patterns in Android are explained with examples.
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...Sagar Verma
Collection Framework in Java,Generics,Input-Output in Java,Serialization,Inner Classes
Collection Framework in Java
The Collections Framework - Set Interface- List Interface - Map Interface - Queue Interface -Sorting collections using utility methods
equals () and hash Code contract in Java collections
Overriding equals and hash Code methods in Java
Generics
Generics for Collections, class and methods
Input-Output in Java
What is a stream? ,Bytes vs. Characters, Java IO API ,Reading a file; writing to a file using various APIs
Reading User input from console , PrintWriter Class
Serialization
Object Serialization , Serializable Interface , De-Serializable
Inner Classes
Inner Classes ,Member Classes, Local Classes, Anonymous Classes, Static Nested Classes
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...Sagar Verma
OOPS and its application in Java, Super class AND This Keyword,Java Bean, POJO ,Memory management in Java ,Packages ,Miscellaneous (Var-Args, toString(), Double equals operator(==))
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...Sagar Verma
Collection Framework in Java,Generics,Input-Output in Java,Serialization,Inner Classes
Collection Framework in Java
The Collections Framework - Set Interface- List Interface - Map Interface - Queue Interface -Sorting collections using utility methods
equals () and hash Code contract in Java collections
Overriding equals and hash Code methods in Java
Generics
Generics for Collections, class and methods
Input-Output in Java
What is a stream? ,Bytes vs. Characters, Java IO API ,Reading a file; writing to a file using various APIs
Reading User input from console , PrintWriter Class
Serialization
Object Serialization , Serializable Interface , De-Serializable
Inner Classes
Inner Classes ,Member Classes, Local Classes, Anonymous Classes, Static Nested Classes
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...Sagar Verma
OOPS and its application in Java, Super class AND This Keyword,Java Bean, POJO ,Memory management in Java ,Packages ,Miscellaneous (Var-Args, toString(), Double equals operator(==))
In this core java training session, you will learn Inner Classes. Topics covered in this session are:
• Inner Classes
• Method-local Inner Class
• Anonymous Inner Class
• Static Nested Inner Class
For more information about this course visit on this link: https://www.mindsmapped.com/courses/software-development/learn-java-fundamentals-hands-on-training-on-core-java-concepts/
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions Soumen Santra
Features
JVM
Architecture
Security
Data Types
Class and Object
Program
First Java Application
Declaring and creating objects
Arrays
Constructors
this keyword
static keyword
Inheritance
Overriding
Access Modifiers
super keyword
final keyword
abstract classes
interfaces
Exceptions (error handling)
User Defining exceptions
Chapter 02: Classes Objects and Methods Java by Tushar B KuteTushar B Kute
The lecture was condcuted by Tushar B Kute at YCMOU, Nashik through VLC orgnanized by MSBTE. The contents can be found in book "Core Java Programming - A Practical Approach' by Laxmi Publications.
Java OOP Programming language (Part 3) - Class and ObjectOUM SAOKOSAL
Java OOP Programming language (Part 3) - Class and Object
Oum Saokosal
Where to me find me more:
YouTube: https://www.youtube.com/user/oumsaokosal
FB Page: https://facebook.com/kosalgeek
PPT: https://www.slideshare.net/oumsaokosal
Twitter: https://twitter.com/okosal
Web: http://kosalgeek.com
OOP with Java - Abstract Classes and InterfacesHitesh-Java
In this core java training session, you will learn OOPs with Java & Exception Handling. Topics covered in this session are:
• Overview of OOP continued…
• Abstraction – using Abstract Classes and Interfaces.
For more information about this course visit on this link: https://www.mindsmapped.com/courses/software-development/learn-java-fundamentals-hands-on-training-on-core-java-concepts/
Object Oriented Programming_Lecture 3
Let’s think on fields of class
Visibility Modifiers and Accessor Methods
الكلية الجامعية للعلوم والتكنولوجيا - خان يونس
University college of science & technology
To learn about the basic concepts of Object Oriented Programming and Inheritance plus different Inheritance Models and interview questions will be covered.
In this core java training session, you will learn Inner Classes. Topics covered in this session are:
• Inner Classes
• Method-local Inner Class
• Anonymous Inner Class
• Static Nested Inner Class
For more information about this course visit on this link: https://www.mindsmapped.com/courses/software-development/learn-java-fundamentals-hands-on-training-on-core-java-concepts/
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions Soumen Santra
Features
JVM
Architecture
Security
Data Types
Class and Object
Program
First Java Application
Declaring and creating objects
Arrays
Constructors
this keyword
static keyword
Inheritance
Overriding
Access Modifiers
super keyword
final keyword
abstract classes
interfaces
Exceptions (error handling)
User Defining exceptions
Chapter 02: Classes Objects and Methods Java by Tushar B KuteTushar B Kute
The lecture was condcuted by Tushar B Kute at YCMOU, Nashik through VLC orgnanized by MSBTE. The contents can be found in book "Core Java Programming - A Practical Approach' by Laxmi Publications.
Java OOP Programming language (Part 3) - Class and ObjectOUM SAOKOSAL
Java OOP Programming language (Part 3) - Class and Object
Oum Saokosal
Where to me find me more:
YouTube: https://www.youtube.com/user/oumsaokosal
FB Page: https://facebook.com/kosalgeek
PPT: https://www.slideshare.net/oumsaokosal
Twitter: https://twitter.com/okosal
Web: http://kosalgeek.com
OOP with Java - Abstract Classes and InterfacesHitesh-Java
In this core java training session, you will learn OOPs with Java & Exception Handling. Topics covered in this session are:
• Overview of OOP continued…
• Abstraction – using Abstract Classes and Interfaces.
For more information about this course visit on this link: https://www.mindsmapped.com/courses/software-development/learn-java-fundamentals-hands-on-training-on-core-java-concepts/
Object Oriented Programming_Lecture 3
Let’s think on fields of class
Visibility Modifiers and Accessor Methods
الكلية الجامعية للعلوم والتكنولوجيا - خان يونس
University college of science & technology
To learn about the basic concepts of Object Oriented Programming and Inheritance plus different Inheritance Models and interview questions will be covered.
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
Neuro-symbolic (NeSy) AI is on the rise. However, simply machine learning on just any symbolic structure is not sufficient to really harvest the gains of NeSy. These will only be gained when the symbolic structures have an actual semantics. I give an operational definition of semantics as “predictable inference”.
All of this illustrated with link prediction over knowledge graphs, but the argument is general.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
4. Classes & Objects
● Coming code example will explain:
○ Classes
○ Objects
○ Encapsulation
○ Constructors
○ Class Members & Methods
○ Instance Members & Methods
○ Entry Point
○ Getter & Setters
Muhammad Usman Chaudhry CS4615 SZABIST
5. //Student.java
class Student{ Access
Modifier Attribute
private String studentName;
Static
private static int count; Member
Not Recommended Setter
public void setStudentName(String _studentName){
if(!_studentName.equals("")) this.studentName = _studentName;
}
Validation
Getter
public String getStudentName(){
return this.studentName;
}
Instance
Method
public String getEncodedUrlForStudentName(){
return UrlEncoder.encode(this.getStudentName(),"UTF-8");
}
...
Muhammad Usman Chaudhry CS4615 SZABIST
6. ...
Class Method
public static int getCount(){
return Student.count;
}
Default Constructor
public Student(){
Calling 1-argument
this("No Name"); constructor
} 1-argument
public Student(String studentName){ Constructor
this.setStudentName(studentName);
} Entry Point
public static void main(String[] args){
Object of Type
Student stduent = new Student();
Student
String name = student.getName();
int count = Student.getCount(); Instance Method
Call
}
} Class Method Call
Muhammad Usman Chaudhry CS4615 SZABIST
7. Nested Classes
● Java allows defining class within another class.
● Nested classes are divided into 2 more
categories:
○ Static Nested Classes (Declared Static)
○ Inner Nested Classes (Non-static)
■ Local Classes
■ Anonymous Classes
○ Both Inner & Static nested classes have
member scope.
● Examples & Uses are in coming slides.
Muhammad Usman Chaudhry CS4615 SZABIST
8. Example: Static & Inner Nested Classes
//Outer class can only be public or package-private
class OuterClass{
private int someVariable;
//Modifier can be private, protected, public or package-private
static class StaticNestedClass{
//Cannot access private members of outer class directly.
}
class InnerClass{
//Can access private members of outer class
OuterClass oc = OuterClass.this; // implicit reference available
int a = oc.someVariable; //can be done
int b = OuterClass.this.someVariable; //is another way to access...
}
//Cannot declare static members within inner nested class.
}
Muhammad Usman Chaudhry CS4615 SZABIST
9. Example: Accessing Nested Inner Class
//Accessing Nested Inner Class
OuterClass oc = new OuterClass(); //Either create new object or use previous instance
OuterClass.InnerClass innerClassObject = oc.new InnerClass(); //Way#1
OuterClass.InnerClass innerClassObject = new OuterClass().new InnerClass(); //Way#2
● Way#1 is using previous instance so all
values of the object of outer class will be
intact and accessible via inner class.
● Way#2 is creating new instance of outer
class as well.
Muhammad Usman Chaudhry CS4615 SZABIST
10. Example: Accessing Nested Static Class
//Accessing Nested Static Class
OuterClass.StaticNestedClass sncObj = new OuterClass.StaticNestedClass();
● As simple as creating the normal object. No
added syntax.
Muhammad Usman Chaudhry CS4615 SZABIST
11. Local & Anonymous Inner Classes
● Inner class within 'body' of a method is
known as local inner class.
● Inner class within 'body' of a method
without naming it is known as anonymous
inner class.
● Scope of local inner class is local to
function.
● Scope of anonymous inner class is only to
the point where it's declared.
Muhammad Usman Chaudhry CS4615 SZABIST
12. Example: Local Inner Class
class OuterClass{
private int someVariable;
public OuterClass(){
//Local inner classes don't specify access modifiers
class LocalInnerClass{
public void myInnerMethod(){
//implicit reference available to access members of outer class...
int count = OuterClass.this.someVariable;
}
}
LocalInnerClass lic = new LocalInnerClass();
lic.myInnerMethod();
}
}
Muhammad Usman Chaudhry CS4615 SZABIST
13. Example: Anonymous Inner Class
public void someFunction(){ class RunnableThread implements Runnable{
new Thread(new Runnable(){ RunnableThread(){
@Override //do something in constructor
public void run(){ }
//do something here... public void run(){
} //do something here...
}).start(); }
} }
.
.
//To access it
RunnableThread myThread = new RunnableThread();
new Thread(myThread).start();
● Left (Anonymous) Vs Right (Normal)
● No clutter in coding
Muhammad Usman Chaudhry CS4615 SZABIST
15. Important
● Java don't have anything exactly similar to
Objective-C or .Net delegates, the closest
thing is anonymous inner class which are
used instead of delegates.
● The main trick is to create an interface
with a single function and then implement
it via anonymous inner class.
Muhammad Usman Chaudhry CS4615 SZABIST
16. Inheritance
● When you want to create a new class and there is
already a class that includes some of the code that you
want, you can derive your new class from the existing
class.
● A class that is derived from another class is called sub-
class, inherited class (derived, extended, child etc.)
● Java does support multi-level inheritance.
● There is no support for multiple inheritance in Java
and every class can extend up to one class at a time.
● Lets go through examples in next slides.
Muhammad Usman Chaudhry CS4615 SZABIST
17. //A bicycle class : Example taken from Oracle Docs...
public class Bicycle {
public int cadence; public int gear; public int speed;
public Bicycle(int startCadence, int startSpeed, int startGear) {
gear = startGear;
cadence = startCadence;
speed = startSpeed;
}
public void setCadence(int newValue) {
cadence = newValue;
}
public void setGear(int newValue) {
gear = newValue;
}
public void applyBrake(int decrement) {
speed -= decrement;
}
public void speedUp(int increment) {
speed += increment;
}
}
Muhammad Usman Chaudhry CS4615 SZABIST
18. public class MountainBike extends Bicycle {
// the MountainBike subclass adds
// one field
public int seatHeight;
// the MountainBike subclass has one
// constructor
public MountainBike(int startHeight,
int startCadence,
int startSpeed,
int startGear) {
super(startCadence, startSpeed, startGear);
seatHeight = startHeight;
}
// the MountainBike subclass adds
// one method
public void setHeight(int newValue) {
seatHeight = newValue;
}
}
Muhammad Usman Chaudhry CS4615 SZABIST
19. Method Overriding & Dynamic Polymorphism
● Redefining superclass method in subclass.
● An instance method in subclass with the same signature
(name, number, type of params & return type) as instance
method in superclass overrides the superclass's method.
● We may access the functionality of methods and members
of super class via 'super' keyword.
● In case reference variable is calling an overridden method
the method to be invoked is determined by the object, your
reference variable is pointing to. (dynamic polymorphism).
● Examples to follow in coming slides.
Muhammad Usman Chaudhry CS4615 SZABIST
20. //Class professional //Calling all
class Professional { Professional p = new Professional();
public String name;
public Professional(){
Programmer prog = new Programmer();
}
public boolean isDisciplined(){
//professional level implementations p.isDisciplined();//Normal call
}
} //First professional is called, then
//programmer's isDisciplined is called.
//Class programmer prog.isDisciplined();
class Programmer extends Professional{
public Programmer(){
//without super.isDisciplined() statement
}
@Override //calling prog.isDisciplined(); will only call
public boolean isDisciplined(){ //programmer's isDisciplined() method.
//professional rules also apply
super.isDisciplined(); //dynamic polymorphism
//programmer level implementations Professional pr = new Programmer();
}
pr.isDisciplined();
}
Muhammad Usman Chaudhry CS4615 SZABIST
21. Abstraction
● An abstract class cannot be instantiated.
● Abstract class can be subclassed.
● An abstract method, only has signatures.
● If any class has abstract methods it must be declared
abstract itself.
● Subclass must implement all the abstract methods of
abstract class otherwise it must be declared abstract
as well.
● Abstract class may also contain abstract methods.
● Examples in next slides.
Muhammad Usman Chaudhry CS4615 SZABIST
22. //Abstract class example //Implementation
abstract class GraphicObject { class Circle extends GraphicObject {
int x; void draw() {
int y;
//circle specific implementation
void moveTo(int newX, int newY) {
//some implementation
}
} void resize() {
abstract void draw(); //circle specific resize
abstract void resize(); }
} }
class Rectangle extends GraphicObject {
void draw() {
//rectangle specific implementation
}
void resize() {
//rectangle specific resizing
}
}
Muhammad Usman Chaudhry CS4615 SZABIST
23. Interfaces
● Interfaces are implemented by other classes
and extended by other interfaces.
● Unlike class inheritance an interface can
extend multiple interfaces.
● Interface body contains signatures only.
● All methods in an interface are implicitly
public.
● Example to follow.
Muhammad Usman Chaudhry CS4615 SZABIST
24. //Interface example //Implementation
public Interface GraphicInterface { class Circle implements GraphicInterface {
void draw(); void draw() {
void resize();
//circle specific implementation
}
}
void resize() {
//circle specific resize
}
}
class Rectangle extends GraphicInterface {
void draw() {
//rectangle specific implementation
}
void resize() {
//rectangle specific resizing
}
}
Muhammad Usman Chaudhry CS4615 SZABIST
25. Abstract Class Vs Interface
● Abstract class can contain fields that are
not static & final.
● Similarly abstract class can contain
implementations, while interface is
signature only.
● One class can implement multiple
interfaces. While the same class cannot
extend multiple abstract classes.
Muhammad Usman Chaudhry CS4615 SZABIST
26. Packages
● Grouping similar classes together is called
package.
● It's similar to that of namespace in .Net
● An example would be custom controls
related classes are in controls package, or
graphics related classes in graphics package
etc.
● import statement is used to include
packages.
● Examples to follow.
Muhammad Usman Chaudhry CS4615 SZABIST
27. //Package example
//Sample package
package net.thepaksoft.appname; //current package
//all graphics related customized classes
import net.thepaksoft.appname.graphics.*;
//ListView class
import net.thepaksoft.appname.controls.ListView;
Muhammad Usman Chaudhry CS4615 SZABIST
28. Annotations & Javadocs
● Annotation provide data about code, they
don't have direct impact over it.
● Annotations are mostly used for:
○ Information for compiler. //Suppress warnings etc.
○ Compile time & deploy time processing.//Code generation.
○ Runtime processing.//Examination at runtime
● Annotations are used in comments for
Javadocs to generate automatic
documentation against code.
● Examples to follow.
Muhammad Usman Chaudhry CS4615 SZABIST
29. // Javadoc comment follows
/**
* @deprecated
* explanation of why it
* was deprecated
*/
@Deprecated
static void deprecatedMethod() { }
}
// mark method as a superclass method
// that has been overridden
@Override
int overriddenMethod() { }
// use a deprecated method and tell
// compiler not to generate a warning
@SuppressWarnings("deprecation")
void useDeprecatedMethod() {
// deprecation warning
// - suppressed
objectOne.deprecatedMethod();
}
Muhammad Usman Chaudhry CS4615 SZABIST
30. Design Patterns
● They're used to solve the common problems.
● Classical design patterns include 3 categories and 23
patterns:
○ Creational - Deals with creation of object.
○ Structural - Deals with structure of object/class.
○ Behavioral - Communication between objects
● Bad patterns or approaches are known as anti-
patterns as well.
● There are 100s of other patterns.
● We'll study the most relevant and commonly used
under android.
Muhammad Usman Chaudhry CS4615 SZABIST
31. Context Pattern in Android
● Interface to global information about application
environment.
● It maintains current state of application/object.
● Mostly used to get information about other part of
program.
● Used to access standard common resources.
● Used to access components implicitly.
● Implemented by Android System to provide access to
application specific resources and classes.
Muhammad Usman Chaudhry CS4615 SZABIST
32. Context Pattern in Android
● We may get context by invoking any of these:
○ getApplicationContext()
○ getContext()
○ getBaseContext()
○ this (Current activity)
● And use above like:
○ ListAdapter adapter = new SimpleCursorAdapter(getApplicationContext(),...);
○ getApplicationContext().getSharedPreference(name,mode);
Muhammad Usman Chaudhry CS4615 SZABIST
33. Adapter Pattern in Android
● Aimed at binding view with data.
● When your data changes your view changes as well.
● No need to add/update data one by one into the view.
● Android have following implementations for Adapter:
○ BaseAdapter inherits Adapter implements
ListAdapter, SpinnerAdapter
○ ArrayAdatper
○ ResrouceCursorAdapter
Muhammad Usman Chaudhry CS4615 SZABIST
34. Adapter Pattern Android (Code)
ArrayList<HashMap> myList = new ArrayList<HashMap>();
String[] data = new String[] { "line1","line2" } ;
int[] idList = new int[] { R.id.text1, R.id.text2 } ;
SimpleAdapter dataToView = new SimpleAdapter(this,
myList, R.layout.two_lines, data, idList);
setListAdapter( dataToView );
Muhammad Usman Chaudhry CS4615 SZABIST
35. Separation of Concerns
● Appropriate layered approach
● Separate Presentation, Business Logic, from
Design
● Partial classes, under Smalltalk, .Net &
Ruby
● MVC, MVP, MVVM etc. Patterns
Muhammad Usman Chaudhry CS4615 SZABIST
36. MVC - Model-View-Controller
● UI Presentation pattern
● Separates View (UI) from Model (Business
Logic)
● Separation of Concerns:
○ View is responsible for rendering UI.
○ Model is responsible for business behavior.
○ Controller is responsible for responding to UI
Actions & communication between Model & View.
● All 3 can directly communicate with each
other.
Muhammad Usman Chaudhry CS4615 SZABIST
37. MVC - Model-View-Controller
● Implementations as discussed in previous
slides exist in many web frameworks like
Rails & Yii etc.
● Implementation varies in some frameworks
like Cocoa Touch, where:
○ Controller is used as communication bridge
between Model & Views, as mentioned previously
but Models & Views cannot communicate directly.
○ Views don't have knowledge of Model.
○ Models have no knowledge of Views.
Muhammad Usman Chaudhry CS4615 SZABIST
38. MVC in Android
● MVC is kind of built into Android
● You may create as many 'Model' classes you
like to represent the business data.
● 'Views' are there in form of XML Layouts.
● 'Controllers' are there in form of Activity
classes.
Muhammad Usman Chaudhry CS4615 SZABIST
39. That's All for Today
● Have great vacations & Eid Mubarak!
Muhammad Usman Chaudhry CS4615 SZABIST
40. Coming Up Next Week
● Dive into Android.
○ Hello World
○ SDK
○ File Organization
○ AVD
○ DDMS
○ LogCat
○ Debugging
○ Manifest
○ And Much more...
● Totally interactive class.
Muhammad Usman Chaudhry CS4615 SZABIST