Sunday, April 15, 2012

Setting Up Modular Application Structure In Zend Framework.


I would be taking time out to write blog posts on Zend Framework and I hope to share as much as I can.

I started using Zend framework a couple of months back and it gets the job done nicely. The only pain I had when I picked up the framework was the relative steep learning curve (steep when compared to things like Kohana and Code Igniter which I have played with in the past). And the steep learning curve is not as a result of the framework being inherently difficult to use but due to the apparent paucity of up to date and useful resources and guides out there. Truth be told, the level of documentation has improved in recent times, but I feel a framework as matured as Zend deserves more.

My ensuing posts on Zend Framework won’t touch on the basics, i.e. setting up the framework; understanding MVC, how controllers work etc. No, the things I would write about would be a little bit above the basics. The ideal audience would be someone who has managed to set up a working copy of the framework but still find concepts like Auto loading, Resource plugins, View Helpers etc. little bit fuzzy.

Looking for setup articles? You would find a nice one on Nettut. The quick start guide on Zend.com is also a good read.

So that been said, let’s get to business.

The very first thing I would blog about is something I feel you should take into consideration right after you have mastered the set up process of Zend Framework and you are able to set up your project. And this is Directory structure your application would take.

Before we get into the details, let’s talk about what I mean by Directory Structure in the context of Zend Framework. It is simply the way your files are arranged in directories in the file system.

There are different ways you can have your files laid out on the file system for your application and the way you choose would go a long way in determining how your application is structured and managed.   The recommended structure (my personal recommendation and a couple of others) would be the Modular structure.

As you must probably know, if you use Zend_Tool  to create your project the default layout would look thus:

/app
    application/
        configs/
        controllers/
     ErrorController.php
              IndexController.php
        views/
             helpers/
             scripts/
                 error/
                      error.phtml
                 index/
                      index.phtml

        forms/
    docs/
    library/
    public/
        css/
        js/
        images/
        uploads/


In this set up, there is one general Controllers, Views, and Models folder where all the respective controllers, views and models files would be found. This set up is workable for a relatively small project, but when it comes to a much larger project the modular directory structure is most of the time advised.

And what is the Modular Directory Structure? It looks like this.


/app
    application/
        configs/
        modules/
             default/
                   controllers/
                   layouts/
                   views/
                   forms/
             admin/
                   controllers/
                   layouts/
                   views/
                   forms/
             profile/
                   controllers/
                   layouts/
                   views/
                   forms/
    search/
                   controllers/
                   layouts/
                   views/
                   forms/
    docs/
    library/
    public/
        css/
        js/
        images/
        uploads/


In this set up, your models, views, and controllers are grouped together into self-contained “boxes” based on the different functional areas of your Web application. So for example if you have a web application that has the following functionalities/sections Admin, profile, search. You can easily package the files (controllers, views, models and more) responsible for these sections into distinct boxes (actually directory). Having such helps in having an easily decoupled and manageable set up where new functionality or third party component can easily be plugged in into your application.


So how do we create a modular directory structure in Zend?

There are two ways. You can either do it with the Zend_Tool or create it manually. It is recommended you use the Zend_Tool. Creating it manually is just having to create the files and directories the Zend_Tool would have created for you automatically.

Note that to use the Zend_Tool you need to set it up. Find instructions on how to do this here

To create a modular application structure using Zend_Tool, issue the following command:


# mkdir /var/www/app
# cd /var/www/app
# zf create project .
Creating project at /var/www/app


Now change into the app directory and issue the following command, to create the admin module

zf create module admin

The following operations would be performed


Creating the following module and artifacts:
/var/www/app/application/modules/admin/controllers
/var/www/app/application/modules/admin/models
/var/www/app/application/modules/admin/views
/var/www/app/application/modules/admin/views/scripts
/var/www/app/application/modules/admin/views/helpers
/var/www/app/application/modules/admin/views/filters
Updating project profile '/var/www/app/.zfproject.xml'


Now as you can see you have your respective ‘controllers’, ‘models’, views/scripts, views/helpers, views/filters created. All you now need to do is to populate them with respective .php and .phtml files.

