Reputation
2,118
Top tag
Next privilege 2,500 Rep.
Create tag synonyms
Badges
1 10 21
Newest
 Yearling
Impact
~229k people reached

  • 0 posts edited
  • 1 helpful flag
  • 138 votes cast
Jun
23
comment What can I use to distinguish a user chosen name from other identical names
If there's no natural key then common practice is to just use an autoincrementing value as a primary key.
Jun
23
awarded  Yearling
May
26
comment SQL: empty string vs NULL value
Your example is flawed because a) a good designer avoids long forms like the plague on the grounds that the length of a form is inversely proportional to how many people actually complete it, and b) you could work around the problem described by holding the data in a temporary store (such as a PHP session) and only submitting it to the database when it's complete and valid. If it's not and you need to reload the page then you can repopulate the form from the temporary store.
May
25
comment Lesser of two evils regarding return types
It's more a question of building a library for managing computations with things like money whilst avoiding floating point calculations.
May
25
accepted Lesser of two evils regarding return types
May
21
answered Lesser of two evils regarding return types
May
20
asked Lesser of two evils regarding return types
Apr
27
comment Why were frames deprecated in HTML5, but not iFrames?
Because frames were a terrible idea from the start but iframes do have a few legitimate use cases?
Mar
18
comment What's so bad about creative coding?
Act in haste, repent at your leisure. I deal with some codebases that are full of things that seemed like a good idea at the time to some developer. Had they taken a few hours to think about what they were going to do they could have avoided a lot of pain for me!
Mar
18
comment How can QA staff test caching logic that they can't see?
Well generally a cache is meant to speed up an operation by storing results in memory that would otherwise come from another source (db, remote server, computationally expensive method, etc). Therefore measuring the time things are supposed to take when hitting the cache seems like the simplest way. Also check for stale cache problems (updates to the actual data not appearing because the previous version is still cached)
Jan
8
comment Will a profound knowledge of C++ help you in learning other languages faster/easier?
depends on how like C++ the other languages are. The more they deviate the less helpful it will be.
Jan
8
answered How does a developer code in anticipation of change?
Jan
8
comment Best practice for using namespaces in my PHP libraries
In Java the common practice is to start with a vendor name as your topmost package (or a URL in reverse such as com.apple). You can then create anything you like inside that package without having to worry about it colliding with other similar generic names in other packages. You can do the same thing in PHP namespaces (and I'm pretty sure that it's starting to become standard practice to do so, \com\apple in the above example)
Jan
8
comment Why does PHP allow sending mail from any address
Because the specifications for email as a whole allow it. There's no authentication in email addresses.
Nov
27
comment Determining a class structure
I haven't had time to look at this in a while but to be brief a ProductBundle is basically a collection of products that are to be treated as a single unit addressed by a distinct SKU. Its price is the sum of all the prices of its bundled products, its weight is the sum of those products, its stock is equivalent to the stock of the bundled product with the least stock, etc. This is a bit different from a component because while a component can be purchased separately, a component is implicitly already assembled into its product, which is a single unit.
Nov
3
awarded  Great Answer
Oct
28
comment Determining a class structure
The adaptor idea sounds interesting, but I'm not sure it's right as weight would be part of the business logic rather than just a presentation thing. For example the total shipping weight could determine how much delivery is going to cost.
Oct
28
awarded  Curious
Oct
27
comment Determining a class structure
I'm glad you mentioned Magento and that EAV tables can be a pain to work with. :) That's the kind of design I'm trying to avoid if at all possible (assuming that this project sits purely on an SQL database and not entirely or partially on another storage mechanism, a decision I've not made yet). It's not just a matter of storing inapplicable data though, it's also a case of what constitutes a "clean" design, and putting stuff in the superclass because some subclasses might need it feels like a very wrong approach.
Oct
27
asked Determining a class structure