As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Most of you will probably label this is a very generic question, but still, I feel that I should make it:
What are the best practices while developing an android app so it can handle errors in a way that doesn't Force Close?
I'm asking this because I'm newbie developing android apps and I'm struggling with force closes a lot... I'm guessing that must be a way to design the APP so it can avoid force closes whenever a problem exists (ex:no internet)
Right know I'm using try/catch but it doesn't seem a very programmatic and clean way of doing things, is there other options to handle exceptions besides try/catch ?
If you guys could send links to some good documentation or some sample code on this subject I would be very appreciated! tks!
Force Closes happen in cases of uncaught exceptions. You should be able to avoid them by good coding practices and, in general, cleaning up after yourself. If you have questions about a specific force close scenario, post a question about it and we'll see what we can do.
The very specific answer to your question (which is probably a very bad idea in this case) is that you can use a global default uncaught exception handler which will supersede the Google "force close" dialog. This is usually only a good idea if you have a very well-developed app and are guarding against rare errors in production or want to use some other logging/reporting functionality than the Google market default.
Note that this won't prevent exceptions; it will only pass them somewhere other than the default Google handler.
You may find some use in the Android Activity lifecycle for persisting data or looking at threading (which are two cases where you can get force closes if you don't have your head wrapped around it) if you're new to Android.
Actually force close is just a symptom of something going really bad in your app. Try/catch is the good mechanism to use in java (and on android) to make your app more robust and declare some behavior in case of errors.
I disagree with other comments. It's quite hard to build apps and foresee every possible exceptions/errors that can occur. So don't worry about no getting force close, you should better focus on how you can read them, understand log cat traces and find out bugs that caused there force close.
Programming is error prone and difficult, and it has always been somewhat tinted by a process of trying and getting errors and correcting them. So don't get desperate, you are on the right track.
This is a very broad question, as you said yourself. You should read 'Best practices' section at android developers site. Also for responsiveness see this page.
As for other way of handling exception rather than try/catch, bad news; there is none. BUT what you can do is check before using a resource for its availability. You can check for many things, including internet access, before you actually use it. I cannot list all of them here, but you will learn with time. This post will tell you how to check for internet availability.
Hope this helps.
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
Files will ship with bugs, and companies will always want to provide new features. There must
be a way to distribute new files with the hope that the applications will work just fine. And if the application doesn't work fine, there has to be an easy way to restore the application to its last-known good state.
I know this will be general question but I think that is also a general problem.
Comparisons of the solution in different platforms will be amassing.
Dear friends, Actually I am not talking about How to develop software,
Its about How to deploy software with minimum side effects on end users machine
(should be step 0, or -1) use a capable source code management tool, and use it to its full potential: especially branching)
Test Driven Development - always have tests for what you can test, and design code to be testable (to the point it is feasible, of course.)
never do any of these two the same time:
refactoring
introducing new features
fixing a bug
use continuous integration wherever possible
Reverting to "last stable" release in case of emergency
This must be supported by some infrastructural decisions, like keeping around the last stable release compiled and ready to be redeployed if something goes awry despite the efforts (been there, done that)
You should do unit testing. That's a good solution to avoid and track regressions.
But you can't just fast make a change in a big application and build a test unit ensuring everything is OK. You have to make a bunch of test units.
Which is costly, but there is no cheap way to ensure an application is bug free. The only solution is to dedicate a lot of work to testing, be it using unit testing or human testers or both. There's emphasis on that point in Joel Test because a serious team must spend enough in testing.
Restoring an application to an old state is just having a good version control system and not a mess with configuration and data parts. Some VCS have tools to help you find when a bug occured, for example git-bisect.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I want to develop an application where server pushes a lot of data to client. (20 kb every 20 milliseconds) 500kbps. All of the data are double/float values.
I am trying to answer the question, if there is something inherent to desktop apps (Java Swing app) which will make it a better option for this use case as compared to a web app where data will be pushed over http.
Is there something about Java swing app and how data transfer takes place there from server to client, that makes them faster as compared to web apps (tomcat as app server .. JS at client side).
And how answer varies, if I say that web server and application are on the same local network.
My vote is desktop, but I'm bias (when the only tool you have is a hammer...)
My first thought is threads and custom networking. You get the added benefit of push and pull protocols as you need (yeah you can get this in a web environment to, but Java was designed for this, AJAX has been bent this need)
I'd also push a diverse and customisable UI toolkit, but one might argue that you can achieve this using HTML, but I've, personally, found the Swing toolkit faster to get running & easier to maintain, IMHO.
The downside would have to the need to install the app on each client machine and deal with updating
That's my general opinion anyway, hope it helps
The other question is, what does the app need to do?
It is highly unlikely that the UI will be displaying 1000 meters all at once. The users will most likely be looking at small number of meters at a time. The UI only needs to be updated for the meters that are displayed on the screen. This should cut down on the load considerably. Assuming that networking and cache database components will be about the same for both web as well as desktop app, the real differentiator then becomes how fast the charts/graphs can be rendered, and how often or how many people will be inclined to use it.
MadProgrammer's suggestion of prototyping make sense. The test data gained from the prototypes would answer the performance question.
Web based will be more useful/valuable because it can be used from any desktop, tablet or smartphone. I am assuming that it is desirable to get the data in front of as many users as possible, anytime and anywhere. Also, I don't think human eye can detect 20ms updates. You could probably make that longer and users would not even notice it. Movies are about 25 frames a second, i.e. 40ms/frame.
How many concurrent user are you anticipating? I don't think that should affect the solution as both can be made scalable.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I am going to work on an complex application.Application is about to create lakhs of form dynamically, on those form rules can be apply dynamically and transactions of that forms.
For this application points that must be keep in mind are below:
1.Fast Loading:
1.1 Intial application load time must be smaller.
1.2 As there are lacs of forms then controls many in count of lakhs of lakhs with all properties.So while fetching forms from DB it should be fast.
2.Control Richness:
Which ever frame work used, It should be rich in controls, Control like:Date, Date Time Picker, Grid,TextBox,TextAera,Combox etc.
3.Browser Comapibilty
It should be compatible with all browser.
4.Resolution Indepedance
Application should be resolution independent.i.e It should work for every resolution and for every browser.
5.Mobile Compatibility
For this purpose I just started with a demo application.For this I selected GWT2.0.3 + gwt-ext,Hibernate
Hibernate is satisfying all the need regarding back end.But I am not satisfied with GWT as there loading issues,Browser issuse.
So I just need assistance for selecting frame work.Please also suggest me about the pattern
i.e. MVP,MVC.
I also searched abut spring framework But not much aware of it.
So please suggest me regarding this.
I am surprised you found issues with GWT. Personally I feel, it is one of the cleanest front-end implementations. (did you face issues integrating it with hybernate maybe?)
Anyways, another framework that is java style based (extends gwt and is richer) is Smart GWT that you can look into. I did a detailed comparison here which answers your questions - GWT,Smart GWT,GWT-ext comparison
If you are not looking for a java style based front end, you should look at jQuery too. http://jquery.com/. It even has a version optimized for touch http://jquerymobile.com/
EDIT -
1) You could even look at flex, which is a flash based. http://www.adobe.com/products/flex/
2) Also, if web based forms is the major area, look at Grails http://www.grails.org/
Point 1. Since you consider using Hibernate try "Extra‐lazy" collection fetching and lazy attribute fetching. The elements of the collection are accessed from the database as needed. I think it is a configuration issue to start up faster.
You will probably get faster startup if you use JDBC instead, but Hibernate will cut a lot of development time.
Also the JavaScript files containing your client application may take a lot of initial time to load, so split your application in smaller parts.
and 2. GWT covers your Control Richness issues and gives you a fairly reasonable Browser Compatibility. Gives you everything you have in a desktop Java Application.
About "all browsers": You can not have GUI Richness and Netscape 1.0 compatibility. JavaScript was not invented before Netscape 2.0
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I'm a beginner in programming. My experience so far is only in Actionscript 2 and 3. So I have a basic understanding of declaring variables, loops, arrays, if/then, do/while... I'm wanting to move to developing for Android phones so I'm wondering what suggestions people have for where to go next. Should I jump right to Android? Start with a 'beginning Java' approach? Or should I go some other route to beef up my knowledge of OOP concepts before launching into Android? I have my Dev environment set up and completed the Hello Android tutorial and I'm just wondering if I am going to be in over my head quickly?
I'm just wondering if I am going to be in over my head quickly?
Almost without a doubt. ^_^
My suggestion: Buy two books from Amazon.com
An Android development book. Work through every example in this book, do the problems at the ends of the chapters, take your time, understand what you're doing.
Buy an up-to-date Java book. Use it for reference when the Android book discusses something you don't understand.
This is very similar to what I did years ago to learn Obj-C and Mac development and it worked well. It will take you longer to get up to speed than diving into development and hacking something together, but at the end of the day you'll have a much better understanding of the principals and intricacies of writing code for the Android platform.
I should also mention my reasoning behind suggesting you buy books instead of using free Google results. Books are structured and highly edited. Assuming the author(s) are competent, a decent book will teach you what you need to know and leave out details that are either unimportant or more advanced that what you strictly need. It's difficult to impossible to find that level of structure in an online tutorial.
definitely nail down java syntax, so as little as possible confuses you in android development. android has some interesting objects to say the least--and their names don't hold traditional data structure names that you would be used to seeing. so, again, master the syntax, write some apps, then think about diving into android.
Yep, I'd say you need to learn java properly, and doing it exclusively through android is probably not the quickest approach. Try working your way through a recently published (it is essential that it covers generics) Java introduction book, then take on Android.
Android would be trial by fire. If you continue directly in Android, choose a few more simple hello world with bells on types of project. With ActionScript you were learning both a language and the platform, and switching to Android means learning a new language and very different platform. Most of the assumptions you acquired learning Flash will be wrong in Android.
I began learning Android with an understanding of JavaScript from front end web development. I grabbed the Wrox Android book and used the tutorials at http://java.sun.com/docs/books/tutorial/index.html to help me through the Java parts. I suggest diving head first into Android and going back to Java reference/tutorials where needed.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I am trying to use Spring for the first time in an application. The general issue that comes up repeatedly is how to debug Spring. The framework is configuration heavy so traditional code debugging seems fruitless. I have no real idea how to go about troubleshooting short of turning on the debugging level logs (which are lacking) and scanning through.
Are there any general tips or tools to assist Spring debugging?
If you're using Eclipse, then get hold of the Spring IDE (available from the Eclipse Marketplace within the Help menu of Eclipse). This will provide code-completion, bean visualisation, and hot-linking to your config files.
I don't think Spring debugging should be any different to any other debugging scenario.
What aspects of Spring are you using ? If you're using dependency injection properly, then I wouldn't anticipate any problems.
However if you're dynamically resolving beans via their name (at runtime, using ApplicationContext.getBean()) then I can see that's going to cause you problems anticipating flow of control etc., and would suggest that you revisit your IoC.
EDIT: It's quite useful to have the Spring source code available. It's well put together and quite readable, and therefore possibly of use when debugging.
I generally just use the java debugger in eclipse - it works fine on most classes. Some classes are wrapped at compile/runtime by bytecode changes - for these you generally cannot put breakpoints in methods, however you can set a breakpoint at method entry.
If you have a very specific situation you maybe should elaborate a bit in your question.
I'm generally also ok with the logging levels - what do you think is wrong with them?
As of 09/2011 (Version: 2.6.1.RELEASE, Build Id: 201105041000) a real annoyance is the fact that the debugger doesn't stop inside closures, so you have to remember to put a breakpoint inside the ones you want to examine; that is fine as it is "almost" going to a different class which a lot of time doens't matter, but when it does, you have to remember that.