SlideShare a Scribd company logo
Software development with Java

Prepared By: Ms Samar Shilbayeh ,sshilbayeh@arabou.edu.sa
Modified By: Mrs. Nibal Abu Samaa, nebal_samaan@yahoo.com
1
Component base software
development

2
3









Software quality.
The concept of components, and consider the
characteristics of object oriented software
components
Component-related aspects of Java
The contribution of object-oriented
components to the quality of software,
Production and use of components.

4


A good quality software is the software
features:

1. delivered on time
2. delivered in specific budget (around
predefined budget)
3. reliably carry out its specified tasks
4. Efficiency
5. Portability
6. Testability

5
Efficiency



how well does the
system carry out its
tasks, including
making use of the
hardware (e.g. the
processor) and other
software (e.g. the
operating system)?

Portability



how easily can the
system run on different
platforms, i.e. different
hardware and software
combinations?


6
Testability


how easily can
the software be
tested?

7


In this section, we concentrate on two
aspects of software quality which generate
much debate amongst software developers
and which have a significant impact on the
design of software. They are:

◦ maintainability
◦ reusability.

8







All tasks required to keep the software in use
and performing to the satisfaction of its
users, after it has been deployed.
fixing emerging problems;
fine-tuning the system to improve its
performance;
enhancing the system by adding extra
facilities:
1-Changing requirements
2-Changing user interfaces
9
HAT system


Briefly review the
requirements of the
Hospital system, and
imagine what might
happen to the system
after it is put into
operation. Suggest an
example of each of the
following:

◦ An requirement that may
emerge.
◦ A change to the Hospital
system’s user interface.

answer
Requirement may emerge:
 produce a list of all patients
on a given ward who have
not been treated by any
doctor.
 a requirement for the
hospital system to have
online access to patient
records at local health
centres.
A change in user interface:
 a patient’s details might be
entered by scanning his or
her identity card.
10
Using a specific part of the software in
another software .
 If two programs needed to carry out
the same task, the relevant part could
simply be copied from one program to
the other.


11
Some disadvantages of copying the code:
1. You realize after copying a code to another
program that there is much better way of
writing this code.
2. The copying code does not fit into all
software circumstances. Now you have to
find all the places the code has been reused
and bring them up to date. This will take a
great deal of effort, and some copies will
probably be missed.
12
Good approach:
 Writing the code once and
 refer to it whenever needed.
 Then only this shared copy will need
updating.
 In this way the code itself is reused.
 avoiding unnecessary duplication of
effort
13
14








a component-based approach to development
and aiming towards component-based
software.
A piece of software with a well defined purpose
that can be combined with other software to
construct a larger system.
This means that the cost of designing the parts
in the first place is spread over all the products
that use it, so the end product can be cheaper.
Example:
◦ the using of components such as spellchecker
and drawing component in the a word
processing application.

15



1.
2.

Designing a components that have been
tried and tested or designing a new
components that could be reused in other
component such as nuts, bolts, engines and
fuel pumps
When new components have to be designed
engineers:
Use existing components;
Design new components so that they can
be reused.
16
Different perspectives on an engineering component:




As independent building blocks:
◦ that may be used in the construction of different
products
As a hierarchy of building blocks:
◦ Each engineering component itself may be
constructed from several simpler components,
which themselves may be constructed from
several yet simpler components, and so on until
the components are fundamental building blocks.


17


An engineering component is
designed and built to a specification,
which describes:
1. its interface (how it connects to other
components);
2. its requirements (what it needs);
3. its services (the results of correct usage).

18
19
1.

2.

3.
4.

Components are designed and packaged as
interacting yet independent building blocks that
may be used in the construction of different
products.
Components are constructed from a hierarchy of
building blocks which are themselves
components.
Components are designed and built to a
specification.
Manufacturers and users of components have
different perspectives on the components, but
have the specification of the component as a
common element.
20








Of course, an object does not exist in isolation, but
is an instance of a particular class which defines its
behaviour.
we will refer to either classes or objects as
components.
In practice, to be a useful reusable entity, a
component may be larger than a single class.
in general, though, the properties of a component
are largely determined by the properties of its
individual classes, so we initially concentrate on
individual classes.

21




Recall that engineering components are:
1. designed and packaged as building
blocks;
2. interacting;
3. independent.
In the discussion that follows, you will see
that classes/objects have all these qualities

22
Encapsulation:
 the packaging together of data and
the operations that can be applied to
that data This means that everything
needed for the working of a class of
objects is contained within the class.

23
The definition of a class includes the following: (providing a
building block that can potentially be reused in different
systems requiring the services offered by objects of that
class):
◦ A class specification of each method that can be invoked on
objects of that class; that is, a description of its purpose
and usage.
◦ Class protocol: the messages that the object could respond
to.
◦ Implementations details how it is coded:
 Code for methods
 Code for constructors
 Declaration of the instance variable
 .
24










Object-oriented software is based on the notion
of a collection of objects that interact with each
other to perform some useful purpose.
This interaction is effected by objects
communicating with each other via messages,
that is, collaborating with each other.
In a collaboration, one object (the client) requests
a service of another object (the server).
Each object has a well-defined set of
responsibilities – tasks, or services, which it
carries out on receipt of appropriate messages.
Taken together, an object’s responsibilities
define its behaviour.

25








A key concept in object-oriented technology is that
of data hiding.
Data hiding means protecting an object’s
implementation details by restricting access to
them.
Data hiding provides a basis for the independence
of classes. Clients of an object should be
unaffected by changes made to the implementation
of the object’s class, provided its protocol remains
unchanged.
Data hiding also protects the object’s integrity, that
is, the validity of its state. so that the values of its
instance variable must be consistent with the
invariant of its state

26
27








