Preface


I BEGAN WORKING WITH JAVA TECHNOLOGY in late 1995, shortly before the Java Development Kit (JDK) 1.0 was formally released. Prior to that, I was programming in C and C++ for many years. I was truly excited about the features that Java offered, such as cross-platform portability, simpler syntax (simpler than C++, for example), objectoriented, secure, rich API, and more.

Over my 20-year career, I have learned a few things. Among these, my favorite is simplicity; anytime I see complexity, I begin doubting whether the solution is correct. This is how I had begun to feel about Java right around 2000, when the Java 2 Enterprise Edition (J2EE) started becoming mainstream. Note that from this point on, I will refer to J2EE as JEE because the "2" was recently dropped from the name by Sun Microsystems.

My growing lack of interest in Java was a result of what I saw as unnecessary complexity in JEE introduced by layers of abstraction. I began to believe that Sun Microsystems (inventor of Java) was focusing Java and JEE on solving the most complex enterprise applications, but somewhat ignoring the relatively less complex, small- to medium-sized applications. Furthermore, I saw the hype take over people's common sense because I ran across projects in which Enterprise JavaBeans (EJB) were used for nondistributed processing, such as local logging. I felt strongly enough about this subject to write a short article for JavaWorld.com in 2000 (http://www.javaworld.com/javaworld/jw-10-2000/jw-1006-soapbox.html) titled, "Do You Really Need Enterprise JavaBeans?" (About five years later, we saw EJB 3.0 specifications being rewritten to become more simplified, to ease the development.) This brings us to this book and the reason I wrote it.

I was recently hired as a consultant for a Fortune 100 company to build an enterprise web application running in a clustered environment. While reviewing alternatives to the standard JEE/EJB model by researching online and having discussions with some smart people, I decided on a solution, which included the Spring MVC web framework, Hibernate object-relational (OR) persistence framework, the Eclipse IDE, JUnit testing framework, Ant build utility, several tag libraries, and a few other products. (All these products are covered in detail later in this book, along with my rationale for choosing these technologies.)

I have enjoyed working with Spring and Hibernate, mainly because they allow me to work with plain-old Java objects (POJOs) and avoid some of the hassles of working with EJBs. Also, working with the Eclipse IDE has been a nice experience. I continue to be amazed at how well this product works, and that is the reason I dedicate a whole chapter in this book to it. In my opinion, products such as the ones mentioned here are breathing new life into Java at a time when Java is at risk of losing its popularity to alternatives such as Microsoft's .NET, LAMP (Linux, Apache, MySQL, and PHP or Python/PERL), and Ruby on Rails.

In this book, although Spring, Hibernate, and Eclipse are highlighted, a key goal for me is to provide you with a complete solution from technical and process perspectives. From a technical perspective, I provide an end-to-end solution (using a variety of tools) for implementing a complete sample web application with transaction management in the backend and suitable for a clustered environment. From a process perspective, I recently switched from using the Rational Unified Process (RUP) to a process composed of guidelines provided by Agile Model Driven Development (AMDD; agilemodeling.com) and Extreme Programming (XP; extremeprogramming.org). As a result, in this book you will find concepts and artifacts such as user stories, release plans, CRC cards, and more. The idea is to provide you with a comprehensive solution for rapidly developing and deploying enterprise Java applications.

One additional note about my background. I have been a developer for almost 20 years, primarily working with core technologies such as C/C++, Java, enterprise relational databases, application servers, Unix, Microsoft Windows, and so on. However, I took a detour for approximately five years around 1998 to build the company I had founded in 1996 (I was doing minimal programming during this time). I later sold this company to get back into development. However, even though I was the CEO of this company and had several people working for me, I got the opportunity to meet and interview literally hundreds of developers over a seven-year period and discuss technology with them. Apart from this company, I also founded an online community for Java developers, grew it to over 100,000 members, and won several awards for this. I hope my experience from these ventures adds a unique perspective to this book.

In summary, I truly hope you will find this book useful and will enjoy reading it!

Who This Book Is For

