Monday, July 23, 2012

What is design pattern ? What are good design patter in Android ?

What is design pattern?  What is design pattern in Android?

In software engineering, a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. A design pattern is not a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations. So patterns are formalized best practices that you must implement yourself in your application

Patterns originated as an architectural concept by Christopher Alexander (1977/79).
Design patterns can speed up the development process by providing tested, proven development paradigms
Effective software design requires considering issues that may not become visible until later in the implementation.
In order to achieve flexibility, design patterns usually introduce additional levels of indirection, which in some cases may complicate the resulting designs and hurt application performance.
By definition, a pattern must be programmed anew into each application that uses it
Designs patterns are composed of several sections of particular interest are the Structure, Participants, and Collaboration sections.
There is no single, standard format for documenting design patterns.  Rather, a variety of different formats have been used by different companies.

It contains the following sections:
ü  Pattern Name and Classification: A descriptive and unique name that helps in identifying and referring to the pattern.
ü  Intent: A description of the goal behind the pattern and the reason for using it.
ü  Also Known As: Other names for the pattern.
ü  Motivation (Forces): A scenario consisting of a problem and a context in which this pattern can be used.
ü  Applicability: Situations in which this pattern is usable; the context for the pattern.
ü  Structure: A graphical representation of the pattern. Class diagrams and Interaction diagrams may be used for this purpose.
ü  Participants: A listing of the classes and objects used in the pattern and their roles in the design.
ü  Collaboration: A description of how classes and objects used in the pattern interact with each other.
ü  Consequences: A description of the results, side effects, and trade offs caused by using the pattern.
ü  Implementation: A description of an implementation of the pattern; the solution part of the pattern.
ü  Sample Code: An illustration of how the pattern can be used in a programming language.
ü  Known Uses: Examples of real usages of the pattern.
ü  Related Patterns: Other patterns that have some relationship with the pattern; discussion of the differences between the pattern and similar patterns.

 inappropriate use of patterns may unnecessarily increase complexity
The design patterns may just be a sign of some missing features of a given programming language

Design Pattern For Android
DP describe a general solution to a common problem
Natural by-product of software design lifecycle
So, DPFA, is the best practice to represents UI, widgets in such a way that, more and more items to be placed in common and small area.

Some design pattern in Android

  1. MVC
  1. 2 Spring
  1. RoboGuice 
  1. 4 Singleton

Spring –
Spring for Android is an extension of the Spring Framework that aims to simplify the development of native Android applications.
Spring for Android supports usage of the Spring Framework in a Android environment
Ø  A Rest Client for Android
Ø  Auth support for accessing secure APIs
Ø  Support for Spring Social 1.0.2.RELEASE, and Spring Security 3.1.0.RELEASE through the Spring for Android Auth module, which includes a SQLite datastore for persisting OAuth API connections.
Ø  Updated RestTemplate support, now at the level of Spring Framework 3.1.0.RELEASE.
Ø  Added support for Basic Authentication.
Ø  Added AssetResource for accessing static resources stored in the assets directory of an Android project.
Ø  Removed automatic loading of GsonHttpMessageConverter due to incompatibilities with preinstalled versions of Gson on some devices.
Ø  Improved gzip support in RestTemplate.
Ø  Now defaulting to standard J2SE facilities (HttpURLConnection) in Gingerbread and newer, as recommended by Google.
Ø  Disabled connection reuse on Eclair and older versions when using HttpURLConnection, because of a defect in connection pooling on those versions of Android.
Ø  Added several additional bug fixes and improvements.
Ø  A Device resolver abstraction for server-side detection of mobile devices
Ø  Site preference management that allows the user to indicate if he or she prefers a "normal" or "mobile" experience
Ø  A site switcher capable of switching the user to the most appropriate site, either mobile or normal, based on his or her device and optionally indicated site preference

Spring Mobile is an extension to Spring MVC that aims to simplify the development of mobile web applications

Best Practice –

  1. 1Important to ensure apps with UI design pattern and guide lines  
  2. 2Single Threading Model

Link Building