A new pattern to keep Common Interfaces

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Created: vdharankar (30 Jul 2009)
Last edited: hamishwillee (30 May 2013)

While interfacing UI with its corresponding functionality, every developer must have come across a common problem, i.e. multiple views may have same UI components demanding for same functionality. For example two views having same menu options invoking same code but since these views are different one can not share the code.

So one solution can be as follows

Create the interfaces in an abstract class

class MInterface {
void MyInterface() = 0;

Implement your interface with the AppUi class

class CMyApplicationUi : public CAknViewAppUi, public MInterface {

Now with the help of AppUi reference these functions are easily accessible from any view as shown below.

// some view 
CMyApplicationUi * ui = static_cast<CMyApplicationUi*>(AppUi());

One of the advantages of this method is that all the user interface components are easily accessible in AppUi class, so UI related code which is common and needs sharing can be placed here.

But if the UI related code is large in amount which needs to be shared by multiple views then only inference is the design needs improvement and in such case this solutions will be an over kill. Hence this solution need to be used carefully depending on the usage context.

This method might not be a standard practice but it’s a common solution to a commonly seen problem.

This page was last modified on 30 May 2013, at 07:36.
39 page views in the last 30 days.