In the case of objects, the state of an object is
made up of other data in the system, which the
object references.
In Java, this ‘other data’ may consist of objects or
values of primitive types.
Each object so referenced may itself reference
other data, and so on until the data items involved
(the ‘leaves’) are all values of primitive types such
as numbers and characters, that is, fundamental
building blocks that cannot be further broken
down.
The state of each object can therefore be viewed as
a tree-like structure constructed from a hierarchy
of objects and primitive data values, as in the
following object diagram.

28



A tree-like hierarchy, illustrating the state of an object, order1, of a class Order.
Arrows denote references; ‘leaves’ are highlighted
29







An instance, account1, of a Java class Account has
instance variables as follows:
balance, with value 555.25 (double);
interestPaid, with value true (boolean);
passwords, referencing the HashSet object
{"$abc", "$xy" }.
Draw a tree-like hierarchy of the objects and
primitive data values that make up the state of
account1.
What are the ‘leaves’ in this case?
You should assume that the state of a HashSet
object is made up of the elements it contains, and
that the state of a String object is made up of its
individual characters.
30







The ‘leaves’ are:
the double
value 555.25;
the boolean
value true;
the char values
'$', 'a', 'b', 'c', 'x'
and 'y'.
In summary, objects, like engineering components, are
constructed from a hierarchy of building blocks.
31
Because engineering components are built to a specification,
one component may be replaced by another one meeting
the same specification.
In object-oriented software, the concept of polymorphism is
required to achieve the analogous effect with classes.

In object oriented
 The concept of polymorphism
 Like engineering components,
classes are built to a
specification.
 Polymorphism : a capability of
the objects of different classes
to respond to the same
messages in a manner that
appropriate for each class.

In engineering
components




its interface (how it is
interacted with);
its requirements (what
it needs);
its services (what it
does).
32




There similarities that object-oriented
technology could facilitate component-based
software development, with object-oriented
features such as encapsulation, protocols,
data hiding and polymorphism contributing
to this capability.
Object approach can lead to components
more naturally and successfully than other
approach.

33






consists of one or more classes grouped together in some
way to form a piece of software that has a well defined
purpose and can be combined with other pieces of software
to construct a larger system.
Interacting with the component means, in effect, interacting
with one or more of the classes within it; the component’s
protocol is taken to mean the combined protocols of its
constituent classes.
An object-oriented software component should have a
specification which includes:
◦ a description of how it should be interacted with (its
protocol);
◦ a description of any other components it requires;
◦ a description of what results from using it in the specified
way.
34




A java package is a group of java classes together
and it can be considered a component.
Creating a new package:
1. Named package: package mypackage;
2. Unnamed package contains all the classes which
are not in any named package.
3. Reusable package: package that already defined
(application programming interface (API)) and
used in other applications
Example : import java.io.*;

35




Describes the purpose and usage of the
package, giving a specification for each class
that is available to a client of the package
When you create your own packages, the
Javadoc program provided with the Java SDK,
and also as part of NetBeans, can be used to
produce a specification of your component
for other users.

36
public void add(int index, E element)
Inserts the specified element at the specified position in this list.
Shifts the element currently at that position (if any) and any
subsequent elements to the right (adds one to their indices).
Specified by:
add in interface List<E>
Overrides:
add in class AbstractList<E>
Parameters:
index - index at which the specified element is to be inserted.
element -element to be inserted.
Throws:
IndexOutOfBoundsException - if index is out of range
(index < 0 || index > size()).

37
38




In NetBeans, open the project School, which is
in the folder M256M256CodeSystems.
(a) The School source code is structured into
two parts, called schoolcore and schoolgui.
These are in fact the two packages,
developed by the M256 course team, that
constitute the School System.

39
40


Briefly look at the
classes each package
contains.

1. The schoolcore
package contains the
classes Form, Teacher
and Pupil, which
correspond to entities
within the real-world
environment of a
school.
2. The schoolgui
package contains a
single class,
SchoolGUI.
41




Now turn to the
definition of the
class SchoolCoord
in the file
SchoolCoord.java,
which is in the
schoolcore package.
Explain the effect of
each of the first 4
lines of code from
the class definition

42






package schoolcore;//1 declares that the
class being defined – SchoolCoord – is
situated within the package schoolcore.
import java.util.*;//2 import java.io.*; //3
respectively make available the classes in the
predefined packages java.util and java.io.
import m256date. *; //4makes available the
classes in the package m256date. This is a
package created by the M256 course team,
containing, in fact,just the class M256Date,
which simplifies your work with dates.

43






It is provided in the form of a JAR file which is
required to see the compiled file and to see
the detailed implementation
This is a form of zip file used to distribute
compiled code.
Decompiles can take compiled java files and
derive the source code.

44
45


1.

2.
3.

What ‘accessible from outside’ means ?
Accessing an instance variable from outside
its class.
Accessing a method from outside its class.
Access modifiers.

46


Accessing an instance
variable from outside its
class

◦ Setting and/or retrieving
the value of the instance
variable by using the
instance variable directly in
code external to class
definition.



Accessing a method from
outside its class
◦ Invoking the method
directly in code external to
the class definition.

myAccount.setBalance(300);
The code for a class which is a client of
Account
47




Access modifiers are used in protecting integrity
by preventing inappropriate access to class
members.
Access modifiers are the keywords public, private
and protected, which are used to prefix class
members in the class definition. They control
access as follows:
◦ public :Any class, in any package, has access to a
public member.
◦ protected :The class itself, all classes in the same
package as that class, and all subclasses of the class
(including those outside the package) have
access to a protected member.
◦ private :Only the class itself has access to a private
member.

48
49
50






Helps protect the data from inappropriate
external use.
When developing a package, you should use
access modifiers to enable appropriate
interactions with and within the package, as
well as providing appropriate data hiding.
The integrity of a package refers to the
consistency of the states of the objects in
the package with any invariants on those
objects.
51


To illustrate, recall the package schoolcore,
which houses the core system classes
within the School System. The package
should respect the fact that each pupil is a
member of a form. If a client were able to
create a Pupil object without linking it to
any Form object, then the integrity of the
package would be violated: an invariant on
the system would be broken.