But we are not finished yet. Final thing to do in other to have our Zend Framework Module aware is to edit the application.ini file appropriately. To do so, just add the following lines to the end of the Production block.

resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"

resources.modules[] =


One last thing that you might want to do is to have autoloading functionality within your module. To do this, just create a Bootstrap.php file inside your module directory, in this case admin and have the following codes contained in it


class Admin_Bootstrap extends Zend_Application_Module_Bootstrap
{


public function _initload()
{

//your code goes here
}
}


And you have everything set up.

To access your admin module, navigate to the url: http://hostname/admin/

Thursday, April 12, 2012

Google: The Overrated Poster Child Of Innovative Tech Company?


Lately, I have found myself reviewing Google with a more objective point of view and becoming a little critical of the company’s success with innovation. Do not get me wrong, I still think Google is a great company where any developer would enjoy working; just that its awesome cool tech aura is fading and my rose tinted glasses are falling off.

Truth be told, I, like most developers out there had bought into the Google brand and I really believed in their “do no evil” mantra. Google could do no wrong; they were cool; all about innovation and committed to developers and cutting edge technology! While, other tech companies are the villains. (Note that most of the time other tech companies often refer to Microsoft).

We end up labeling these other companies as “the evil doers” who held back the frontiers of technology with crappy software just to protect their cash cows and their bottom line; the slow bureaucratic corporate mammoths and Google on the other hand was innocent of all similar antics and was the company that is fast as a whip and always pushing the envelope when it comes to technology.

But as the rose tinted glasses fell off, Google stopped being that much of the good guy and in all honesty, I presently consider their do no evil motto; patronizing. And for good reasons, various events have lead to this perception.

First on the list would be the Mocality scandal. Where a staff of Google allegedly hacked into the database of Mocality: a business directory based in Kenya, one of the biggest in Africa, and tried using the information sourced to sell Google’s services. You can read the full account here and note from the account, that the crime appears not to be a localized one, perpetuated only by folks in Google Kenya. Yes, this atrocity is far from being a companies culture but the actions of some miscreant but yet it left a sour taste especially if you read the full lowdown.


Next, you have Google’s unscrupulous practice of sabotaging startups that they do not like or feel threatened by. Read about the experiences of Yelp and the most recent that I came across is that of Hatchlings which you can read here, another victim to Google questionable behavior.

Further, to consolidate my growing skepticism, you have the recent “Search my world” thing which was just a blatant “do evil” move; a move that corrupts the fairness of search results in favor of Google's own products. View Focus on Users for more info on this.

Add all these up and you’d understand why I really feel Google’s “Do no Evil” is patronizing.

The final event that led to my present view of Google was the purchase of a Windows Phone; a Nokia Lumia. I got the phone and I was honestly impressed by the cool and refreshing feel of its operating system which I think is a massive and superb job well done on the part of Microsoft and before I knew it, the negative perception of Microsoft being one of the bad guys; a corporate mammoth that is slow to innovate, started to drop.

Interesting right? And typical of such situations, where you find yourself reevaluating your opinion about a bad guy, I ended up also reevaluating my opinion of the so called good guys; hence the revaluation of Google.

What even made this reevaluation of Google such an inevitable event is the almost close to knee jerking reaction I usually get from people whenever I talk about how cool the new Windows phone is. They usually reply; "hey its Microsoft not Google (or Apple), don’t expect us to take you seriously.” It would appear that in their minds, the impression of “If it’s not Google then it isn’t cool" is well imprinted and Google has the copyright on cool tech. Seems lot of people have been brainwashed?

It’s called Brand capital yes I know and yes Google has it; but no more; at least for me.

This rant seeks to put things in a bit of perspective by any chance and to take a more critical look at things as it concerns Google. Like I said earlier on, I still think Google is a great company in tech, just that it’s cool factor; the halo; the trendy aura that is often acclaimed to them, might just be a little bit overrated.

You see, the brand capital Google enjoys makes people to automatically think Google is cool and its cool majorly because people believe they do innovation right and create the perfect environment for it. They do cool stuff with tech. But once I began to take a more critical look at Google, I begin to doubt how really successful the company has been with innovation; homebrewed innovation, not just the ones they buy over and slaps the Google name on.

How well has Google done in coming up with an innovative service or product and become successful with it? What appears to be the situation seems very interesting.

I would hereby quickly list some of the cool and great stuff we know from Google, Just outline them in two different lists and see if they testify to how well Google does innovation.

First List

Google Maps
One of the flagship services of Google, an innovative product that has radically changed how we find our way. But Google Maps was never a home brewed innovation. It was an acquired product. The original creators of Google maps are Lars Rasmussen and Jens Rasmussen with Australians Noel Gordon and Stephen Ma. They were the ones that co-founded Where 2 Technologies, the mapping-related start-up in Sydney, Australia that made Mapping solutions that was later bought over by Google in October 2004 to become Google Maps.

Youtube
Another of Google's Popular product which has also revolutionized the way video is consumed. They say in a 2 month period we have more videos being uploaded to Youtube than if ABC, NBC and CBS air new contents 24/7 non-stop since 1948; truly disruptive right? Yet Youtube was another acquired technology. Youtube was created by 3 former PayPal employees Steve Chen, Chad Hurley and Jawed Karim back in February 2005. It was bought over by Google in 2006. It is worth noting that before the acquisition, Google had its own Video sharing service called Google Videos, which never really had much of a success.

Android
And yes we have Android. And yes it is also an acquired asset! Surprise surprise? The initial developers of the Mobile Operating system was Android Inc a company founded by Andy Rubin. It was later purchased by Google in 2005. (iOS and Mango on the other hand are OS that were built from ground up by the companies backing them).

Blogger
Blogger is another popular and successful Google service which also was not conceived within Google. Blogger was originally created by Evan Williams (who later went on to create twitter) and Meg Hourihan. Their company, Pyra labs was acquired by Google in 2003.

Google Analytics
Ha! Yes! all the lovers of Analytics; a truly innovative product, has changed the way we now do online marketing and SEO. It has to be Google to pull such a product off right? But bet most of you don’t know that Google Analytics was also an acquired asset. The original company was Urchin Software Corporation and it was purchased by Google in 2005.

Google AdWords
Even Google Adwords. The core idea that powers Google revenue stream was never invented at Google. The original inventor of the idea of ads based on Pay per click was Bill Gross. Read more on this here

Interesting?

But this is not all. Let us look at another set of cool tech things that came out of Google.

Second List

Orkut
Am sure a huge amount of people would be hearing this service for the first time. Orkut is Google’s own Social Networking site that nobody uses. And by the way, Orkut had been in existence way before Facebook came on the block. Here http://www.orkut.com
Orkut is proudly Google!

Google Wave
Yes Google wave was another Innovation that came out of Google. It was supposed to be the bold attempt at re-imaging how we communicate and collaborate online. Truly and really Innovative? But we all know where Google wave is today? In the deadpool

Google Buzz
Haha! Google Buzz. Another home brewed Google product meant to take Twitter head on. It was an innovative social networking and micro blogging tool that integrated nicely with your email. It was cool innit? But guess it was too cool to be a hit. You would find Google buzz in the deadpool too.

Knol
Yet another ambitious project by Google. A knol was supposed to represent a unit of Knowledge. Quite cool. If you wondering what the hell Knol is, it is not your fault. The whole Knol idea never took off.

Knol was supposed to be the Wikipedia killer. It was a project that aimed to include user-written articles on a range of topics just like Wikipedia only that it was supposed to be better. By the way, Knol is also in the deadpool.

Google Plus
To be fair, it is too early to comment on this one :)

So did you see any Trend here? Any peculiarities between the two sets of Google products? any characteristics that are shared amongst the two lists?

Truth is, it has not being a tale of absolute misses but looking at the the general observation the facts stacks up nicely for us to see a trend and more importantly bring some balance to the way we perceive the company.

I would desist from giving further comments on the lists. I would rather allow you draw up your own conclusions.

The only thought I would want to leave you with is this: maybe if you look at things a bit more critical, maybe you would find that Google might not be that much of an Outlier; the poster boy for innovative tech companies that we all seem to make them to be and maybe they are as evil as the rest of the bunch or perhaps the rest are as good...

UPDATE

We can add Google Glass to these lists...I guess we know where it would fall under!

Saturday, December 31, 2011

So what is Padly?

Padly is a side pet project- I have been spending some of my time on.



When building a web application that requires user login, it could be quite a boring and repetitive task to always have to code the user management functionality for application you work on, over and over again. Just as every developer fast realizes, getting this functionality handled by someone or something else is the way to go. Services like Facebook, Google and other federated login services/standards like openID have risen to handle these needs; and they work.

However, it is not every time you would want to build your application using Facebook or any other login service. But on the other hand, having to code the user management part of applications from scratch, is not something you may want to spend valuable time doing. This is where Padly could help.

Simply put, Padly is going to be a simple User Management System that handles the processes of user/account creation, password retrieval, profile management etc. It takes care of these tasks such that you can easily focus on developing the other parts of an application.

And it is easy to integrate. You just need to drop Padly into your application, make some configurations, your application then hooks into the User Management part, and that’s all. It is as simple as that.

Am almost done with it, in fact, I can say that 90% of it is already done. As such, it can be used as it stands, but some rough edges need to be polished and some features need to be tweaked.

Some of the things I’m looking at adding before final release include: adding of Upload Form Fields, Review Security, Client Side Verification for Radio, Checkbox and Text Area, etc.

The Project is going to be open and everybody can use and contribute to it. You can find the development branch here on github https://github.com/dadepo/Padly/tree/dev and instructions on how to integrate it into your application can be found here https://github.com/dadepo/Padly/blob/dev/README

Feel free to give it a spin, feedback any issue you have and do follow the project for updates.

Thursday, December 08, 2011

The Love for Data is The Beginning of Wisdom

I’m in Stockholm, and would be here till the end of the week. I would be busy for the next couple of days in a Strategic meeting . Asides many other results, one of the anticipated outcome of the meetings I would be part of is to build IT tools that would enable the organization I work for make sense out of the Data it has, spot patterns; opportunities and capitalize on it.

Data is interesting. It is interesting because it conceals stories. And the process of extracting the information from the Data, extracting the story being told by the Data itself is an exciting task; because you never know. You never know you have so much information to work it and make strategic decisions with. You never know you have a trend, a pattern, a window of opportunity, a threat until you pay attention to your Data. There are a lot of Information out there. We are swimming in an ocean of patterns and trends but you never know until you get down to Data analysis.

Thing is this: The love for Data is the beginning of wisdom, there is no way an organization can become intelligent without capturing and analysis the Internally and externally generated Data which affects its operations. This realization, although simple, is quite powerful and it made me reflect on realities back home in Nigeria; asking myself exactly how intelligently are the public sectors in the country being run?

Data is king. If you have ever read any of Malcom Gladwells books, you would appreciate the power of analyzing Data and connecting the dots. From the Outlier to Blink, he usually, often or frequently delivers an exceptional essay which provides an excellent insight into the captured Data, showing the trends and telling the hidden stories.

So in Nigeria, I ask ; can I easily access and analyze trends in the National Budgets of the last 10 years? Can I see how spending has changed and the effect of this in the development of the country? What about common occurrence like Accidents? Where is the Data on this? And how can I utilize these Data to see what region, sex, age group are prone to this issue. What about Data being generated around health issues in the country? How much of it is even been captured? What’s the correlation between a particular tribe and the occurrence of twins? You never know, what interesting patterns lie hidden within Data until you pay attention.

It is a stupid institution that won’t bother about Data because, really the tools to capture and analyze data abound! So there is no excuse to not make Data Analysis a strategy and practice: Per country, per State or per organization.

One of the areas Information Technology can easily be leveraged on for Development in the country is via capitalizing on Data. And the fact is that using Information Technology for development need not be fancy in every case nor does it need to be the implementation of cutting edge and cool and geeky stuffs. Simply applying existing data visualization tools in the country to capture and analyze trends and patterns and making this information available, might just be one effective step towards the attainment of intelligent institutions and applying IT for development.

