Results 1 to 6 of 6

Thread: Programming in Android, problem of inheritance and object handling

  1. #1
    Join Date
    Apr 2010
    Posts
    31

    Programming in Android, problem of inheritance and object handling

    I have several years of experience developing for Windows Mobile through the Compact Framework. But still I am struggling with the transition to Android. In modern programming languages and when I include C++ I am used to transmit object references around the program for use or modification of data. The Android is not as easy. Each screen inherits from Activity. The only way to provide input to an Activity is through an Intent object which can add a Primitives as string, int, double, bool, etc. This goes against everything I have been trained in computer programming. If I edit an object in a dialogue I submit the item and change the dialogue. The object may of course contain several sub-items to be opened in the dialogues, etc. This is impossible in Android. Nor that I will open a dialogue and the DialogResult OK so I will for example return a new object of any type through a property or something. Often I build, for example, up dialogue and put providers etc with the DI (Dependency Injection), which also is impossible here. The only way I am in a reasonable way to share resources etc in the program to be living the "runtime" to close the program is through to have a Singleton "service provider" that can retain the services I need. This can not solve many of the problems I describe earlier. Someone who has experience in Android, with the idea why they have done as they have done and how you possibly have solved these problems? Have searched and read some of this around and see many struggling with the same things as me. But no one has a good solution on how to create larger heavier applications that are not on TicTacToe level. In Windows Mobile, I have built a program of 150,000+ lines of code and 150+ dialogues and does not know how I'm going to build similar complexity on Android.

  2. #2
    Join Date
    May 2009
    Posts
    543

    Re: Programming in Android, problem of inheritance and object handling

    I've developed a few simple programs, and as you say its the static resource managers or Singleton thing that you are looking for. I have at least in my android programs took advantage of static resources. Today, about a use case can not be described in an activity, I look carefully for this use case which should not be changed, but I completely agree that the Android way of dealing with resource sharing is something odd, but think this is only because it's different than what I am used to. Otherwise, here is the link what explains you how to fix it: http://developer.android.com/guide/a...framework.html.

    Otherwise I would advise you to leave advanced patterns and best practices from other languages when you come across on the android. Create simple code, your application will not be extended in perpetuity. On my first application on android I walked into the trap of trying mvp, in the end I was forced to see what the platform was intended for. It ended up with only one model (which I kept static), and view controller per activity. Since you choose (today at least) primarily mobile language is not made for and is not suitable for advanced applications with n features.

  3. #3
    Join Date
    Apr 2010
    Posts
    31

    Re: Programming in Android, problem of inheritance and object handling

    Thanks for the detailed reply! Had come to similar conclusions as you. Someone who disappoint me a bit. Although Windows Mobile has its obvious weaknesses, I feel that the Compact CF is very flexible and a good platform. While Android is a small step back. Modern and flexible in terms of making small, quick simple programs in a short time. But hard to make some young half complex applications. Google has probably done this deliberately to create small simple applications with low memory usage and fast start. Unfortunately, this works poorly for me as trying to make a little heavier application on this platform. Will make the best out of it. Stripping down what was the plan and remove some ingrained habits in a MVC head

  4. #4
    Join Date
    Apr 2009
    Posts
    569

    Re: Programming in Android, problem of inheritance and object handling

    At the risk of missing some of what you ask. If you serialize the object, you can send it right intent. And thus bring it into activity by the Caste of the object you want. Used it myself on objects that only contained a 7-8 primitives and then it went fine. It is right that when new objects are created all the time and to update the earlier views, it must be reloaded. It seems that it becomes very quickly messy code in android. If it is of little experience or architecture, I will not say much about the first. And you can use a SQLite database to store things in between activities.

  5. #5
    Join Date
    Apr 2010
    Posts
    31

    Re: Programming in Android, problem of inheritance and object handling

    But this does not mean that I must de-serialize objects on the activity page? To do this, that would be different "references" on the objects? That means that I can not submit an item for the change because it will be changed everywhere in the program. The other problem is that there is relatively much data in these objects. Up to 10.5 MB on the worst. If this is to serialize and de-serialize so I imagine that this will take quite a long time. If only I had submitted the object unchanged it would not demanded any resources. Do you think I'm wrong now so happy to give a hint. But interpreted serialization variant so that it worked for my purposes. But I may have misunderstood. Currently I have landed on a kind of servicelocator pattern to retrieve data. But this is not really solving the problem of sending objects between dialogues. I have made a "static-like pattern" to fit the data but this is messy code I am unhappy with.

  6. #6
    Join Date
    May 2009
    Posts
    637

    Re: Programming in Android, problem of inheritance and object handling

    I understand basically your problem, but I really feel that I am very curious about what kind of (mobile) application that you create that need to send so much data between activities. Is it necessary that the dialogues you say will be used to edit the data known to the whole object? In many cases, you might do with an alert dialog? It can be built as an inner class and have access to objects that are already loaded by the activity. It was not straight forward to get to pure MVC in Compact Framework, and you should have a certain complexity of the program so that it would pay off with regards extra time spent. Unfortunately, it is probably even more difficult in Android as you say.

Similar Threads

  1. Object oriented programming with java
    By cloud101 in forum Software Development
    Replies: 2
    Last Post: 22-02-2012, 01:11 AM
  2. Write a COM object in C++ .NET programming
    By Banned-BlackBadal in forum Software Development
    Replies: 5
    Last Post: 26-06-2011, 07:31 AM
  3. Replies: 3
    Last Post: 08-01-2011, 06:20 AM
  4. Inheritance in an object oriented language
    By Satchel in forum Software Development
    Replies: 4
    Last Post: 17-12-2010, 05:06 AM
  5. What is event handling in the java programming?
    By rashmi_ay in forum Software Development
    Replies: 3
    Last Post: 09-12-2009, 02:01 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,406,116.12784 seconds with 17 queries