![cppcolors | Embarcadero RAD Studio Delphi C++Builder Blogs](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2020/08/cpp_colors.jpg?resize=1140%2C628&ssl=1)
This blog post accompanies the webinar Make Your Apps Scalable and Web-Enabled – Leverage your Business Logic with a Fast Flexible Multi-Tier Architecture – Using RAD Server and REST Services.
Create high performance, scalable applications by adopting a multi-tier architecture. By separating the UI/presentation layer, the server and the data layer, your apps will scale more easily with changing business needs and accommodate larger numbers of users. Multi-tier architecture also allows dev team members to focus on their strengths and add new services through a loosely coupled architecture which keeps the impact of changes small. This webinar demonstrates how easy it is to create a services-based app using REST/JSON, database integration, and RAD Server. We will look at the use case of the RAD Server Field Services Application Template and also provide examples of web-enabling your application with an Ext JS front-end.
Table of Contents
Agenda
- The Monolithic Problem
- Architecture Types
- Why Does Scalability Matter?
- Microservices vs. Monolithic Services
- Making Your Business Logic Scalable
- Field Services RAD Server Template
- Using Ext JS for Web-Enablement
- Different Editions of RAD Studio
The Monolithic Problem
We all start with the monolith. This is the app that is easy to develop, just drop our data access controls on the form, mixing the business logic with the data access and the user interface. The monolith gets us to market quickly, but over time is harder to maintain.
- Does Everything in one tightly coupled module:
UI, Logic, Data, etc. - Quick when Apps are Small
- Doesn’t Scale Well. Can’t easily adjust as features, new users, and new platforms are added
- Doesn’t scale and typically only available via one platform (usually desktop), and not web enabled
- Difficult to Maintain as App Grows
Software Architectural Coupling
When our software modules are coupled they are hard to maintain. Wikipedia has an article on coupling, and Nick Hodges covers it in his books.
- Coupling is the degree of interdependence between software modules
- Disadvantages of tightly coupled systems:
- A change in one module forces a ripple effect of changes in other modules
- Adding and removing modules requires more effort due to increased dependencies
- Module are harder to reuse and test because inter-dependence
- Loose coupling is characterized by well defined & limited interactions
Why Scalability Matters?
As the app does more and gets more workload, the need to scale goes up. Horizontal scaling allows the software to handle more workload without the cost per unit of work going up.
- More important with growth
- Support more users & workload
- Reduce cost per users & work unit
- Allows for horizontal scale
Microservices vs. Monolithic Services
Going straight for Microservices usually isn’t a good plan.
- Martin Fowler suggests Monolith First
- Microservices require additional overhead
- Introduce Microservices to solve complexity issues
- Optimizing early may fix wrong problems (YAGNI You Aren’t Gonna Need It)
- Shortens time to market, allows for scale over time
Migrating your Business Logic with RAD Server
RAD Server makes it easy to make your monolithic app scalable.
- RAD Server’s EMS Packages are built with either Data Modules or Units.
- Refactor your code into loosely coupled Data Modules
- Move Data Modules to RAD Server
- Use remote calls to access endpoints
- Be aware of latency issues
- See Nick Hodges’ RAD Server Story
Remote Data Call Latency Tips
- When moving from LAN to WAN the response time of each request increases
- Bundle multiple requests into one request
- Utilize local cache instead of repeating the same call
- Parallel requests can be faster than a series of requests
- Proper architecture can prevent latency issues
Field Services RAD Server Template
There are a few different Industry Templates available in GetIt. They are a great resource to learn more about RAD Server and scalable app development.
- Available via GetIt Package Manager in the IDE
- Includes full source and graphic resources
- Written in Delphi (the technology all works with C++Builder too)
- Includes Field Service App, Admin, Server (uses RAD Server), & Setup
- Designed for mobile and desktop use
- Includes detailed documentation and video instructions
- Great resource to learn about REST services & RAD Server
- Use this template as a base to build your own solutions
Why Web Enable?
You are a big fan of native app development. What does the web give you? Adding a web interface is one way to take advantage of your new scalable architecture.
- Minimal friction for new users to connect
- Compatible across more devices and platforms
- Trade-off some performance and features from native apps
- No installation required – access from shared computers
- On-ramp to move users to native experience
Sencha Ext JS
The go to choice for web front ends is Sencha’s Ext JS.
- Ext JS helps you build data-intensive web apps
- Uses JavaScript, HTML, & CSS
- Includes 115+ UI components including calendar, grids, charts, pivot grid, and more
- Two flavors:
- Classic: Focused on Desktop and greater compatibility
- Modern: Focused on modern standards & Mobile (FKA Sencha Touch)
- Also Universal Applications for both Desktop and Mobile (using both Modern and Classic)
- More information
- Product Overview www.sencha.com/products/extjs
- The REST Proxy lets you connect to RAD Server docs.sencha.com/extjs/6.6.0/classic/Ext.data.proxy.Rest.html
- Here is an example you can build on examples.sencha.com/extjs/6.6.0/examples/classic/restful/restful.html
- Take a look at Kitto2 and UNIGui as additional resources to integrate Ext JS
- Web Development with ExtJS for Delphi Developers
RAD Server + Ext JS
- Tokyo 10.2.2 included a new FireDAC TFDBatchMoveJSONWriter component to generate JSON for a Sencha Ext JS client.
- Tokyo 10.2.3 expanded RAD Server to host static HTML, JS, CSS files (and any other files)
- EMS Server File Dispatching Support
- Edit [Server.PublicPaths] in the EMS.ini file
- See https://embt.co/EditingEMSConfig
ColumbusEgg4Delphi
Useful framework in refactoring your Monolithic App to multi-tier to make it more scalable.
- A simple to use Delphi framework to correctly write business logic in Delphi “RAD style” applications
- Provides a single point for the Business Logic code
- Forms and data modules are free of Business Logic code
- You can do unit tests; Business Logic can be unit tested using in-memory datasets.
- You can still use the RAD approach to design you forms
- If your data comes from an application server, you can fill in-memory datasets (or virtual dataset) and still use the same Business Logic.
- Free and Open Source
RAD Server Resources
- RAD Servier Video Playlist: https://embt.co/RADServerVideos
- Migrating to RAD Server Webinar Replay
- Deep Dive – Creating a Department Store Retail Solution
- RAD Server Multi-Tenancy
- Building a Microservices Architecture with RAD Server
- Build Flexible and Robust Apps with a Multi-Tier Architecture
- https://embt.co/FlexibleRobustMultiTier Blog post by Marco Cantu
- RAD Server & EMS DocWiki
- RAD Server Overview: http://docwiki.embarcadero.com/RADStudio/en/RAD_Server
- Multi-Tenancy: http://docwiki.embarcadero.com/RADStudio/en/RAD_Server_Multi-Tenancy_Support
- Configuring EMS: https://embt.co/ConfiguringEMS & https://embt.co/EditingEMSConfig
- Case Study Foresiight & Migrating to RAD Server https://embt.co/ForesiightRADServer (YouTube)
RAD Server Field Services Template
- Available from GetIt Package Manager in the IDE
- Includes detailed documentation
- Overview post: https://embt.co/FieldServicesOverview
- Deep Dive Article: https://embt.co/FieldServicesDeepDive
- YouTube Videos: https://embt.co/FieldServicesVideos
- Setup & Configuration
- Development Server
- Admin Application
- Client Application
- UI Tips and Tricks
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition