Wednesday, October 5, 2011

My Android AsyncTask implementation vis-a-vis Command Pattern...

Note: If someone wants to learn about the Asynctask internal, please have a look at this document.

As i was developing a sample Android App to showcase the Android AsyncTask, i found it very much similar to the Command design pattern. i would like to share this with you...


Let me first state about the Command design pattern. The purpose of the command pattern is to associate a command object with its receiver where the receiver knows what to do when this command is called... We have an interface called command, from where we deduce different concrete commend classes... The client creates the concrete command objects passing the information of the receiver for that command... And when the invoker ( which is generally a framework object) calls the execute method of the command, the concrete command actually executes it with the help of the Receiver’s functionalities...


The class diagram of the command pattern is as follows:

And the sequence diagram is as follows:




Now let me decipher my App to show how it implements the command pattern... the class diagram of this application looks like the following:



As it becomes clear from the code, the client (which is the Activity class) creates a concrete command class, the Callback interface through the concept of Anonymous inner class (see the code c = new CallBack() {.....}; it then stores this command in the invoker (the MyAsyncTask class) by passing the reference to the invoker (see the line of code aTask = new MyAsyncTask(c)).. . the invoker (the MyAsyncTask class here) stores a reference to this command object... then if something interesting happens, the invoker calls the functionality from the callback interface (the command)... the functionality of the callback interface have been implemented in the Client (the Activity class)...

hence i think that my implementation of the Asynctask is very similar to the Command design pattern implementation...

Hope this discussion helps the android learners...

Here is my AsyncTask implementation.. Here you can find the callback interface... And you can find the main Activity class here.

And here goes the apk of the sample app... You can clone the whole source from here...

Monday, July 11, 2011

SMS Scheduler App for Android with Source Code...

I have developed a simple SMSScheduler App for android devices. This has been open sourced and the source code can be cloned from github.

This can be found at Google Play. This app will let the users schedule his/her sms, view them and cancel them if he/she wants it to. Hope you enjoy it. And i am pretty sure that it will come handy for those people who want to learn how to develop an android app.

Here is a screenshot of this app.



I have also developed another rudimentary SMS Scheduler App with the help of Buzzbox. Here is the link to download it... hope you enjoy it...
please find here the full source code.. it is pretty simple with BuzzBox.

Here are the screenshots of the App





hope this discussion becomes useful for Android learners...

Friday, July 8, 2011

My good days with Ubuntu...

i have now almost completely switched over from Windows to Ubuntu... when the google page first comes out in the chrome browser, or the test page prints Ubuntu, the feeling is of sheer joy... i am loving it... no fear of spyware, no fear of virus... no headache for installing spybot or spyware doctor... no worry about how to install malware bytes... hopefully my days with Ubuntu will pass by peacefully...

Monday, June 27, 2011

CS != Programming

While teaching the Computer Science students in an engineering college, i had this strange feelings that CS != Programming... The theoretical aspects of computer science which the students usually learn in the engineering college will never help them become proficient programmers... many people would shun this point of view... some times back i interacted with one of my colleagues who insisted that programming is only  small part of computer science world... however i feel that it is the most important part of the computer science... with the wake of Test Driven Development and other Agile processes, when the long quality process is loosing its significance, its only good efficient programming that remains the most significant factor of the software project development... i believe that one can get a CS degree without even  having a computer... but one cannot develop and design software that runs without getting his hands dirty with debugger, breakpoint, issues with memory leaks and so on...

Wednesday, June 8, 2011

Patent and Copyright - from my perspective

today during our breakfast my wife asked me a question about the difference between patent and copyright... while answering her queries, i reminded her how the way we create patents of software these days has become an hindrance to innovation... if one is not convinced see this or this... think about the situation had all the basic scientific theories (e.g. newton’s law of motion and gravity, Archimedes's principles, Einstein's theory of relativity, the knowledge of periodic table and in-numerous chemical reactions or the basic ideas of zero and decimals) being patented and copyrighted, where would our scientific exploration have gone so far? from another angle had the Almighty patented air, water, earth, fire or so many of His living creatures on whom we do scientific experimentation, where would our mankind and civilization stand today?or even had we have to pay royalty to the community of cows for their milk or to the community of plants and vegetables for their own products, where would we go for the money?

Thursday, April 7, 2011

Eye opener for educators...

“Intellect has been cultured with the result that hundreds of sciences have been discovered, and their effect has been that the few have made slaves of the many – that is all the good that has been done. Artificial wants have been created; and every poor man, whether he has money or not, desires to have those wants satisfied, and when he cannot, he struggles, and dies in the struggle” - Swami Vivekananda.

Is the mad rush towards consumerism of the modern day a product of such faulty education system?

Thursday, March 24, 2011

Unit Converter App with Source Code

Note : Good news for avid learners... Here is my free training on How to Design and Develop a simple Unit Converter App.....  Enroll and enjoy... Happy learning...

http://som-itsolutions.teachable.com/

For the past few days i was in a dilemma about ethics, openness and honesty... the reason behind this was should i show the whole world the source code of my Android apps? as i don’t have a job, i thought of earning some money for my family by offering training to the people who want to learn how to develop Android apps... but then i thought that as i am using an open source platform to develop the Android App, i should show the source code to the others so that if someone really wants to learn, he can learn it from this source code... being a believer in Swami Vivekananda, i thought not to do business just by selling knowledge...if i face difficulty in feeding my family in the future, there is definitely another way to earn money, but not by selling the knowledge which i got because of the Almighty.

You can download the app from Google Play and here goes the source code of an Unit Converter App which i started developing to help some of my students...



if somebody can learn from it, i will be the happiest person...

Here is a screenshot of this app...



i have used Strategy Pattern to develop this App.

Hope this helps others.