So my candid Recommendations:

Capture Data
Simply described as Record Keeping. Make use of easily accessible tools like our good old Microsoft excel to capture the data.

Make it Open.
Don’t just stop at capturing these Data. Make it available in format that can easily be accessed, make the Data public, build API’s, release Data in CVS. Make it available! One of the Data sources I would be working with is http://data.un.org/. Data made open for everybody to access. This is the way to go.

Analyze/Visualize it
The power is in the visualization and analyzes. Make use of available tools to do this. Like I said, you do not need to build any fancy tools; there are existing IT tools that can be leveraged on.

One example is Tableau, a cool data visualizing tool which by the way, would be one of the tools I would be working with these coming couple of days. Capitalize on these tools and just use it.

Finally, I know all these won’t go anywhere without a culture that supports paying attention to Data, but really it would really be inept of us to continue in such direction as a country or institution.

Monday, December 27, 2010

Is Google Making Me Lazy?


Is Google turning me into a Lazy programmer? Something tells me no, that it is just a tool that aid my productivity. There is no way having at your finger tips, the access to almost the entire index of the web, make you lazy; it is a good reference I can fall back on when my memory fails me. Right?

Right. It should not be a problem only that I just feel as if my memory now fails me more often than before. Not that I am getting amnesic, I sure do remember stuffs, the general concept of things, the procedures, but when it comes to stacking in my memory the exact syntax or steps of an algorithm or a procedure...well I sort of outsourced that functionality off to Google.

I don’t even make the effort of remembering the idiosyncrasies of frameworks or tools I use, since I know with a Google Search, the docs come up.

Is this in itself a bad thing? In fact has my productivity not increased with the help of Google? And wasn’t Albert Einstein credited to have said he does not know the numerical value of the speed of light; that why should he stack up such information in his head, when he can quickly retrieve it from an encyclopaedia.

So is the question warranted? Is Google making me Lazy? I would have to say no. My heavy reliance on Google's Index of the web, I would say aids my productivity. There are tons of things I have been able to achieve and achieve in a shorter amount of time because I was able to make a Google search.

So I guess my fears are just unwarranted.Right? But something tells me “what if I get thrown into a civilization where I have no access to the internet”? Well again, I think that thought, that very thought itself is unwarranted. :)