52








objects of classes within the
package should be able to
interact appropriately to provide
the services required of the
package;
clients of the package should be
able to interact with the package,
obtaining its services;
clients of the package should be
protected from implementation
changes within the package;
the integrity of the package as a
whole, and that of the individual
objects within it, should be
protected during its use by
clients.
53








Setter methods: A method enabling clients
to change the value of an instance variable
in a controlled way.
Getter methods: A method enabling clients
to discover the value of an instance
variable.
Mutable object :one who’s state can be
changed.
Immutable object: one who's state can’t be
changed.
54




In NetBeans, open the project School. Recall
that it consists of two packages, schoolcore
and schoolgui.
(a) The core system package, schoolcore, is
where the ‘underlying’ part of the system,
representing forms and pupils and so on, is
implemented. Open the source code for the
class Pupil, in schoolcore. This class has
several members: instance variables, a
constructor and methods. To what extent can
each member be accessed outside the Pupil
class?

55
56










Pupil has two instance variables, name and birthDate,
which both have private accessibility.
They cannot be accessed by objects of any other class.
The constructor Pupil(aName, aBirthDate) has no access
modifier, so it has package accessibility. This means
that objects of any of the classes within the same
package, schoolcore, can access this constructor. But
classes in other packages, such as schoolgui, cannot.
The methods getName(), getBirthDate() and toString()
have public accessibility. They can be accessed from any
class, regardless of its location.
Note also that the Pupil class itself is declared as public.
If a class is not declared as public, then access to its
entire class definition is restricted to that class’s
package
57










In NetBeans, open the project CompromisedSchool
which is in the folder
M256M256CodeExercisesUnit5.
(a) Open the source code for the class SchoolClient
in the package schoolclient. What packages does
SchoolClient import?
(b) Now look at the source code for the class
SchoolCoord in the package schoolcore.
(i) What does the instance variable forms reference?
What is its accessibility?
(ii) Read the code for the method getForms(), and
explain what this method does. What is its
accessibility?
58
59
60


(a) It imports the schoolcore package, via the imports
choolcore. *;statement, and the java.util package, via the

import java.util.*; statement.


(b) In the class SchoolCoord:
◦ (i) The instance variable forms references a collection of
Form objects, representing all the forms in the school. It
has private accessibility. This can be seen from the
following declaration.
 /** A collection of all the forms in the school. */
 private Collection<Form> forms;

◦ (ii) The method getForms()simply returns the value of the
forms instance variable. It has public accessibility.

61


Return to NetBeans and the project CompromisedSchool.



Consider the following SchoolClient code, which you saw above:
Collection<Form>clientForms =school.getForms();
clientForms.clear();



In the first line of code, a variable, clientForms, is set to reference

the collection of Form


objects that results from sending the message getForms()to the
object referenced by school.



In the second line of code, a message clear()is sent to this collection
of Form objects.



(a) Use the specification of the Collection method clear() to describe
what you think the second line of code will achieve.

62
If a client can create a reference
to a mutable object, then it can
change its state. The mutable
object in the example is the
collection of Form objects; the
client exploited its mutability by
removing all of its elements.

Notice the clear message
63






From the previous
example: even if the
instance variable is
private it may be
possible to be accessed
and manipulated
There is a danger of
accessing and
manipulating a mutable
object
If a client can create a
reference to an object it
can manipulate it.

64
65




One way is for the method to create and
return as defensive copy of a mutable
object, ie., a distinct object with the same
state.
Many predefined Java API classes have a
particular kind of constructor called a copy
constructor takes as argument an object of
that class, and creates and returns a
defensive copy of that object.

66
67
68


There are two aspects of the componentbased approach that need to be
distinguished:
1. Using existing components in creating a new
piece of software (design with reuse).

2. Producing components as part of developing new
software, or specifically as marketable
commodities (design for reuse).

69
1.

2.

The first alternative is reusing a component
by creating a subclass of one of its classes –
reuse by inheritance.
The second is referred to as reuse by
composition, based on including one object
within the state of another.

70
1.

2.

3.
4.

Allows the expert knowledge of those who
created them to be exploited by other
developers.
The software can be produced more quickly
and cheaply.
Component-based software can be easier to
test.
Increase software reliability

71






The search for a suitable component may be
a lengthy process, especially if
documentation of available components is
poor.
The challenge of creating something from
scratch can be very attractive, and developers
may resist using ‘other people’s’ products.
Sometimes it may be necessary to test the
component in the new context.

72
1. Once a component has been specified, it
may be implemented largely
independently from the rest of the
software, by different people.
2. Errors of implementation are separated
from errors of specification.
3. Once in operation, a component can be
re-implemented or replaced, provided its
specification is maintained

73
1. To have genuine potential for reuse, a
component should have responsibility for
providing a well-defined set of services.
2. Cohesion is a measure of how strongly
related and focused the responsibilities
of a component are.
3. Coupling is a measure of the extend to
which a component is dependent on
other components
74
75
76
77

More Related Content

What's hot

Reusability Metrics for Object-Oriented System: An Alternative Approach
Reusability Metrics for Object-Oriented System: An Alternative ApproachReusability Metrics for Object-Oriented System: An Alternative Approach
Reusability Metrics for Object-Oriented System: An Alternative Approach
Waqas Tariq
 
IRJET - Cognitive based Emotion Analysis of a Child Reading a Book
IRJET -  	  Cognitive based Emotion Analysis of a Child Reading a BookIRJET -  	  Cognitive based Emotion Analysis of a Child Reading a Book
IRJET - Cognitive based Emotion Analysis of a Child Reading a Book
IRJET Journal
 
Cs690 object oriented_software_engineering_team01_ report
Cs690 object oriented_software_engineering_team01_ reportCs690 object oriented_software_engineering_team01_ report
Cs690 object oriented_software_engineering_team01_ report
Khushboo Wadhwani
 