This book assumes that you have some working knowledge of Java and relational databases (including SQL) as well as experience working on the command line. Aside from prerequisites mentioned here, the following types of people can use it:

  • Software Developers/Architects Developers and architects can gain value from this book because it includes a high-level software development process, application design, and an in-depth and complete inspection of the Java and related files of a fully functional, sample enterprise web application.

  • Technical Leads/Managers Technical leads and managers with a programming background, preferably in Java or similar language, can get an in-depth look at how applications are built using a variety of Java technologies. This knowledge might help during project planning or with staff troubleshooting technical problems (perhaps just for moral support during frustrating times). Alternatively, technical managers can dive into a specific chapter (for example, Chapter 5, "Using Hibernate for Persistent Objects") to understand how that specific technology works and fits into the big picture.

In addition, as a reader, you might gain some insight from this book on alternatives to JEE that you can use for building a robust enterprise-class application. Furthermore, if you are not familiar with Agile Modeling or Extreme Programming or are looking for a nimble software development process, this book might have just enough to get you going with a complete process for developing software applications iteratively and incrementally.

Goals of This Book

The goals of this book are as follows:

  • Agile development The first and foremost goal of this book is to show you how to do rapid enterprise Java development. This is achieved by combining multiple facets: a nimble/minimal software development process, a simple design (moderate use of design patterns or layers of abstraction), convenience technologies (such as Spring and Hibernate), working with POJOs versus remote objects, and in general, leveraging stable open source technologies whenever possible. In short, the idea is to make Java simpler and faster to work with for developing enterprise-ready applications.

  • Complete solution A close second goal of this book is to provide you with a complete solution, from a technical and process perspective. After reading this book, you should be able to build an entire application, not just technically, but also using the process outlined in this book. In addition, when I cannot cover a given technology in depth, I provide references to resources (websites) for further investigation of the technology. The cool thing about the technologies covered in this book is that you can have a complete system, from the user interface to an embedded database along with the capability to schedule jobs (thanks to the Spring Framework), all self-contained in a single web application archive (.war) file! However, you can always replace the technologies mentioned in here with some other technology of your choice (for example, using an Oracle database instead of HSQLDB). In summary, you will have the complete solution to do thisprocess and technologies!

  • Using an open source only solution is not a goal of this book Although I have based this book entirely on open source frameworks, tools, and products, preaching an open source only solution isn't a goal of this book. For instance, you can leverage Java's vendor portability and replace one of the products covered in here with a commercial product. However, open source has come a very long way, and I'm thoroughly impressed by how robust these technologies are and how well documented they are. For example, technologies such as the Eclipse SDK and Hibernate are arguably better than some of their commercial counterparts. You could just as well use all the technologies mention in this book for an enterprise solution and rest assured that they will perform as advertised. In fact, I recently implemented an enterprise solution for a large company using the Spring Framework, Hibernate, Eclipse, JUnit, Ant, and other tools mentioned in this book! However, we also used commercial products such as BEA's WebLogic Server and an Oracle database server. The same company (and several others I know of) are basing their enterprise solutions on the open source technologies I mentioned.

  • Quick read This book is intentionally smaller than the typical 600+ page books you find on Java. This was done to enable you to get through the book quickly and begin using the solutions in the real world. In light of this, I have tried to keep the content in this book streamlined and more to the point. The one downside of not writing an extremely thick book is that I had to make some tough decisions about which material to forego; however, I have tried hard to include all the important process- and technology-related material you will need for agile Java development (as explained in the previous goal of providing a complete solution).

  • Simplicity Whenever possible, I take the simpler approach to accomplishing the same objective over a complex solution. For example, the sample application covered in this book uses minimal layers of abstraction to accomplish our objective. By layers of abstraction, I am referring to the excessive use of design patterns, interfaces, and application partitioning. Each of these makes enormous sense, but using everything in moderation is a good practice and one I like to follow when I am working with a software development process and artifacts produced from such a process. Furthermore, I believe simplicity should also extend to designing, in that I tend to use UML when appropriate, but lean toward simpler, free-form diagrams using tools such as OpenOffice.org, PowerPoint, or Visio versus something heavy like Rational Rose.

  • Tips and tricks As you might already know, when working with tools and technologies, tips and tricks not only make the product work more effectively for you, but also make it more fun to use. I provide tips and tricks for some of the technologies covered in this book. However, the appendixes also contain some goodies such as useful cheat sheets and a list of cool tools.

  • Alternatives Throughout this book (although not in detail), I try to provide alternatives to the solution I am proposing. I realize that one solution does not fit everyone's need. For example, you might be using Sun Microsystems's NetBeans or JetBrains's IntelliJ as your IDE and do not want to switch to Eclipse. This type of scenario is to be expected and is completely understandable. The organization of this book takes this into consideration; you should still be able to gain value from the remainder of the book and replace a technology covered in this book with the technology of your choice (for example, JDO versus Hibernate).

What Is Not Covered

This book assumes that you have working knowledge of Java and a relatively good understanding of JEE. It also largely assumes that you have a reasonable understanding of software development processes, relational databases, n-tier architectures, and so on. Given this assumption, I delve right into the specifics required to build our sample application. Furthermore, I refer you to the respective websites for setup (and advance features) instructions instead of duplicating this information in this book and risk having it become out-of-date.

On the flip side, this book assumes that you have no working knowledge of the key technologies covered here, such as the Spring Framework, Hibernate, Eclipse, and so on. Given this view, this book provides the basics on these technologies to get them to work together; this book also goes one step further to provide you with a brief introduction to some of the advanced features offered by these technologies. Anything beyond what is mentioned here is beyond the scope of this book because there are literally entire books dedicated to many of the technologies mentioned in this book.

What Is Covered (Technologies and Process)

The focus of this book is more on development and less on infrastructure. In other words, I've focused more on the application development technologies such as Spring, Hibernate, and Eclipse than on products such as an application server (for example, JBoss) or database (for example, MySQL). When in doubt, I went with the one easiest to set up. Also, I'm a big believer in getting the functionality implemented in an application first and then optimizing later in the form of refactoring and optimization techniques. What I have presented in this book has been tried in real-world applications that are running successfully in production (some in a clustered application server environment), so I don't want to give you the impression that we are ignoring infrastructure altogether. One of the goals of this book was to keep it short and to the point, so I have chosen to focus almost entirely on a well-designed application that scales well.

