Mobile - Other
Transform yourself, but watch out for the pitfalls.
This article is not a big pointing finger to shame you about errors you make when you start creating your first mobile apps. This article is meant as a guideline to help you avoid some pitfalls in your work.
“But what can you do then?” you might ask. Well, I can read data from an IBM i (DB2), MySQL, or MS SQL database, combine the data, and by using some general tools, publish it in a web browser running on some device. My users can then use the information daily, saving them both time and money.
I have written quite a few articles in MC Press Online about jQuery, Bootstrap, and other web tools over the years, so I will use this article to sum up some of the things I have struggled with along the way.
First Mistake to Avoid: HTML Is Not That Difficult to Master
Learning a new language (if you can call HTML that) can be a challenge, but you should spend some time learning HTML. The fun thing about learning it is that you can enter some code and right away you can see the result in your browser. Learn the tables (take divs later) and the ways to add pictures, links, iframes—all the basic stuff to place data on a website.
Many great sites out there offer the basic knowledge to learn HTML. One of the ones I can recommend is w3schools.com. They offer tutorials as well as quizzes to test your skills. If you want to lean back and enjoy a film, YouTube of course is the place. Do a search for “HTML basic” or “learn HTML,” and you will find a lot of nice people just sitting there waiting to teach you.
Second Mistake to Avoid: Cascading Style Sheets (CSS) Is a Must These Days
CSS is not really a language. It is more the glue that makes your HTML elements display correctly on the page or even in print. Using CSS, you can control where HTML elements can be placed and what size and color they have.
CSS should be stored in external stylesheets and can then serve as the layout master for various webpages, so you’ll be more productive and it will be easy to maintain the layout of the page.
CSS has classes, not like in an OO language, but still it is a way of adding layout properties to various HTML elements in an easy way.
Again, there are many places to learn it. And again, w3schools does a great job. Please note that I have no interest in the site for personal reasons. I just find it very easy to use, and it has a good way of explaining things. Of course, both YouTube and Google can point you to the right CSS place for you.
I repeat: In my opinion, CSS is essential if you want to create a nice-looking webpage in 2017.
This means that you should carefully plan a programming standard for things that you just not are used to if you are an RPG programmer.
Fourth Mistake to Avoid: Your DB Skills Can Serve Data to Web Apps
You need data for your web apps. Not so long ago, the data on your IBM i was all you needed, but that sure is not the case anymore. Today, data is spread all around, in MySQL or MS SQL databases, in Excel files, in CSV files, in XML files, in JSON objects, in web services…and you need to master them all in order to provide your users with the needed information. So you need some tools in your tool belt to bring the data to the web page surface.
The way I do it is very simple. On the IBM i, I use RPG CGI. I use the web APIs provided by IBM to read data from the database and then transform it into either HTML or XML, and I let Apache do the job of sending the data to the requester and then let the web page handle the result and present the data to the user. To me, writing to a display file or to the browser is the same thing. Although the output format is different, it is the same cycle: get some input, read data, process it, and output.
When it comes to the other DB sources mentioned above, you must learn a language that can act the same way as RPG. In my case, PHP was the one. It is pretty easy to learn the basics, and there are so many examples of all you can ever think of on the Internet and even on MC Press Online. Our own David Shirey has written some great tips about the secrets of PHP.
I use PHP the same way as I use RPG: get some input, read the data, process it, and output. This way, the retrieving of data will be transparent to the web app. “Why is that important?” you might ask. Well, that way, you can change the database layer very easily and even have the same web app running on various databases.
Fifth Mistake to Avoid: Libraries and Frameworks Are Not Bad Things
Until now, I have just mentioned “basic” stuff that you must learn and pitfalls to avoid in order to show some data on a webpage. But when it comes to mobile devices like smartphones and tablets, things change radically. You are now facing things like responsive design, small bandwidth signals, different web browser engines, and all kinds of display sizes.
I once tried to make my pages fit the requirements by hand-coding it, but it was such a daunting task that I never got it to work the correct way. Then I got involved in a project where somebody spoke about something called jQuery, and that became my savior when it came to creating dynamic functionality.
One of the most important things to learn when starting to use jQuery is AJAX. To me, that is the cornerstone in all web programming, and it is a must to master (in my opinion).
To handle all the responsive tasks, Bootstrap is the one for me. It takes a little effort to get the hang of, but when you learn the grid system and the main classes, you are on your way.
I have also written articles about jQuery Mobile, and I like that very much, but the thing about it is that it fits only mobile devices and does not look very good on a PC.
So, to avoid any mistakes, I have a golden rule: If your web app is to run just on a mobile device, jQuery Mobile is a great solution, but if you want to use it on both PCs and mobile devices, Bootstrap is a very good solution.
Let’s Sum It Up
I know this has been a very long article, and I really hope that you still are with me to this point. Creating web apps and trying to avoid mistakes are not as easy as it might seem.
To me, it has been a journey of transforming myself from a green-screen programmer who (still) loves DDS and RPG and the way the IBM i just helps you do things in an easy and structured way to a web/mobile programmer in a world of various databases, web technologies, new ways of designing screens, and security issues you never have to deal with in a IBM i world.
It might sound like a lot of work, and sure it is, but I tell you it is all worth it. And the first time you enter a URL that fetches data from various platforms and you see the result on your smartphone, your heart will make an extra beat.