CIS 406 Entire Course NEW
CIS 406 Entire Course NEWCIS 406 Entire Course NEW
CIS 406 Entire Course NEW
shyamuopfive
 
Top 50 .NET Interview Questions and Answers 2019 | Edureka
Top 50 .NET Interview Questions and Answers 2019 | EdurekaTop 50 .NET Interview Questions and Answers 2019 | Edureka
Top 50 .NET Interview Questions and Answers 2019 | Edureka
Edureka!
 
C# Interview Questions | Edureka
C# Interview Questions | EdurekaC# Interview Questions | Edureka
C# Interview Questions | Edureka
Edureka!
 
Training report anish
Training report anishTraining report anish
Training report anish
Anish Yadav
 
PhD Maintainability of transformations in evolving MDE ecosystems
PhD Maintainability of transformations in evolving MDE ecosystemsPhD Maintainability of transformations in evolving MDE ecosystems
PhD Maintainability of transformations in evolving MDE ecosystems
Jokin García Pérez
 
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
 
Core java report
Core java reportCore java report
Core java report
Sumit Jain
 
Android Application Development - Level 1
Android Application Development - Level 1Android Application Development - Level 1
Android Application Development - Level 1
Isham Rashik
 
Android Application Development - Level 3
Android Application Development - Level 3Android Application Development - Level 3
Android Application Development - Level 3
Isham Rashik
 
Android Application Development - Level 2
Android Application Development - Level 2Android Application Development - Level 2
Android Application Development - Level 2
Isham Rashik
 
EEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answerEEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answer
Jeba Moses
 
Introduction to UML
Introduction to UMLIntroduction to UML
Introduction to UML
yndaravind
 
C# classes
C#   classesC#   classes
C# classes
Tiago
 
Andrey Kutuzov and Elizaveta Kuzmenko - WebVectors: Toolkit for Building Web...
Andrey Kutuzov and  Elizaveta Kuzmenko - WebVectors: Toolkit for Building Web...Andrey Kutuzov and  Elizaveta Kuzmenko - WebVectors: Toolkit for Building Web...
Andrey Kutuzov and Elizaveta Kuzmenko - WebVectors: Toolkit for Building Web...
AIST
 

What's hot (17)

Reusability Metrics for Object-Oriented System: An Alternative Approach
Reusability Metrics for Object-Oriented System: An Alternative ApproachReusability Metrics for Object-Oriented System: An Alternative Approach
Reusability Metrics for Object-Oriented System: An Alternative Approach
 
IRJET - Cognitive based Emotion Analysis of a Child Reading a Book
IRJET -  	  Cognitive based Emotion Analysis of a Child Reading a BookIRJET -  	  Cognitive based Emotion Analysis of a Child Reading a Book
IRJET - Cognitive based Emotion Analysis of a Child Reading a Book
 
Cs690 object oriented_software_engineering_team01_ report
Cs690 object oriented_software_engineering_team01_ reportCs690 object oriented_software_engineering_team01_ report
Cs690 object oriented_software_engineering_team01_ report
 
CIS 406 Entire Course NEW
CIS 406 Entire Course NEWCIS 406 Entire Course NEW
CIS 406 Entire Course NEW
 
Top 50 .NET Interview Questions and Answers 2019 | Edureka
Top 50 .NET Interview Questions and Answers 2019 | EdurekaTop 50 .NET Interview Questions and Answers 2019 | Edureka
Top 50 .NET Interview Questions and Answers 2019 | Edureka
 
C# Interview Questions | Edureka
C# Interview Questions | EdurekaC# Interview Questions | Edureka
C# Interview Questions | Edureka
 
Training report anish
Training report anishTraining report anish
Training report anish
 
PhD Maintainability of transformations in evolving MDE ecosystems
PhD Maintainability of transformations in evolving MDE ecosystemsPhD Maintainability of transformations in evolving MDE ecosystems
PhD Maintainability of transformations in evolving MDE ecosystems
 
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...
 
Core java report
Core java reportCore java report
Core java report
 
Android Application Development - Level 1
Android Application Development - Level 1Android Application Development - Level 1
Android Application Development - Level 1
 
Android Application Development - Level 3
Android Application Development - Level 3Android Application Development - Level 3
Android Application Development - Level 3
 
Android Application Development - Level 2
Android Application Development - Level 2Android Application Development - Level 2
Android Application Development - Level 2
 
EEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answerEEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answer
 
Introduction to UML
Introduction to UMLIntroduction to UML
Introduction to UML
 
C# classes
C#   classesC#   classes
C# classes
 
Andrey Kutuzov and Elizaveta Kuzmenko - WebVectors: Toolkit for Building Web...
Andrey Kutuzov and  Elizaveta Kuzmenko - WebVectors: Toolkit for Building Web...Andrey Kutuzov and  Elizaveta Kuzmenko - WebVectors: Toolkit for Building Web...
Andrey Kutuzov and Elizaveta Kuzmenko - WebVectors: Toolkit for Building Web...
 

Similar to L5 m256 block2_unit5

DOC-20210303-WA0017..pptx,coding stuff in c
DOC-20210303-WA0017..pptx,coding stuff in cDOC-20210303-WA0017..pptx,coding stuff in c
DOC-20210303-WA0017..pptx,coding stuff in c
floraaluoch3
 
Tcs NQTExam technical questions
Tcs NQTExam technical questionsTcs NQTExam technical questions
Tcs NQTExam technical questions
AniketBhandare2
 
Bt8901 objective oriented systems1
Bt8901 objective oriented systems1Bt8901 objective oriented systems1
Bt8901 objective oriented systems1
Techglyphs
 
Nt1310 Unit 3 Language Analysis
Nt1310 Unit 3 Language AnalysisNt1310 Unit 3 Language Analysis
Nt1310 Unit 3 Language Analysis
Nicole Gomez
 
Design concepts and principles
Design concepts and principlesDesign concepts and principles
Design concepts and principles
saurabhshertukde
 