Given the operating system (OS) and vendor portability benefits of Java, in theory, when your application is ready to be deployed, you can deploy it to a more robust web application server and database combination. For instance, you could use the low-end products used in this book (Apache's Tomcat and HSQLDB), upgrade to a JBoss Application Server and a MySQL database combination, or further upgrade to a BEA WebLogic Server and Oracle's database server combination, for example. This is the beauty of Java; it is not only OS portable, but also vendor portable.

One more note about the core technologies covered in this booknamely, Spring, Hibernate, and Eclipse. Although these are the technologies I've worked with recently and use in this book, I have provided alternative and competitive technologies in the industry, which I encourage you to look at. For example, if you choose to use JDO rather than Hibernate, you can still gain and apply the knowledge from all chapters, except perhaps the one on Hibernate.

How This Book Is Organized

The chapters in this book are organized so that each chapter builds on the previous one. Furthermore, because the chapters are logically segregated, you could jump into a chapter directly (for example, Chapter 6, "Overview of the Spring Framework") and learn about just that chapter's content. Also, you might want to skip a chapter if you are not interested in using that technology (for example, you might want to use NetBeans instead of Eclipse; therefore, you would skip Chapter 8, "The Eclipse Phenomenon!").

Chapter 1, "Introduction to Agile Java Development," gives you an overview and a preview of the technologies and process we will use in this book. Chapter 2, "The Sample Application: An Online Timesheet System," is primarily dedicated to defining the business requirements for our sample application; however, it also provides a nice overview of AMDD and XP methodologies. Chapter 3, "XP and AMDD-Based Architecture and Design Modeling," covers the design of our sample application. Chapter 4, "Environment Setup: JDK, Ant, and JUnit," covers the environment setup. From here, we enter the world of Java coding at a rapid pace, when we look at programming with Hibernate in Chapter 5. Chapters 6 and 7 are dedicated to the Spring Framework. Chapter 7, "The Spring Web MVC Framework," and Chapter 8 are what I call the "wow!" chapters, because everything converges in these chapters and you will see and appreciate why we went through the earlier chapters in the way we did. You will know what happens underneath the covers and hence have a solid foundation of the technologies such as Spring, Hibernate, Ant, and JUnit. From there, we will cover some advanced concepts and wrap up the book with some goodies in the appendixes.

One other note is in regard to command-line development versus GUI (for example, using the Eclipse SDK). The earlier chapters intentionally use the command line so that you can get some fundamental understanding of how these Java tools work. Then, when you use these tools (for example, Ant and JUnit) in an IDE such as Eclipse, you will know exactly what is going on behind the scenes. This becomes particularly important if the IDE does not meet your needs.

About the Code For This Book

This book is about Java coding and there is a lot of code related to the sample application we will build in this book. This completely functional sample application with all the source code and related files can be downloaded from the publisher's website. Having the code in electronic form versus printed in the book enables you to browse and test-drive the code/application for yourself.

The code itself is referenced and explained throughout the book using notable snippets/excerpts from the complete code. Furthermore, there are two conventions used for this code:

  • In certain places, long single line of code (that is, more than 82 characters) have been split into two lines for readability in this book

  • The code itself appears in monospace font.

Note

All the book's code is available for download at the publisher's website. For convenient access to this book's example files and source code, as well as any possible updates or corrections, be sure to register your book at www.samspublishing.com/register.


About The Figures For This Book

A picture truly says a thousand words, so you will find many diagrams and screenshots in this book. While I have provided some UML diagrams in this book, I tend to lean towards quick free-form diagrams and instead generate UML diagrams by reverse engineering an application. I don't spend a lot of time on formal diagrams because many of these are throw-away diagrams after they have served their purpose and most projects aren't able to keep these diagrams up-to-date anyways. I'm a big believer that the code and database are the final and most important artifacts.

In summary, I believe diagrams should do the following:

  • Be developed only when they will be effective.

  • Be self-explanatory (for example, use words versus confusing notations, use legends).

  • Be simple, to the point, and really get across the intended message.

  • Conform to a standard notation (for example, UML) either if required by your organization, for a handover of a system to another person or group, for code generation, or because you prefer to use a standard notation

One additional note about the figures in this book. In a few chapters, I have repeated/reused figures from previous chapters. This was done for the following reasons:

  • To set context for the chapter or section that is about to be discussed

  • I did not want to inconvenience you by requiring you to flip back to a previous chapter where the figure was first introduced.

Personal Opinion Sidebars

Throughout this book, you will notice sidebars labeled "Personal Opinion," which is exactly what the content in these sidebar is. I have tried hard to separate this subjective material from the objective material in the book. However, I hope you will find the viewpoints expressed in these sections useful, as they are little nuggets of my experience from various perspectives: as a software engineer, consultant, trainer, author, community builder, and even CEO of an IT services company.

XP and AMDD-Based Comics

You will see an illustration at the top of each chapter that makes up a fictional story throughout the book about an eight-week project using AMDD. The four main characters in this story, also fictional, include a customer (Susan), a Project Manager (Ron), and two programmers (Steve and Raj). The idea behind these illustrations is simple: to add a bit of humor to this book while teaching you about AMDD and XP along the way. Also, the relaxed style of these illustrations is based on my interest in writing books for children (early readers). I must warn you, these get a bit corny, but I hope you will find some humor and knowledge in them.

If you like the style of these illustrations and want to see more of these, please visit visualpatterns.com.

Recommended Resources

This book covers many technologies, and given the nature of this book, it provides just enough information on the technology to complete our sample application. However, each technology warrants a book itself; indeed, there are books dedicated to many of the technologies covered here.

Meanwhile, the following are websites for the key technologies covered in this book. Each provides additional documentation (and in some cases, discussion forums) for their respective technology:

  • Agile Modeling http://www.agilemodeling.com

  • Ant http://ant.apache.org/

  • Eclipse SDK http://eclipse.org

  • Extreme Programming http://extremeprogramming.org

  • Hibernate Framework http://hibernate.org

  • HSQLDB database engine http://hsqldb.org/

  • JUnit http://junit.org

  • Spring Framework http://springframework.org

  • Visual Patterns http://visualpatterns.com

I will provide chapter specific resources at the end of each chapter, so you will have plenty of resources for further reading by the end of this book!



Agile Java Development with Spring, Hibernate and Eclipse
Agile Java Development with Spring, Hibernate and Eclipse
ISBN: 0672328968
EAN: 2147483647
Year: 2006
Pages: 219

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net