Structure101

I've found today my post on project wiki from Sept 1, 2008 about Structure 101. Structure101 is really a useful piece of software. Here is a post, which was written to introduce this program to other team members.

Structure101 is used to visualize the structure of application in graph of modules/packages/classes or in dependency matrix presentation. It is also hepls to build the architecture diagram with violations check support, find the tangles, fat packages, classes and methos in code-base.
Structure101 also provides web application that helps to find the information about current status of codebase, watch for changes in code-base, code complexity and dependencies. The web application shows information in informative tables and charts, helps to watch the changes from previouses versions etc.
Structure101 provides the plugins for IDE (Eclipse and IntellijIdea. Plugins can synchronize with public repository (it can be configured to use web application to get data from repository), so any updates to repository are available to developers and developers are always updated with the last architecture desicions.
Plugin can check for architecture violations while IDE builds the project and show the messages as warnings or errors (depends on configuration).

Using Structure101 were created few diagrams (Dao and Services, Functional Presentation, Layers Diagram, Current architecture diagram] that helps to see the architecture almost-complete-view.
In picture you may see the screenshot of Structure101 with architecture Layers Diagram:

Layered Diagram Structure101


IntellijIdea and Structure101
Developer's IDE (IntellijIdea) with installed Structure101 plugin can help to prevent not permitted dependencies within code:

Violatins of Layered Diagram IDEA


Structure101 web application
Structure101 has also web application that can be used to view the project code-base status using WEB. Web application gives to the architect and project manager complete information about dependencies, changes after previous version, tangles, XS etc.

Pricing
- Structure101 is payable. See more http://www.headwaysoftware.com/products/purchase.php.
+ Structure101 web application as plugins for Eclipse and IntellijIdea are free of charge.

Tips: developing for Android

Here I want to post a list of some interesting facts about developing applications for Android. Although, my experience with it isn't huge, I believe this information will be useful for starters who want to create an Android application.

Lets get started.

  1. To publish your application to Android market you'll need to register and pay registration fee - $25. It's paid only once and is not returned.
  2. Name your application simple. If you application isn't part of your brand (like Facebook, Gmail or Twitter), it's the best to title application with some description of it. For example, Send Links and Phone 2 Chrome are good names, but SyncTab is not. At least, call it like 'SyncTab - send links easily'. The name should help user to understand what's your application for.
  3. Don't hard code values. Move them to appropriate files like strings.xml, integers.xml, arrays.xml, colors.xml etc. This will save your time to localize application and hone application for different devices.
  4. Use styles and themes.
  5. Prefer to use Content Providers to work with database.
  6. Use different forums to find first users and beta testers.
  7. Release often. This will help to get new users faster. Each time you release a new version of application, it's added to the Just Released feed. Prefer to make such releases before or on weekends.
  8. Make a nice but simple icon. Follow Android's style guide.
  9. Remember that you'll need a promotional and feature graphics.
  10. Use different techniques to cleanup the code. Like Android annotations, intent helpers etc.
  11. Optimize!
  12. Investigate Android applications of other developers, like iosched application from Google.
  13. You can use Google Analytics to track not only usage of application, but also errors
  14. Save resources: memory, cpu, network traffic.

SyncTab architecture. Part 2. Android Application

This post is a continuation for recent post with description of SyncTab server application. In this post I'm going to tell about SyncTab Android application.

As android application is very simple, I will make a very short description.

SyncTab application has a few activities only: the main activity is a list of shared links. When user first opens an application, she can either login into or register a new account. There is also a way to reset a password. User can only reset password, as original password is not stored; only salted hash of the password is stored on server. After user is signed in, she can see the list of links, edit settings and tags etc.

When user is authenticated and device is online, application starts two services: SyncService and RefreshService.

RefreshService connects to the server and checks if there are any new links to open on this device. Each device has an associated tag and opens only links with specified tag. Android device by default checks for the links with Android tag, and opens them if any. By default, RefreshService checks the server every minute if connection is up. But it is possible to change a period time or disable this service at all (if user doesn't want to receive links on device).

SyncService is used to synchronize android application status with server. Application allows to send links, when device is offline. In this case, link can't be send, but is added to the sync queue. Well, there are other operations that can be proceeded offline, like logout, remove link, re-send link, add/edit/remove tags. If device is offline, such operations are added to the sync queue. When network is app and device is online, SyncService checks the sync queue and executes each task in it. Sync queue tasks are persistent and stored in the database.

No hard coded values, except preferences names. Everything moved to the appropriate files like strings.xml, array.xml, integers.xml, colors.xml etc. Values vary not only for different localization, but for different devices (e.g. phone and tablet).

Documentation is available only online from synctab website. Website has two versions: for normal clients and for mobile clients. While, my phone will be redirected to the mobile version, a tablet will open a normal version of website.

There are two managers for each entity, a regular manager and remote manager. Application works mostly with regular manager, which itself calls remote manager if need. For example, there are TagManager and RemoteTagManager. To call an operation, activities use SyncTabFacade, while SyncTabFacade calls managers.

Activities started using special IntentHelper class, that provides a static functions like showLoginActivity(), showAboutActivity(), browseDocumentation() etc.

Links' favicons are cached as files in the cache directory. When a list of new links is retrieved, a favicon preloader thread starts. Thus, favicons are downloaded in background. If device is offline, and favicons can't be loaded, than an appropriate task is added to the sync queue for each favicon (and next time device is online, the favicons will be downloaded).

Well, looks like nothing interesting I can tell more about SyncTab android application.

So I decided to write a list of helpful facts about developing for Android as a separate post – "Tips: developing for Android".

Memory v0.1 is released

A few weeks ago I decided to create a simple library that emulates a virtual memory but with some extra features. My primary interest is to play with memory (de)allocation algorithms, replication algorithms, improve my knowledge in concurrency programming etc.

As for now, I have implemented a virtual memory with allocation mechanism, added concurrency and a basic transaction support.

Today I'm releasing a first version of this library, ie v0.1. This library can't do much yet, and if I'll have some time, I will start working on next version soon.

Library is open sourced, I'm hosting it on GitHub https://github.com/rkhmelyuk/memory. Documentation can be found in project's Wiki.

First memory should b allocated. There a few different allocators for this:
  • FixedMemoryAllocator - to allocate a memory of fixed size
  • DynamicMemoryAllocator - to allocate a memory of dynamic size (with initial and max size specified)
  • FileMemoryAllocator - to allocate a memory mapped to file, supports both fixed and dynamic allocation

After memory is allocated, it can be used in application. The common workflow is to allocate spaces in this memory. Space represents a block of memory. This block will be not available for allocation till a space is freed. A space is like a window to specified block of memory: it can be used to read and write data at this block.

Spaces are thread-safe. This means that locking is used when read/write operation happens. For a single write operation there is no change other thread will read a corrupted data. For a multiple sequence read and write operation it's possible to use a transactional space currently. In the next version I plan to add a lock/unlock operation, so single client can lock and use space without a chance a space to be changed by other thread.

A simple example for the end of this post:


// allocate a memory with a fixed size 20KB
FixedMemoryAllocator allocator = new FixedMemoryAllocator();
Memory memory = allocator.allocate(20 * Memory.MB);

// allocate a space in the memory with a size 10KB
Space space = memory.allocate(10 * Memory.KB);

// write a string to space memory
space.write("Hi world");

// create a transactional space, and start a transaction
TransactionalSpace transactional = space.transactional();
transactional.start();
try {
    transactional.write("Hello");
    transactional.write(transactional.readString() + " world!");

    // in transaction - original space is not changed
    assert space.readString().equals("Hi World");

    // but transactional does
    assert transactional.readString().equals("Hello world!");

    // commit transaction
    transactional.commit();
}
catch (Exception e) {
    // rollback transaction
    transactional.rollback();
}

// check transaction was committed correctly
assert space.readString().equals("Hello world!");

// it's safe to use in multiple threads
executor1.processData(space.getInputStream());
executor2.processData(space.getInputStream());