Chapter1
Chapter1Chapter1
Chapter1
jammiashok123
 
Technical_Interview_Questions.pdf
Technical_Interview_Questions.pdfTechnical_Interview_Questions.pdf
Technical_Interview_Questions.pdf
adityashukla939020
 
Object Oriented Database
Object Oriented DatabaseObject Oriented Database
Object Oriented Database
Megan Espinoza
 
Object Oriented Programming Lecture Notes
Object Oriented Programming Lecture NotesObject Oriented Programming Lecture Notes
Object Oriented Programming Lecture Notes
FellowBuddy.com
 
Encapsulation
EncapsulationEncapsulation
Encapsulation
FALLEE31188
 
Design Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur UniversityDesign Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur University
Shubham Narkhede
 
Sofwear deasign and need of design pattern
Sofwear deasign and need of design patternSofwear deasign and need of design pattern
Sofwear deasign and need of design pattern
chetankane
 
SDLC
SDLCSDLC
Middleware Technologies
Middleware Technologies Middleware Technologies
Middleware Technologies
prakashk453625
 
EMC Documentum xCP 2.0 Design Patterns
EMC Documentum xCP 2.0 Design PatternsEMC Documentum xCP 2.0 Design Patterns
EMC Documentum xCP 2.0 Design Patterns
Haytham Ghandour
 
Software engineering Questions and Answers
Software engineering Questions and AnswersSoftware engineering Questions and Answers
Software engineering Questions and Answers
Bala Ganesh
 
Middle ware Technologies
Middle ware TechnologiesMiddle ware Technologies
Middle ware Technologies
prakashk453625
 
