Welcome!

Java IoT Authors: Elizabeth White, Zakia Bouachraoui, Liz McMillan, Pat Romanski, Yeshim Deniz

Related Topics: Java IoT

Java IoT: Article

Splitting Tiers

Splitting Tiers

The story about how the n-tier architectures evolved from the single-tier mainframe model has probably been told umpteen times by now (in fact, I retold it myself in last month's e-Java column). Nowadays the trend is to distribute functionality. Modularize everything. Components provide the means to successfully replicate your product in a gazillion scenarios. Client/server is old news. Think distributed architectures. Personalized Webtops. That's the name of the game today.

It's easy to get caught up in the hype and lose touch with reality. The Internet fosters a new type of dynamics that encourages and embraces change faster than the stability of technology. It's an ever-increasing challenge for developers and architects to make decisions regarding when to adopt a new technology and how long to retain the old one. The complexity of these decisions is compounded in that computing technologies usually span multiple tiers of an n-tier application. Development managers and project managers face their own problems when dealing with distributed architectures. One of them is how to structure the development team such that the skillsets of the team members map across the various technologies used to implement the business solution. Who is the architect and how does he or she keep a handle on both ends of the spectrum - from the back office to the front-end browser? What kind of middleware expertise is needed? What kind of GUI needs to be built and how much are the tools going to cost? How does the team responsible for the middleware interact with the front-end Web developers?

One way to alleviate the risk in making such decisions is to clearly define what the tiers of the architecture are going to be and how the functionality of your application maps to those tiers. Everybody talks about n-tier architectures and distributed architectures. But the bottom line is - How do you serve up data to your clients? This month in e-Java we'll start from where we left off last month.

We'll revisit the four basic tiers of a distributed e-commerce application. Our focus will be more on the front end and middle tiers, and on some alternative Java and Web technologies available in the market to implement functional modules in business applications.

The Four Tiers
A typical distributed architecture that nurtures e-commerce applications consists of four-tiers:

  • Client user interface tier
  • Presentation tier
  • Business logic tier
  • Data access tier
Table 1 describes the purpose of each tier in an e-commerce application. In today's Web applications all of us strive to make the client as thin as possible. One of the main reasons for this is that end-user devices today range from desktop PCs to handheld PCs, cell phones and pagers. Thus, in the optimum distribution of tiers, the client UI tier will have minimum functionality; its only purpose will be to render the data on the screen using the display device's native graphic utilities. The thinnest "universal" client in today's distributed systems is the browser.

After All, It's All HTML
When it comes to the browser-based UI, all the data that the browser renders is interpreted from HTML. This means that the next tier down in the distributed system serves up HTML to the client. Traditional HTML serves static data only. To provide the high degree of interactivity typical of e-commerce transactions, HTML allows Web developers to embed tags that direct the browser to get fresh data from the server.

Why do we have to go to the server to get data? Because the thin client doesn't do anything else but display data; it doesn't produce data. That's the job of the presentation tier.

Java applets provide a way to dynamically generate HTML content. However, applets are downloaded to the client and executed there, thus making the client thicker. Applets enable highly interactive behavior for the client and are good for calculations that can be conducted on the client side. But more complex computations that involve frequent data access (and require security) on the server side need to be executed in the next tier. This is the presentation tier and its responsibility in our context is serving up HTML to the browser-based client.

Splitting the Middle Tier
Thus dynamic content is generated by the tier next to the client UI. This tier, called the middle tier in traditional three-tier systems, could basically access the data from the back-office system, apply business logic to it and serve up HTML to the client. So why split this into a presentation and a business logic tier? Let me answer that question with another question. How do you get data from your data source that resides in the back office? The data could be obtained from sources of various types - database server, file servers, LDAP servers or some legacy system's proprietary interface. The result is that the means of getting the data will differ. Depending on the back-office interface, the middle tier's connection to the back office could be via DCOM, CORBA, RMI, raw HTTP or a variety of other protocols. The scope of a transaction could be very different, depending on the business logic defined in the middle tier. If it's the same logical layer that deals with presentation logic as well as business logic, it becomes very complex. Also, since it's tightly coupled with the back office, it becomes less flexible and nonportable. This leads to scalability and performance issues.

The popular approach to solve these problems is to allow multiple application objects in a business logic layer. These application objects are responsible for getting the data from the server and making it available to the presentation layer. The presentation layer generates the dynamic HTML and makes it available to the client browser.

Generating Dynamic Content
The presentation layer has several alternatives for generating the dynamic content and serving it back to the client. The most popular approaches are via server-side scripting, Java servlets and Java Server Pages (JSPs), and Active Server Pages (ASPs). ASPs, Microsoft's technology for accessing COM objects, are beyond the scope of this article. JSPs are Java's counterpart to ASPs (hence the name JSP) and are Sun's technology for accessing Java objects on the server. All services on the servlets are Java's gateway to all services on the server side. Servlets are always associated with a Web server. They're created as server threads as a result of a client's HTTP request and they serve up HTML content as a response. A JSP allows developers to embed Java code in HTML pages. These hybrid pages have a .jsp extension and can contain a combination of HTML, Java code and JavaBean components. When the client makes an HTTP request, the servlet engine on the server compiles the JSPs into corresponding servlets.

Another way to add dynamism to HTML is via server-side scripting using JavaScript or JScript. Scripting code is embedded in the page. The difference is that, unlike JSPs, scripting code isn't compiled, it's interpreted. Although this is slower, it's faster to develop, prototype and test. Another popular middleware technique for generating dynamic HTML is to use extensions to HTML tags, which allow the page to access dynamic content. This technique is offered by Web application programming languages like Allaire's CFML.

These presentation technologies are still needed to talk to the business logic tier in order to actually obtain the data that needs to be presented. That is where server-side technologies like EJBs and COM come into the picture. The business logic and data source accessibility is abstracted by these technologies.

E-Commerce Functional modules
The technologies selected for your application should be based on the behavior that's expected from the functional module. For example, you can create a shopping cart component using CGI, JavaScript, servlets, JSPs, CFML or other types of dynamic-content generation technologies. However, when settling on a technology, you should ask yourself what the interface to the business logic tier is. Are your business objects COM objects, EJB objects or just database adapters? Can you access the COM objects via CORBA? Is there even a need to talk to the business logic tier for all transactions? For example, if the next step in your workflow is a credit card payment, the information doesn't need to go beyond the presentation layer, provided that the presentation layer has hooks into a credit card payment system like CyberCash.

One of the unique features offered by technologies like CFML is that it allows you to embed SQL inside your HTML. This means you can access the database directly from your HTML page as opposed to going to a business logic layer. This allows you to segregate your database into a front-end database, which could contain, for example, user profiles, account information and maybe local catalog information. On the other hand, if you need to access services offered by the back office such as information pulled out in real time from a reservation engine, you probably need to call Java or COM objects on the server side. In addition, if your catalog information is dependent on business rules that tie into the back office, then you'd probably like to go through a business logic tier. In that case JSPs may be a better alternative to build your shopping cart.

Trading Places
The notion of splitting the middle tier is important for building robust and flexible business applications. You may also want to divide the responsibility of load balancing and fault tolerance between the two middle-tier layers (presentation and business logic). For example, both ColdFusion (presentation) and WebLogic (business logic) offer clustering capabilities. Some transactions, such as credit card payments or catalog queries, may not need to go back to the business logic tier. Decoupling these two layers gives a large boost to scalability.

In the end, what the end user sees is your workflow that abstracts him or her from all these complexities. However, as someone who provides e-business solutions, I believe it's our job to create these abstractions to offer a more satisfying experience for the users of our systems.

E-Book
Starting this month, I'd like to add a monthly book review to the e-Java column, an idea I am shamelessly stealing from Alan Williamson of Straight Talking fame. Having received mail from several readers who have asked about good sources of information on several topics, I figured this is a good way to share my opinion on recently released books with all you fine folks.

In the mad rush for deliverables and the race to overcome the time-to-market dilemma, I find myself more often than not desperately trying to catch up on technology. In Java, that roughly translates to new APIs. Since I returned to Dallas pumped up from JavaOne in June, I've been trying to find time to catch up on J2EE. O'Reilly & Associates' Nutshell Handbook series seems to be created for such situations. Java Enterprise in a Nutshell: A Desktop Quick Reference is a great book if you want to get a quick ramp-up on the J2EE APIs.

It starts off where Java in a Nutshell ended. This is an excellent reference, but it's not for everyone. If you're looking for a comprehensive Java reference that covers Java in all its glory, this isn't the book for you - try Core Java published by Prentice Hall. If you're looking for a book on Java 1.1 APIs, don't start with this one - start with its predecessor.

If you know core Java, however, and are interested in a quick introduction to the APIs provided by the Java platform for developing enterprise applications, make sure you get a copy of Java Enterprise in a Nutshell. In typical "nutshell" style, Part I starts with a quick introduction to the Java enterprise APIs, and also gives a concise explanation of what enterprise computing means and how it relates to Java. The diagram on page 12 and the corresponding discussion in chapter 1 are instrumental in bringing readers up to speed with the current role of Java APIs in an e-commerce application. Part II covers the J2EE APIs - JDBC, RMI, Java IDL, Java servlets, JNDI and EJBs. There's just enough code to get your feet wet. If you want to look up an API, read the corresponding chapter, play around with the examples and then go write your application. For more detail and complex examples you'll have to get a book that focuses on that particular API. Finally, Part III of the book is a comprehensive quick reference for the enterprise APIs.

All in all, this is a good book to add to your library. And it's light enough to haul along if you have to travel.

More Stories By Ajit Sagar

Ajit Sagar is Associate VP, Digital Transformation Practice at Infosys Limited. A seasoned IT executive with 20+ years experience across various facts of the industry including consulting, business development, architecture and design he is architecture consulting and delivery lead for Infosys's Digital Transformation practice. He was also the Founding Editor of XML Journal and Chief Editor of Java Developer's Journal.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


IoT & Smart Cities Stories
Whenever a new technology hits the high points of hype, everyone starts talking about it like it will solve all their business problems. Blockchain is one of those technologies. According to Gartner's latest report on the hype cycle of emerging technologies, blockchain has just passed the peak of their hype cycle curve. If you read the news articles about it, one would think it has taken over the technology world. No disruptive technology is without its challenges and potential impediments t...
Nicolas Fierro is CEO of MIMIR Blockchain Solutions. He is a programmer, technologist, and operations dev who has worked with Ethereum and blockchain since 2014. His knowledge in blockchain dates to when he performed dev ops services to the Ethereum Foundation as one the privileged few developers to work with the original core team in Switzerland.
Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life settlement products to hedge funds and investment banks. After, he co-founded a revenue cycle management company where he learned about Bitcoin and eventually Ethereal. Andrew's role at ConsenSys Enterprise is a mul...
René Bostic is the Technical VP of the IBM Cloud Unit in North America. Enjoying her career with IBM during the modern millennial technological era, she is an expert in cloud computing, DevOps and emerging cloud technologies such as Blockchain. Her strengths and core competencies include a proven record of accomplishments in consensus building at all levels to assess, plan, and implement enterprise and cloud computing solutions. René is a member of the Society of Women Engineers (SWE) and a m...
If a machine can invent, does this mean the end of the patent system as we know it? The patent system, both in the US and Europe, allows companies to protect their inventions and helps foster innovation. However, Artificial Intelligence (AI) could be set to disrupt the patent system as we know it. This talk will examine how AI may change the patent landscape in the years to come. Furthermore, ways in which companies can best protect their AI related inventions will be examined from both a US and...
In his general session at 19th Cloud Expo, Manish Dixit, VP of Product and Engineering at Dice, discussed how Dice leverages data insights and tools to help both tech professionals and recruiters better understand how skills relate to each other and which skills are in high demand using interactive visualizations and salary indicator tools to maximize earning potential. Manish Dixit is VP of Product and Engineering at Dice. As the leader of the Product, Engineering and Data Sciences team at D...
Bill Schmarzo, Tech Chair of "Big Data | Analytics" of upcoming CloudEXPO | DXWorldEXPO New York (November 12-13, 2018, New York City) today announced the outline and schedule of the track. "The track has been designed in experience/degree order," said Schmarzo. "So, that folks who attend the entire track can leave the conference with some of the skills necessary to get their work done when they get back to their offices. It actually ties back to some work that I'm doing at the University of San...
When talking IoT we often focus on the devices, the sensors, the hardware itself. The new smart appliances, the new smart or self-driving cars (which are amalgamations of many ‘things'). When we are looking at the world of IoT, we should take a step back, look at the big picture. What value are these devices providing. IoT is not about the devices, its about the data consumed and generated. The devices are tools, mechanisms, conduits. This paper discusses the considerations when dealing with the...
Bill Schmarzo, author of "Big Data: Understanding How Data Powers Big Business" and "Big Data MBA: Driving Business Strategies with Data Science," is responsible for setting the strategy and defining the Big Data service offerings and capabilities for EMC Global Services Big Data Practice. As the CTO for the Big Data Practice, he is responsible for working with organizations to help them identify where and how to start their big data journeys. He's written several white papers, is an avid blogge...
Dynatrace is an application performance management software company with products for the information technology departments and digital business owners of medium and large businesses. Building the Future of Monitoring with Artificial Intelligence. Today we can collect lots and lots of performance data. We build beautiful dashboards and even have fancy query languages to access and transform the data. Still performance data is a secret language only a couple of people understand. The more busine...