Friday, March 27, 2009

my first cakephp interview

It was around 5:30 pm on regular friday, i moved out of office and went to a big building, i was in front of two experts for an interview, they were fat not only physically but mentally as well.

Questionnaire started with some of the questions from core php like what all functions do you use in your development can you just list them ,tell us what was that you did special in php.

after that the cakephp questions were asked. It ranged from various perspective in cakephp, i am just putting them down as i remember, order of questions would be changed as i do not remember them.
hope you get some idea from this and this helps you in your next interview

Interviewer : what is cakephp
Me : Cakephp is a rapid development framework for PHP that provides an extensible architecture for developing, maintaining, and deploying applications. it uses commonly known design patterns like MVC,ORM within the convention over configuration paradigm, It also reduces development costs and helps developers write less code.

Interviewer : why cakephp, and why not any other framework.
Me : it has been for years in the market with strong support in the form of communities and online documentation, it supports php 4/5 , sometimes it becomes mandatory to support php4 because of client's limitation in support php5, there cakephp helps.

3. can you remember what is the directory structure when you download cakephp
* app/
o config/
o controllers/
o models/
o plugins/
o tmp/
o vendors/
o views/
o webroot/
* cake/
o config/
o docs/
o libs/
* vendors/

Interviewer : what is the first file that gets loaded when you run a application using cakephp., Me : can you change that file.
bootstrap.php , yes it can be changed , either through index.php , or through htaccess

Interviewer : using cakephp, what all are drawbacks.
Me : The learning curve, and it loads full application before it starts your task. Its not recommended for small projects because of its resource heavy structure.

Interviewer : what is model,view,controller.
Me : Model–view–controller (MVC) is an architectural pattern used in software engineering. Successful use of the pattern isolates business logic from user interface considerations, resulting in an application where it is easier to modify either the visual appearance of the application or the underlying business rules without affecting the other. In MVC, the model represents the information (the data) of the application; the view corresponds to elements of the user interface such as text, checkbox items, and so forth; and the controller manages the communication of data and the business rules used to manipulate the data to and from the model.

Interviewer : what is the naming convention in cakephp
Me : table names are plural and lowercased,model names are singular and CamelCased: ModelName, model filenames are singular and underscored: model_name.php, controller names are plural and CamelCased with *Controller* appended: ControllerNamesController, controller filenames are plural and underscored with *controller* appended: controller_names_controller.php, associations should use the ModelName, and the order should match the order of the foreignKeys: var $belongsTo = ‘User’; , foreign keys should always be: table_name_in_singular_form_id: user_id (foreign key) → users (table) , many-to-many join tables should be named: alphabetically_first_table_plural_alphabetically_second_table_plural: tags_users , columns in many-to-many join tables should be named like other foreign keys: tag_id and user_id , columns named “created” and “modified” will automatically be populated correctly

Interviewer : what is a component,helper and why are they used, is there other way we can do same thing, what is better.
Me: A component is an independent piece of code written for specific task that can be used by calling in controllers (example : email component), helper is used for helping cakephp in rendering the data to be shown to user with views, these only adds to modularity in code otherwise same coding can be implemented in conrollers.

Interviewer : how do you proceed when you have to use cakephp for any application.
Me : take the framework either from cake site or if you have changed according to your needs start from there. proceed with basic software engg. concepts as requirement gathering etc

Interviewer : what is the first function that gets loaded from a controller.
Me : index

Interviewer : what is habtm.
Me : has and belongs to many is a kind of associations that can be defined in models for retrieving associated data across different entities.

Interviewer : how can we use ajax in cakephp.
Me : by calling ajax helper and then using it in controller for rendering.

Interviewer : if you have to validate a registration module for a user, what all can be possible ways , which one is the best.
Me : can be done on submission in controller, or using javascript/ajax while user is still filling the data. second option is better.

Interviewer : can you list some database related functions in cakephp.
find, findAll , findAllBy , findBy , findNeighbours , query

Interviewer : how canInterviewer : how can you include a javascript menu throughout the site. give steps.
Me : By adding the javascript files in webroot and call them in default views if needed everywhere or just in the related veiws.

Interviewer : how can you make urls search engine friendly while using cakephp
Me : it is an automatic task that is done by cakephp.

Interviewer : do you prefer to use cakephp,yes then why ? no then why not.
Me : Its a wide question and the answer would depend upon the kind of application for which it is to be decided, if its a basic cms i would prefer to have joomla. but yes cakephp is prefered for large systems, “simplicity” is the most important factor.
you include a javascript menu throughout the site. give steps.


these were some of the questions, let me know there answers if you know any/all.
enjoy baking. I am in process of sharing with you guys a new website focusing towards my experiences including all interviews in my 10 years career.