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

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

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

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











Performance and API Abstraction Levels


It is important to work at the right level of abstraction. Higher levels of API abstraction offer a simplified, convenient, and well-tested programming model, but often at the expense of added overhead. Lower-level APIs offer the possibility of the greatest control of performance but do so at the cost of added complexity in your code. Networking code and XML parsing are two examples of framework functionality where multiple layers of abstraction exist for the application developer to choose from. Your application should always use the highest level of abstraction that is appropriate for the tasks it is trying to accomplish.

The case of working with XML is an instructive example. In theory, developers could achieve the absolute maximum performance by working directly at a file I/O stream level to parse the data they needed. However, this would be a foolish, error prone, and thankless task if well-designed and proven higher-level APIs exist to do the work without incurring a significant performance penalty. Ideally, developers would like to use the XML Document Object Model (DOM) to load and save their data as an XML tree. If the XML data being worked on is of moderate size, this is a great model. Developers must remember, however, that the XML DOM is a stateful API; when it loads XML into memory, it actually creates an in-memory tree of objects representing the XML document. For a large-enough XML file, this in-memory tree will cause severe memory pressure. In contrast, the XML DOM itself is built on top of stateless and forward-only XMLReader and XMLWriter classes; these classes parse or generate XML data in a minimally stateful way. The XMLReader and XMLWriter keep only enough data around to allow them to continue parsing or streaming the XML; they neither generate nor use an in-memory tree of the data. When working with larger XML documents on mobile devices with limited memory resources, the stateless forward-only model is the right way to go. This is true even with the greater programming burden that the lower-level APIs place on the application developer to manage the XML parsing process. Choosing the right level of API abstractions requires understanding how much data is going to be moved and what the overhead is that is associated with higher-level abstractions.


/ 159