CSC/ECE 517 Fall 2009/wiki3 21 MobileDesignPattern: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
(Copy in notes, need to paraphraze)
 
(39 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Design Pattern for Mobile Applications ==
== Design Pattern for Mobile Applications ==


The popularity of mobile applications is rising.  Design patterns are useful in almost any coding tasks.  While almost any design pattern could be used within mobile applications, certain patterns are well suited for the unique environment of mobile applications.  This wiki explains the mobile application environment, then focuses on design patterns that work well within this new emerging environment.
The popularity and number of mobile applications rising quickly.  Design patterns can help make the development process more efficient.  While almost any design pattern could be used within mobile applications, certain patterns are well suited for the unique environment of mobile applications.  This wiki explains the mobile application environment, then focuses on design patterns that work well within this new emerging environment.


__TOC__
__TOC__
Line 7: Line 7:
== The Mobile Application Environment ==
== The Mobile Application Environment ==


The mobile application environment is new and presents many unique opportunities and challenges for developers.  It seems almost everyone now has a cellphone, blackberry, or other small portable device.  These devices are "getting smarter" in that many people are developing new applications for them.  Cell phones no longer are just used to call people, they often have features like text messaging, cameras, video games, web browsers and more.  There is much opportunity for developers to write new applications for mobile devices.
The emerging mobile application environment presents many unique opportunities and challenges for developers.  It seems almost everyone has a cellphone, blackberry, or other small portable device.  These devices are "getting smarter" in that many people are developing new applications for them.  Cell phones are no longer only used to call people, they often have features like text messaging, cameras, video games, web browsers and more.  There is much opportunity for developers to write new applications for mobile devices.


While opportunity abounds, there are also quite a few challenges.  Mobile applications have less resources than are typically found in other development environments.  The screen om mobile devices is typically smaller, there is usually not a keyboard and mouse (user inputs are reduced) [5].  CPU resources are generally less than those found in the typical environment [7].  Power usage is also limited because a battery is typically used, so reducing power use by the application is an important goal [7].  Connections are typically expensive and are often prone to loss of signals [6].
While opportunity abounds, there are also quite a few challenges.  Mobile applications have fewer resources than are typically found in other development environments.  The screen on mobile devices is typically smaller and there is usually not a keyboard and mouse (user inputs are reduced) [5].  CPU resources are generally lower than those found in the typical environment [7].  Power usage is also limited because batteries are usually the power source, so reducing power use by the application is an important goal [7].  Connections are typically expensive and are often prone to loss of signals [6].


Another problem is that there is a high demand for applications to be developed quickly [7].  The mobile environment is changing rapidly [2].  Some of the lower level programming languages were useful because they produced fast applications, but they took too long to develop with.  Now, with the increased demand for applications quickly, Object Oriented Programming (OOP) is used more.  While this causes a greater usage of resources, this is outweighed by the much quicker development cycle and the re-use of code.  In particular, good solutions may be re-used in OOP [7].
Another problem is that there is a high demand for applications to be developed quickly [7].  The mobile environment is changing rapidly [2].  Some of the lower level programming languages were useful because they produced fast applications, but they took too long to develop with[http://www.umsl.edu/~subramaniana/concepts1.html 12].  Now, with the increased demand for applications quickly, Object Oriented Programming (OOP) is used more often.  While this causes a greater usage of resources, this is outweighed by the benefits of much quicker development cycle and the re-use of code.  In particular, good solutions may be re-used in Object Oriented Programming (OOP) [7].


In the mobile environment, applications are often written on different operating systems on different mobile systems.  There is increased interaction between mobile systems, especially for cell phones.  The Service Oriented Architecture design pattern is especially well suited for this situation.  This is a fairly new field, and methods are currently being developed to aid developers.
In the mobile environment, applications are often written on different operating systems [http://en.wikipedia.org/wiki/Mobile_operating_system] on different mobile systems.  There is increased interaction between mobile systems, especially for cell phones.  The Service Oriented Architecture design pattern is especially well suited for this situation.  This is a fairly new field, and methods are currently being developed to aid developers.


== Ways to Adapt Using Design Patterns ==
== Ways to Adapt Using Design Patterns ==


Several principles and patterns have been understood and developed in developing for mobile applications.  Many of these methods are still undergoing change and experimentation.  There are new methods being developed and others left behind.  A design pattern can be defined as a repeatable solution to a common problem in software.  It is a template for how to solve the problem, not actual code [7].
Several principles and patterns have been recognized and further developed in coding for mobile applications.  Many of these methods are still undergoing change and experimentation.  There are new methods being developed and others left behind.  A design pattern can be defined as a repeatable solution to a common problem in software.  It is a template for how to solve the problem, not actual code [7].


Ease of navigation is a particularly important principle, because of the reduced number of user inputs (for example, buttons from 0 to 9 instead of a mouse and keyboard).  Everything in an application should be no more than three clicks away.  If a program is too "deep", requiring many clicks, this will be a problem because it takes longer to navigate on a mobile device.  If the application is to "broad" as in too many links on one page, the data may not all fit on the screen.  One way to mitigate this problem is to reduce functionality, to keep the application as simple as possible [5].
Ease of navigation is a particularly important principle, because of the reduced number of user inputs (for example, buttons from 0 to 9 instead of a mouse and keyboard).  Everything in an application should be no more than three clicks away.  If a program is too "deep", requiring many clicks, this will be a problem because it takes longer to navigate on a mobile device.  If the application is to "broad" as in too many links on one page, the data may not all fit on the screen.  One way to mitigate this problem is to reduce functionality, to keep the application as simple as possible [5].


!!!! Insert EC Factory here


The [http://www.javaworld.com/javaworld/jw-10-2005/jw-1003-mvc.html Model View Controller] pattern [1] fits the mobile environment well.  Models may be set up so that optimum data structures are used, as was discussed for the EC Factory pattern [7].  Effecient designs may be built into the controllers.  Views may be standardized for the application to handle the small screens.
The [http://www.javaworld.com/javaworld/jw-10-2005/jw-1003-mvc.html Model View Controller] pattern [1] fits the mobile environment well.  Models may be set up so that optimum data structures are used, as was discussed for the EC Factory pattern [7].  Efficient designs may be built into the controllers.  Views may be standardized for the application to handle the small screens.


The meeting pattern is especially useful in mobile environments.  One device or application serves as the meeting manager.  The meeting manager coordinates and tracks the other agents (programs or applications).  These agents communicate with the oversight of the meeting manager.  Agents may be located on different devices, even on computers with more resources.  This is especially well suited for the mobile environment because it is a good way to manage the communications and relatively small applicationsA further benefit of the meeting pattern is that mobile applications may be combined (somewhat in the fashion of parallel computing) to do more and provide more resources [6].
We will now discuss few important ones.<br>
 
 
Two major design patterns that have come up to help in mobile software and to address the above discussed issues in a mobile device are : Energy Conscious design pattern and Mobile agent design pattern
 
=== Energy Conscious Factory Design ===
According to the research published in ''[10]''
 
Power consumption has not been much of a concern to developers in the past, but this is important in the mobile environment.  Battery power on cell phones is limited[7]  To cope with this:
- Use registers instead of memory whenever possible (registers use less energy)
- Use structs instead of classes
- Use static instead of dynamic


The master slave pattern is simmilar to the meeting pattern.  Instead of a meeting manager and agents, there is a master that creates, uses, and destroys slave objects.  The master assigns the slaves tasks to complete.  Like agents in the meeting pattern, slaves may be located on different mobile devices, or even on computers that have more resources.  The master / slave pattern is very useful for performing actions in parallel on different mobile devices [6].
Some strategies and their experimental results are discussed in [10]:<br>
[[Image:ECFactory_Fig8.jpg| General Strategies]]


== Conclusion ==
'''''Factory Method pattern''''' is a pattern that returns an object from one of various possible classesWhich class is chosen to be an object generator  is  depended  on  data  provided to it.   
In conclusion, certain design patterns are especially useful in the mobile design environmentThese patterns help developers to produce applications quickly and applications which make efficient use of the limited resources in the mobile environment. Most design patterns can be of benefit to mobile applications, but certain patterns have features that are especially well suited.  The EC factory pattern was designed for the mobile environment to reduce energy use [7]. A few other patterns show much promise with mobile devices, including the meeting pattern, master / slave pattern, and service oriented architectures.
The Factory Method Pattern is a good pattern to build upon for the energy conscious pattern.<br>
Lets look at both versions.<br>
Class Diagram of sample Factory Method pattern:


== References ==
[[Image:ECFactory_Fig1.jpg|Class Diagram of sample Factory Method pattern ]]


1. http://www.javaworld.com/javaworld/jw-10-2005/jw-1003-mvc.html
Sequence Diagram (with Activations) of sample Factory Method pattern:  


2. http://patterns.littlespringsdesign.com/index.php/The_mobile_challenge
[[Image:ECFactory_Fig2.jpg|Sequence Diagram (with Activations) of sample Factory Method pattern ]]


3. http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2009/wiki2_17_va - Service Oriented Architecture


4. http://wiki.forum.nokia.com/index.php/Understading_Desing_Patterns - Understanding Design Patterns
'''''Modified  Factory  Method  pattern'''''
As regular Factory Method pattern was not designed for being energy concerned, so, it is slightly modified. Some of the critical tweaks are:
*Factory Method Pattern that mixes usage of struct and class in several manners.  
*Factory Method Pattern that uses a static factory method in the Factory struct.  
*Factory Method Pattern that applies generics principle which is parametered type.  
*Factory Method Pattern That Uses ConcreteProduct Class, ConcreteCreator Struct with Non-Static FactoryMethod().


5. http://dev.opera.com/articles/view/designing-and-developing-mobile-web-site/
The Modified Factory Method Pattern applies both struct and class recommendations.


6. Emerson F.A Lima, Patrícia D. L. Machado, Fláavio R. Sampaio, and Jorge C. A. Figueiredo. ACM SIGSOFT Software Engineering Notes.  Volume 29, issue 3 ISSN: 0163-5948 http://portal.acm.org/citation.cfm?id=986710.986726 Universidade Federal de Campina Grande, Paraíba, Brazil, May, 2004.
''The Factory Method Pattern that uses ConcreteProduct Class, ConcreteCreator Struct with Non-Static FactoryMethod():''


7. Kayun Chantarasathaporn, Chonawat Srisa-an. ACM International Conference Proceeding Series; Vol. 270 Proceedings of the 3rd international conference on Mobile technology, applications & systems SESSION: Mobile applications, article 29. ISBN:1-59593-519-3 http://portal.acm.org/citation.cfm?id=1292331.1292364 Bangkok, Thailand, 2006
[[Image:ECFactory_Fig3.jpg|Class Diagram of Factory Method pattern]]


In this case, we use VehicleChooser which is a ConcreteCreator, which is a struct, while Car, Plane and Ship (which are ConcreteProduct as  is a class).  Method ChooseVehicle(...) which is a FactoryMethod() is non-static.


[[Image:ECFactory_Fig1.jpg]]
''The Factory Method Pattern that uses ConcreteProduct Struct, ConcreteCreator Struct with Static FactoryMethod():''
[[Image:ECFactory_Fig2.jpg]]
[[Image:ECFactory_Fig5.jpg]]
[[Image:ECFactory_Fig6.jpg]]
[[Image:MCFigure3.jpg]]


[[Image:ECFactory_Fig4.jpg|Class Diagram of Factory Method pattern]]<br>
If we use the static method appropriately, CPU workload will be reduced.  This affects directly in lessening power consumption as a whole.


Ref: Energy Conscious Factory Method Design Pattern for Mobile Devices with C# and Intermediate Language,  
'''''Experimental Result:'''''
by Kayun Chantarasathaporn  and Chonawat Srisa-an, Ph.D. at  Faculty of Information Technology,  Rangsit University, Thailand.
<br>For various combination shown in figure, the tests were run, and the result obtained are shown in the graph below.
-----------------------------------
<br><br>''Characteristic of components in each combination:''
[[Image:ECFactory_Fig5.jpg|Characteristic of components in each combination ]]<br>


Two major design patterns that have come up to help in mobile softwares and to address the above discussed issues in a mobile device are :  
''CPU Usage Comparison:''


  1. Energy Conscious design pattern
[[Image:ECFactory_Fig6.jpg|CPU Usage Comparison ]]<br>
  2. Mobile agent design pattern
UPT is utilized processor time and TPT is total processor time


Energy Conscious Factory Design
<br><br>''Energy Usage Comparison:''
Power consumption has not been much of a concern to developers in the past, but this is important in the mobile environment.  Battery power on cell phones is limited. 


[[Image:ECFactory_Fig7.jpg|Energy Usage Comparison]]<br>


Energy Conscious design pattern:
It is observed that the optimum Energy Concerned Factory Method Pattern can be obtained from the combination of ConcreteProduct classes and the ConcreteCreator struct with the static FactoryMethod(). The ECFactory Method Pattern consumes less CPU time than the regular Factory Method  Pattern (around  11%), which is is better than the worst case around 80%.  The bigger the ConcreteProduct type size is, the more range between the best and the worst case in terms of energy consumption will be.  This pattern saves energy.


In oo design pattern, forever minimizing  power  consumption was never considered as they were used on normal computers. But nowadays due to high usage of smartphone and demand for better performance on the portable gadgets, energy usage is considered as an important issue. Due to business reasons, everyone wants their applications to come to market as soon as possible time to market, thus the usual practice of writing an optimized code in low level language has shifted towards high level object oriented language. This also helps to create much more complicated software, which can exploit the dual core mobile processors up in market these days. Thus there is an high demand for patterns in oops which can take care of energy optimization in the software.
===Service Oriented Architecture ===
However, using  Design  Patterns  directly  in  software  development for  power  conscious  systems  is  not  recommended  because  they were  not  originally  designed  for  such  environmentSo energy conscious design pattern is tweaked version of these patterns to suit for this need.
Service Oriented Architectures are well suited for the mobile environment [3]. Within this architecture, applications can make use of various services by sending messages to them via a protocolApplications may interact with services on operating systems and written in different languages, as long as the protocol is followedServices may be located on different mobile devicesThis protocol is a good fit, allowing applications to reach out to services on other mobile devices, even though they may be on very different devices.


Energy Concerned  Design  Patterns.    EC  Design  Patterns  are  based  on existing patterns in GOF book. 
''Example of a SOA:''
One general rule followed is should  avoid  using  memories  and  use  registers  since  the  latter  required less energy. 


Some strategies and their experimental results: Ref:: http://www.codeproject.com/csharp/structs_in_csharp.asp
[[Image:SOA_Example.jpg]]


What to work with? Choice 1 Choice 2 Recommendation
===Meeting pattern Example===
Type class struct struct
According to the research published in [6]. <br>
Field static dynamic static
The meeting pattern is especially useful in mobile environments.  One device or application serves as the meeting manager.  The meeting manager coordinates and tracks the other agents (programs or applications).  These agents communicate with the oversight of the meeting manager.  Agents may be located on different devices, even on computers with more resources.  This is especially well suited for the mobile environment because it is a good way to manage the communications and relatively small applications.  A further benefit of the meeting pattern is that mobile applications may be combined (somewhat in the fashion of parallel computing) to do more and provide more resources [6].
Method static dynamic static


Factory Method Pattern is a good pattern to build upon for energy conscious pattern.
''Meeting pattern Example:''
Factory Method pattern is a pattern that returns an object from one of various possible classes.  Which class is chosen to be an object generator  is  depended  on  data  provided  to  it. 


[[Image:MCFigure3.jpg]]


Figure 1. Class Diagram of sample Factory Method pattern  
The master slave pattern is similar to the meeting pattern. Instead of a meeting manager and agents, there is a master that creates, uses, and destroys slave objects.  The master assigns the slaves tasks to complete.  Like agents in the meeting pattern, slaves may be located on different mobile devices, or even on computers that have more resources. The master / slave pattern is very useful for performing actions in parallel on different mobile devices [6].
   
Figure 2. Sequence Diagram (with Activations) of sample Factory Method pattern


In Factory  Method  pattern, the  actor  need  not  know  which exact  class  will  create  the  object for it.   
== Conclusion ==
Actor  just  sends  the ChooseVehicle()  message, and specifies condition in "order" parameter, to object of VehicleChooser class, then instance of the appropriated class will be provided.
In conclusion, certain design patterns are especially useful in the mobile design environment. These patterns help developers to produce applications quickly and applications which make efficient use of the limited resources in the mobile environment. Most design patterns can be of benefit to mobile applications, but certain patterns have features that are especially well suited. The EC factory pattern was designed for the mobile environment to reduce energy use [7]A few other patterns show much promise with mobile devices, including the meeting pattern, master / slave pattern, and service oriented architectures.


As regular Factory Method pattern was not designed for being energy concerned, so, it is slightly modified. Some of the critical tweaks are:
== References ==


    *  Factory Method Pattern that mixes usage of struct and class in several manners.  
1. http://www.javaworld.com/javaworld/jw-10-2005/jw-1003-mvc.html - Model View Controller Architecture


    *  Factory  Method  Pattern  that  uses  static  factory  method  in Factory struct
2. http://patterns.littlespringsdesign.com/index.php/The_mobile_challenge - Challenges of the Mobile Environment


    *  Factory Method Pattern that applies generics principle which is parametered type
3. http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2009/wiki2_17_va - Service Oriented Architecture


4. http://wiki.forum.nokia.com/index.php/Understading_Desing_Patterns - Understanding Design Patterns


Modified  Factory  Method  pattern applies both struct  and class recommendations.
5. http://dev.opera.com/articles/view/designing-and-developing-mobile-web-site/ - Designing and Developing mobile web sites in the real world


Factory Method Pattern That Uses ConcreteProduct Class, ConcreteCreator Struct with Non-Static FactoryMethod()
6. Emerson F.A Lima, Patrícia D. L. Machado, Fláavio R. Sampaio, and Jorge C. A. Figueiredo. ACM SIGSOFT Software Engineering Notes. Volume 29, issue 3 ISSN: 0163-5948 http://portal.acm.org/citation.cfm?id=986710.986726 Universidade Federal de Campina Grande, Paraíba, Brazil, May, 2004.
Figure 3. Class Diagram of Factory Method pattern : 
In  this  case, we  use VehicleChooser  which  is  a  ConcreteCreator  as  struct  while  Car, Plane  and  Ship  which  are  ConcreteProduct  as  class.   Method ChooseVehicle(...) which is as FactoryMethod() is non-static.  


Factory Method Pattern That Uses ConcreteProduct Struct, ConcreteCreator Struct with Static FactoryMethod()
7. Kayun Chantarasathaporn, Chonawat Srisa-an. ACM International Conference Proceeding Series; Vol. 270 Proceedings of the 3rd international conference on Mobile technology, applications & systems SESSION: Mobile applications, article 29. ISBN:1-59593-519-3 http://portal.acm.org/citation.cfm?id=1292331.1292364 Bangkok, Thailand, 2006
Figure 4. Class Diagram of Factory Method pattern
If we use static method appropriately, CPU workload will be reduced. This affects directly in lessening power consumption as a whole.


Experimental Result:
8. WIM Workshop,Uppsala, 17.9.2004
For various combination shown in figure, the tests were run, and the result obtained are shown in the graph below.
Characteristic of components in each combination
Fig5


CPU Usage Comparison
9. Mobile Application Development, Sam Nasr , www.CleavelandDotNet.info
fig6


Energy Usage Comparison
10. Energy Conscious Factory Method Design Pattern for Mobile Devices with C# and Intermediate Language, by Kayun Chantarasathaporn  and Chonawat Srisa-an, Ph.D.  at  Faculty of Information Technology,  Rangsit University, Thailand.
fig 7


Here i8 is regular Factory Method pattern which turns out to be worst performer,  best  solution  from  our  test  in  both  regular  and  light  weight
11. http://www.codeproject.com/csharp/structs_in_csharp.asp
type    is    "i5"    Factory    Method    pattern    that    comprises    of ConcreteProduct    class,    ConcreteCreator    struct    with    static
FactoryMethod  inside.


Conclusion(this can be put in the main conclusion) :: It is observed that  Energy Concerned  Factory  Method  Pattern can be obtained from the combination    of    ConcreteProduct    classes    and ConcreteCreator    struct    with    static    FactoryMethod(). The ECFactory  Method  Pattern  consumes  less  CPU  time  than  regular Factory  Method  Pattern  around  11%  while  it  is  better  than  the worst case around 80%. The bigger the ConcreteProduct type size is, the more range between the best and the worst case in term of energy consumption will be.
12. http://www.umsl.edu/~subramaniana/concepts1.html

Latest revision as of 03:44, 23 November 2009

Design Pattern for Mobile Applications

The popularity and number of mobile applications rising quickly. Design patterns can help make the development process more efficient. While almost any design pattern could be used within mobile applications, certain patterns are well suited for the unique environment of mobile applications. This wiki explains the mobile application environment, then focuses on design patterns that work well within this new emerging environment.

The Mobile Application Environment

The emerging mobile application environment presents many unique opportunities and challenges for developers. It seems almost everyone has a cellphone, blackberry, or other small portable device. These devices are "getting smarter" in that many people are developing new applications for them. Cell phones are no longer only used to call people, they often have features like text messaging, cameras, video games, web browsers and more. There is much opportunity for developers to write new applications for mobile devices.

While opportunity abounds, there are also quite a few challenges. Mobile applications have fewer resources than are typically found in other development environments. The screen on mobile devices is typically smaller and there is usually not a keyboard and mouse (user inputs are reduced) [5]. CPU resources are generally lower than those found in the typical environment [7]. Power usage is also limited because batteries are usually the power source, so reducing power use by the application is an important goal [7]. Connections are typically expensive and are often prone to loss of signals [6].

Another problem is that there is a high demand for applications to be developed quickly [7]. The mobile environment is changing rapidly [2]. Some of the lower level programming languages were useful because they produced fast applications, but they took too long to develop with12. Now, with the increased demand for applications quickly, Object Oriented Programming (OOP) is used more often. While this causes a greater usage of resources, this is outweighed by the benefits of much quicker development cycle and the re-use of code. In particular, good solutions may be re-used in Object Oriented Programming (OOP) [7].

In the mobile environment, applications are often written on different operating systems [1] on different mobile systems. There is increased interaction between mobile systems, especially for cell phones. The Service Oriented Architecture design pattern is especially well suited for this situation. This is a fairly new field, and methods are currently being developed to aid developers.

Ways to Adapt Using Design Patterns

Several principles and patterns have been recognized and further developed in coding for mobile applications. Many of these methods are still undergoing change and experimentation. There are new methods being developed and others left behind. A design pattern can be defined as a repeatable solution to a common problem in software. It is a template for how to solve the problem, not actual code [7].

Ease of navigation is a particularly important principle, because of the reduced number of user inputs (for example, buttons from 0 to 9 instead of a mouse and keyboard). Everything in an application should be no more than three clicks away. If a program is too "deep", requiring many clicks, this will be a problem because it takes longer to navigate on a mobile device. If the application is to "broad" as in too many links on one page, the data may not all fit on the screen. One way to mitigate this problem is to reduce functionality, to keep the application as simple as possible [5].


The Model View Controller pattern [1] fits the mobile environment well. Models may be set up so that optimum data structures are used, as was discussed for the EC Factory pattern [7]. Efficient designs may be built into the controllers. Views may be standardized for the application to handle the small screens.

We will now discuss few important ones.


Two major design patterns that have come up to help in mobile software and to address the above discussed issues in a mobile device are : Energy Conscious design pattern and Mobile agent design pattern

Energy Conscious Factory Design

According to the research published in [10]

Power consumption has not been much of a concern to developers in the past, but this is important in the mobile environment. Battery power on cell phones is limited. [7] To cope with this: - Use registers instead of memory whenever possible (registers use less energy) - Use structs instead of classes - Use static instead of dynamic

Some strategies and their experimental results are discussed in [10]:
General Strategies

Factory Method pattern is a pattern that returns an object from one of various possible classes. Which class is chosen to be an object generator is depended on data provided to it. The Factory Method Pattern is a good pattern to build upon for the energy conscious pattern.
Lets look at both versions.
Class Diagram of sample Factory Method pattern:

Class Diagram of sample Factory Method pattern

Sequence Diagram (with Activations) of sample Factory Method pattern:

Sequence Diagram (with Activations) of sample Factory Method pattern


Modified Factory Method pattern As regular Factory Method pattern was not designed for being energy concerned, so, it is slightly modified. Some of the critical tweaks are:

  • Factory Method Pattern that mixes usage of struct and class in several manners.
  • Factory Method Pattern that uses a static factory method in the Factory struct.
  • Factory Method Pattern that applies generics principle which is parametered type.
  • Factory Method Pattern That Uses ConcreteProduct Class, ConcreteCreator Struct with Non-Static FactoryMethod().

The Modified Factory Method Pattern applies both struct and class recommendations.

The Factory Method Pattern that uses ConcreteProduct Class, ConcreteCreator Struct with Non-Static FactoryMethod():

Class Diagram of Factory Method pattern

In this case, we use VehicleChooser which is a ConcreteCreator, which is a struct, while Car, Plane and Ship (which are ConcreteProduct as is a class). Method ChooseVehicle(...) which is a FactoryMethod() is non-static.

The Factory Method Pattern that uses ConcreteProduct Struct, ConcreteCreator Struct with Static FactoryMethod():

Class Diagram of Factory Method pattern
If we use the static method appropriately, CPU workload will be reduced. This affects directly in lessening power consumption as a whole.

Experimental Result:
For various combination shown in figure, the tests were run, and the result obtained are shown in the graph below.

Characteristic of components in each combination: Characteristic of components in each combination

CPU Usage Comparison:

CPU Usage Comparison
UPT is utilized processor time and TPT is total processor time



Energy Usage Comparison:

Energy Usage Comparison

It is observed that the optimum Energy Concerned Factory Method Pattern can be obtained from the combination of ConcreteProduct classes and the ConcreteCreator struct with the static FactoryMethod(). The ECFactory Method Pattern consumes less CPU time than the regular Factory Method Pattern (around 11%), which is is better than the worst case around 80%. The bigger the ConcreteProduct type size is, the more range between the best and the worst case in terms of energy consumption will be. This pattern saves energy.

Service Oriented Architecture

Service Oriented Architectures are well suited for the mobile environment [3]. Within this architecture, applications can make use of various services by sending messages to them via a protocol. Applications may interact with services on operating systems and written in different languages, as long as the protocol is followed. Services may be located on different mobile devices. This protocol is a good fit, allowing applications to reach out to services on other mobile devices, even though they may be on very different devices.

Example of a SOA:

Meeting pattern Example

According to the research published in [6].
The meeting pattern is especially useful in mobile environments. One device or application serves as the meeting manager. The meeting manager coordinates and tracks the other agents (programs or applications). These agents communicate with the oversight of the meeting manager. Agents may be located on different devices, even on computers with more resources. This is especially well suited for the mobile environment because it is a good way to manage the communications and relatively small applications. A further benefit of the meeting pattern is that mobile applications may be combined (somewhat in the fashion of parallel computing) to do more and provide more resources [6].

Meeting pattern Example:

The master slave pattern is similar to the meeting pattern. Instead of a meeting manager and agents, there is a master that creates, uses, and destroys slave objects. The master assigns the slaves tasks to complete. Like agents in the meeting pattern, slaves may be located on different mobile devices, or even on computers that have more resources. The master / slave pattern is very useful for performing actions in parallel on different mobile devices [6].

Conclusion

In conclusion, certain design patterns are especially useful in the mobile design environment. These patterns help developers to produce applications quickly and applications which make efficient use of the limited resources in the mobile environment. Most design patterns can be of benefit to mobile applications, but certain patterns have features that are especially well suited. The EC factory pattern was designed for the mobile environment to reduce energy use [7]. A few other patterns show much promise with mobile devices, including the meeting pattern, master / slave pattern, and service oriented architectures.

References

1. http://www.javaworld.com/javaworld/jw-10-2005/jw-1003-mvc.html - Model View Controller Architecture

2. http://patterns.littlespringsdesign.com/index.php/The_mobile_challenge - Challenges of the Mobile Environment

3. http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2009/wiki2_17_va - Service Oriented Architecture

4. http://wiki.forum.nokia.com/index.php/Understading_Desing_Patterns - Understanding Design Patterns

5. http://dev.opera.com/articles/view/designing-and-developing-mobile-web-site/ - Designing and Developing mobile web sites in the real world

6. Emerson F.A Lima, Patrícia D. L. Machado, Fláavio R. Sampaio, and Jorge C. A. Figueiredo. ACM SIGSOFT Software Engineering Notes. Volume 29, issue 3 ISSN: 0163-5948 http://portal.acm.org/citation.cfm?id=986710.986726 Universidade Federal de Campina Grande, Paraíba, Brazil, May, 2004.

7. Kayun Chantarasathaporn, Chonawat Srisa-an. ACM International Conference Proceeding Series; Vol. 270 Proceedings of the 3rd international conference on Mobile technology, applications & systems SESSION: Mobile applications, article 29. ISBN:1-59593-519-3 http://portal.acm.org/citation.cfm?id=1292331.1292364 Bangkok, Thailand, 2006

8. WIM Workshop,Uppsala, 17.9.2004

9. Mobile Application Development, Sam Nasr , www.CleavelandDotNet.info

10. Energy Conscious Factory Method Design Pattern for Mobile Devices with C# and Intermediate Language, by Kayun Chantarasathaporn and Chonawat Srisa-an, Ph.D. at Faculty of Information Technology, Rangsit University, Thailand.

11. http://www.codeproject.com/csharp/structs_in_csharp.asp

12. http://www.umsl.edu/~subramaniana/concepts1.html