Software Architecture Design Patterns in Java 1st Edition Partha Kuchana instant download
Software Architecture Design Patterns in Java 1st Edition Partha Kuchana instant download
https://ebookname.com/product/software-architecture-design-
patterns-in-java-1st-edition-partha-kuchana-2/
https://ebookname.com/product/software-architecture-design-
patterns-in-java-1st-edition-partha-kuchana/
https://ebookname.com/product/patterns-in-java-a-catalog-of-
reusable-design-patterns-illustrated-with-uml-2nd-edition-
volume-1-grand/
https://ebookname.com/product/integration-ready-architecture-and-
design-software-engineering-with-xml-java-net-wireless-speech-
and-knowledge-technologies-1st-edition-jeff-zhuk/
https://ebookname.com/product/membrane-technology-
volume-3-membranes-for-food-applications-1st-edition-klaus-
viktor-peinemann/
Flavor chemistry and technology 2nd Edition Gary
Reineccius
https://ebookname.com/product/flavor-chemistry-and-
technology-2nd-edition-gary-reineccius/
https://ebookname.com/product/the-fifth-freedom-jobs-politics-
and-civil-rights-in-the-united-states-1941-1972-anthony-s-chen/
https://ebookname.com/product/ethnography-principles-in-
practice-3rd-edition-martyn-hammersley/
https://ebookname.com/product/maximum-likelihood-estimation-of-
misspecified-models-twenty-years-later-1-edition-t-fomby-r-
carter-hill-editors/
https://ebookname.com/product/piloting-palm-andrea-butter/
Assault on Nightwyrm Fortress Adventure P3 D D
Adventure Dungeons Dragons Bruce R. Cordell
https://ebookname.com/product/assault-on-nightwyrm-fortress-
adventure-p3-d-d-adventure-dungeons-dragons-bruce-r-cordell/
Software
Architecture
Design Patterns
in Java
AUERBACH PUBLICATIONS
www.auerbach-publications.com
To Order Call: 1-800-272-7737 • Fax: 1-800-374-3401
E-mail: orders@crcpress.com
© 2004 by CRC Press LLC
Software
Architecture
Design Patterns
in Java
Partha Kuchana
AUERBACH PUBLICATIONS
A CRC Press Company
Boca Raton London New York Washington, D.C.
Kuchana, Partha.
Software architecture design patterns in Java / Partha Kuchana.
p. cm.
Includes bibliographical references and index.
ISBN 0-8493-2142-5 (alk. paper)
1. Java (Computer program language) 2. Computer Software. 3. Computer architecture.
4. Software patterns. I. Title.
QA76.73.J38K83 2004
005.13′3—dc22 2003070897
This book contains information obtained from authentic and highly regarded sources. Reprinted material is quoted
with permission, and sources are indicated. A wide variety of references are listed. Reasonable efforts have been
made to publish reliable data and information, but the author and the publisher cannot assume responsibility for the
validity of all materials or for the consequences of their use.
Neither this book nor any part may be reproduced or transmitted in any form or by any means, electronic or
mechanical, including photocopying, microfilming, and recording, or by any information storage or retrieval system,
without prior permission in writing from the publisher.
The consent of CRC Press LLC does not extend to copying for general distribution, for promotion, for creating new
works, or for resale. Specific permission must be obtained in writing from CRC Press LLC for such copying.
Direct all inquiries to CRC Press LLC, 2000 N.W. Corporate Blvd., Boca Raton, Florida 33431.
Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for
identification and explanation, without intent to infringe.
To my family
5 Private Methods
Description
Example
Practice Questions
6 Accessor Methods
Description
Accessor Method Nomenclature
Example
Direct Reference versus Accessor Methods
Practice Questions
8 Immutable Object
Description
Example
Practice Questions
9 Monitor
Description
Example
Practice Questions
11 Singleton
Description
Who Should Be Responsible?
Example
Make the Constructor Private
Static Public Interface to Access an Instance
Practice Questions
13 Prototype
Description
Shallow Copy versus Deep Copy
Shallow Copy Example
Deep Copy Example
Example I
Design Highlights of the HostingPlanKit Class
Example II
Redesign the UserAccount Class
Create a Prototype Factory Class
Practice Questions
14 Builder
Description
Example I
A Side Note
Back to the Example Application
Example II
Example III
Practice Questions
16 Iterator
Description
Iterators in Java
Filtered Iterators
Internal versus External Iterators
Example: Internal Iterator
Client/Container Interaction
Example: External Filtered Iterator
Practice Questions
18 Visitor
Description
Design Idea 1
Design Idea 2
Defining New Operations on the Object Collection
Adding Objects of a New Type to the Collection
Example
Design Approach I
Design Approach II
Design Approach III (Composite Pattern)
Design Approach IV (The Visitor Pattern)
Application Flow
Defining a New Operation on the Order Object Collection
Adding a New Order Type to the Collection
Practice Questions
20 Adapter
Description
Class Adapters versus Object Adapters
Class Adapter
Object Adapter
Example
Address Adapter as an Object Adapter
Practice Questions
21 Chain of Responsibility
Description
Example
Practice Questions
23 Proxy
Description
Proxy versus Other Patterns.
Proxy versus Decorator
Proxy versus Façade
Proxy versus Chain of Responsibility
RMI: A Quick Overview
RMI Components
RMI Communication Mechanism
RMI and Proxy Pattern
Example
Additional Notes
Compilation and Deployment Notes
Practice Questions
24 Bridge
Description
Example
Abstraction Implementation Design
Abstraction Interface Design
Design Highlights of the Abstraction Interface Classes
Bridge Pattern versus Adapter Pattern
Practice Questions
25 Virtual Proxy
Description
Advantage
Disadvantage
Example
Practice Questions
26 Counting Proxy
Description
Example
Practice Questions
27 Aggregate Enforcer
Description
Example
Design Approach I (On-Demand Initialization)
Design Approach II (Early Initialization)
Design Approach III (Final Variables)
Practice Questions
29 Object Cache
Description
Example
Practice Questions
31 Mediator
Description
Mediator versus Façade
Example I
Client Usage of the Mediator
User Interface Objects: Mediator Interaction
Example II
Practice Questions
32 Memento
Description
Example
DataConverter (Originator)
ID
Memento
process
createMemento
setMemento
DCClient (Client)
MementoHandler
Practice Questions
33 Observer
Description
Adding New Observers
Example
Subject–Observer Association
Logical Flow
34 Interpreter
Description
Example
Infix-to-Postfix Conversion (Listing 34.8)
Construction of the Tree Structure (Listing 34.9)
Postorder Traversal of the Tree
Additional Notes
Infix-to-Postfix Conversion
Infix Expression
Postfix Expression
Conversion Algorithm
Example
Binary Tree Traversal Techniques
Preorder (Node-Left-Right)
In-Order (Left-Node-Right)
Postorder (Left-Right-Node)
Level-Order
Practice Questions
35 State
Description
Stateful Object: An Example
Example
Practice Questions
36 Strategy
Description
Strategies versus Other Alternatives
Strategy versus State
Example
SimpleEncryption
CaesarCypher
SubstitutionCypher
CodeBookCypher
Practice Questions
37 Null Object
Description
Example
Practice Questions
38 Template Method
Description
Abstract Class
Concrete Class
Example
Additional Notes
Mod 10 Check Digit Algorithm
Practice Questions
39 Object Authenticator
Description
43 Guarded Suspension
Description
Example
Use of wait() and notify() in the ParkingLot Class Design
Practice Questions
44 Read-Write Lock
Description
Design Highlights of the ReadWriteLock Class
Lock Statistics
Lock Methods
Lock Release
Example
Practice Questions
SECTION X: APPENDICES
Appendix A: List of Design Patterns
Appendix B: References
䡲 7 Basic patterns
䡲 5 Creational patterns
䡲 4 Collectional patterns
䡲 11 Structural patterns
䡲 11 Behavioral patterns
䡲 4 Concurrency patterns
First and foremost, I would like to thank my wife for her patience and support,
for taking some of my workload especially in the ar eas of UML and Java
programming and for her inspirational contributions at the time of frustrating
moments. I would like to thank my parents, my sister, my brother and my dear
friends whose support and encouragement throughout my life have made it
possible for me to build the skill set necessary to succeed.
I would like to thank Venu Kuchana and D.R. Sudhakar for their contributions
in terms of writing different Java programs. I would like to thank BalaLingam
Kuchana for his contributions in the area of UML and for being in charge of
creating the formatted version of my draft.
I would like to thank the entire team at Auerbach publications for their
contributions in this project and for making this a remarkable experience. In
particular, I have a deep sense of gratitude towards my acquisitions editor, John
Wyzalek, for sharing my enthusiasm and providing me with great advice and
help. I also would like to thank the managing editor, Claire Miller, for her
invaluable advice and contribution in arranging the book in a presentable form.
My sincere thanks to Linda Rising for writing the Foreword.
I am truly appreciative and thankful to the following reviewers who have
taken the time to read the draft and provide me with feedback.
During the late 1970s, an architect named Christopher Alexander carried out the
first known work in the area of patterns. In an attempt to identify and describe
the wholeness or aliveness of quality designs, Alexander and his colleagues studied
different structures that were designed to solve the same problem. He identified
similarities among designs that were of high quality. He used the term pattern in
the following books to refer to these similarities.
Software frameworks can be confused with design patterns. They are closely
related. Table 1.1 lists the similarities and differences between the two.
Source Code
The source code for all example applications is available on the following Web
site for this book: http://www.crcpress.com/e_products/download.asp.
And why does any one stay in so precarious an outpost on the verge
of the fighting line? Some perhaps because to set forth alone or with
a brood of children into an unknown world already trampled by
countless refugees seems an equally perilous outlook. Others
because their maintenance still depends upon the docks and
shipyards, though the 6,000 longshoremen usually employed about
the piers have disappeared. Then there are those whose interests
are bound up in a shop or other investment in the town, and
business is brisk in Dunkirk, owing to the presence of two armies. A
few there are who are not only of Dunkirk but who are Dunkirk itself,
upon whose presence depends the prosperity of the town and its
usefulness to the State.
One of those largely responsible for the order of the port is the
Consular Agent of the United States, M. Morel, also President of the
Chamber of Commerce of Dunkirk. His house, a mere skeleton, has
long since been abandoned for the superior comforts and safety of
the cellar. Attached to the jamb of the almost equally ruined office
building his small sign in black and gold makes a brave showing. The
front of the building had been largely torn away and with it a part of
the roof. Looking up one saw a dizzy arrangement of laths and
rafters, suggestive of the underside of a heap of jackstraws. But the
staircase was firm and led to a small back room, where a bright fire
burned and where business was transacted as usual; not only the
business of the port, for while I was there an American Red Cross
doctor and a bevy of nurses came in to have their passports
renewed.
A STAG AT BAY
In the heart of the forest I once saw a stag leading his herd to the
shelter of a rock in the rush of an oncoming storm. Having urged
them into crouching positions around him, he turned and with a
simple gesture lifted his head to the storm. There was that in his
attitude which compelled reverence. One mentally saluted, though
one might think "poor, silly beast, in what way could he mitigate the
lash of the tempest?" But instinctively he had obeyed the highest for
which he had been created, the protection of the weak. And his calm
presence caught away all panic from those around him. Often while
in Dunkirk this scene came back to me, recalled by the simple
matter-of-courseness with which these brave men and equally brave
women stayed on because it was the place for them to be.
Everywhere warmth and order prevailed, from the wards where the
bandaged soldiers sat about with their pipes and their knitting to the
big bakery where the fragrant brown bread is baked and to the
kitchens with their caldrons of broth and crisp roasts of meat.
Mlle. Guyot, who has been at the hospital since the beginning of the
war, knows as well as any one what the city has endured. It was she
who said to me:
"I shall never forget that Dunkirk has borne the weight of the war
from the first day; that she has seen the exodus of the Belgian
population, to whom she has given refuge as well as to the people
of the Department du Nord; that she has known the passing of
innumerable armies going and coming from the Yser; that in
October, 1914, she began to be bombarded, having at the same time
to fulfill the immense duty of bringing in and caring for the wounded
from that immortal battlefield; and through it all I have seen Dunkirk
living and working and saving with a smile!"
The military position of Dunkirk is sometimes confusing because it
has been alternately on the French and English fronts. The English
are now retiring, but sentinels of three nationalities still guard the
city gates; English Tommy and French poilu stand with their arms
across each other's shoulders, the Belgian stands apart.
As the sea has been the life of Dunkirk in the past, so it will be its
resurrection. The city cannot be struck a deathblow from the land
side as has many another less favorably situated. But what a unique
protégé for some god-mothering American city to help re-establish
through her sympathy and aid!
Is it any wonder that France has just included in the arms of Dunkirk
the following legend in addition to the one gained by the naval battle
of 1793: "Ville heroique, sert d'exemple à toute la nation"?
Brutal Treatment of Italian
Prisoners
The thought that inspired this intrigue dates back to a period almost
two years earlier. On April 5, 1916, the German Chancellor, in
defining the war aims of Germany before the Reichstag, had outlined
the imperial policy of establishing a protectorate over the Flemings.
Later there were found in Belgium some obscure and discredited
citizens who, betraying their sacred duty, placed themselves in the
pay of the enemy and consented to make themselves the agents
and accomplices of the invaders.
At the end of 1917 the German authorities believed that the moment
had come to consummate the enterprise by completing the
administrative separation with a political separation. Thus the end
would be attained: Belgium would be dismembered; one part of the
country would fall under vassalage to Germany, and, in case there
were no annexation, would become in a way a sphere of influence
for the empire.
Thus one has the right to conclude that the whole organism of the
"Council of Flanders" is only a foreign tool to serve the enemy in his
designs of division and oppression. The delegates of the council
cannot pretend to any independence, since the decree of Jan. 18
reduces them to the rôle of functionaries of German authority,
named by that authority and expected to contribute, by their advice,
to its political work.
This nation can remain free. It stoically endures the presence and
domination of the enemy in its territory. The foreign occupation that
has lasted three and a half years has not broken its spirit or its will
to resistance. The Flemish, like the Walloon communities, victims of
the most frightful brutalities, subjected to a system of forced labor,
decimated by deportations, have remained immovably faithful to
King and country. The moral unity of the nation has continued intact.
FLEMISH QUESTION NOT NEW
The Flemish question does not imperil this unity. It dates much
further back than the war and has often been a subject of lively
debate. It is a question of interior policy which the nation alone must
solve, after the war, independently, under its own free constitutional
powers. Belgium has had the same Constitution since 1831, and has
not dreamed of altering its principles, unless we except the
proclamation of universal manhood suffrage in 1893. In eighty-three
years of peace and prosperity there was not a single political party
that cast doubt upon the validity of the fundamental charter—an
eloquent proof of its plastic vitality and perfect harmony with the
deepest needs of the nation's collective existence.
Finally, side by side with the three great political branches, the
provincial and communal Governments deal with all matters of local
interest. Chief among them are—for the commune: the City Council,
elected by direct vote, and the "College of Burgomasters and
Aldermen," whose members are chosen by the Common Council,
with the exception of the Burgomaster, who is appointed by the
King; and for the province: the Provincial Council, directly elected,
the "Permanent Deputation," elected by the Provincial Council, and
the Governor, who represents the National Government.
Belgium has always lived an intense life, yet this has never
compromised its unity. Three great parties, the Catholic, the Liberal,
the Socialist, struggle for preponderance, and their action extends to
all parts of the country without distinction of language. Each of them
supports an identical program, in Flanders as in Wallonia, regardless
of whether the citizens speak Flemish or French. The party lines
have never corresponded with the linguistic lines. In each are found
leaders of the Flemish movement, whose aspirations have given rise
to many speeches, but have never been repudiated as anti-patriotic.
This movement is thus described by the Flemish societies in their
protest against the "Council of Flanders:" It is the expression of the
fundamental principle that every population possesses the
inalienable right to develop itself according to its own character and
its own language, life, and historic personality." But it remains
essentially national and declares itself, in the document just cited,
unalterably hostile to the separation of the country into two
Governments with two capitals, two Ministries, two Parliaments. The
Flemish societies see in separation only "a weakening that will lead
to a catastrophe for the Flemings, as well as for the Walloons." They
add:
Only after the war can the Government solve the problems arising
out of the Flemish movement. The promoters of that movement
themselves deplore the intervention of an alien power and scorn the
traitors who have conspired with the enemy, accepting money and
positions at his hand. It is as loyal Belgian citizens, they declare, that
they are striving for reforms from which they expect a fuller
intellectual development of Flemish communities, and they see in
such culture a new force of unity for the nation, from which they by
no means wish to be separated.
The Belgian people, after three and a half years of the most grinding
oppression, have shown by the courageous defiance of enemy
bayonets which brought about the collapse of the "activist" plot, that
they have lost none of their sturdy resolve to be free; that the spirit
which moved them to reject the German ultimatum of Aug. 2, 1914,
is as strong as ever. * * *
Only one thing is worrying and humiliating in a quite special degree
all Belgians in occupied territory. It is the fear lest abroad it may be
imagined that there really is an "activist" movement in Belgium. All
the reports we have received on this point amount to this: "No one
in Belgium talks of this alleged movement, for it is nonexistent.
There are a few miserable individuals in German pay—always the
same—who intrigue and plot. All they have achieved is to arouse
against them such feelings of repulsion and hate that they have
been thrust forever forth from the nation, and nothing can cleanse
them of their crime. For mercy's sake, beg people not to insult us by
treating the agitation of these individuals seriously, and to stop
seeing any agitation where there is nothing but the work of a few
paid traitors.
UNJUST FINES
A dispatch from Minister Whitlock dated at Brussels, Aug. 2, 1915,
gives a fuller memorandum on the subject, as follows:
Francs.
Cereals 18,000,000
Oilcake, about 5,000,000
Nitrate, over 4,000,000
Oils—animal and vegetable—
2,000,000
over
Oils—petrol and mineral—about 3,000,000
Wools 6,000,000
Rubber 10,000,000
Foreign leathers, to Dec. 1,
20,000,000
about
Hair 1,500,000
Ivory, about 800,000
Wood 500,000
Cacao 2,000,000
Coffee 275,000
Wines 1,100,000
PAYMENT WITHHELD
The requisitions from Antwerp, which Mr. Whitlock enumerates, were
the subject of a protest by the Acting President of the Antwerp
Chamber of Commerce on March 18, 1915. He valued these goods
at more than 83,000,000 francs ($16,600,000) and stated that only
20,000,000 francs ($4,000,000) had been paid by the German
authorities. The reply of Governor General von Bissing on Sept. 24
shows that up to that time payment had not been made. The reason
is indicated in the following statement of German policy, published in
the Frankfurter Zeitung Dec. 21, 1914:
Professor Munro and his fellow-editors have drawn freely upon the
official texts printed in the work entitled "German Legislation for the
Occupied Territories of Belgium," edited, in ten volumes, by Huberich
and Nicol-Speyer, (The Hague, 1915-17.) These volumes cover the
period from Sept. 5, 1914, to March 29, 1917, and contain a reprint
of "The Official Bulletin of Laws and Ordinances" in German, French,
and Flemish. The documents show that the first step under the
Rathenau plan was to ascertain what raw materials and other
supplies were accessible. Consequently, there were many ordinances
commanding the declaration of certain wares. The following is an
example:
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookname.com