Welcome to onepd
Patterns help solve complex design problems in better ways, more efficiently,
while avoiding potential pitfalls, based on our own and others' previous work.
One Page design pattern eliminates conversation transaction management,
reduces client-server interaction.
Java Persistence conversation enables you to create long units of work that span user think-time.
In web applications, you don’t usually maintain a database transaction
across a user interaction. Users take a long time to think about modifications,
but, for scalability reasons, you must keep database transactions short and
release database resources as soon as possible. You’ll likely face this issue whenever
you need to guide the user through several screens to complete a unit of
work (from the user’s perspective)—for example, to fill an online form. In this
common scenario, it’s extremely useful to have the support of the persistence service,
so you can implement such a conversation with a minimum of coding and
best scalability.
Two strategies are available to implement a conversation in Java
Persistence application: with detached objects or by extending a persistence context.
Both have strength and weaknesses.
But you should not use any of them.
One Page design pattern eliminates conversation transaction management:
you use display:none; property of CSS stylesheets to
hide new form and open another one
without interaction with the server.
Thank you for taking the time to review One Page design pattern Web site.
Your feedback is vital to ONEPD's success.
Please tell us how we are doing and, more importantly, how we can improve.
Send customer service feedback by e-mail to https://sourceforge.net/projects/struts2tutorial.
Your comments will receive attention from senior ONEPD management.
The Struts 2 tutorial will help the reader truly understand Struts 2 concepts,
it starts with simple examples and explains not only how to use Struts' features,
but also how certain features work under the hood; Integrates Struts 2 application with Tiles 2, Freemarker, Spring
and Hibernate/JPA.
1. Apache Struts 2, Java SE Development Kit, Apache Tomcat
2. Eclipse IDE for Java EE Developers, Struts 2 tags
3. Model-View-Controller (MVC), Object-Graph Navigation Language (OGNL)
4. The Spring framework, Hibernate + Microsoft SQL Server
5. JUnit + MySQL
6. Tiles + Oracle, Oracle SQL Developer
7. CRUD, i18n
8. Interceptors
9. Validation
Yes, there will be more lessons soon.
If you feel the code could use new features or fixes, or the tutorial can be improved,
please get involved and lend us a hand! The Struts 2 titorial welcomes your participation.
Let us know what you think!
We will start with a simple Struts2 application.
All what you need for now:
Download Java SE Development Kit
1. Run the self-installing executable to unpack and install the JDK software bundle
2. Add JAVA_HOME to the location of your JDK, C:\Program Files\Java\jdk1.6.0_07
3. Update Path environment variable, add the value %JAVA_HOME%\bin
4. Open a new command prompt and run javac -version to verify that it is correctly installed.
Download and install Apache Tomcat
Check Tomcat installation & configuration: http://127.0.0.1:8080/
Download lesson1.war file and save to your Tomcat
C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps
directory. Tomcat will create lesson1 directory.
Test Struts 2 Lesson 1 example: http://127.0.0.1:8080/lesson1/test.action
Examine C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\lesson1 directory.
In WEB-INF\web.xml all requests are redirected to FilterDispatcher.
WEB-INF\classes\struts.xml configures User class. When you request test.action, execute() method from User class sets
Congratulation message, displayed by test.jsp.
Actions do the actual work for a given request, it serves as a data carrier in the framework’s automatic transfer of data
from the request to the view, assists the framework in determining which result should
render the view that’ll be returned in the request response.
In the Lesson 1 the action’s work is to build a customized greeting for the User class.
In the next lessons we will remove this logic out to a business component and injected
that component into the action using Spring framework.
Starting Lesson 2 we will use Eclipse IDE to enhance our application.
Stop Tomcat server: open Control Panel, Administrative Tools, Services, double click Apache Tomcat, Properties, General tab,
set Startup type to Manual, stop Tomcat6.
Download lesson2.war.
Download Eclipse IDE for Java EE Developers and unpack
zip file to
C:\Program Files\eclipse.
Run C:\Program Files\eclipse\eclipse.exe, close welcome window.
In Project Explorer, right click mouse and select Import->War file. In War Import click Browse...
and select lesson2.war file. Click Finish.
Right click mouse on lesson2 project. Select Run As-> Run on Server. Open Apache, select Tomcat v6.0 server.
Click Next, Browse... Select C:\Program Files\Apache Software Foundation\Tomcat 6.0, click Finish.
Change url to http://127.0.0.1:8080/lesson2/forum.action You will get input text element.
Open web browser and run http://127.0.0.1:8080/lesson2/forum.action Play with the application, add new forum thread.
Explorer lesson2 web project. Open Java Resources: src, WebContent, WebContent WEB-INF, com.onepd.struts2.lesson tabs.
Forum.java implements Action interface - Struts 2 entry point execute() method and set/get methods for
name variable.
forum.jsp uses Struts 2 tags to pull data into rendering view page, to build the user interface of our web application.
Some of these tags mimic standard HTML tag while providing added value, other tags create non-standard, but useful controls.
s:form tag renders HTML an input form, s:textfield renders an HTML input field of type text,
s:submit tag is used together with the form tag to provide form submissions, s:property is used to get the property of a value.
In this lesson we will introduce ActionContext, interceptors, the ValueStack, and OGNL.
The ActionContext contains all of the data that makes up the context in which an
action occurs. This includes the ValueStack and stuff the framework
itself will use internally, such as the request, session, and application maps from the
Servlet API.
Interceptors are invoked both before and after the action,
they allow common, cross-cutting tasks to be defined in clean, reusable components that you can keep separate from your action code.
Struts 2 uses the ValueStack as a storage area for all application domain
data that will be needed during the processing of a request, it is
manipulated there during action execution.
OGNL is used in many places in the framework to reference and manipulate data in the ValueStack.
It binds HTML form fields to data objects on the ValueStack for data transfer,
pulls data into the rendering of JSPs and other result types.
Download lesson3.war.
Make sure that Tomcat service is stopped. Start Eclipse and import lesson3.war file. Open Servers tab,
right click mouse on Tomcat V6.0 Server as localhost, open Add and Remove Projects..., add lesson3 project, click Start the server.
Open web browser and enter http://127.0.0.1:8080/lesson3/forum.action
Open lesson3 project.
In our Forum application classes from com.onepd.struts2.lesson
represent the Model and test.jsp represents the View.
Variables name and threads from Forum.java stored in ValueStack and transferred
by OGNL to test.jsp. We use s:iterator tag to navigate through threads list
created in ThreadSession class and saved in the session by
Forum class that implements SessionAware.
In the first three lessons we created and tested Struts 2 development environment.
Now let's have some real fun.
Download Microsoft SQL Server 2005 Express Edition Service Pack 2
In the next lessons we will show how to use Oracle and MySql.
Run SQLEXPR.EXE, perhaps you will be asked to download and install .NET Framework, Windows Installer or some other software;
yes it is Microsoft! We just want to show that nothing can prevent from using Struts 2, even tough Microsoft environment.
Go to Programs, Microsoft SQL Server 2005
In Configuration tools:
SQL Server Configuration Manager, SQL Server 2005 Network Configuration, Protocols for SQLEXPRESS; Enable TCP/IP
In TCP/IP properties, IP Addresses, IPAll; set TCP Dynamic Ports: 1944
Restart SQL Server (SQLEXPRESS).
Open web browser, http://127.0.0.1:1944/ should produce blank page.
Go to settings, Control Panel, Administrative Tools, services:
SQL Server Browser, Properties, Status Type; select Automatic, Start SQL Server Browser.
Download Microsoft SQL Server Management Studio Express Service Pack 2,
Run SQLServer2005_SSMSEE.msi
Go to Microsoft SQL Server Management Studio Express: SQLEXPRESS (top line, mouse right click), Properties, Security,
select SQL Server and Windows Authentication mode.
Restart SQL Server (SQLEXPRESS).
Go to Microsoft SQL Server Management Studio Express: Databases, New Database; forum
Security, New Login, General, Login name; onepd
SQL Server authentication; Password: onepd, Confirm Password onepd
Enforce password policy; checked off
Default Database: forum.
Click OK
Security, Logins, onepd, User Mapping: Check forum database, set db_owner.
Click OK, Exit SQL Server Management Studio Express.
Check that you can login as onepd user. Go to Microsoft SQL Server Management Studio Express.
Authentication: SQL Server Authentication
Login: onepd
Password onepd
Exit SQL Server Management Studio Express.
Download lesson4.war.
Make sure that Tomcat service is stopped. Start Eclipse and import lesson4.war file.
Open Servers tab, right click mouse on Tomcat V6.0 Server as localhost, open Add and Remove Projects..., add lesson4 project, click Start the server.
Open web browser and enter http://127.0.0.1:8080/lesson4/forum.action
To make Stuts2 work with Spring and Hibernate we updated web.xml and added applicationContext.xml in WEB-INF.
applicationContext.xml has database configuration information:
name="database" value="SQL_SERVER"
name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"
name="url" value="jdbc:sqlserver://localhost:1944;databaseName=forum"
name="username" value="onepd"
name="password" value="onepd"
Thread class has @Entity annotation and additional member id - Hibernate uses it to track unique entries,
name variable is annotated as a column and database index will be created for it.
ThreadInterface is the same, we change only implementation, now it is ThreadJPA class.
Spring will create it for us. We configured com.onepd.struts2.lesson.ThreadJPA as a bean in applicationContext.xml.
Instead of session ThreadJPA works with EntityManager, injected by Spring.
Every time you restarts Tomcat, Hibernate recreates database tables. In Eclipse, open Java Resources: src-> META-INF-> persistence.xml,
comment the line with name="hibernate.hbm2ddl.auto" value="create" and uncomment name="hibernate.hbm2ddl.auto" value="validate".
This will keep entered data.
In the Lesson 5 we add Reply class;
use @OneToMany annotatin to link Thread and Replies;
add JUnit 5 test case for Forum class.
Download MySQL 5.1, unzip and run Setup.exe.
Use default setting: port number 3306,
new password: admin
confirm: admin
Go to Programs, MySQL, MySQL Server 5.1, MySQL Command Line Client
Enter password: admin
create database forum;
Download lesson5.war.
Make sure that Tomcat service is stopped.
Start Eclipse and import lesson5.war file.
File Java Resources: src struts.properties has new line struts.action.extension=html.
This replaces action extension with html extension.
Open WebContent WEB-INF applicationContext.xml file, notice the changes made to work with MySQL database.
Open Servers tab, right click mouse on Tomcat V6.0 Server as localhost, open Add and Remove Projects..., add lesson5 project,
click Start the server. Open web browser and enter http://127.0.0.1:8080/lesson5/forum.html
Open Java Resources: src struts.xml file, we added new action messages to process new Posts, added forum.jsp and messages.jsp files.
Open Java Resources: src ForumTest.java file.
If you have missed HttpServletRequest message, right click lesson5, properties,
Add Library..., Server Runtime, Next> Apache Tomcat v6.0, Finish.
JUnit tests do not require human judgment to interpret,
and it is easy to run many of them at the same time.
Initialization was made with @org.junit.Before annotation,
Test methods were annotated with @org.junit.Test
In Project Explorer, select lesson5, right click mouse, Run as, JUnit Test
Open JUnit tab, check that all three tests passed.
Download Oracle Database 10g Express Edition.
You will have to sign in, run OracleXE.exe, use default settings.
Enter Password: admin
Confirm Password: admin
Oracle will use Port for Oracle Database Listener: 1521
In the next lessons we will use Oracle database and we suggest to install Oracle SQL Developer.
Oracle SQL Developer is a free and fully supported graphical tool for database development.
With SQL Developer, you can browse database objects, run SQL statements and SQL scripts, and edit and debug PL/SQL statements.
You can also run any number of provided reports, as well as create and save your own.
SQL Developer enhances productivity and simplifies your database development tasks.
Download Oracle SQL Developer for Windows (This zip does not include a JDK).
Unzip sqldeveloper-5783-no-jre.zip to C:\Program Files\sqldeveloper
Run C:\Program Files\sqldeveloper\sqldeveloper.exe, provide Java location C:\Program Files\Java\jdk1.6.0_07\bin\java.exe.
Create new connection:
Username: system
Password: admin
In the Lesson 6 (lesson6.war)
we add StrutsTilesListener to web.xml file,
tiles.xml file in WEB-INF and layout jsp files in the layout directory.
In tiles.xml the Struts2Lesson definition specifies layout.jsp, that keeps the base for our project,
all other definitions inherits from Struts2Lesson and to look differently specify its own put-attribute.
struts.xml has result-type name="tiles", now result calls tiles definition instead of jsp file.
We will use default Oracle Database, XE.
Open Servers tab, right click mouse on Tomcat V6.0 Server as localhost, open Add and Remove Projects..., add lesson6 project,
click Start the server. Open web browser and enter http://localhost:8080/lesson6/forum.html
Lessin7
demonstrates how to write a web application with CRUD (Create, Read, Update, Delete)
functionality that uses the Java Persistence API (JPA) to access the database.
In the tutorial we first create entity classes based on tables in a database and then create
business logic and presentation layer.
In the Lesson 7 we refactored our forum application:
Category class and associated CategoryInterface Interface and CategoryJPA class were added,
Base class was added to encapsulate reusable functionality,
packages were created and classes were separated according to model and business logic.
To prevent unsanctioned access jsp files were moved to WEB-INF directory.
To keep global properties, perhaps you will use Japanese language, global-messages.properties file
was added.
Create, read, update and delete (CRUD) is configured in struts.xml file.
We demonstrate three approaches:
boolean variables, class methods and wildcards.
Open struts.xml file, action manager is associated with Manager class and default method execute, and
action managecategory will call method manageCategory from Manage class.
Open manager.jsp; form with action managecategory has three submit buttons.
Click on EditCategory button will lead to setEditCategory() and in manageCategory() the test will result in EditCategory function call.
The second approach sets actions with different methods:
In Forum class < action newthread will lead to newThread method and
< action deletethread to deleteThread method.
You can combine this behavior in one action replacing specific word in < acton with * and in the method with {1},
so that class Message has newMessage and deleteMessage set in struts.xlm like < action name="*message".
The Struts 2 framework comes with many built-in stacks that provide convenient
arrangements of the built-in interceptors.
Forum application, Lesson 8 inherits all built-in stacks by extending the struts-default package
defined in struts.xml file.
An interceptor has a three-stage, conditional execution cycle:
During the preprocessing phase, the interceptor can be used to prepare, filter,
alter, or otherwise manipulate any of the important data available to it.
This data includes all of the key objects and data, including the action itself, that pertain to the current request.
Call invoke() or divert workflow. If an interceptor determines that the request
processing should not continue, it can return a control string rather than call
the invoke() method on the ActionInvocation. In this manner, it can stop
execution and determine itself which result will render.
Even after the invoke() method returns a control string, any of the returning
interceptors can arbitrarily decide to alter any of the objects or data available to
them as part of their postprocessing. Note, however, that at this point the result
has already been rendered.
The intercept() method of the com.onepd.struts2.lesson.action.Authentication class
(that implements Interceptor interface) is the entry point into an
interceptor’s execution. The intercept() method receives the ActionInvocation
instance. The intercept() checks session for Constants.USER, gets current action and if
you are logged in resets User objects from the database.
This interceptor does not halt the execution process, and calls invoke(), passing control to whatever
comes next in the chain.
After calling invoke(), the interceptor waits for this method.
The result (the response page has already been sent back to the client)
tells the interceptor which result was rendered but it doesn’t indicate whether the action itself fired
or not. It’s possible that one of the deeper interceptors altered workflow by
returning a control string itself without calling invoke().
Authentication interceptor could implement some conditional
postprocessing logic that uses the result string to make some decision, but it can’t stop
or alter the response at this point.
When finished, Authentication interceptor returns the control string that it received from invoke().
Doing this causes the recursion to travel back up the chain of interceptors.
These outer interceptors will then have the opportunity to conduct any postprocessing they might be interested in.
The Lesson 8 uses the exception interceptor to route all exceptions of
type java.lang.Exception to the manager page.
The exception interceptor comes first in the defaultStack, its position
at the top of the stack guarantees that it’ll be able to catch all exceptions that may
be generated during all phases of action invocation because, as the
top interceptor, it’ll be the last to fire during postprocessing.
In the Lesson 9 Register action of Forum application extends ActionSupport, which implements
com.opensymphony.xwork2.Validateable and com.opensymphony.xwork2.Validation-Aware.
Interface Validateable exposes the validate() method, com.onepd.struts2.lesson.action.Register uses
validate() to check if some user name was registered before.
Interface ValidationAware exposes methods ( addFieldError ) for storing error messages generated when validation finds invalid data.
These interfaces work in tandem with an important interceptor known as the workflow interceptor.
When the workflow interceptor fires, it first checks to see whether the action implements
Validateable. If it does, the workflow interceptor invokes the validate()
method. If our validation code finds that some piece of data isn’t valid, an error message
is created and added to one of the ValidationAware methods that store error messages.
When the validate() method returns, it calls ValidationAware’s hasErrors() method to see if there were any problems with
validation.
If errors exist, the workflow interceptor intervenes by stopping further execution
of the action by returning the input result, which returns the user back to the
form that was submitted.
AccountEdit-validation.xml declares the validation metadata for com.onepd.struts2.lesson.action.AccountEdit class and all its subclasses.
AccountEdit-validation.xml sets requiredstring, stringlength, email field-validators or custom passwordIntegrity validator
declared in validators.xml as com.onepd.struts2.lesson.action.PasswordIntegrity class.
Struts 2 in Action
Donald Brown, Chad Michael Davis, and Scott Stanlick
ISBN: 193398807X
Pub Date: May, 2008
Pages: 424
The original Struts project revolutionized Java web development and its rapid adoption resulted in the thousands of Struts-based applications deployed worldwide. Keeping pace with new ideas and trends, Apache Struts 2 has emerged as the product of a merger between the Apache Struts and OpenSymphony WebWork projects, united in their goal to develop an easy-to-use yet feature-rich framework. Struts 2 represents a revolution in design and ease of use when compared to classic Struts. It adds exciting and powerful features such as a plugin framework, JavaServer Faces integration, and XML-free configuration.
Struts 2 In Action introduces the Apache Struts 2 web application framework and shows you how to quickly develop professional, production-ready modern web applications. Written by Don Brown, one of the leading developers of Struts 2, Chad Davis, a passionate Struts 2 developer, along with Scott Stanlick, this book gently walks you through the key features of Struts 2 in example-driven, easy-to-digest sections.
Struts 2 in Action delivers accurate, seasoned information that can immediately be put to work. This book is designed for working Java web developers—especially those with some background in Struts 1 or WebWork. The core content, covering key framework components such as Actions, Results, and Interceptors, includes new features like the annotation-based configuration options.
Spring Recipes: A Problem-Solution Approach
By: Gary Mak
ISBN: 1-59059-979-9
Pub Date: Jun 2008
Pages: 752
Spring addresses most aspects of Java/Java EE application development and offers simple solutions to them. By using Spring, you will be lead to use industry best practices to design and implement your applications. The releases of Spring 2.x have added many improvements and new features to the 1.x versions. Spring Recipes: A Problem–Solution Approach focuses on the latest Spring 2.5 features for building enterprise Java applications.
Spring Recipes covers Spring 2.5 from basic to advanced, including Spring IoC container, Spring AOP and AspectJ, Spring data access support, Spring transaction management, Spring Web and Portlet MVC, Spring testing support, Spring support for remoting, EJB, JMS, JMX, E–mail, scheduling, and scripting languages. This book also introduces several common Spring Portfolio projects that will bring significant value to your application development, including Spring Security, Spring Web Flow, and Spring Web Services.
The topics in this book are introduced by complete and real–world code examples that you can follow step by step. Instead of abstract descriptions on complex concepts, you will find live examples in this book. When you start a new project, you can consider copying the code and configuration files from this book, and then modifying them for your needs. This can save you a great deal of work over creating a project from scratch.
Java Persistence with Hibernate
Second Edition of Hibernate in Action
Christian Bauer and Gavin King
ISBN: 1-932394-88-5
Pub Date: November, 2006
Pages: 880
Persistence -- the ability of data to outlive an instance of a program -- is central to modern applications. Hibernate, the most popular Java persistence tool, provides automatic and transparent object/relational mapping so it's a snap to work with SQL databases in Java applications. Hibernate conforms to the new EJB 3.0 and Java Persistence 1.0 standards.
Java Persistence with Hibernate explores Hibernate by developing an application that ties together hundreds of individual examples. You'll immediately dig into the rich programming model of Hibernate 3.2 and Java Persistence, working through queries, fetching strategies, caching, transactions, conversations, and more. You'll also appreciate the well-illustrated discussion of best practices in database design, object/relational mapping, and optimization techniques.
In this revised edition of Manning's bestselling Hibernate in Action, authors Christian Bauer and Gavin King -- the founder of the Hibernate project -- cover Hibernate 3.2 in detail along with the EJB 3.0 and Java Persistence 1.0 standards.
Agile Java Crafting Code with Test-Driven Development
By Jeff Langr
ISBN: 0-13-148239-4
Pub Date: February 14, 2005
Pages: 792
Master Java 5.0, object-oriented design, and Test-Driven Development (TDD) by learning them together. Agile Java weaves all three into a single coherent approach to building professional, robust software systems. Jeff Langr shows exactly how Java and TDD integrate throughout the entire development lifecycle, helping you leverage today's fastest, most efficient development techniques from the very outset.
Langr writes for every programmer, even those with little or no experience with Java, object-oriented development, or agile methods. He shows how to translate oral requirements into practical tests, and then how to use those tests to create reliable, high-performance Java code that solves real problems. Agile Java doesn't just teach the core features of the Java language: it presents coded test examples for each of them.
This TDD-centered approach doesn't just lead to better code: it provides powerful feedback that will help you learn Java far more rapidly.
The use of TDD as a learning mechanism is a landmark departure from conventional teaching techniques.
Transcending CSS: The Fine Art of Web Design
by Andy Clarke; Molly E. Holzschlag; Dave Shea
ISBN: 0-321-41097-1
Pub Date: November 15, 2006
Pages: 384
As the Web evolves to incorporate new standards and the latest browsers offer new possibilities for creative design, the art of creating Web sites is also changing.
Few Web designers are experiences programmers, and as a result, working with semantic markup and CSS can create roadblocks to achieving truly beautiful designs using all the resources available.
Add to this the pressures of presenting exceptional design to clients and employers, without compromising efficient workflow, and the challenge deepens for those working in a fast-paced environment.
As someone who understands these complexities firsthand, author and designer Andy Clarke offers visual designers a progressive approach to creating artistic, usable, and accessible sites using transcendent CSS.
In this groundbreaking book, you’ll discover how to implement highly original designs through visual demonstrations of the creative possibilities using markup and CSS. You’ll learn to use a new design workflow, build prototypes that work well for designers and all team members, use grids effectively, visualize markup, and discover every phase of the transcendent design process, from working with the latest browsers to incorporating CSS3 to collaborating with team members effectively.
Java(TM) Puzzlers: Traps, Pitfalls, and Corner Cases
by Joshua Bloch; Neal Gafter
ISBN: 0-321-33678-X
Pub Date: June 24, 2005
Pages: 312
"Every programming language has its quirks. This lively book reveals oddities of the Java programming language through entertaining and thought-provoking programming puzzles." --Guy Steele, Sun Fellow and coauthor of The Java Language Specification "I laughed, I cried, I threw up (my hands in admiration)." --Tim Peierls, president, Prior Artisans LLC, and member of the JSR 166 Expert Group How well do you really know Java? Are you a code sleuth? Have you ever spent days chasing a bug caused by a trap or pitfall in Java or its libraries? Do you like brainteasers?
Then this is the book for you! In the tradition of Effective Java , Bloch and Gafter dive deep into the subtleties of the Java programming language and its core libraries. Illustrated with visually stunning optical illusions, Java Puzzlers features 95 diabolical puzzles that educate and entertain. Anyone with a working knowledge of Java will understand the puzzles, but even the most seasoned veteran will find them challenging. Most of the puzzles take the form of a short program whose behavior isn't what it seems.
Can you figure out what it does?Puzzles are grouped loosely according to the features they use, and detailed solutions follow each puzzle. The solutions go well beyond a simple explanation of the program's behavior--they show you how to avoid the underlying traps and pitfalls for good. A handy catalog of traps and pitfalls at the back of the book provides a concise taxonomy for future reference. Solve these puzzles and you'll never again fall prey to the counterintuitive or obscure behaviors that can fool even the most experienced programmers.
Effective Java™, Second Edition
by Joshua Bloch
ISBN: 0-321-35668-3
Pub Date: May 08, 2008
Pages: 384
Are you looking for a deeper understanding of the Java™ programming language so that you can write code that is clearer, more correct, more robust, and more reusable? Look no further! Effective Java™, Second Edition, brings together seventy-eight indispensable programmer's rules of thumb: working, best-practice solutions for the programming challenges you encounter every day.
This highly anticipated new edition of the classic, Jolt Award-winning work has been thoroughly updated to cover Java SE 5 and Java SE 6 features introduced since the first edition. Bloch explores new design patterns and language idioms, showing you how to make the most of features ranging from generics to enums, annotations to autoboxing.
Each chapter in the book consists of several "items" presented in the form of a short, standalone essay that provides specific advice, insight into Java platform subtleties, and outstanding code examples. The comprehensive descriptions and explanations for each item illuminate what to do, what not to do, and why.
Simply put, Effective Java™, Second Edition, presents the most practical, authoritative guidelines available for writing efficient, well-designed programs.
The C++ Programming Language, Special Edition
By: Bjarne Stroustrup
Pub. Date: 2000/02/01
ISBN: 0-201-70073-5
Pages: 1040
More than three-quarters of a million programmers have benefited from this book in all of its editions Written by Bjarne Stroustrup, the creator of C++, this is the world's most trusted and widely read book on C++. For this special hardcover edition, two new appendixes on locales and standard library exception safety (also available at www.research.att.com/~bs/) have been added. The result is complete, authoritative coverage of the C++ language, its standard library, and key design techniques.
Based on the ANSI/ISO C++ standard, The C++ Programming Language provides current and comprehensive coverage of all C++ language features and standard library components.For example: *abstract classes as interfaces *class hierarchies for object-oriented programming *templates as the basis for type-safe generic software *exceptions for regular error handling *namespaces for modularity in large-scale software *run-time type identification for loosely coupled systems *the C subset of C++ for C compatibility and system-level work *standard containers and algorithms *standard strings, I/O streams, and numerics *C compatibility, internationalization, and exception safety Bjarne Stroustrup makes C++ even more accessible to those new to the language, while adding advanced information and techniques that even expert C++ programmers will find invaluable.
C++ Templates: The Complete Guide
by David Vandevoorde; Nicolai M. Josuttis
ISBN: 0-201-73484-2
Pub Date: November 12, 2002
Pages: 552
This book will be the next C++ classic. Although templates have been part of C++ for well over a decade, they still lead to misunderstanding, misuse, and controversy. At the same time, they are increasingly found to be powerful instruments for the development of cleaner, faster, and smarter software. This has made templates one of the hottest topics in the C++ community. This book will be both a complete reference as well as a tutorial. It will emphasize the practical use of templates, and will include real-world examples. Every working C++ programmer will need a copy of this book for his or her library.
Templates are among the most powerful features of C++, but they are too often neglected, misunderstood, and misused. C++ Templates: The Complete Guide provides software architects and engineers with a clear understanding of why, when, and how to use templates to build and maintain cleaner, faster, and smarter software more efficiently.
C++ Templates begins with an insightful tutorial on basic concepts and language features. The remainder of the book serves as a comprehensive reference, focusing first on language details, then on a wide range of coding techniques, and finally on advanced applications for templates. Examples used throughout the book illustrate abstract concepts and demonstrate best practices.
Modern C++ Design: Generic Programming and Design Patterns Applied
by Andrei Alexandrescu
ISBN: 0-201-70431-5
Pub Date: February 13, 2001
Pages: 352
In Modern C++ Design, Andrei Alexandrescu opens new vistas for C++ programmers. Displaying extraordinary creativity and virtuosity, Alexandrescu offers a cutting-edge approach to software design that unites design patterns, generic programming, and C++, enabling programmers to achieve expressive, flexible, and highly reusable code.
The book introduces the concept of generic components, reusable design templates that enable an easier and more seamless transition from design to application code, generate code that better expresses the original design intention, and support the reuse of design structures with minimal recoding. The author then shows how to apply this approach to recurring, real-world issues that C++ programmers face in their day-to-day activity. All code is available on the Web, along with Alexandrescu's downloadable Loki C++ library, which provides powerful out-of-the-box functionality for virtually any C++ project. For experienced C++ programmers who have at least some familiarity with the Standard Template Library (STL).
You might be holding this book in a bookstore, asking yourself whether you should buy it. Or maybe you are in your employers library, wondering whether you should invest time in reading it. I know you dont have time, so Ill cut to the chase. If you have ever asked yourself how to write higher-level programs in C++, how to cope with the avalanche of irrelevant details that plague even the cleanest design, or how to build reusable components that you dont have to hack into each time you take them to your next application, then this book is for you.