Tagged Questions
0
votes
0answers
13 views
Remapping Heading Angle to Coordinates to Move By
I wrote the following code to take the heading of an object, and determine which direction (x,y) it needs to move to be heading forward in a 2D plane. I have debugged the code and know that it ...
3
votes
4answers
420 views
Best practices in PHP
I've posted here before and got pretty helpful reviews. So, how does my code look now. To keep it really helpful, I just copied this from the middle of one of my projects. Review please?
<?php
...
1
vote
2answers
147 views
Basic PHP comment form: what ways can I improve security, efficiency/cleanliness, or conventionality?
I am a programming novice. I've written this simple PHP script to run a very basic comment form and would appreciate any feedback, especially on these three topics:
Efficiency (not sure the right ...
4
votes
1answer
152 views
Loading Javascript Libraries with PHP API
First question on this site so please take it easy on me and let me know if I infringe the common etiquette :-)
I have written the following script which simply:
Loops through javascript files ...
2
votes
1answer
214 views
Improving a “Http request URl builder” to be shorter, faster, easier to read
I've setup up a nice, little parent class that I can extend easily to do Http request to servers offering some sort of data with JSON/XML/whatever output.
You can see the init() function that is ...
3
votes
2answers
107 views
Closures power and concise style vs readability and maintainability?
Is large use of closures actually a bad thing for readability and maintainability of the code? For example, consider the following code with (comments removed on purpose):
$withMobile = function($c) ...
7
votes
3answers
463 views
Code Readability vs Code Length
library.php
My own HTML tag encoder that will print HTML codes according to the input.
<?php
function tag($tagname, $content = NULL, array $properties = NULL)
{
$html = ...
4
votes
3answers
305 views
Validating password rules
Edit: I already know password rules beside length are counter-productive. It's not my choice. Also, I know that performance is absolutely trivial here. I only care about performance by way of ...
2
votes
2answers
156 views
PHP Validation with functions and list()
I have multiple form validation checks around my site so I decided to write them as functions to simplify the process of creating the validation pages, here is a snippet for an understanding of what ...
1
vote
2answers
2k views
PHP - create a new user into a db using MVC framework
All,
I am a beginner and am creating a small web app. I'm working on the registration process for new users, and as this is largely a learning project I'm doing it from scratch.
Here is my user ...
2
votes
2answers
1k views
PHP Request Class
This class handles HTTP requests. It's a singleton class that parses URI to get the controller, method and parameters and then executes the controller's method.
Maybe parseUri should be in another ...
23
votes
5answers
785 views
Instantiating objects with many attributes
I have a class with quite a few attributes, most of which are known when I create an instance of the object. So I pass all the values in the constructor:
$op = new OpenIdProvider($imgPath . $name . ...
9
votes
4answers
244 views
How to improve this to a readable Unittests that explain the Class better ?
for starters i though of going with a mostly code only example.
This shows a testcase for an old caching library i use for a project. It features simple save/load/delete functions (saidly static ...