Skip to main content

Home/ PHP Programming/ Group items tagged coding

Rss Feed Group items tagged

Sarah HL

ongoing · Test-Driven Heresy - 0 views

  • As a profession, we do a lot more software maintenance than we do greenfield development.
  • the deep-TDD rules: ¶ Never write code until you have a failing test. Never write any more code than is necessary to un-fail the test.
  • we do way more maintenance than initial development. And in my experience, the first-cut release of any nontrivial software is pretty well crap.
  • ...38 more annotations...
  • But to do that well, you absolutely must have enough test coverage that you just aren’t afraid to rip your code’s guts out
  • I always end up sketching in a few classes and then tearing them up and re-sketching, and after a few iterations I’m starting to have a feeling for X and Y.
  • once you’re into maintenance mode, there are really no excuses. Because you really know what all your X’s and Y’s are
  • I freely admit that this is not really truly TDD
  • Writing the tests points out all the mistakes you might make in signatures, prerequisites, etc. If the tests are too hard to make then you know that your API will be too hard to use, you're doing it completely wrong, and may as well pause for a rethink.
  • While the approach you advocate makes sense, it does require professionalism, not just from the developer but from management too.
  • the person left to maintain the code isn't the person who wrote it, leaving the maintainer with an unholy mess to untangle. Getting unit tests into such code is a monumental task.
  • he failure to address how unit tests can be introduced to an existing non unit-test codebase. (i.e. go from non-TDD to TDD)
  • I feel the TDD community only wants to focus on greenfield projects and has ignored maintenance/legacy issues. Which is strange when as you say code spends most of it's time in maintenance
  • The thing is that as long as the project is small you really don't see the benefits of TDD. I've done a couple of small projects and never had to go back to them ever again
  • Never use mocks unless you are mocking an interface that will almost never change
  • You are writing the client code (in the form of a test) so you are thinking how the worker code will be used. What is its public interface and what do you want it to do when it's called
  • From: Tathagata Chakraborty (Jun 24 2009, at 07:31)TDD is useful in another situation - in a commercial setting and when detailed specification documents have already been created by say a technical expert/architect. In this case you don't have to do a lot of designing while coding, so you can start off with the test cases.
  • writing the tests *first* is that it helps keep your code focused on exactly what it's meant to do, and no more
  • When work on production code begins, most of the code should fall into the categories of things that are not to be tested.
  • In theory, TDD is a great idea. The problem with TDD can be expressed in one word: money.
  • One approach to the unknown X and Y problem that I've been using recently has been to pretend that class X has been written already, and then write code that uses this pretend X object/API. I usually write this directly in the file that will become my unit test. Since X doesn't exist, I'm allowed to call whatever methods I want and pretend it all works. Once I'm satisfied with how it all looks, I cut and paste everything into a bunch of failing tests.
  • I get really bored adding tests to code that already runs
  • the seductive TDD trap
  • religious zealots
  • There is nothing wrong with building tests after you have built your product.
  • that goes a long way towards taking software development from a form of artisanal craftsmanship to a real engineering profession.
  • using tests to drive development cripples innovation, dramatically slows development
  • It always seem to me to be a codified form of reverse engineering, or at least a way to force the programmers into looking at their code from two separate angles at the same time.
  • If you're just adding tests at the end, then it's normal unit-testing, isn't it?
  • I do realize that this type of exercise might help younger coders in getting better structure, they do often rush in too quickly and focus more on the instructions than the abstractions.
  • TDD is test-driven *design*
  • He said he didn't write tests in cases where it would have taken him several hours to get a working test for a small piece of code.
  • In some applications, objects are self-contained, activities are sequential, and algorithms are tricky
  • I've seen cases where people have wrecked the architecture of systems in the name of making them testable... But have never written the tests.
  • Yes, it's possible to make peace with testability, and in the best situation, testability can improve the architecture of a program, but it can also lead people away from highly reliable and maintainable KISS approaches.
  • Like any infrastructure, it is always beneficial to provide unit testing. The most benefit is derived from installing it as early on in the project as possible.
  • The value of an untested feature, to a client, is ... zero. So, it doesn't matter how many of these you have rattled off in the past week, your net throughput is effectively... zero."
  • You can see in this thread the word "professionalism" (substitute "morality" with little gain/loss of substance) and even "sin" (used in jest, but not really!)
  • if I delay writing unit tests until after all the units are working together then because the system "already works" my subconscious enthusiasm for writing unit tests falls markedly, and so their quality and coverage fall
  • Experience teaches that if I generate that output by hand (1) it takes *much* longer (2) I almost always get it wrong. So I often write the code, get its output, carefully check it (really...) and then use it as the correct result.
  • My main objections to TDD are: 1) it promotes micro-design over macro-design and 2) it's hard to apply in practice (i.e. for any code that is not a bowling card calculator or a stack).
  • the tests are just a persistent artifact of the exploratory coding I've already done.
