stacanovist Posted October 11, 2012 Share Posted October 11, 2012 Hi everybody Just signed up at this site. I dont really know if this is the right section, but anyway. I would like to ask to people that consider themselves as php experts what they think of a quite little application I have written I wrote and that is considered (by the one that commissioned it) not at a very good level or not as good as an expert would write it. Is this the right place to post it? I dont know if it is possible to attacch zip files. And if there will be someone interested in looking at it. Thanks. Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted October 11, 2012 Share Posted October 11, 2012 I've moved you to the "website critiques" section. Do you not have this project running anywhere? Very few people will open and run an anonymous zip file full of code. What parts are they saying isn't very good? Maybe post a representative sample in the thread here Quote Link to comment Share on other sites More sharing options...
premiso Posted October 11, 2012 Share Posted October 11, 2012 Oh is this a venting thread? I am very angry at the fact that the internet exists. There is no good reason why and the fact that it exists proves that evolution is a failure and that your God does not exist. Please expand! Quote Link to comment Share on other sites More sharing options...
stacanovist Posted October 11, 2012 Author Share Posted October 11, 2012 I've moved you to the "website critiques" section. Do you not have this project running anywhere? Very few people will open and run an anonymous zip file full of code. What parts are they saying isn't very good? Maybe post a representative sample in the thread here Ok, I understand. People that would look at my code are doing me a favor. So ask them to also download the code maybe is too much. So I will do my best to explain what this is about and put some code sample. Preface: Someone asked me to make a test. He was looking for a real php-expert. I have many years experience in PHP. And I think I am good enough. The test was about doing a simple PHP-application, with js/css/html, for managing employers. When I sent the zip package with the code, after he reviewed it, he said that its not enough. He needs someone very experienced. Yes, Im very angry, even because he didnt tell me what part of the code makes him understand/think Im not enough experienced. Yes, I need to learn more, like everybody. But it would be a good idea to know what part of the code is not considered qualitative. I tried to make something similar to Codeigniter. The head folder contains the subfodlers: app, database, logs, www In app there are the folders models and views. And also the folder config, containing environment.php and bootstrap.php. In app/models there are the classes: Admin.php (to handle admin login, the admin needs to manage employees), Database.php (which basically has the method connect and the mysql->close in the destructor.), the class Employee itself, with all the crud methods, and Logger which contains the static method for writing to log folder. In app/views there are the index.php for showing html for the login. The home.php for listing the employees. Then there is employee_form which is used both for creating and editing an employee. Depending on the params sent to this view, it will customize messages for whether its about editing or creating. The last view is layout. In the middle it includes the view file itself (index, home or employee_form). The head folder "database" only contains the schema for the DB. Im using indexes for all the fields that can be in where or order by. In www there are index (which includes the view index), home (which includes the view home), newemploye and editemploye. Yes, there is no controller folder. There is the risk for repeating code. But I was not really sure about having an htaccess to redirect every request to a single index, which in turn should select the controller. But I think its quite ok. Then a page like www/home.php looks something like this: <?php require_once($_SERVER['DOCUMENT_ROOT'] . '/config/config.php'); require_once(APP_PATH . '/config/bootstrap.php'); $employee = new Employee($db); $all_employees = $employee->get_all(); $view_name = 'home'; require_once(APP_PATH . '/views/layout.php'); In bootstrap the db-instance is created. COnnection to it is made. And reference to db is passssed to the Employee-class (so it can use mysql). Im using things that are considered important to make good and secure code. Im omitting the closing php-tag. Im escaping all the strings with real_escape_string(Im using mysqli). Im printing all the GET/POST and data from DB using htmlspecialchars. Im logging errors to the customized Logger class. Im using an home made FlashMessages for printing messages on the page. Guys, I hope you read until here. Im aware that you never end learning new things. But I have alot of experience. This guy says Im not experienced enough. I want to know why. I want to improve my coding skills. What do you think? Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 11, 2012 Share Posted October 11, 2012 Did you send someone code without having a contract or getting paid? If the answer is yes, then yes, you are not experienced enough. Now you have learned a lesson. Quote Link to comment Share on other sites More sharing options...
stacanovist Posted October 11, 2012 Author Share Posted October 11, 2012 Did you send someone code without having a contract or getting paid? If the answer is yes, then yes, you are not experienced enough. Now you have learned a lesson. Ok. Lets pretend they were not interested in getting work done for free. Whats bad with the code i wrote, from the description I wrote? Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted October 11, 2012 Share Posted October 11, 2012 Yeah he probably is using your "test" right now without paying you. Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 11, 2012 Share Posted October 11, 2012 Did you ask the person to whom you gave the code for free what he meant? If he can't define what is wrong, send the invoice. Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted October 11, 2012 Share Posted October 11, 2012 He could send all the invoices he wants, he agreed to do work for free with no expectation of pay and no mention of how that work would be used once it was judged. Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 11, 2012 Share Posted October 11, 2012 I'm assuming he had an agreement to get paid. If he actually agreed to do it for free, then yes. But I take "Lets pretend they were not interested in getting work done for free." to mean the OP thinks he was going to get paid. Honestly, me personally, I'm not even going to bother looking at any code from someone who didn't get a contract and sent work without payment. *shrug* Maybe other people have more free time, but I am going to assume there's going to be issues with the code if there's that big an issue with the developer's business. Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted October 11, 2012 Share Posted October 11, 2012 Preface: Someone asked me to make a test. [...] The test was about doing a simple PHP-application, with js/css/html, for managing employers.Looks like our scammer said "make me this small little thing that nobody will use, and if it's good enough, I'll give you the real work." Quote Link to comment Share on other sites More sharing options...
stacanovist Posted October 12, 2012 Author Share Posted October 12, 2012 Let me ask you guys: Would you never do an application for a company that is going to recruit a programmer? I mean, doing an app to show them you level as programmer? If they say: "we are looking for a php-developer, but we require him to do a test so we can understand if he has a good level as programmer". You would say: no?? or you would say: "Yes but you have to pay me for that"? Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 12, 2012 Share Posted October 12, 2012 A test is not programming an entire app. Interview test questions will cover small issues and usually be things like fixing a bug, not writing an entire app. Quote Link to comment Share on other sites More sharing options...
KevinM1 Posted October 12, 2012 Share Posted October 12, 2012 Exactly. Legit companies don't ask for a full app to be written. Instead, they look at the applicant's portfolio, and then ask a variety of small (but perhaps complex) programming questions to be solved then and there, like the infamous FizzBuzz question. If you don't have a portfolio you can show potential clients/employers, you need to make one. Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted October 12, 2012 Share Posted October 12, 2012 I've been asked to do a number of applications for potential employers. One of them was small enough and easy enough that I actually did it, but it took me half an hour while I was watching TV. They never called me back. I ended up walking right past their office a few months later and noticed their logo on the door, so I went inside and asked to speak to the guy who asked for the assignment. He refused to come out of his office. They probably used my stupid address book in production for a while, complete with the subtle security holes I put into it on purpose. You did free work for someone, you generated an entire application you could have sold for hundreds of dollars. At the very least you could have attached a copyright notice to the code, though they probably don't care. Wait a couple weeks, see if they're using something on their sites or client sites that looks like what you wrote. If it does, send them a take-down notice. If possible, send it to the client instead of the people who scammed you. Quote Link to comment Share on other sites More sharing options...
gizmola Posted October 13, 2012 Share Posted October 13, 2012 Hi Stacanovist, It is possible that you got scammed into making an application for someone. We really don't have enough information, but I will say that it is highly unusual for someone to ask for a complete application of any level of complexity. Some of the other replies touched upon better ways to market yourself. It sounds like you have some solid capabilities and built a decent functional application. However, some of the techniques you used, not to mention the overall approach you took is antiquated and could be interpreted as amateurish. For example, you seem to have utilized a good deal of the mvc pattern, but yet don't have a front controller or controllers at all, even though you seem to understand the idea and purpose of controllers. A bigger question I would have is -- considering the options, why wouldn't you use a micro framework? Why write a bunch of code that reinvents wheels? Was this part of the exercise? If it was, that would probably be a sign that this is a scam artist or someone you'd want to steer clear of. I can't think of a single justifiable reason anyone would ask a prospective employee to implement a small application, and require them to write it from scratch. The good news is, that you are clearly experienced enough to create useful applications, and you should be able to find a market for your talent and ability. I'd recommend that you channel your energy into gaining experience with the state of the art php frameworks. Not only will this challenge you, and move you towards the state of the art, it will give you valuable skills that are in demand, and will help you avoid getting sucked into situations like the one you just experienced. Last but not least, if you want to post a zip of the code I'd be glad to take a look at it for you and give you an evaluation. Good luck, and don't let this get you down. Lots of people have made a mistake like this at one time or another. I'm sure you'll learn from it, and you'll be that much more savvy the next time. Quote Link to comment Share on other sites More sharing options...
stacanovist Posted October 15, 2012 Author Share Posted October 15, 2012 Hi Gizmola Well, they didnt specify how I should solve it. Only told me it should be easy to read the code and that I should use best practices for php, js, html and css. After I read all the answers I understand that there is big risk he is using my code for free. This was the first and last time I will make this kind of tests. Anyway, regarding how experienced I am with coding it would still be very helpful if somebody with a lot of experience would give a look at the code and give some feedback. I would really appreciate it. I will attach the rar file and hope you (and maybe somebody else) can give me some feedback. Thanks a lot. Quote Link to comment Share on other sites More sharing options...
stacanovist Posted October 15, 2012 Author Share Posted October 15, 2012 PS: I didnt use a framework because I was unsure how they would consider that. I tought it could be a good idea to make my own tiny framework just to show them I know the basic concept of building an mvc. Not using a real single controller instead of a controller for each requested page is probably not a great idea. Im aware of it. PS2: it seems the file has not been attached?? Seems wont accept rar files. I uploaded the file here: http://memnotic.com/phpfreaks.rar Quote Link to comment Share on other sites More sharing options...
Adam Posted October 16, 2012 Share Posted October 16, 2012 @KevinM1 @Jessica You've never been asked to complete a test to demonstrate your abilities? Of course people ask for that kind of thing. I've done several. For my current job I was given two hours to implement an MVC-esque application, with bonus points for unit tests. Since I started I also re-took their new test as a benchmark (of amazing of course), which was more about creating a RESTful API, again with bonus points for things like unit tests. Done several others in the past, one which had a three day delivery time. People ask for demonstrations of ability. Anybody can say "oh yeah I did that", or have their own little niche of ability in which they're comfortable, but asked to create something to spec and they could nose dive. It's about testing someone. @stacanovist What were the exact instructions given to you? Do you have an email or anything you can post? Also I think Gizmola gave you some decent advice, though to add, after looking at your code it is a little amateur if I'm honest. Looking at the login.php file in www/form_process for example, where does $admin come from? You're using POST vars before checking they're set. In process_employee.php there's just this huge jumble of code, that looks more complex than just doing it with vanilla PHP. Again you're also using some mystery var $db. There doesn't seem to be any kind of library or recognisable structure, things are just stuck all over the place. Your Database class is in the models dir. The models use super globals like $_SESSION and seem bizarelly indented. Your bootstrap file just instantiates everything, what happens when there's hundreds of classes? It's completely unscalable. Even some of the simple things like a DOCTYPE in the layout view are missing, and you've included jQuery just for one simple selector. A lot of this can be forgiven if you were under a time constraint, but you haven't mentioned one as of yet. I'm not ruling out this was a genuine test and they just weren't happy, but not giving you any kind of feedback is pretty disrespectful. Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 16, 2012 Share Posted October 16, 2012 @KevinM1 @Jessica You've never been asked to complete a test to demonstrate your abilities? Of course people ask for that kind of thing. I've done several. For my current job I was given two hours to implement an MVC-esque application, with bonus points for unit tests. Since I started I also re-took their new test as a benchmark (of amazing of course), which was more about creating a RESTful API, again with bonus points for things like unit tests. Done several others in the past, one which had a three day delivery time. A test is not programming an entire app. Interview test questions will cover small issues and usually be things like fixing a bug, not writing an entire app. I think it was pretty clear what I meant... Of course I've been asked to do programming tests. I've taken programming tests from those staffing agencies, and I've done plenty of interviews which included actual technical questions. As a consultant, I've been given problematic code and asked to fix it, or to outline how I would design an application. But I've never been asked to create an entire application and hand it over, and if I were I'd reject that "opportunity". Giving someone an assignment, sending them off to do it, then accepting the work days or weeks later and not providing adequate feedback is not a test. It's a scam or someone who doesn't know what they're looking for. What you're describing at your current job, I can only assume happened in person, or at least in a structured setting. OP is describing something entirely different. What OP is describing is someone asking my husband to come diagnose their broken air conditioning, fix it with his own parts, use his tools he's paid for himself, and then if they think he did a good job they might hire him a few weeks later to install a new furnace. If he came home and said that was his job interview, you bet I would be sending an invoice to those people. Programming is the same thing, it's just harder to see tangible value because there are no parts that cost money upfront, it's all your time and skill. I could be wrong. My husband did actually once offer to do work for someone and said "pay me what you think it's worth when I'm done." We made a bet, I thought she'd pay him under $50. He got $90 for it. He still came out just barely even. Too often I seen people undervalue their own time, effort, and education, and let other people undervalue them as well. Spending any more than an hour on a "test" for the prospect of maybe getting a job isn't worth it to me, and in the setting the OP is describing, it's letting someone take advantage of you. Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted October 16, 2012 Share Posted October 16, 2012 As a consultant, I've been given problematic code and asked to fix it, or to outline how I would design an application. But I've never been asked to create an entire application and hand it over, and if I were I'd reject that "opportunity". I'm with Jess on this one. It shows very little respect, to me, to assign someone a task which takes longer than 20 minutes as a pre-interview task. Maybe after 2-3 interviews, when they've already spent a couple hours (and hopefully the cost of lunch or dinner) on me, then I'd perform some kind of test, but this example of "spend a lot of time doing work before we'll even deign to interview you" ticks me off. I've had companies do that before, and I decline every time. Right out of college I tried to work for Robert Half, an IT staffing firm. After an entire business day of taking poorly written, out-of-date multiple choice tests they told me that they'd "be in touch" and I never heard from them again. I don't do schoolwork for people anymore, I graduated from college on purpose. Quote Link to comment Share on other sites More sharing options...
stacanovist Posted October 16, 2012 Author Share Posted October 16, 2012 @stacanovist CUT Hi Adam Thanks you for taking time to look at the code. The instructions were to make a "easy-readable-code" php-app. So I thought using a framework was not a good choise (this is how I interpreted it). Of course I had used it if I could. Yes, I oonly now realized about using POST vars in login.php without checking them. Strange, I normally have some code like: $username = isset($_POST['username']) ? $_POST['username'] : ''; I missed that. Yes. I think in other scripts I have that kind of control. Anyway, the posted vars are at least escaped when querying DB. About process_employee. Well, I dislike code repetition. There are maybe better ways to do it. But I dont like to fetch the same variables twice in two different scripts. As they do more or less the same thing. A part from either creating or editing the user. The $db variable (and the same applies for $admin variable) are created in bootstrap.php. All the script-controllers (or all the pages should I say) includes boortstrap at the top of the script. As $db is always used by all the scripts (you always need to query DB in these scripts) I thought it was the best place to put it in. $admin is also created in bootstrap. All the pages (almost all of them) need to verify that the admin has logged in. So even for $admin I thought the best place was in bootstrap. Where would you have put Database class? In some core dir? I didnt understand what you meant about indentation in models. I think it is allright. The bootstrap instantiates everything because more or less al the pages use all the instances. I included jquery, even if I only used it once, just to show the style I use when having javascript/jquery. There was not much more to use it for. But I prefered to use it anyway to make them underrstand I know how to use it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.