So why then did i write this post? I guess am not convinced :(

Saturday, December 25, 2010

Looking for The Next Cool Thing After Twitter


I have stopped tweeting. Ok not totally stopped, but the frequency in which I tweet now has drastically reduced. And it is not as if I would be deleting my twitter account soon to never tweet again, it is just that...well...Twitter to me doesn’t feel cool anymore...like it used to be in those early days.

This is my present sentiment or Phase, regarding twitter.

And to appreciate my sentiment you might need to understand where I am coming from and how I got started with twitter and the prior phases I have gone through.

I got on twitter 2007. Sure, i was an early adopter. Back then the user base of twitter was still in the thousands. It was around 400,000 to 500,000. Compared to the whopping 145 Million plus user base the service now enjoys. It was Tim Akinbo that brought twitter to my attention and the reason why I got on board was simple: It was just the latest geeky thing to play around with. It was fun and elitist in a sort of way.

So here i am now, some couple of years down the line, and twitter is feeling noisy. But before getting to this present state, I have actually gone through other phases in time past, using twitter. Let me outline:

The WOW Phase. The Really Really WOW Phase:
In the early days of twitter, If you are following someone and they tweet, you get their tweet sent, free of charge, to your phone as SMS. Yeah right. That was back then. A lot of folks do not know this, but that made twitter really really cool for me. I remembered vividly, taking a bike from INTECU to Fajuyi Hall and my phone was abuzz with SMS all from tweets I was getting from following CNN, BBC etc on twitter. I felt connected to the world. But then twitter started growing; growing to that level where sending free SMS was not sustainable. So they pull the plugged on it and all of a sudden it became...well a little less useful. Because having to browse to twitter.com every time to read my tweets felt unnatural. So I eased off twitter.

The Third Party Application Phase
Then I discovered the Firefox pluggin: Twitterfox, which has since been renamed to Echofon. It marked a twitter revival for me.  Like I said in my previous post, the very nature of twitter makes accessing it via the website a little awkward and unnatural. Consuming twitter requires a non intrusive user notification paradigm. and that was exactly what the Firefox Plugin provided.

With this firefox plugin, my usage of twitter soared. But then again, this particular phase had it own limitations: which was the fact that I had to be seated by my PC, connected to the internet before I can use Twitter.

Mobile Internet Phase
Then I got on mobile internet and my usage of twitter just sky rocketed; It just went off the roof. Having twitter right there in my palms made it possible for me to consume and create tweets just anywhere and at anytime. I was abreast of all happening in the tech community. I had access to useful tips and pointers to resources thanks to the community of twitter following I had. It was cool, really cool. But it did not last forever. I was pushed unto the next phase:

The Crowded and Noisy Phase
Then all of a sudden twitter became noisy and crowded. I think this was due to the fact that a lot of regular Joe started getting bored with facebook and unfortunately twitter was getting a lot of mention in mainstream media, so the natural thing started happening: folks started flocking to twitter.

The other thing that happened, i think, that led to twitter growing to become crowded was that “Who to  Follow” feature twitter incorporated. It was just like the “Suggested friends” feature in facebook. All of a sudden a lot of folks I know started following me...and I started following back...and before I knew it, my timeline...well... became unrecognizable!

I hardly get to catch @takinbo or @dfasoro’s tweets. Or @budzeg tips on security. I follow @jeresig and @gvanrossum but I can’t remember the last time I caught their tweets.

Why? Because all of these useful tweets are now getting swamped and buried in the slew of RT’s RETWEETS and mentions of folks who have taken the liberty to use my timeline as the medium for their conversation; conversations I have no iota of interest in.

O! how I missed the useful tips and pointers to useful resources on mobile dev and UI design @barbietunnie shares. How I missed Guy kawasaki funny and sometimes out rightly useless tweets via @alltop not to talk about @jason. @mashable used to be one of my favorite pointers to interesting articles and resources, but not anymore.

So right now am in that phase where I spend little time on twitter because it just feels too noisy. I have been thinking of things I could do:

  1. Create another account which would solely be used to consume tweets I consider useful. But then again, I don’t really like the idea of managing multiple accounts so I really don’t see myself going down that lane.
  2. Start unfollowing people.
  3. Create a list of followers whose tweets am interested in.
  4. Or just go find/create the next cool and geeky thing to play with.
One of my girlfriends commented on the fact that I am no longer active on tweeter: my response? I told her it stopped being fun. That it feels as if every tom dick and harry is now on twitter, and that it has stopped being cool and geeky, like it used to be.

Or well, maybe it’s because I’ve just got geek coy? Whatever!  Twitter just feels *arrrghh* right now, and i am just on the look out for that next cool thing to play with, together with my techhead pals.

My Presentation at WordCamp Nigeria 2010

I am pro wordpress but not the kind to consider the usage of any other content management system as sacrilegious. If I have to handle a project in say Joomla, Plone or Drupal I would gladly dig into it. In fact I have had some couple of dint with Drupal and I think it is very powerful, but all the same wordpress still remain my personal favourite.

And the reason is not farfetched. I personal find wordpress fun to work with, it is intuitive, it is simple yet powerful and it is easy to tweak, bend over, and extend.

And these were the exact things I talked about during my presentation at the first ever wordcamp that held in Lagos a couple of months back. Apart from introducing wordpress and the concept of wordpress being more than a blogging system, my talk also did a great deal in communicating the fact that wordpress is quite powerful, yet simple and a joy to work with.

Here is my presentation

View more presentations from Aderemi Dadepo.


And if you are considering digging into wordpress, there is no other resource I can recommend than the official wordpress codex. It is an exhaustive resource, and a very handy reference. And it is just as simple to use: but then again am not surprised: it is wordpress!