lemike

PHP: rfc:isset_ternary - 0 views

  • The short ternary operator, ?: provides a way to do this much more conveniently: $_GET['mykey'] ?: "". However, this is not good practise, as if the value does not exist it will raise an E_NOTICE.
  • The coalesce, or ??, operator is added, which returns the result of its first operand if it exists and is not NULL, or else its second operand.
  • chained
  • ...3 more annotations...
  • precedence relative to the ternary operator and the boolean or operator
  • short-circuiting operator
  • PHP 7
  •  
    In PHP7 you can use $foo = $_GET['x'] ?? 'default_content' which raises no notices if $_GET['x'] is not set
Sarah HL

Dr. Dobb's | Extreme Testing | juin 1, 2003 - 0 views

shared by Sarah HL on 29 Jun 09 - Cached
  • First, you quickly add a test
  • TDD employs five basic steps
  • The second step involves running your tests
  • ...15 more annotations...
  • Third, you make a little change to your functional code
  • Next, you run the tests
  • In the optional fifth step, you refactor your code to remove any duplication.
  • two simple rules. First, you should write new business code only when an automated test has failed. Second, you should eliminate any duplication that you find.
  • the running code providing feedback between decisions
  • You write your own tests because you can’t wait
  • Your designs must consist of highly cohesive
  • Test-Driven Development (Addison-Wesley 2003)
  • a Smalltalk system with a completely test-driven approach that took four years and 40 person-years of effort
  • there’s far more to testing than unit tests, so you’ll still need other testing techniques such as functional testing, user acceptance testing, system integration testing and so on.
  • you have a clear measure of success
  • most programmers don’t read the written documentation for a system; instead, they prefer to dig right into the code.
    • Sarah HL
       
      Follow the "natural" tendance of the developers, a pro TDD
  • Your acceptance tests define exactly what your stakeholders expect of your system; therefore, they truly do determine a good portion of your requirements.
  • Bob Martin says it best: “The act of writing a unit test is more an act of design than of verification. It’s also more an act of documentation than of verification.
  • Side by Side: Comparing TDD and AMDD TDD shortens the programming feedback loop; AMDD abridges the modeling feedback loop. TDD provides detailed specification (tests), while AMDD provides traditional specifications (agile documents). TDD promotes the development of high-quality code; AMDD encourages high-quality communication between your stakeholders and other developers. TDD provides concrete evidence that your software works, whereas AMDD supports your entire team, including stakeholders, in working toward a common understanding. TDD provides finely grained, concrete feedback in minutes. However, concrete feedback requires developers to follow the practice Prove It With Code, and they may become dependent on non-AM techniques; AMDD lets you get verbal feedback in minutes. TDD ensures that your design is clean by focusing on creation of callable and testable operations; AMDD lets you think through larger design and architectural issues before you code. TDD isn’t visually oriented; AMDD is. Both techniques are new and therefore may be threatening to traditional developers. Both techniques support evolutionary development. —S. W. Ambler
Sarah HL

Brendel Consulting - 0 views

  • "I don't want to write comments, because then I will have to scroll more to see the code.""Writing comments in the code takes time."Formatting the code nicely takes time, especially when I need to change a few things, in which case I then have to re-format the code."Code changes, and before you know it the comments are obsolete."
  • Meaningful variable and function names
  • Thoughtful source code documentation.
  • ...1 more annotation...
  • A legible and consistent coding style.
Jungle Jar

JungleJar | Taking a Look at a Few More Paste Bins - 0 views

  •  
    It wasn't that long ago when I was searching for a couple of good code-snippet applications to store bits of source code. Well, I found a couple and published 2 Really Useful Code Snippet Applications. Now, I've found a few more worth noting, each with their own strengths and weaknesses, but they all serve their purpose nicely.
Raúl - [^BgTA^]

