Archive for November, 2011

Android Development some Facts

Posted on November 10th, 2011 by admin  |  No Comments »

I am taking this information from Google’s Android site just for easy browsing and record keeping of myself and other peoples, All information is owned by Google and I mean NO violation of their copyright, While I cannot guarantee the accuracy of information provided here, for more detailed information please visit http://developer.android.com/guide

  • Android components are Application, Application framework, libraries, Core libraries and Linux kernal.
  • Android was built on linux kernal v2.6 which has four basic functioning security management, process management, network stack and driver module.
  • Android application are built on Java language and runs on Dalvik Virtual Machine those files are .dex extension
  • Application are packaged as .apk extension Each of them runs as process and creates instance of Davik virtual machine.
  • With its multi-user capability Android allows unique users id to assign with each running application that runs on its own container limited by the permission of that user.
  • Due to every Android apps are running in separate instance of VM they are isolated and security risk and failure are minimized.
  • Application can access resource outside its scope by sharing same user id with other process or requesting to Resource manager library.
  • Application components are divide into four types 1 Activity -Front end  functionality it provides using user interaction, 2Services – Backend operations to support activity, 3 Content provide – access data from other applications, 4Broadcast receiver – receive triggers system wide
  • Android system are multi entry point
  • Android applications are invoked as services or activity by Intent Call from other components/application, some applications for example content provider cannot be started by this method but you will have to go through contentResolver

Migrating to cakephp 2.0 tips and changes

Posted on November 2nd, 2011 by admin  |  No Comments »

Cakephp has released 2.0 version with lot of changes in API, and nice features. The highly sought ORM capability is also added in this version, while I was migrating from my old 1.3.x app to cake 2.0 faced lots of dificulties and thought to share with you peoples. This is a quick note, more verbose information can be found at

http://book.cakephp.org/2.0/en/appendices/2-0-migration-guide.html

1. Rename all controllers pizza_controller.php becomes PizzaController.php same as classs name

2. Rename All components for example my_mail.php becomes MyMailComponent.php

# Rename all helpers in view directory to match for example country.php becomes CountryHelper.php.

3. Move AppController (former app_controller) from app/ directory to app/Controller/ directory.

Also capitalize all model class for example user.php becomes User.php

4. In views

  • Use $this->Html->link() instead of $html->link()
  • Use $this->Form-> instead of $form->
  • Use $this->Session-> instead of $session->
  • Use $this->Paginator-> intead of $paginator ->
  • For JavaScript inclusion use $this->Html->script(“”) instead of $javascript->link()

NOTE: Cakephp 2.0 has some built in folders under Views like Scanffold, Elements, Emails etc similar to those if want to capitalize view folders for example dont make users => Users, then make sure that Controllers are same name $name = “Users” otherwise they will not work in unix boxes where folder path app/Views/users/ are treated differently than app/Views/Users.

# In Helpers

If you have custom helpers under “Views/Helpers” directory that loads other helpers for example $Html or $Form there will be small change in construct process for example $html = new HtmlHelper() becomes $html = new HtmlHelper($this->_View)

5. In Controller

  • Using model find method $this->Student->find(array(“id” => 123)) will not work use find(“first”, array(“id” => 123)).
  • If you have tried to modify $this->data like $this->data["xyz"] = “abc” inside controller method this will throw error [Indirect modification of overloaded property ... has no effect] instead you need to do $this->request->data["xyz"] = “abc”.
  • In controllers for example AppController Helper inclusion for view should be carefully stated for example var $helpers = array(‘ ‘Js’,  ’Html’,  ’Form) etc javascript Helper is now called Js helper and html is Html.’

# Authentication

  • Cake 1.3.x was automatically checking if user has correctly entered username/password inside your login() method of users_controller but in cake 2 we need to manually call $this->Auth->login() this returns boolean value based on successful login or failure.

# Saving forms

When submitting forms from views to controllers Model->save() method check for !empty($this->request->data) instead of !empty($this->data)

File uploads

  • When submitting multipart-form-data for attaching files from views to controllers, the file data cannot be accessed via $this->data variable rather they are stored into $this->params["data"]

6. Others

  • All component files should be extended by Component Class instead of Object

Some precautions

  1. Do not overwrite routes.php file under your app/Config folder.

Tips

You can use Dreamweaver’s excellent find and replace tool, it works for a single file or recursively on a entire directory. or Netbeans also has Edit -> Replace in project