Best approach for an online store which changes its product’s price over time? [Designing the DB Table]


I am currently creating a website which will allow people to buy consumer products (deodorant, shampoo, toothpastes, etc…) from a store. Those products tend to change price and other details twice per year or more. And I want to show past purchases’ prices and other details to the client.
And I wanted to know what the best approach is.
I’ve come up with the following approaches. Are they any good?

Thanks!

1st. Approach: I have a Product table, with the columns that tend to change, appended with the time of change as a suffix.

1st Approach.

2nd Approach: In this one, I have the price and other details in a separate column.
2nd. Approach

I did make some research:
How to store prices that have effective dates?
http://talentedmonkeys.wordpress.com/2010/05/15/temporal-data-in-a-relational-database/

But couldn’t find them appropriate for my problem.

Move semantics in C++ – Move-return of local variables


My understanding is that in C++11, when you return a local variable from a function by value, the compiler is allowed to treat that variable as an r-value reference and ‘move’ it out of the function to return it (if RVO/NRVO doesn’t happen instead, of course).

My question is, can’t this break existing code?

Consider the following code:

#include <iostream>
#include <string>

struct bar
{
  bar(const std::string& str) : _str(str) {}
  bar(const bar&) = delete;
  bar(bar&& other) : _str(std::move(other._str)) {other._str = "Stolen";}
  void print() {std::cout << _str << std::endl;}

  std::string _str;
};

struct foo
{
  foo(bar& b) : _b(b) {}
  ~foo() {_b.print();}

  bar& _b;
};

bar foobar()
{
  bar b("Hello, World!");
  foo f(b);

  return std::move(b);
}

int main()
{
  foobar();
  return EXIT_SUCCESS;
}

My thoughts were that it would be possible for a destructor of a local object to reference the object that gets implicitly moved, and therefore unexpectedly see an ‘empty’ object. I tried to test this (see http://ideone.com/ZURoeT ), but I got the ‘correct’ result without the explicit std::move in foobar(). I’m guessing that was due to NRVO, but I didn’t try to rearrange the code to disable that.

Am I correct in that this transformation (causing a move out of the function) happens implicitly and could break existing code?

UPDATE
Here is an example which illustrates what I’m talking about. The following two links are for the same code.
http://ideone.com/4GFIRu – C++03
http://ideone.com/FcL2Xj – C++11

If you look at the output, it’s different.

So, I guess this question now becomes, was this considered when adding implicit move to the standard, and it was decided that it was OK to add this breaking change as this kind of code is rare enough? I also wonder if any compilers will warn in cases like this…

JavaFX with or without Rich Client Platform


I’m starting to delve into JavaFX and have heard that one of the cons of java fx is that there isn’t a mature rich client platform or application framework ala eclipse rcp or netbeats platform for it.

Why does JavaFX need a rich client platform? Do these things offer something that pure java fx does not offer on it’s own? Does this lack of an application framework mean that JavaFX is not suited for huge enterprise applications that require plugins and stuff like that?

TDD: how to test file outputs?


I’m really new to TDD, so I guess this question is pretty basic.

We’re building a website, and part of the functionality is generating some files (binary files: Excel, PDF, whatever). How should I test this feature?

I’ve think about creating some static files and compare those with the generated ones, but a binary comparison isn’t reliable (the files can have the same content but different checksums), and, if I understood TDD correctly, a logic comparison isn’t a good idea, since I should use basically the same algorithm I use to generate the files, so I wouldn’t be really testing anything.

How are this kind of things usually dealt with?

Is there a particular coding standard with comments between function name and body?


I’m integrating with a shipping API built in php.

They have a strange coding standard where the comments are between the function name and the first curly bracket.. which – subjectively – makes the code really hard to read.

Is this a particular, albeit non-standard, commenting standard?

Here’s an example of a such a function

public function qualityControlDescription($qcCode)
/*
Converts a Quality Control code (e.g. 'U') to a descriptive string.
Input parameters (case-insensitive):
    $qcCode = a Quality Control code, as returned by invokeWebService

Returned:
    Description string (e.g. 'UNSERVICEABLE'), or "" if not found
*/
{
    if (is_null($qcCode))
    {
        return "";
    }
    $descriptionMap = $this->qualityControlDescriptionMap();
    $returnVal = $descriptionMap[strtoupper($qcCode)];
    if (is_null($returnVal))
    {
        $returnVal = "";
    }
    return $returnVal;
}

What is the rule for simplicity over complexity? [closed]


We have a site which is hugely complex in its implementation. Conceptually, it is simple – a web-based catalog. But the implementation has become a multi-layered nightmare.

Can anyone indicate a “rule of thumb” for measuring when something has become too complex for the job it is doing?

Creating a generic framework for application loading [closed]


I have multiple applications that use a generic framework for creating a graphical user interface. All run with a certain gui.cpp (600 lines) and gui.h (150 lines) containing the int main() function, and the only differences for each file are the following:

gui.h:

  1. #define PROGRAM_NAME "SomeName" (and some other defines with the same identifying name)
  2. #include "ProgramSpecificPanel.h"

gui.cpp

  1. ProgramSpecificPanel *pnl_center = new ProgramSpecificPanel(this); (where this refers to the main panel that can hold subpanels)

Each ProgramSpecificPanel inherits from LoadablePanel, which provides generic interaction functions with the GUI. Nevertheless, each panel contains a lot more additional functions specific for the panel.

How can I generalize the gui.cpp and gui.h further so that they know which panel to load for compiling the application, so that when I modify the gui.cpp or gui.h in one application, this modification is reflected in other applications as well (sharing the source files)? Is that even possible?

Learn how to write/design code in a “organic” way? [closed]


I’m an average programmer, I have not issue accomplish the most of daily task and figure out solution, instead my issue is how to design code.

let me try to explain:

I don’t need to learn OO (method,class,interfaces ecc … ) instead I need a more productive methodology of coding/design software and Debugging/Fix/Understand code is ok …

BUT Whenever I have to write a new functionality from scratch I’m quite slow and I can see my methodology is a kind of “incremental code” instead of designing the full functionality and then implement it “all in once”.
I can define it in 2 words “Blank Page” issue.

So I would like to switch to a more “organic” approach.

  • how can I proceed in order to improve my skills ?
  • Any practical advice in design code ? ( ex. write pseudo-code and then implement ecc … )
  • I know external resources are off topic any way if you have any that you think it really helped you on this, you are welcome. ( ex. I can see many people advice this book Code Complete 2)

Update
If you want make the question more specific to a particular programming field, I’m interested in Web development.

Some similar questions:
http://stackoverflow.com/questions/268231/how-to-learn-good-software-design-architecture

Abstract Class confusion


I have learnt so far that abstract classes can’t be instantiated because they are only there for other classes to inherit from. But i cant get my head around this code i came across in the msdn library:

WebRequest myRequest = WebRequest.Create("http://www.contoso.com");

in the documentation it says the above code returns a WebRequest instance.

but the WebRequest class is an abstract class, and how comes the above code returns an instance of an abstract class when abstract classes can’t be instantiated.

please relieve me from my agony.

How to get feature fields and values?


How can I get features from EID? I cannot define a Geodatabase connection since it changes. I have to get it from IUtilityNetworkAnalysisExt or IEditor. I figured out how to get EIDs on downstream. I would like to get fields and values by EIDs.

Question and Answer is proudly powered by WordPress.
Theme "The Fundamentals of Graphic Design" by Arjuna
Icons by FamFamFam