30+ Firefox Add-ons for Web Developers & Designers - 0 views

  •  
    Las 30 mejores extensiones para Firefox:


    Aardvark - A cool extension for web developers and designers, allows them to view CSS attributes, id, class by highlighting page element individually. chromEdit - Alter the appearance of any page by editing CSS and Javascript files with this extension. CSSMate - Firefox extension to edit CSS files.
    CSS validator - Check the validity of your webpage using this CSS validator extension. CSSViewer - See the CSS properties of page elements with this extension.
    EditCSS - Play around with loaded CSS, Web Developer extension also provides this functionality.
    IE Tab - Designers and developers can view their CSS projects on Internet Explorer using this extension.
    Style Sheet Chooser II - Users can pick and choose alternate style sheets for a website. FireBug - A console for debugging JavaScript, HTML, and Ajax code snippets. HTML Validator - Cool extension to validate web pages with HTML standards of W3C. JavaScript Debugger - JavaScript debugging extension enables a strong debugging environment.

Richard Boss

Steps to Write PHP Code in Joomla Article | TechNet - 0 views

  •  
    This article explores you how to follow steps to write PHP code in Joomla article. In this post, you will get full information. Read this post now!
qualitypoint Tech

Need to solve error in PHP code useful for getting Google PageRank - 0 views

  •  
    We are working on to get Google pagerank using php code for one of our customer projects.I referred http://www.pagerankcode.com/down\nfor doing this.This code works fine in our local machine. We are using it for long time from our local machine. And, we tried to use it in our server few months back.
qualitypoint Tech

Adding piece of PHP code in all files within a sub-folder - 4 views

  •  
    In this post I will explain about how to add piece of php code in all files (including new files to be added) within a particular sub-folder in Apache server hosting environment. Let me explain why we need to add piece of php code in all files within a folder.
  •  
    I wanted to read it, but I won't, because Chromium blocked it and gave me a warning that the site hosts malware... just to let you know.
  •  
    Bart Deruyter Thanks for your note, now it should be fine.we removed unwanted external links.
Sarah HL

Building semantic Web CRUD operations using PHP - 0 views

  • When developing a Web application, it's standard practice to create a database structure on which server-side code is placed for the logic and UI layers. To connect to the database, the server-side code needs to do some basic creating, updating, deleting, and — most importantly — reading of records.
    • Sarah HL
       
      Interet du CRUD
  • SPARQL — Simple Protocol and RDF Query Language
    • Sarah HL
       
      PHP works with SPARQK to implement CRUD
  • Why move from SQL to SPARQL? There are many reasons why you would want to move from SQL to SPARQL. The details extend beyond the scope of this article, but you could be motivated by the following points: You want a more distributed data solution. You want to expose your data on the Web for people to use and link to. You may find Node-Arc-Node relationships (triple) easier to understand than relational database models. You may want to understand your data in a pure object-oriented fashion to work with an OOP paradigm (PHP V5 and later supports OOP). You want to build generic agents that can connect to data sources on the Web.
    • Sarah HL
       
      Interest of SPARQL
  •  
    "When developing a Web application, it's standard practice to create a database structure on which server-side code is placed for the logic and UI layers. To connect to the database, the server-side code needs to do some basic creating, updating, deleting
Sarah HL

PHP Worst Practices at blog.phpdeveloper.org - 0 views

  • Beware the Outsiders
  • Sure, you could cobble together your own library to add that feature and yes, it might integrate excellently with your code, but what does that gain you? One of the points of Open Source development is to share your knowledge with the rest of the community.
  • Unplanification
  • ...8 more annotations...
  • This would be the combined voices of everyone in your past that tried to teach you the mantra: “Plan First, Code Later”.
  • The Documentation Wasteland
  • If you’re writing your code without any sort of documentation, you’re dooming you and possibly future maintainers of the code into many a pointless search to try to figure out why method a() returns two completely different value types depending on which parameters it’s given.
  • ets you know the “why” instead of just the “how” the code gives you
  • You’d be surprised how often you’ll find yourself referring to it once it’s reliable.
  • Free Your Mind
  • You, as a developer, know that there’s always more than one way to solve a problem.
  • Just like ‘anti patterns’, who are an important read as well, ‘worst practices’ help developers avoid mistakes.
Sarah HL