Coupling based structural metrics for measuring the quality of a software (sy...
Coupling based structural metrics for measuring the quality of a software (sy...Coupling based structural metrics for measuring the quality of a software (sy...
Coupling based structural metrics for measuring the quality of a software (sy...
Mumbai Academisc
 
ArchitectureOfAOMsWICSA3
ArchitectureOfAOMsWICSA3ArchitectureOfAOMsWICSA3
ArchitectureOfAOMsWICSA3
Erdem Sahin
 
Ch7-Software Engineering 9
Ch7-Software Engineering 9Ch7-Software Engineering 9
Ch7-Software Engineering 9
Ian Sommerville
 

Similar to L5 m256 block2_unit5 (20)

DOC-20210303-WA0017..pptx,coding stuff in c
DOC-20210303-WA0017..pptx,coding stuff in cDOC-20210303-WA0017..pptx,coding stuff in c
DOC-20210303-WA0017..pptx,coding stuff in c
 
Tcs NQTExam technical questions
Tcs NQTExam technical questionsTcs NQTExam technical questions
Tcs NQTExam technical questions
 
Bt8901 objective oriented systems1
Bt8901 objective oriented systems1Bt8901 objective oriented systems1
Bt8901 objective oriented systems1
 
Nt1310 Unit 3 Language Analysis
Nt1310 Unit 3 Language AnalysisNt1310 Unit 3 Language Analysis
Nt1310 Unit 3 Language Analysis
 
Design concepts and principles
Design concepts and principlesDesign concepts and principles
Design concepts and principles
 
Chapter1
Chapter1Chapter1
Chapter1
 
Technical_Interview_Questions.pdf
Technical_Interview_Questions.pdfTechnical_Interview_Questions.pdf
Technical_Interview_Questions.pdf
 
Object Oriented Database
Object Oriented DatabaseObject Oriented Database
Object Oriented Database
 
Object Oriented Programming Lecture Notes
Object Oriented Programming Lecture NotesObject Oriented Programming Lecture Notes
Object Oriented Programming Lecture Notes
 
Encapsulation
EncapsulationEncapsulation
Encapsulation
 
Design Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur UniversityDesign Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur University
 
Sofwear deasign and need of design pattern
Sofwear deasign and need of design patternSofwear deasign and need of design pattern
Sofwear deasign and need of design pattern
 
SDLC
SDLCSDLC
SDLC
 
Middleware Technologies
Middleware Technologies Middleware Technologies
Middleware Technologies
 
EMC Documentum xCP 2.0 Design Patterns
EMC Documentum xCP 2.0 Design PatternsEMC Documentum xCP 2.0 Design Patterns
EMC Documentum xCP 2.0 Design Patterns
 
Software engineering Questions and Answers
Software engineering Questions and AnswersSoftware engineering Questions and Answers
Software engineering Questions and Answers
 
Middle ware Technologies
Middle ware TechnologiesMiddle ware Technologies
Middle ware Technologies
 
Coupling based structural metrics for measuring the quality of a software (sy...
Coupling based structural metrics for measuring the quality of a software (sy...Coupling based structural metrics for measuring the quality of a software (sy...
Coupling based structural metrics for measuring the quality of a software (sy...
 
ArchitectureOfAOMsWICSA3
ArchitectureOfAOMsWICSA3ArchitectureOfAOMsWICSA3
ArchitectureOfAOMsWICSA3
 
Ch7-Software Engineering 9
Ch7-Software Engineering 9Ch7-Software Engineering 9
Ch7-Software Engineering 9
 

Recently uploaded

clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
สมใจ จันสุกสี
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
iammrhaywood
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 

Recently uploaded (20)

clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 

L5 m256 block2_unit5

  • 1. Software development with Java Prepared By: Ms Samar Shilbayeh ,sshilbayeh@arabou.edu.sa Modified By: Mrs. Nibal Abu Samaa, nebal_samaan@yahoo.com 1
  • 3. 3
  • 4.      Software quality. The concept of components, and consider the characteristics of object oriented software components Component-related aspects of Java The contribution of object-oriented components to the quality of software, Production and use of components. 4
  • 5.  A good quality software is the software features: 1. delivered on time 2. delivered in specific budget (around predefined budget) 3. reliably carry out its specified tasks 4. Efficiency 5. Portability 6. Testability 5
  • 6. Efficiency  how well does the system carry out its tasks, including making use of the hardware (e.g. the processor) and other software (e.g. the operating system)? Portability  how easily can the system run on different platforms, i.e. different hardware and software combinations?  6
  • 7. Testability  how easily can the software be tested? 7
  • 8.  In this section, we concentrate on two aspects of software quality which generate much debate amongst software developers and which have a significant impact on the design of software. They are: ◦ maintainability ◦ reusability. 8
  • 9.     All tasks required to keep the software in use and performing to the satisfaction of its users, after it has been deployed. fixing emerging problems; fine-tuning the system to improve its performance; enhancing the system by adding extra facilities: 1-Changing requirements 2-Changing user interfaces 9
  • 10. HAT system  Briefly review the requirements of the Hospital system, and imagine what might happen to the system after it is put into operation. Suggest an example of each of the following: ◦ An requirement that may emerge. ◦ A change to the Hospital system’s user interface. answer Requirement may emerge:  produce a list of all patients on a given ward who have not been treated by any doctor.  a requirement for the hospital system to have online access to patient records at local health centres. A change in user interface:  a patient’s details might be entered by scanning his or her identity card. 10
  • 11. Using a specific part of the software in another software .  If two programs needed to carry out the same task, the relevant part could simply be copied from one program to the other.  11
  • 12. Some disadvantages of copying the code: 1. You realize after copying a code to another program that there is much better way of writing this code. 2. The copying code does not fit into all software circumstances. Now you have to find all the places the code has been reused and bring them up to date. This will take a great deal of effort, and some copies will probably be missed. 12
  • 13. Good approach:  Writing the code once and  refer to it whenever needed.  Then only this shared copy will need updating.  In this way the code itself is reused.  avoiding unnecessary duplication of effort 13
  • 14. 14
  • 15.     a component-based approach to development and aiming towards component-based software. A piece of software with a well defined purpose that can be combined with other software to construct a larger system. This means that the cost of designing the parts in the first place is spread over all the products that use it, so the end product can be cheaper. Example: ◦ the using of components such as spellchecker and drawing component in the a word processing application. 15
  • 16.   1. 2. Designing a components that have been tried and tested or designing a new components that could be reused in other component such as nuts, bolts, engines and fuel pumps When new components have to be designed engineers: Use existing components; Design new components so that they can be reused. 16
  • 17. Different perspectives on an engineering component:   As independent building blocks: ◦ that may be used in the construction of different products As a hierarchy of building blocks: ◦ Each engineering component itself may be constructed from several simpler components, which themselves may be constructed from several yet simpler components, and so on until the components are fundamental building blocks.  17
  • 18.  An engineering component is designed and built to a specification, which describes: 1. its interface (how it connects to other components); 2. its requirements (what it needs); 3. its services (the results of correct usage). 18
  • 19. 19
  • 20. 1. 2. 3. 4. Components are designed and packaged as interacting yet independent building blocks that may be used in the construction of different products. Components are constructed from a hierarchy of building blocks which are themselves components. Components are designed and built to a specification. Manufacturers and users of components have different perspectives on the components, but have the specification of the component as a common element. 20
  • 21.     Of course, an object does not exist in isolation, but is an instance of a particular class which defines its behaviour. we will refer to either classes or objects as components. In practice, to be a useful reusable entity, a component may be larger than a single class. in general, though, the properties of a component are largely determined by the properties of its individual classes, so we initially concentrate on individual classes. 21
  • 22.   Recall that engineering components are: 1. designed and packaged as building blocks; 2. interacting; 3. independent. In the discussion that follows, you will see that classes/objects have all these qualities 22
  • 23. Encapsulation:  the packaging together of data and the operations that can be applied to that data This means that everything needed for the working of a class of objects is contained within the class. 23
  • 24. The definition of a class includes the following: (providing a building block that can potentially be reused in different systems requiring the services offered by objects of that class): ◦ A class specification of each method that can be invoked on objects of that class; that is, a description of its purpose and usage. ◦ Class protocol: the messages that the object could respond to. ◦ Implementations details how it is coded:  Code for methods  Code for constructors  Declaration of the instance variable  . 24
  • 25.      Object-oriented software is based on the notion of a collection of objects that interact with each other to perform some useful purpose. This interaction is effected by objects communicating with each other via messages, that is, collaborating with each other. In a collaboration, one object (the client) requests a service of another object (the server). Each object has a well-defined set of responsibilities – tasks, or services, which it carries out on receipt of appropriate messages. Taken together, an object’s responsibilities define its behaviour. 25
  • 26.     A key concept in object-oriented technology is that of data hiding. Data hiding means protecting an object’s implementation details by restricting access to them. Data hiding provides a basis for the independence of classes. Clients of an object should be unaffected by changes made to the implementation of the object’s class, provided its protocol remains unchanged. Data hiding also protects the object’s integrity, that is, the validity of its state. so that the values of its instance variable must be consistent with the invariant of its state 26
  • 27. 27
  • 28.     In the case of objects, the state of an object is made up of other data in the system, which the object references. In Java, this ‘other data’ may consist of objects or values of primitive types. Each object so referenced may itself reference other data, and so on until the data items involved (the ‘leaves’) are all values of primitive types such as numbers and characters, that is, fundamental building blocks that cannot be further broken down. The state of each object can therefore be viewed as a tree-like structure constructed from a hierarchy of objects and primitive data values, as in the following object diagram. 28
  • 29.   A tree-like hierarchy, illustrating the state of an object, order1, of a class Order. Arrows denote references; ‘leaves’ are highlighted 29
  • 30.     An instance, account1, of a Java class Account has instance variables as follows: balance, with value 555.25 (double); interestPaid, with value true (boolean); passwords, referencing the HashSet object {"$abc", "$xy" }. Draw a tree-like hierarchy of the objects and primitive data values that make up the state of account1. What are the ‘leaves’ in this case? You should assume that the state of a HashSet object is made up of the elements it contains, and that the state of a String object is made up of its individual characters. 30
  • 31.     The ‘leaves’ are: the double value 555.25; the boolean value true; the char values '$', 'a', 'b', 'c', 'x' and 'y'. In summary, objects, like engineering components, are constructed from a hierarchy of building blocks. 31
  • 32. Because engineering components are built to a specification, one component may be replaced by another one meeting the same specification. In object-oriented software, the concept of polymorphism is required to achieve the analogous effect with classes. In object oriented  The concept of polymorphism  Like engineering components, classes are built to a specification.  Polymorphism : a capability of the objects of different classes to respond to the same messages in a manner that appropriate for each class. In engineering components    its interface (how it is interacted with); its requirements (what it needs); its services (what it does). 32
  • 33.   There similarities that object-oriented technology could facilitate component-based software development, with object-oriented features such as encapsulation, protocols, data hiding and polymorphism contributing to this capability. Object approach can lead to components more naturally and successfully than other approach. 33
  • 34.    consists of one or more classes grouped together in some way to form a piece of software that has a well defined purpose and can be combined with other pieces of software to construct a larger system. Interacting with the component means, in effect, interacting with one or more of the classes within it; the component’s protocol is taken to mean the combined protocols of its constituent classes. An object-oriented software component should have a specification which includes: ◦ a description of how it should be interacted with (its protocol); ◦ a description of any other components it requires; ◦ a description of what results from using it in the specified way. 34
  • 35.   A java package is a group of java classes together and it can be considered a component. Creating a new package: 1. Named package: package mypackage; 2. Unnamed package contains all the classes which are not in any named package. 3. Reusable package: package that already defined (application programming interface (API)) and used in other applications Example : import java.io.*; 35
  • 36.   Describes the purpose and usage of the package, giving a specification for each class that is available to a client of the package When you create your own packages, the Javadoc program provided with the Java SDK, and also as part of NetBeans, can be used to produce a specification of your component for other users. 36
  • 37. public void add(int index, E element) Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices). Specified by: add in interface List<E> Overrides: add in class AbstractList<E> Parameters: index - index at which the specified element is to be inserted. element -element to be inserted. Throws: IndexOutOfBoundsException - if index is out of range (index < 0 || index > size()). 37
  • 38. 38
  • 39.   In NetBeans, open the project School, which is in the folder M256M256CodeSystems. (a) The School source code is structured into two parts, called schoolcore and schoolgui. These are in fact the two packages, developed by the M256 course team, that constitute the School System. 39
  • 40. 40
  • 41.  Briefly look at the classes each package contains. 1. The schoolcore package contains the classes Form, Teacher and Pupil, which correspond to entities within the real-world environment of a school. 2. The schoolgui package contains a single class, SchoolGUI. 41
  • 42.   Now turn to the definition of the class SchoolCoord in the file SchoolCoord.java, which is in the schoolcore package. Explain the effect of each of the first 4 lines of code from the class definition 42
  • 43.    package schoolcore;//1 declares that the class being defined – SchoolCoord – is situated within the package schoolcore. import java.util.*;//2 import java.io.*; //3 respectively make available the classes in the predefined packages java.util and java.io. import m256date. *; //4makes available the classes in the package m256date. This is a package created by the M256 course team, containing, in fact,just the class M256Date, which simplifies your work with dates. 43
  • 44.    It is provided in the form of a JAR file which is required to see the compiled file and to see the detailed implementation This is a form of zip file used to distribute compiled code. Decompiles can take compiled java files and derive the source code. 44
  • 45. 45
  • 46.  1. 2. 3. What ‘accessible from outside’ means ? Accessing an instance variable from outside its class. Accessing a method from outside its class. Access modifiers. 46
  • 47.  Accessing an instance variable from outside its class ◦ Setting and/or retrieving the value of the instance variable by using the instance variable directly in code external to class definition.  Accessing a method from outside its class ◦ Invoking the method directly in code external to the class definition. myAccount.setBalance(300); The code for a class which is a client of Account 47
  • 48.   Access modifiers are used in protecting integrity by preventing inappropriate access to class members. Access modifiers are the keywords public, private and protected, which are used to prefix class members in the class definition. They control access as follows: ◦ public :Any class, in any package, has access to a public member. ◦ protected :The class itself, all classes in the same package as that class, and all subclasses of the class (including those outside the package) have access to a protected member. ◦ private :Only the class itself has access to a private member. 48
  • 49. 49
  • 50. 50
  • 51.    Helps protect the data from inappropriate external use. When developing a package, you should use access modifiers to enable appropriate interactions with and within the package, as well as providing appropriate data hiding. The integrity of a package refers to the consistency of the states of the objects in the package with any invariants on those objects. 51
  • 52.  To illustrate, recall the package schoolcore, which houses the core system classes within the School System. The package should respect the fact that each pupil is a member of a form. If a client were able to create a Pupil object without linking it to any Form object, then the integrity of the package would be violated: an invariant on the system would be broken. 52
  • 53.     objects of classes within the package should be able to interact appropriately to provide the services required of the package; clients of the package should be able to interact with the package, obtaining its services; clients of the package should be protected from implementation changes within the package; the integrity of the package as a whole, and that of the individual objects within it, should be protected during its use by clients. 53
  • 54.     Setter methods: A method enabling clients to change the value of an instance variable in a controlled way. Getter methods: A method enabling clients to discover the value of an instance variable. Mutable object :one who’s state can be changed. Immutable object: one who's state can’t be changed. 54
  • 55.   In NetBeans, open the project School. Recall that it consists of two packages, schoolcore and schoolgui. (a) The core system package, schoolcore, is where the ‘underlying’ part of the system, representing forms and pupils and so on, is implemented. Open the source code for the class Pupil, in schoolcore. This class has several members: instance variables, a constructor and methods. To what extent can each member be accessed outside the Pupil class? 55
  • 56. 56
  • 57.      Pupil has two instance variables, name and birthDate, which both have private accessibility. They cannot be accessed by objects of any other class. The constructor Pupil(aName, aBirthDate) has no access modifier, so it has package accessibility. This means that objects of any of the classes within the same package, schoolcore, can access this constructor. But classes in other packages, such as schoolgui, cannot. The methods getName(), getBirthDate() and toString() have public accessibility. They can be accessed from any class, regardless of its location. Note also that the Pupil class itself is declared as public. If a class is not declared as public, then access to its entire class definition is restricted to that class’s package 57
  • 58.      In NetBeans, open the project CompromisedSchool which is in the folder M256M256CodeExercisesUnit5. (a) Open the source code for the class SchoolClient in the package schoolclient. What packages does SchoolClient import? (b) Now look at the source code for the class SchoolCoord in the package schoolcore. (i) What does the instance variable forms reference? What is its accessibility? (ii) Read the code for the method getForms(), and explain what this method does. What is its accessibility? 58
  • 59. 59
  • 60. 60
  • 61.  (a) It imports the schoolcore package, via the imports choolcore. *;statement, and the java.util package, via the import java.util.*; statement.  (b) In the class SchoolCoord: ◦ (i) The instance variable forms references a collection of Form objects, representing all the forms in the school. It has private accessibility. This can be seen from the following declaration.  /** A collection of all the forms in the school. */  private Collection<Form> forms; ◦ (ii) The method getForms()simply returns the value of the forms instance variable. It has public accessibility. 61
  • 62.  Return to NetBeans and the project CompromisedSchool.  Consider the following SchoolClient code, which you saw above: Collection<Form>clientForms =school.getForms(); clientForms.clear();  In the first line of code, a variable, clientForms, is set to reference the collection of Form  objects that results from sending the message getForms()to the object referenced by school.  In the second line of code, a message clear()is sent to this collection of Form objects.  (a) Use the specification of the Collection method clear() to describe what you think the second line of code will achieve. 62
  • 63. If a client can create a reference to a mutable object, then it can change its state. The mutable object in the example is the collection of Form objects; the client exploited its mutability by removing all of its elements. Notice the clear message 63
  • 64.    From the previous example: even if the instance variable is private it may be possible to be accessed and manipulated There is a danger of accessing and manipulating a mutable object If a client can create a reference to an object it can manipulate it. 64
  • 65. 65
  • 66.   One way is for the method to create and return as defensive copy of a mutable object, ie., a distinct object with the same state. Many predefined Java API classes have a particular kind of constructor called a copy constructor takes as argument an object of that class, and creates and returns a defensive copy of that object. 66
  • 67. 67
  • 68. 68
  • 69.  There are two aspects of the componentbased approach that need to be distinguished: 1. Using existing components in creating a new piece of software (design with reuse). 2. Producing components as part of developing new software, or specifically as marketable commodities (design for reuse). 69
  • 70. 1. 2. The first alternative is reusing a component by creating a subclass of one of its classes – reuse by inheritance. The second is referred to as reuse by composition, based on including one object within the state of another. 70
  • 71. 1. 2. 3. 4. Allows the expert knowledge of those who created them to be exploited by other developers. The software can be produced more quickly and cheaply. Component-based software can be easier to test. Increase software reliability 71
  • 72.    The search for a suitable component may be a lengthy process, especially if documentation of available components is poor. The challenge of creating something from scratch can be very attractive, and developers may resist using ‘other people’s’ products. Sometimes it may be necessary to test the component in the new context. 72
  • 73. 1. Once a component has been specified, it may be implemented largely independently from the rest of the software, by different people. 2. Errors of implementation are separated from errors of specification. 3. Once in operation, a component can be re-implemented or replaced, provided its specification is maintained 73
  • 74. 1. To have genuine potential for reuse, a component should have responsibility for providing a well-defined set of services. 2. Cohesion is a measure of how strongly related and focused the responsibilities of a component are. 3. Coupling is a measure of the extend to which a component is dependent on other components 74
  • 75. 75
  • 76. 76
  • 77. 77

Editor's Notes

  1. .
  2. cars have been built from components – wheels, gearboxes and so on. At first, product design (that is, car design) came before component design: the components were made to suit the product, and could not be used for other products, which was very inefficient
  3. Polymorphism تعدد الأشكالis the capability for objects of different classes to respond to the same message in a manner appropriate for each object.
  4. Excerpt مقتطفات
  5. situated تقع
  6. validity صدق شرعية
  7. Consider the example of an Account class intended to model bank accounts, and which defines instance variables overdraftLimit and balance. The code in Figure 7 defines, outside the Account class definition, another class AccountClient. It illustrates the balance instance variable of an Account object, myAccount, being accessed from outside the Account class definition.
  8. Consider the example of an Account class intended to model bank accounts, and which defines instance variables overdraftLimit and balance. The code in Figure 7 defines, outside the Account class definition, another class AccountClient. It illustrates the balance instance variable of an Account object, myAccount, being accessed from outside the Account class definition.
  9. the default in the absence of an explicit modifier in front of a class member is that the member cannot be accessed from outside the class’s package.
  10. Overdraftالسحب على المكشوفTo fix this, the balance and overdraftLimit access modifiers should be changed. Declaring these instance variables as private would mean (in the absence of any other Account methods modifying these instance variables) that a client outside the Account class could not change an Account object’s overdraft limit, and could only change the balance of an Account object using the method setBalance(anAmount). The integrity of Account objects would be safeguarded.
  11. You have seen the example of the Account class with the public method setBalance(anAmount), which enables clients to modify the balance whilst maintaining the invariant that the overdraft limit should not be exceeded. Such setter methods are common, and their usual purpose is exemplified by setBalance(anAmount): to enable clients to change the value of an instance variable in a controlled way.
  12. privacy leak تسرب الخصوصية
  13. commodities السلع
  14. exploited تستغلReliability دقة وصلابة وامكانية التشغيل
  15. Cohesionتماسك تلاحم