Jump to content

KevinM1

Moderators
  • Posts

    5,222
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by KevinM1

  1. You could (in no particular order): 1. Pass the base/child object as a parameter to the email object's mail function 2. Have the base class implement an email interface if the base class and all of its children need to adhere to that kind of contract 3. Make your email class static, allowing the base/child object to send the email without the need of an email object 4. Use dependency injection to compose one of them into the other - have the email object contain the base/child object (eh, not the way I'd go) or do the opposite, with the base/child object containing the email object (better of the two choices) 5. Do what was suggested above There could be more viable options. Without seeing code, it's hard to say what would be the most elegant solution.
  2. OOP is the dominant paradigm for non-trivial projects. This doesn't mean that the same results couldn't be achieved using procedural, or even purely functional code. The 'point' of OOP is to create systems that are flexible, modular, easy to update, edit, and maintain. Objects, when created and used well, have a natural tendency to do this. Well-formed objects are innately encapsulated, which protects them from being inadvertently changed by something outside of them. It also allows them to be used in a multitude of contexts. This combination therefore allows many objects to be pluggable, giving any system a great deal of flexibility. All that said, OOP isn't objectively better than any other style of programming. It's not necessary to learn if you're a hobbyist. There's a lot of overhead in getting a system to fit OOP, and that overhead may not be appropriate for a project that won't grow substantially. Unless you plan to develop professionally, there's no need to learn OOP.
  3. Separation of concerns. Structure (your HTML) should be separate from its styling (your CSS) and from its behavior (your JavaScript). It makes your life easier as your sites are layered by their composite functionality. You can then change/update one part of it (say, your CSS) with minimal-to-no impact on the rest. A lot of website development is about project structure. The better organized you are and the more self-discipline you have, chances are your projects will be easier to create, modify, maintain, and manage. @cssfreakie: You have a spelling error on your blog (at least, in terms of American spelling). 'Practise' should be 'practice'.
  4. Hmm. I'm not entirely sure why your border isn't showing up. When I look at it in Firebug, your footer takes the entire height of the content-container, but I'm not sure what's causing it. I'm not seeing any explicit heights anywhere, and you don't have enough content to stretch it to that size. You should ask in our CSS subforum. A couple of small things - don't indent your paragraphs. If you have a blank line between them, then don't worry about indents. Also, don't underline anything you don't mean to be a link. Your links have a white underline, so anything else with a white underline looks clickable.
  5. This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=328047.0
  6. KevinM1

    Is this ok?

    No no no. Make a CSS class for that. That's why classes exist - one rule set for any number of elements. And display:inline-block isn't a real rule, AFAIK. Divs are naturally block elements. If you want them to be placed side-by-side, float them left.
  7. I'd remove the left-hand menu altogether. You have one repeated link there ('Contact Us'), and you really don't have enough to warrant a second menu. 'Boarding', 'Lessons', and 'Parties' should be options in a drop down list coming from 'Services'. Shouldn't the Oxford Farm logo be somewhere at the top/in the header? That's the client's branding, which is very important, and shouldn't be thrown in as an afterthought below the fold. Incorporate it. And, again, you need to do something with the footer. Plain text with a hit counter (which, again, unless your client specifically told you to add, should be removed) doesn't cut it. Add your logo, or your company's font. If the client has any Facebook, Twitter, or RSS, add links (with appropriate logos/buttons) there. And give the footer a top border to separate it from the body of the site. The appearance of structure is important. Don't use separate fonts for the news/menu column and the main column. Sans-serif is easier on the eyes, so stick with that. Small thing: You don't need a 'Pictures of the Farm' heading on the index page. It's obvious what the images are, and the heading simply uses up space. You have a good base to work with, but you really need to step back and look at it from a distance. Economy of space, making everything count, should be your concern now that the basic layout and design is done.
  8. Ya I think it is necessary to read Gand of Four cause I am zandstra's book and the author also has mentioned about it and said some good works. But for now I will continue with zandstra's as it is long 600 page book and after all it meets my requirements as it is in PHP. After going through it I will go for GoF... BTW Nightslyr, Do you have anymore books to suggest as I am hungry to learn it right from the core to the top..... http://www.amazon.com/Patterns-Enterprise-Application-Architecture-Martin/dp/0321127420/ref=sr_1_7?s=books&ie=UTF8&qid=1300793706&sr=1-7 http://www.amazon.com/Domain-Driven-Design-Complexity-Software-DOMAIN-DRIVEN/dp/B002VLOJOY/ref=sr_1_24?s=books&ie=UTF8&qid=1300793862&sr=1-24 http://www.amazon.com/Growing-Object-Oriented-Software-Guided-Tests/dp/0321503627/ref=sr_1_3?s=books&ie=UTF8&qid=1300793887&sr=1-3 http://www.amazon.com/Code-Complete-Practical-Handbook-Construction/dp/0735619670/ref=sr_1_1?s=books&ie=UTF8&qid=1300793981&sr=1-1
  9. No, I bought it, read through it, re-read it multiple times, then bought the Gang of Four book to deepen my understanding and see more patterns. The Zandstra book is, IMO, the perfect place to start if you're mainly familiar with PHP and want to learn OOP. But it's certainly not a complete picture of OOP. The Gang of Four book is essential, IMO, as it explains all of the basic patterns, including those that Zandstra doesn't touch. For those that he does examine, the GoF book often shows some interesting variations. This only illustrates the basic premise behind patterns - they're abstract solutions, and need to be modified to fit a particular problem. That said, I don't think the GoF book is ideal as the first step. The Zandstra book shines in that regard, as everything is in PHP. It's comfortable. Blogs and tutorials are good for supplemental learning, but only if they come from a good source. There are more bad tutorials than good, and the only way to separate the good from the crap is to have a basic understanding of the subject. That's why I don't recommend those sources initially. It's too easy to get suckered by bad material. For the free OOP stuff, I tend to stick with C# and Java developers since those languages are focused on OOP, and only the big names (Scott Guthrie, Scott Hanselman, Phil Haack, Jon Galloway, Martin Fowler (even though he's not necessarily a Java guy), etc.). That way, I know I'm getting the right information. Finally, I consider myself barely competent with OOP. I know and understand the basics, but I have so much more to learn - enterprise patterns, domain-driven design, test-driven development, etc. While they're not all topics that are necessarily exclusive to OOP, there's still a ton to learn.
  10. http://www.google.com/search?q=dependency+injection&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
  11. I started with the book I linked to above. Then, I got the Gang of Four's book, which is essentially the foundational book on the subject. Since then, I've been reading the blogs, tutorials, and watching screencasts of other developers.
  12. You're not going to be able to master OOP by simply reading 100 pages from a book. The bulk of OOP is about design, which pros often argue about as there is hardly ever a 'correct' answer to design questions. Instead, design is largely an exercise in balancing many different criteria, which depend on the individual project. As far as a book goes, the best one for PHP-specific OOP is Matt Zandstra's PHP 5: Objects, Patterns, and Practice (http://www.amazon.com/Objects-Patterns-Practice-Experts-Source/dp/143022925X/ref=sr_1_1?ie=UTF8&qid=1300723561&sr=8-1). With that said, it's certainly not the only valuable resource on the subject, and surely cannot be considered complete. This is a broad subject, one with different approaches and styles.
  13. Actually, I found where the 'good' response is being set. It's another die() function call (die(json_encode(array('msg' => $msg)))). Something else to test - have you checked whether or not $ajax is being set properly? That it's actually being set to true? Or, can you try actually returning both the error messages and 'good' message rather than relying on die()? Nothing really jumps out as me as a reason why the div isn't fading in. The only thing I can think of right now is that you're not getting a response back, so the function is failing. Either the Ajax isn't working because $ajax isn't actually true, so your entire function is being skipped over on the server side, or your PHP isn't returning the messages in a way jQuery/Ajax expects to receive them, and you're getting a silent error which is stopping you on the client side.
  14. Ah, I meant from your PHP - where is your "Everything is A-OK" return value? Also, are you getting any JS errors when you uncomment the lines you commented out? I'm just wondering if 'r' is actually being sent back from the PHP when things are working. Like I said, I can see where the error condition messages are being encoded and sent back, but not the success condition message.
  15. What are you supposed to be returning if the function works properly? I see that you return json_encoded error messages when an error/exception occurs, but am having some difficulty seeing what you're sending back when things are actually right.
  16. For HTML/CSS, you don't need any special software aside from a standards compliant web browser (Firefox, Chrome, Opera - take your pick). When testing your markup and styles, it's as simple as: Start browser -> Click 'File' -> Click 'Open File...' -> Open your HTML file Remember separation of concerns? Your PHP development should have no impact on your HTML/CSS development. Making a script work correctly is an entirely different process than making its output look pretty. HTML/CSS should be seen as putting a skin on top of the actual working bits.
  17. When your page first loads, the GET value is set. When you attempt to send POST data, that's a new request, even if it's done asynchronously. At that point, $_GET may be empty, since nothing was set for it in the new request. Try modifying your form's action to re-send the query string (e.g., $_SERVER['SCRIPT_FILENAME'] . "?url=" . $_GET['url']) so the second stage of the process can have it as well. Not 100% sure on this, but it seems likely.
  18. That's because, like I said before, you have two versions of the same form. By the time PHP gets the values sent to it via POST, only the second set of values are there. Why? Because if you have form fields with the same name, PHP will only recognize the last/most recent field with that name. Identifiers must be unique, and PHP assumes they will be.
  19. They're not searching one another. In the case of no matches, both searches display the same message rather than one displaying nothing and the other displaying a message. I do have a question - why are you blindly copying the guts of both forms? Give them unique identifiers - form names, input names, etc. If you have two <input name="field"> elements, PHP will only 'see' the second one. Names, like ids, are supposed to be unique.
  20. Because at the end of both queries, you have: if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query<br><br>"; }
  21. You're trying to use an HTML5 attribute, which may or may not be fully supported in modern browsers, and may or may not be implemented the same way in the browsers which may support it. Try sticking with HTML 4.
  22. Why are you using global at all? Pass everything through your function's argument list: function DisplayGrid($gridx, $gridy, $x, $y, $users_map) { // do stuff } For more on why global is bad, read through the following thread: http://www.phpfreaks.com/forums/index.php?topic=327433.0
  23. Ken Wowwwwwwwww, my book really sucks. I got this stupid reference manual at Borders and it says variables starting with underscores are invalid. WTF When in doubt, consult the actual language manual: http://www.php.net/manual/en/langref.php And having an underscore as the leading character of a variable is used a lot in OOP. They're often used to denote private fields in an effort to increase readability.
  24. This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=327717.0
  25. The functions/methods defined in a class are only invoked when an object explicitly invokes them. They don't automatically run in sequence when you call for a new object.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.