Top 10 Traits of a Rockstar Software Engineer - 1 views

  • Loves To Code Gets Things Done Continuously Refactors Code Uses Design Patterns Writes Tests Leverages Existing Code Focuses on Usability Writes Maintainable Code Can Code in Any Language Knows Basic Computer Science
Sarah HL

Un projet sans développeur ? | Industrialisation des développements PHP - 2 views

  • Il ne s'agit pas de s'en passer  totalement : même les générateurs de code doivent être programmés par quelqu'un....
  • celui qui a produit le code
  • devient rapidement un passage obligé pour nombre de phase de vie de l'entreprise, alors même que le code a quitté son giron depuis longtemps.
  • ...4 more annotations...
  • un script de déploiement automatique permettra de le faire sans interroger l'auteur du code
  • On peut assurer de nombreuses tâches comme ceci : tests unitaires automatiques (phpunit alltests.php) analyse statique (pmd) déploiement (phing, capistrano)
  • Quand on travaille sur du code dans un projet, il est important de savoir s'en séparer, de couper le cordon ombilical. Si on est le seul à maîtriser une application, on devient indispensable, et on risque aussi de finir enchaîné à des corrections et évolutions infinies.
  • comment mes utilisateurs pourront-ils faire des modifications sans passer par moi?
Sarah HL

Learning JavaScript from PHP - a Comparison | Lullabot - 0 views

  • In PHP, all variables are local in scope unless declared as global. JavaScript is opposite, and all variables are global unless declared with the var keyword.
  • Both PHP and JavaScript are loosely typed
  • JavaScript is a bit mixed concerning undeclared variables, if you attempt to modify or compare with an undeclared variable, the script will break entirely, but you can check the variable status using typeof() or in conditional statements containing only that variable.
  • ...6 more annotations...
  • JavaScript only recognizes the keyword true in all lowercase. PHP accepts both uppercase and lowercase
  • PHP is not case-sensitive in function or class declarations, but JavaScript is case sensitive for these also.
  • The key difference between PHP and JavaScript is that JavaScript does not have associative arrays.
  • JSON strings having become very popular as a faster alternative to XML, and can be read and created with the PHP functions json_encode() and json_decode().
  • Let's take one more look at defining an object in JavaScript and see how it can be used to compensate for the lack of associative arrays in JavaScript.
  • // Note that variables should always be// prefixed with "var" to define a local scope.for (var n = 0; n < 10; n++) {  alert(n);}
qualitypoint Tech

Speeding up Coding... - 2 views

  •  
    We are using php coding in most of our projects. And, we are following some important guidelines to improve our performance.
Jungle Jar

JungleJar | Looking at Wordpress Custom Fields and Images Further - 0 views

  •  
    You may remember a previous article I wrote here on JungleJar.com called Using Custom Fields To Post Your Images, but if not, I'm going to reintroduce a few of the code snippets and methods I wrote about in the tutorial about how to save and display image data from custom fields within Wordpress. In this article I'm also going to cover a few of the small yet robust code block methods I myself tend to practice quite a bit that I didn't previously touch on. So, if you're looking for a solid tutorial on how to use Wordpress Custom Fields to display blog post thumbnails in an easy and flexible manner, then this article is for you.
qualitypoint Tech

Convert ASP code into PHP code - 1 views

  •  
    php is having many advantages over asp in terms of cost, Speed, Security and flexibility. So we may need to convert any asp...
Raúl - [^BgTA^]

Posteet: Store, share and tag your favourite tips, tricks, codes and snippets - 0 views

  •  
    Postea código y compartelo
Sarah HL

Easy Unit Testing - Web Mozarts - 0 views

  • Contrary to PHPUnit, lime tests are written in a procedural way.
  • Each test case is, by convention, introduced by a comment that explains the tests purpose.
  • requires you to initiate your fixture manually
  • ...7 more annotations...
  • sfLimeExtraPlugin introduces the new class lime_test_simple
  • @Test A test case @Before Executed before each test case @After Executed after each test case @BeforeAll Executed once before all test cases @AfterAll Executed once after all test cases
  • Currently the plugin is available in version 0.2.0alpha.
  • You can create stubs for interfaces, classes or abstract classes. You can even create stubs for non-existing classes, which is very convenient if you develop test-driven.
  • I personally think that tests can be written in a much more concise and readable way with sfLimeExtraPlugin.
  • Mock and Stub Objects
  • the code is not being considered 100% stable
1 - 20 of 81 Next › Last »
Showing 20 items per page