Writing Mobile Code Essential Software Engineering for Building Mobile Applications [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Writing Mobile Code Essential Software Engineering for Building Mobile Applications [Electronic resources] - نسخه متنی

Ivo Salmre

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید











Summary


When managing memory in your mobile application it is important to think both at a macro/application level and also at the micro/algorithm level. At the macro level, it is important to have a memory model that does not use up too much of your device's memory yet at the same time enables you to keep the data and resources that your application uses frequently close at hand. A state machine approach can be very useful for doing this for application resources. For your application's user data, consider designing a specific class whose job it is to manage the amount of application data that is kept in memory at any given time. This class serves as an encapsulated machine that knows how to bring new user data in when needed as well as shuttle old data out when it is unnecessarily taking up room. For any object that has a Dispose() method, be sure to call it when you are through with the object; this will preemptively release any nonmanaged resources held by the object and increase the overall throughput of the system.

At an algorithmic level, it is important not just to pick the right kind of algorithm for the data you are processing but also to implement the algorithm efficiently. You should strive to implement algorithms with as few object allocations as possible; this is especially true for code that runs in loops. Strings are of particular concern because they are so commonly used and it is very easy to write code that allocates and releases strings implicitly and wastefully. For strings algorithms, two valuable approaches are (1) using indexes to refer to data inside strings instead of extracting the substrings out as new strings and (2) using a StringBuilder (or your runtime environment's equivalent) for the construction of strings. You must be wary of creating and throwing away objects in your algorithms because the allocation and initialization takes time and the objects eventually turn into garbage that must be cleaned up by the runtime. Creating litter means creating a downstream need to clean it up, and this will reduce your application's overall performance. Objects are useful concepts but can be expensive when misused; design your algorithms accordingly.

Your mobile device application's execution environment behaves much like a small apartment. If you do not have too many items lying around, living there can be a joy. Bring too many things into your apartment and it becomes difficult to move around and get things done. If in the course of your daily activities you generate a lot of trash, you are going to spend a good amount of your time walking in and out of your apartment bringing the trash out and tidying up. Cleaning up litter takes time away from what you really want to do. At the macro living level, strive for an elegant but sparse apartment with all the important things you need close at hand but nothing else causing clutter. At the micro level try not to generate too much trash!


/ 159