2 Replies Latest reply on Feb 8, 2017 11:44 PM by MariusAD

    Framework or not?

    MariusAD Level 1

      With some really old blog-posts and a sea full of frameworks that sits on top of Cordova/Phonegap. I was wondering what is the best and why use them.

      I have been playing around with Phonegap for my own amusement for a good while now, and been creating apps from the scratch. Without any use of frameworks like Ionic and such, but now I'm going for creating my first app for publishing to the app store. And want to create it as good as I can get it, and running as smooth as possible.

      I can say that I know HTML5, CSS3 and JS pretty good, and have created a handful of websites from scratch. So I like to create everything custom, per say.

      My fear is that using a framework is loading more assets then needed, and using more space. My goal is to have a lightweight app, that runs smoothly. And I have a custom design for almost everything, and I know that a lot of these frameworks comes with a ton of styles. Which I probably won't use either.

      So my question is this, why should I use a framework with Phonegap and if yes, which one?

        • 1. Re: Framework or not?
          kerrishotts Adobe Employee

          There's no single correct answer in this space because it boils down to your preferences and the kind of app you're building. Really, it comes down to what tools you're comfortable using, and whether or not you consider those tools to be right for the job.


          I've done it both ways -- I've built my own lightweight framework, and I've used other frameworks. Both cases have their benefits and their problems.


          If you don't select a framework you will inevitably build your own, even if it is cobbled from various other libraries. On one hand this is nice: you understand your framework completely -- there's no magic at all involved. On the other hand, it's a pain in the rear: any bugs in the framework are your responsibility, including bugs that might arise on obscure platforms you don't have access to. (Use Crosswalk to help with this on Android.) The degree to which you'll be satisfied with the end result will depend on how close you wish to hew to the OS look & feel -- I consider it a fool's errand for a single dev to aim for 100% pixel perfection in both look and feel, simply because this is not only a moving target with each OS release, but that you'll never actually be able to invest the time to duplicate it perfectly.


          If you build your own framework understand that you are responsible for managing the view stack, handling animations between views, rendering all your widgets, etc. It can be rewarding to do this, but every moment you spend here is also a moment you aren't writing your app. Whether you can live with that is only something you can decide.


          Here's an example of a simple framework I wrote from scratch:


          I did not attempt to duplicate the look and feel of Android or iOS; instead I landed somewhere in the middle. I think it still feels at home on both devices, however.


          If you do select a framework, then you can spend more time on your app instead of debugging your own framework. You also gain a (potentially huge) community that is discovering issues on platforms you'll never encounter (and hopefully fixing them) as well as helping you with any problems you might encounter. There will almost certainly be a wider selection of widgets here, lots of documentation, and almost certainly an "opinion" on how to build apps with the framework. Whether or not this opinion is compatible with your view is, again, up to you.


          Here's another app I built using Framework 7: PhoneGap101-Filer/www at master · kerrishotts/PhoneGap101-Filer · GitHub . Here the L&F is a lot closer to native, but that's because the F7 team is the one devoting their resources to looking like a native app, not me. I get to focus on functionality not LaF. None of this is to say that there isn't some scaffolding around F7 to get it into something I'm comfortable working with -- there is (and F7 isn't highly opinionated -- it can work with Vue and Angular too), but I didn't have to spend a lot of time debugging the framework or painstakingly building styles that look like native widgets.


          So, in the end, it's up to you. Do enjoy the hard work of bootstrapping your app from the ground up? Do you have the time to invest in such an endeavor? The patience to fight all the bugs? If so, building your own framework can be fun and rewarding, even if you eventually transition to something else down the road. OTH if you need to build an app like, now, or don't want to fuss with all the crazy cross-platform quirks that live in mobile webviews while building complex widgets, go with a framework.


          As to which framework? It's up to you. Some big names with large communities include Ionic, Onsen UI, Sencha Touch, Kendo UI, Framework7. All of those should be able to help you create a responsive and nice looking app without too much difficulty.

          • 2. Re: Framework or not?
            MariusAD Level 1

            Thank you so much for a great answer!

            Well written and very precise, this will help me a lot with creating a better app. Think I have much more to read about these frameworks, and maybe developing Phonegap apps.