Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

A new pattern to keep Common Interfaces

From Wiki
Jump to: navigation, search
Article Metadata
Article
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 {
public:
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());
ui->MyInterface();


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 04:36.
58 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×