Results 1 to 7 of 7

Thread: If you were sent this as part of a job application what would you do?

  1. #1

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336

    If you were sent this as part of a job application what would you do?

    Hey guys, I need some real help here. I am applying for a job as an OOP PHP programmer. I know how to code in OOP with PHP, but what they are asking for is confusing and I am not sure what I should send to them.

    Here is what they are asking for:

    "...if you would send me the following: Separation of business logic from display logic. (don't mix classes & HTML) Object oriented code. more than just using $this->function()"


    What would you put together and how would you put it together? I am drawing a blank here. I already sent them a full password protected admin area that was all based on OOP design, but apparently that wasn't complicated enough or something.



    Any input is appreciated! Thanks!
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: If you were sent this as part of a job application what would you do?

    I think all they mean is you should have separate sets of classes for the logic and the presentation, which is fair enough.

    An example of this would be to use a class-based template system for your HTML output. You can therefore instantiate template classes and call output methods as required, that leaves you free to mess with the markup independently of the business logic.

  3. #3
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: If you were sent this as part of a job application what would you do?

    It means that applications should be separated into at least to distinct parts (I like to call them layers).

    The Processing Layer - this should receive any input, make database connections, execute queries. In short (it is responsible for the retrieval and manipulation of data from one format to another). This layer should never produce any output or display specific data (such as HTML code).

    The Output Layer - this receives the processed data from the processing layer and displays it. At the simplest level in OOP, your output layer would be a class called Template with a single method called display(), which when called with the path of a PHP file, includes it like a template an produces output. The output layer deals solely with the display of data; it should never be changed or manipulated here and anything like database interaction, file manipulation and processing of form input is a big no no.

    Why do this? Because it makes refactoring your application easier. So when your boss approaches you and says (our MSSql license is running out, therefore we are moving to MySql), you won't poo your pants and run a mile. Ideally you would have exercised even more fore sight and created a database abstraction layer in you processing layer, making the change as simple as changing a few lines of code.

    It also means redesigning the look of a site is a lot easier, you won't have to dig around inside files littered with PHP code. Sure, the templates can, and in many cases need to contain code, however, this should be limited to conditionals and loops. PHP even provides alternate syntax for this:
    PHP Code:
    <?php if (condition): ?>
      <html>
    <?php elseif (condition): ?>
      <html>
    <?php endif; ?>
    The same goes for, while, for and foreach loops. Have a peek at the article about PHP 5 OOP for a few tips and design patterns in OOP, even if you just use PHP 4, it is still helpful to read.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  4. #4

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336

    Re: If you were sent this as part of a job application what would you do?

    Thanks for the input guys. Would know whre I could get a very simple example of how that would work exactly? I've looked at some things like Smarty and PHP support ticket, but those programs are so large and have so many files it just makes my head spin.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  5. #5
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: If you were sent this as part of a job application what would you do?

    You're applying for a job. You don't want to take someone else's example/program. You need to show them what you're capable of. If you're not capable of this, then it may not be the position for you.

    All you're doing is making seperate classes to do seperate things.

    I hope I'm not being rude but if you're applying for a job and after it's been explained to you what they are looking for and you still want example code, you may want to learn more on PHP.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  6. #6

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336

    Re: If you were sent this as part of a job application what would you do?

    No kidding Kas...what do you think i'm trying to do? That's why I am asking for a simple example, so I can learn from it.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  7. #7
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: If you were sent this as part of a job application what would you do?

    Quote Originally Posted by Arc
    No kidding Kas...what do you think i'm trying to do? That's why I am asking for a simple example, so I can learn from it.
    Kasracer is right. If you are still unsure what to do, then maybe you should consider another position. I am hoping that the explanation I gave in post number 3 is sufficient for an OOP programmer to knock a small sample app up with.

    I am sure the guy doesn't want a huge application like smarty. He simply wants you to demonstrate that you have a sound understanding of the design methodolgies behind OOP.

    If it were I, I would write about 500 words citing applications such as smarty, accompanied with a small demo app, showing how a simple templating system may be constructed and how it acheives the goals of separating business logic from display logic.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width