问:
C++ Renaissance - marketing slogan?

Possible Duplicate:

  What does the latest “C++ Renaissance” mean?

Lately, I hear a lot about C++ Renaissance. What is that?

C++ is currently undergoing a renaissance. This means that, by definition, the language, compilers and compositional tooling are evolving and coalescing into a state that maximizes native developer efficiency, productivity, and creativity across hardware and software domains.

I agree that C++ needs a lot of improvements, mainly, because it was updated in Neolithic Age (98,03).
What really bugs me is the Build conf. They've showed a few metro style apps written in C++ and XAML - like RSS reader or Piano.

I have a feeling that C++ is an overkill for this kind of apps and only case when I see the advantage is battery power, but is it true? C# as well as C++ calls WinRT which is native and C# has only tiny runtime overhead.

Can someone provide case study or hard data where use C++ in windows 8?

I think it will be status quo (games, servers, OSes, databases, apps like Photoshop will be C++ and other client apps run .Net) and renaissance is just a marketing slogan.

答:
It's also C++ is portable. You can write a C++ app in windows move it to Mac/Linux/Android/iOS albeit with some fiddling. Although this probably isn't an angle MS is interested in.

When windows was the only game in town then C# was safe to use.

There are other alternatives Java/Python etc. They all come with a run time and so take some time to port to the new environment and as all these new platforms are coming then native is safer.

Also C++ (and C) are the only ones that have multiple compilers from multiple vendors - so you are safe that no one is going to change the rules - Oracle with java, MS with C# etc.

So if you're writing an app and you want to move it to different platforms then C++ is a very safe choice.

OwnerDisplayName: lukas

Title: C++ Renaissance - marketing slogan?


问:
What makes it hard to monetize browser extensions?
With the monetization of mobile apps being so popular, I'm surprised that extension developers are still mostly relying on donations as their primary form of compensation for their software.

While this is, of course, not a problem, I find myself wondering why browser extensions and plugins are generally exempt from monetization unlike plugins designed for software like Visual Studio and Photoshop are very often available only with purchase.

What makes broswer extensions different, and has anyone had any success charging for a browser extension?

Relevant: http://www.quora.com/Monetization/How-do-browser-extensions-monetize

答:
Most of the answers here relate to the direct monetization of add-ons where the end user is asked to pay for the service. But there are some add-ons (and mobile apps for that matter) that monetize indirectly either by placing advertising on their thank you pages or through direct monetization of their users through affiliate links.

For many of the reasons stated already, I don't believe anyone's quite figured out how to get end users to pay for an add-on or BHO. But I have seen services like After Download that can help developers with really popular add-ons place ads on their thank you pages. You can earn a few easy bucks that way.

I also know there are price comparison/shopping add-ons that are naturally monetized, meaning that its core service is to display coupons, deals, and offers where user clicks generate revenue. The company I work for, Superfish, happens to have such a product and we also offer our service as a "white label" product for add-on developers. That is, we work with developers who simply inject our javascript through their add-on and they automatically get our functionality and monetization. And if you have a relatively large user base, the revenue generated can be quite significant.

ContentLicense: CC BY-SA 4.0

ContentLicense: CC BY-SA 3.0


答:
I think it has a lot to do with payments infrastructure.

Apple's iStore has a well set up near monopoly on iPhone app delivery. Its slick has lots of high value desirable items like tunes and movies as well as applications and the consumer only has to go through the pain of registration and credit card details once.

Apple accounts for the vast majority of paid for phone apps
99% according to this

For web plugins here is no equivalent of iStore or Amazon. I.E. a trusted retailer who you don't mind giving your credit card details to, and, who you are likely to use again so its worth registering with.

Also while plugins are great for developers I cannot think of a use for a plugin app that would be attractive enough to an ordinary consumer that would have them reaching for their credit card.

Title: What makes it hard to monetize browser extensions?

Body:
With the monetization of mobile apps being so popular, I'm surprised that extension developers are still mostly relying on donations as their primary form of compensation for their software.

While this is, of course, not a problem, I find myself wondering why browser extensions and plugins are generally exempt from monetization unlike plugins designed for software like Visual Studio and Photoshop are very often available only with purchase.

What makes broswer extensions different, and has anyone had any success charging for a browser extension?

Relevant: http://www.quora.com/Monetization/How-do-browser-extensions-monetize


问:
Are interfaces and method signatures copyright protected?
For example, is it copyright infringement if I write a class called Random with the exact same purpose and method signatures as Microsoft's .Net System.Random class? Does it make a difference what language it's written in? In this case I want to write a Random class for use in ActionScript, which lacks a built-in seeded PRNG class.

If anyone has good links or reference suggestions for understanding what aspects of software are protected that's great too. And yes I know this isn't the place for "real" legal advice. If anyone goes to court pointing to a public message board as precendence--shame on them.

答:
Copyright protection protects the "artistic expression" of a work, not the technical form (to quote wikipedia).

Copyright protection does not protect facts.

So the question becomes, is an API or interface a "fact" or an artistic expression?  For simple APIs that are just a list of ways to get random numbers and the different kinds of random numbers, the API is probably more like a fact.  But, I could see there being a very sophisticated interface (you know, the ones you stare at for a minute, and then say "Ahh! That's impressive.") could be considered an "artistic expression" worthy of protection.

Here's a recent article about Oracle and Google fighting over API copyright about this very issue being debated in the (US) courts.

I am not a lawyer, and this post should not be construed as legal advice.  I can't even write disclaimers very well.


问:
Is it legal to recreate/opensource a program that you previously coded for another company
At my previous job I created a generic dashboard for automating tasks and it that turned out to be quite useful - and of course my previous employer owns all the code I wrote while I worked there. Now that I'm no longer there, is it legal for me to recreate that dashboard from memory and open source the code? If I do recreate it, the code (maybe 2k-3k lines) could be almost identical to the original since I have pretty good memory and tend to follow my usual coding style and naming conventions.

Edit: a little more background - this is a pretty generic piece of software that's used only internally by a small team (<10) within a global corporation. "The company" is not even aware of this system since it's I create it on my own initiative. It's built on python/django. And by almost identical I mean that for example the django models will have the same name/fields and views will use similar queries to return the same sets of objects.

答:
It would not cost that much time to even ask them for permission. You need written legal signature. To cover your self.

But if you are going to ask them to let you recreate some thing you created for them already. Sell it to them. Sell them the idea. You are going to opensource a pice of software they already use, and make it open to potentially significant reviews and additions from the programming community. They will not have to spend resource internally to manage and improve the software. Unless they want to gain greater benefits. I mean really sell them the idea.

If it is not a core business technology that they are selling to customers you will probably get approval quite easily. If it is some thing they do sell to customers, then they open them selves up to competitors competing with the same product. Only you would really know how important your previous employer views that code. If it is not that import to there income generation, and is only a productivity enhancer, your are very likely to get approval.

It is the cheapest and shortest route to getting what you want. If they say yes no problem. It only cost you some time. If they say no, and you still want to continue then ask a lawyer about his opinion. I expect that the only thing they own is the implementation. If you recreate it with enough changes that it does not look and work exactly the same you are much better off.

It is dysfunctional state, of the current system where we don't own the produce of our labor. Some of the most successful societies where the ones where people could freely profit from their own effort. You could draw comparisons to this situation to the feudal land ownership and the problems it created. At some point people are going to be doing business differently. Like googles 1/5 of your time for your own projects.


问:
How is fundamental mathematics efficiently evaluated by programming languages?
As I get more and more involved with the theory behind programming, I find myself fascinated and dumbfounded by seemingly simple things..
I realize that my understanding of the majority of fundamental processes is justified through circular logic

Q: How does this work?

A: Because it does!

I hate this realization! I love knowledge, and on top of that I love learning, which leads me to my question (albeit it's a broad one).

Question:

How are fundamental mathematical operators assessed with programming languages?

How have current methods been improved?

Example

```<code>var = 5 * 5;
</code>```

My interpretation:

```<code>$num1 = 5; $num2 = 5; $num3 = 0;
while ($num2 > 0) {
    $num3 = $num3 + $num1;
    $num2 = $num2 - 1;
}
echo $num3;
</code>```

This seems to be highly inefficient. With Higher factors, this method is very slow while the standard built in method is instantanious. How would you simulate multiplication without iterating addition?

```<code>var = 5 / 5;
</code>```

How is this even done? I can't think of a way to literally split it 5 into 5 equal parts.

```<code>var = 5 ^ 5;
</code>```

Iterations of iterations of addition?
My interpretation:

```<code>$base = 5;
$mod = 5;
$num1 = $base;
while ($mod > 1) {

    $num2 = 5; $num3 = 0;
    while ($num2 > 0) {
        $num3 = $num3 + $num1;
        $num2 = $num2 - 1;
    }
    $num1 = $num3;
    $mod -=1;
}
echo $num3;
</code>```

Again, this is EXTREMELY inefficient, yet I can't think of another way to do this.
This same question extends to all mathematical related functions that are handled automagically.

答:
When I was a kid, I learned how to multiply and divide with a pen and a paper, without wasting time with too many additions. Later I learned that square roots are computable that way as well.

At university I learned how to compute trigonometric and logarithmic operations with a dozen of multiplications, divisions and additions. They called it Taylor series.

Before that, my father gave me a book where those complex operations were already computed for hundreds of values and presented in tables. There was also some explanations for estimating the error when you wanted the sine of a value between two computed values.

Integer units, floating point units, GPU and DSP just implement all those old techniques on silicon.


答: You can take the purely functional aspects, but you cannot take the expressive aspects. The class name, method names, and signatures are purely functional. You need them to inter-operate. Parameter names and header macros could be considered expressive. For example, in its Windows antitrust case, Microsoft argued that nothing prevented a competitor from replicating Windows APIs and creating their own platform on which Windows applications would run.</p>

Title: Are interfaces and method signatures copyright protected?

Body:
For example, is it copyright infringement if I write a class called Random with the exact same purpose and method signatures as Microsoft's .Net System.Random class? Does it make a difference what language it's written in? In this case I want to write a Random class for use in ActionScript, which lacks a built-in seeded PRNG class.

If anyone has good links or reference suggestions for understanding what aspects of software are protected that's great too. And yes I know this isn't the place for "real" legal advice. If anyone goes to court pointing to a public message board as precendence--shame on them.


问:
Would a NoSQL DB be more efficient than a relational DB for storing JSON objects?
I am using a library that returns a JSON object (as a string, but I think that's standard), and I would like to store the contents of this object into a local database.

I'm fairly fresh-faced in terms of interfacing with DBs, but I can find my way around.  I was using a MySQL database to store the data, but this involved using methods to extract the fields of the raw object, and slicing and dicing.

I'm wondering if it would be more efficient to use a NoSQL solution to store the data, as it's already in the right form.

答:
The decision of whether to use relational DB or non-relational (document/OO/graph) database should not be based on the representation of the data (JSON/BSON/XML/...), but on the operations you intend to preform on the data.

If you have a strict schema, and you need to execute SQL queries - You should use relational DB. Otherwise, you may consider other options.

Look here to consider your options.


答: Surely this all comes down to the contract between you and the client. If you had planned to do this you should have had a clause which states 'this source sode remains the intellectual property of kefeizhou...' or something (I know hindsight is 20/20). I agree with the other comments that Programmers SE is not the best source of legakl advice, and that legal or not, this is setting you up for problems. Incidentally, I used to work as a graphic designer, and in that industry, almost all work remained the IP of the client and not the designer.</p>

Title: Is it legal to recreate/opensource a program that you previously coded for another company

Body:
At my previous job I created a generic dashboard for automating tasks and it that turned out to be quite useful - and of course my previous employer owns all the code I wrote while I worked there. Now that I'm no longer there, is it legal for me to recreate that dashboard from memory and open source the code? If I do recreate it, the code (maybe 2k-3k lines) could be almost identical to the original since I have pretty good memory and tend to follow my usual coding style and naming conventions.

Edit: a little more background - this is a pretty generic piece of software that's used only internally by a small team (<10) within a global corporation. "The company" is not even aware of this system since it's I create it on my own initiative. It's built on python/django. And by almost identical I mean that for example the django models will have the same name/fields and views will use similar queries to return the same sets of objects.


问:
*Code owner* system: is it an efficient way?
There is a new developer in our team. An agile methodology is in use at our company. But the developer has another experience: he considers that particular parts of the code must be assigned to particular developers. So if one developer had created a program procedure or module it would be considered normal that all changes of the procedure/module would be made by him only.

On the plus side, supposedly with the proposed approach we save common development time, because each developer knows his part of the code well and makes fixes fast. The downside is that developers don't know the system entirely.

Do you think the approach will work well for a medium size system (development of a social network site)?

答: As with many things, it's a big "depends". If it's a strict "no one else can work on the code", it's probably verging on bad. If it is "the owner must do a code-review before accepting a change", it's middling to good, depending on how willing the owner is to accept external change.</p>


问:
White box testing with Google Test
I've been trying out using GoogleTest for my C++ hobby project, and I need to test the internals of a component (hence white box testing). At my previous work we just made the test classes friends of the class being tested. But with Google Test that doesn't work as each test is given its own unique class, derived from the fixture class if specified, and friend-ness doesn't transfer to derived classes.

Initially I created a test proxy class that is friends with the tested class. It contains a pointer to an instance of the tested class and provides methods for the required, but hidden, members. This worked for a simple class, but now I'm up to testing a tree class with an internal private node class, of which I need to access and mess with.

I'm just wondering if anyone using the GoogleTest library has done any white box testing and if they have any hints or helpful constructs that would make this easier.

Ok, I've found the FRIEND_TEST macro defined in the documentation, as well as some hints on how to test private code in the advanced guide. But apart from having a huge amount of friend declerations (i.e. one FRIEND_TEST for each test), is there an easier idion to use, or should I abandon using GoogleTest and move to a different test framework?

答:
You should not really be testing private methods here and here.  It makes your tests brittle since a refactor of the internal class code will mean a refactor of some the tests -- thus you lose the confidence that those tests work.

Have you looked at mocks?  I think that this approach may help you more.

In addition, have a look here for a similar question.

Title: White box testing with Google Test


问:
Premium and opensource
I am thinking about releasing my premium (commercial) project as an opensource project, but I am not sure how the user might benefit, how I will benefit and which license will I use.

I really need to know anything possible about this step...

答:
```<code>I am not sure how the user might benefit
</code>```

It will  become free and other users (including themselves) can add and improve the project.

```<code>how I will benefit
</code>```

You will have internet points for creating an open source project. (can also be converted to CV points if your looking for a job/contract work) The project may become far better that it is currently if others contribute. You will also help the open source community, indirectly giving you more great free software.

which license will I use

Your call. There are loads to choose from. GPL is a good one

Title: Premium and opensource

Body:
I am not sure how the user might benefit

It will  become free and other users (including themselves) can add and improve the project.

how I will benefit

You will have internet points for creating an open source project. (can also be converted to CV points if your looking for a job/contract work) The project may become far better that it is currently if others contribute. You will also help the open source community, indirectly giving you more great free software.

which license will I use

Your call. There are loads to choose from. GPL is a good one


问:
Handling false positives and legacy code warnings in static-analysis of C++ code?
We have a large "legacy" C++ code base on which no static analysis is run at the moment.

Every now and then, we are thinking about at least using cppcheck, maybe via Visual Lint. (I've also briefly checked the sites of Coverity or Klocwork or RedLizards/Goanna.)

However, I do expect a huge number of found warnings and probably also false positives (in that the error does not actually cause an observable bug in the application).

We simply do not have the resources available to address these all on rollout of any analysis tool, especially as we would very much only like to touch "code that works (well enough)" if we really have to.

So what I am looking for are experiences and user stories of adding C++ static analysis to legacy code bases:

We had this product, consisting of xxx lines of code over zzz C++ projects and we started using static analysis tool yyy in development. Rooting out the legacy code warnings took aaa effort, (temporarily) ignoring them was hard/easy/impossible. Ignoring warnings selectively for the code base really worked well/didn't work at all. Etc.

Something like this. Thanks!

答:
For each of these tools you can select which classes of warnings you want to see, and which to suppress.

I've got some experience with Klocwork, and the granularity of the selections there is pretty good, as well as the actual reporting, i.e.: you can filter out the "old" errors, and only see the incremental changes, when you run the tool on the changed code. I find it very convenient and useful.

However, a point for consideration:

However, I do expect a huge number of found warnings and probably also
  false positives (in that the error does not actually cause an
  observable bug in the application).

Sometimes, although the error doesn't cause an observable bug in the application now, it might bite you in the future. Seen that happening and it was painful. Ignoring errors just because they don't cause visible damage right now is not a good idea.

Prioritize and manage your time of course, but don't just ignore the errors and forget about them, they tend to remind you of their existence in the least appropriate moment.


问:
Secure cloud based code storage and syncing across multiple computers
I've been thinking recently about how and where I keep my code - I work across multiple locations, with at least three different computers and I'm considering how I manage my code across these machines.

I've got a dropbox account, which I use. For non sensitive files this is fine, and I do keep some sensitive files in there, but in a TrueCrypt file - this won't work large scale as the entire TrueCrypt file would need to be uploaded for any change.  I don't feel safe putting my, or my employers, code on DropBox because of several security issues and news that they can access everyones' files.

I have a github account where I store my code (open and closed source), but I don't want to have to always push up to GitHub, also I work a lot on the train so I can't push as I don't have a stable data connection and chances are that I'll forget to push or grab data at some point and then I'll be stuck!

So - with that in mind, I'd like a discussion about storing code in the cloud:

Is keeping source code in the cloud dangerous?

I understand the implications of keeping employers code in the cloud, but are there alternatives, given that a good number of VPN/RDC solutions that I've used are slow to the point of unusable? (this may be a point against my/my employers network speeds rather than the actual programs - but it's a impediment)

Is there a good cloud based service with good encryption, good uptime, diff, auto
sync?

Is there one aimed solely at developers?  If not, does anyone want to start one with me? (joking but at the same time, it could be a good business venture - drop me a line if interested)

What do you use?  Does it work? how would you change it?

答: I'm trying out BoxCryptor on top of DropBox, with automatic aes-256 encryption of all individual files (including their names). Haven't thought yet about using it in conjunction with a version control system, but for securely syncing files across workstations it seems to work well.</p>


问:
Use switch statements for application flow?
I generally use switch statements to simplify a block of multiple if statements - for example - returning a feedback string to a user based on a multiple choice input.

I also tend to construct classes so that there is one "management" method, to avoid sequential steps or chained method invocation within other methods of the class. I've found this helps to keep methods flexible and focussed - i.e.

```<code>class MyClass{

    // this method does nothing more than invoke the relevant method
    // depending on the status following the previous. It's entire purpose
    // is to control application flow
    public function manageFlow($input){
        $status = $this->stepOne($input);
        if($status == false){
            //exit routine
        }

        $status = $this->stepTwo($input);
        if($status == false){
            //exit routine
       }
    }

    // this method has several sequential steps implemented direcly within it,
    // for example to a user logging in
    // it makes it impossible to re-use any of the intermediary steps
    public function tangledFlow($input){
         if($input == 'something){
         //100 lines of code
         }
         //then handing on to the next bit
         if($this->User->Authenticated){
         //another 100 lines...
         }
    }
}
</code>```

Then it occurred to me that I could use a switch statement to control this kind of sequential execution - so my question is: has anyone used a switch statement for this kind of flow control?

答:
Switch statement is conditional statement used to perform different actions based on different conditions. I.e. Switch statement is used to select one of many blocks of code to be executed.

The Switch statement is a control statement that handles multiple selections by passing control to one of the case statements within its body.

From my own blog post :

Syntax :

```<code>switch (expression)
        {
           case label_1:
             //code to be executed if expression = label_1 ;
           break;
           case label_2:
             //code to be executed if expression = label_2;
           break;
             /*.............
             .............*/
          default:
            //code to be executed if expression is not equal to all label_1, label_2,... etc.
        }
</code>```

ContentLicense: CC BY-SA 2.5

Body:
Switch statement is conditional statement used to perform different actions based on different conditions. I.e. Switch statement is used to select one of many blocks of code to be executed.

The Switch statement is a control statement that handles multiple selections by passing control to one of the case statements within its body.

From my own blog post :

Syntax :

switch (expression)
        {
           case label_1:
             //code to be executed if expression = label_1 ;
           break;
           case label_2:
             //code to be executed if expression = label_2;
           break;
             /*.............
             .............*/
          default:
            //code to be executed if expression is not equal to all label_1, label_2,... etc.
        }


问:
What is a better word for aligning your nesting?
I was taught by an old-time programmer who called this nested code

```<code>if(condition){
  <div>
    <b>text <u>text</u></b><br/>
    <table>
      <tr>
         <td>a</td>
         <td>b</td>
      </tr>
    </table>
  </div>
} else {
  log();
}
</code>```

as opposed to this code which was considered to be not nested

```<code>if(condition){<div>
<b>text
    <u>text</u></b>
    <table><tr><td>a</td><td>b</td></tr></table>
    </div>
} else {log();}
</code>```

When I started reading tutorials I found early on that I had the wrong definition to nested.

Messy vs clean is not sufficient for this because messy code encompasses other problems that I am not talking about, for example confusing flow of logic, using static initializers inappropriately, poor use of variable names, using twice the code to get the job done in a more confusing manner, etc.

What is the right word for this, where the first example is ... and the second example is not ...?

答: I would say "formatted" or "well-formatted".  I disagree with "clean code" and "tight code" which other posters have suggested.</p>


问:
How to translate a German Desktop App into English one
I am working on a desktop application which is in German. And this isn't comfortable for me to see the words and go to Google translate to translate it.

So I am looking to make extra effort for myself to try to translate the App into English using Google translate web service. But the Application doesn't use a Spring or AOP in order to make a single point of calling the web service.

My question is there a way to create a new project to introduce spring with AOP in order to achieve this.

or there is another way to achieve this ?

答:
user12539,

If your set on using Spring for I18N support then take a look at this example at mkyoung.com.

I've been working on something similar with Arabic and I've found Google Translate to be problematic in some areas. Some of the translations were inaccurate, but Google do have the disclaimer telling you that it's a collaborative effort, so you can't really blame them for any inaccuracies.

In the beginning, I followed the usual steps of isolating user visible messages into resource bundles (text files) and I created a Python script that would parse the file for the words and use a Google translate web service to translate each word and finally dump the translations into a new resource bundle. This is fine if you know both languages well, but it's a very bad idea if you don't.

I would recommend getting someone who knows both languages very well and can look at the application as it is and offer suggestions in adapting it work for an English reading audience. You can also create a script like the one I used and show the resource bundles to the translator, but it would be better for him/her to look at the application and create the resource bundles for you. It will save you a great deal of time in the long run.


问:
Do GUI programmers have an undue advantage over others?
It is easy for managers and customers to appreciate what they can see.

I have seen many GUI developers who are average programmers with minimal knowledge of design principles or other programming idioms. However, these shortcomings often go unnoticed, specially by management and customers, if the programmer can create an impressive looking user interface. So much so that many GUI developers I know spend hours beautifying the GUI at the expense of writing bad, unmaintainable code.

On the other hand, middle tier programmers who develop APIs or business functionality or database code (SQLs etc.) are at a disadvantage as there is nothing tangible to showcase. Perhaps a code reviewer or an architect may appreciate the elegance, good design, scalability etc. of code but it means nothing to the outside world. Your code may run for years without breaking, may be very easy to maintain and have good performance, yet it never elicits the 'wow' that a slick looking GUI does.

In my opinion, a corollary to this is (and I am going to get heavily downvoted for this, I know) that there is less motivation for a GUI programmer to write good clean code.

EDIT: I must explain here that by GUI programmer, I don't mean a full-fledged web/GUI designer but a front-end programmer e.g., a java-swing programmer.

Does the rest of the community agree ?

答:
For a person who doesn't deal with programmers any, I can confidently say that they would believe this kind of stuff. They don't know the amount of work that goes in the background, all they see is a bunch of buttons/textboxes/menus/[insert GUI element] and the speed it takes to accomplish what the button started. So initially, GUI people are liked more.

If the person does deal with programmers, then its a bit different. As you said they would notice if you made it scalable, easier to maintain, rewrote an algorithm so it made more sense, or any other maintenance type task. This kind of person would look at all programmers equally.

In the middle it depends on what your doing. Speed then becomes the important factor here. If you can show before and after recordings of how long it takes for a form to be processed and stored and there's an improvement, you are equal. If you can show the app under load from 100 clients and show them the server melting, and then show them your version where everything is fine, your equal. Etc.

In short, it depends on the person and what your doing.


问:
How should I bring my C++ back up to date with modern developments?
How should I bring some very rusty C++ up to date, as I'm sure the language and best practices have evolved? I realise this might be close to being off-topic so let my clarify some details. About 10 years ago I think I was quite a good C++ programmer, I'd devoured the Scott Meyers books, I could solve the puzzles in the lint adverts in Dr. Dobbs. I was probably a bit of a language lawyer. I've been programming mostly Java, some python for the last 10 years so my OO skills are still up to scratch. But having joined a company where C++ is common I've realized I have to admit to myself I am both really rusty, and there are language features now which are either new or a lot more common than I remember - things like namespaces etc.

I realise reading and writing code (especially pairing) is a good way to get up to speed, but is there any other resource people would recommend in this to give me an accelerated head start. Book? Web-page? Tutorials?

To summarize:

Recommendations for C++ specific refresher resources?

Not OO/programming generally.

Things in addition to just reading and writing code.

答:
Nick,

I'd suggest you get involved with an open source project. Have you looked at sourceforge ? This could apply to any language, but the key benefit here is learning from other developers while contributing to a software project. You can pick up some interesting styles and use of language features from working on an open source project. Some good, some bad, some....just plain weird :).


答:
1) start with a modern compiler which has c++11 features (assuming your work will require that sooner than later, if not already)

2) take existing programs (perhaps your pet projects) and update or extend them to  use more modern libraries (such as c++11 standard libraries or boost).

3) read up on the latest C++ features. there are also number of good books. if you have not yet read Modern C++ Design, i'd recommend it. it's a classic for advanced designs using c++ techniques which were introduced and honed during your absence.

that's a starting point.

Title: How should I bring my C++ back up to date with modern developments?

Body:
How should I bring some very rusty C++ up to date, as I'm sure the language and best practices have evolved? I realise this might be close to being off-topic so let my clarify some details. About 10 years ago I think I was quite a good C++ programmer, I'd devoured the Scott Meyers books, I could solve the puzzles in the lint adverts in Dr. Dobbs. I was probably a bit of a language lawyer. I've been programming mostly Java, some python for the last 10 years so my OO skills are still up to scratch. But having joined a company where C++ is common I've realized I have to admit to myself I am both really rusty, and there are language features now which are either new or a lot more common than I remember - things like namespaces etc.

I realise reading and writing code (especially pairing) is a good way to get up to speed, but is there any other resource people would recommend in this to give me an accelerated head start. Book? Web-page? Tutorials?

To summarize:

Recommendations for C++ specific refresher resources?

Not OO/programming generally.

Things in addition to just reading and writing code.


答:
We lack information on your project but if you target at least partly companies you can opt for a dual licensing model. The FAQ of Quantum Leap is quite interesting regarding this model. See also Business model section of the "about" page.

I especially like this part of their explanations:

Business Model: Many first-generation open source vendors (e.g., Linux
  companies) build their business model on a free product and paid
  support, while Quantum Leaps charges for the product and offers free
  1-year technical support for every commercially licensed product. As a
  consequence, we are highly motivated to keep our software free of
  bugs, easy to use, and to supply good documentation with many examples
  to minimize our support load and expenses. This is in contrast to many
  first-generation open-source vendors, where such strategy would
  actually lower their revenue and profit from support contracts.

Title: Premium and opensource

Body:
I am thinking about releasing my premium (commercial) project as an opensource project, but I am not sure how the user might benefit, how I will benefit and which license will I use.

I really need to know anything possible about this step...


答:
If you already "devoured Scott Meyers books", then you are a lot further that the average guy that did C++ 10 years ago (IMHO). Get the 3rd edition of Effective C++ (and the C++ Coding Standards book by Sutter/Alexandrescu) to get a short refresh, and, really, you should be ready to go.

The recommendations in these books (originally 2005 I think) are just as valid today as they've been then.

Oh, and install boost if you haven't already.

Lucky time for you to restart in C++, as I am very sure there will be lots of restart-type resources and books this year and the next when the C++11 standard starts to settle in.


答: Do some code kata in c++: hanoi tower, ring buffer, and that sort of things.  Doing it is going to be a lot more efficient than just reading books about it -- although, reading books will help you learn things you did not know. </p>


问:
What does SVN do better than Git?
No question that the majority of debates over programmer tools distill to either personal choice (by the user) or design emphasis, that is, optimizing design according to particular uses cases (by the tool builder). Text editors are probably the most prominent example--a coder who works on Windows at work and codes in Haskell on the Mac at home, values cross-platform and compiler integration and so chooses Emacs over TextMate, etc.

It's less common that a newly introduced technology is genuinely, demonstrably superior to the extant options.

Is this in fact the case with version-control systems (VCS), in particular, centralized VCS (CVS and SVN) versus distributed VCS (Git and Mercurial)?

I used SVN for about five years, and SVN is currently used where I work. A little less than three years ago, I switched to Git (and GitHub) for all of my personal projects.

I can think of a number of advantages of Git over Subversion (and which for the most part abstract to advantages of distributed over centralized VCS), but I cannot think of one contra example--some task (that's relevant and arises in a programmers usual workflow) that Subversion does better than Git.

The only conclusion I have drawn from this is that I don't have any data--not that Git is better, etc.

My guess is that such counter-examples exist, hence this question.

答:
I can think of three. First, it is quite a bit easier to grok, especially for non developers. Conceptually it is much simpler than DCVS options. Second is maturity, especially TortoiseSVN on Windows. TortoiseHg is catching up fast though. Third, the nature of the beast--just an image of a filesystem where you can check things out from any level of the tree--can come in pretty handy in some scenarios -- like versioning a variety of widely different configuration files across dozens of servers without dozens of repositories. </p>

<p>This isn't to say we aren't moving all development over to Mercurial. </p>

Title: What does SVN do better than Git?

Body:
I can think of three. First, it is quite a bit easier to grok, especially for non developers. Conceptually it is much simpler than DCVS options. Second is maturity, especially TortoiseSVN on Windows. TortoiseHg is catching up fast though. Third, the nature of the beast--just an image of a filesystem where you can check things out from any level of the tree--can come in pretty handy in some scenarios -- like versioning a variety of widely different configuration files across dozens of servers without dozens of repositories.

This isn't to say we aren't moving all development over to Mercurial.


问:
Can I consider interface methods as abstract methods?
I was thinking about that, and I had some doubts.

When I declare an interface, for example:

```<code>public interface MyInterface
{
   public void method1();
   public void method2();
}
</code>```

Could these interface methods be considered abstract? What I mean is that the concept of an abstract method is:

An abstract method is a method that is declared, but contains no implementation.

So, could these methods be considered abstract? They are not "pure" abstract methods as I'm not using the abstract word, but conceptually, it looks like they are.

What can you tell me about it?

Thanks.

答: The difference here is that abstract classes can contain implementation details, although cannot be instantiated by themselves.  Whereas an interface is merely a template for a class</p>


答:
I appreciate that you are looking for good information, but this kind of question just invites, "I think Git is so much win, and svn teh suxorz!" answers.

I tried and personally found Git a little too much for my small team. It seemed like it would be great for a large distributed team or group of teams that are geographically dispersed. I understand greatly the benefits of Git, but source control in my opinion isn't something that keeps me up at night.

I am a deer hunter, and when me and my friends go out they are armed to the teeth, bristled with ammo and high tech gear. I show up with a single rifle, seven bullets and a buck knife.  If I need more than seven rounds then I am doing something wrong, and I do as well as anybody else.

The point I am trying to make is that if you are a small team working on a medium to small project and you are already familiar with SVN then use it. It is certainly better than CVS or (shudder) SourceSafe, and it doesn't take me more than five minutes to set up a repository. Git can sometimes be overkill.

Title: What does SVN do better than Git?

Body:
No question that the majority of debates over programmer tools distill to either personal choice (by the user) or design emphasis, that is, optimizing design according to particular uses cases (by the tool builder). Text editors are probably the most prominent example--a coder who works on Windows at work and codes in Haskell on the Mac at home, values cross-platform and compiler integration and so chooses Emacs over TextMate, etc.

It's less common that a newly introduced technology is genuinely, demonstrably superior to the extant options.

Is this in fact the case with version-control systems (VCS), in particular, centralized VCS (CVS and SVN) versus distributed VCS (Git and Mercurial)?

I used SVN for about five years, and SVN is currently used where I work. A little less than three years ago, I switched to Git (and GitHub) for all of my personal projects.

I can think of a number of advantages of Git over Subversion (and which for the most part abstract to advantages of distributed over centralized VCS), but I cannot think of one contra example--some task (that's relevant and arises in a programmers usual workflow) that Subversion does better than Git.

The only conclusion I have drawn from this is that I don't have any data--not that Git is better, etc.

My guess is that such counter-examples exist, hence this question.


答:
I found an usefull answer here: http://download.oracle.com/javase/tutorial/java/IandI/abstract.html

All of the methods in an interface are implicitly abstract, so the
  abstract modifier is not used with interface methods (it could be—it's
  just not necessary).

Title: Can I consider interface methods as abstract methods?

Body:
I was thinking about that, and I had some doubts.

When I declare an interface, for example:

```<code>public interface MyInterface
{
   public void method1();
   public void method2();
}
</code>```

Could these interface methods be considered abstract? What I mean is that the concept of an abstract method is:

An abstract method is a method that is declared, but contains no implementation.

So, could these methods be considered abstract? They are not "pure" abstract methods as I'm not using the abstract word, but conceptually, it looks like they are.

What can you tell me about it?

Thanks.


答:
One benefit of Subversion over Git can be that Subversion allows checking out sub-trees only. With Git the whole repository is a unit, you can get only all or nothing. With modular code, this can be quite nice compared to Git submodules. (While Git submodules have their place, too, obviously.)

And a small tiny benefit: Subversion can track empty directories. Git tracks file contents, so a directory without any file won't show up.

Title: What does SVN do better than Git?


答:
This is all relative, and like maple_shaft said, if one works for you, don't change!

But if you really want something, I'd say it is maybe better for designers, web programmers and such - it handles images and binary files a bit better.

Title: What does SVN do better than Git?


答:
Subversion is a central repository

While many people will want to have distributed repositories for the obvious benefits of speed and multiple copies, there are situations where a central repository is more desirable. For example, if you've got some critical piece of code that you don't want anyone to access, you'd probably not want to put it under Git. Many corporations want to keep their code centralized, and (I guess) all (serious) government projects are under central repositories.

Subversion is conventional wisdom

This is to say that many people (especially managers and bosses) have the usual way to number the versions and seeing the development as a "single line" along time hardcoded into their brain. No offense, but Git's liberality is not easy to swallow. The first chapter of any Git book tells you to blank out all the conventional ideals from your mind and start anew.

Subversion does it one way, and nothing else

SVN is a version control system. It has one way to do its job and everybody does it the same way. Period. This makes it easy to transition to/from SVN from/to other centralized VCS. Git is NOT even a pure VCS -- it's a file-system, has many topologies for how to set up repositories in different situations -- and there isn't any standard. That makes it harder to choose one.

Other advantages are:

<s>SVN supports empty directories</s>

<s>SVN has better Windows support</s>

<s>SVN can check out/clone a sub-tree</s>

SVN supports exclusive access control svn lock which is useful for hard-to-merge files

SVN supports binary files and large files more easily (and doesn't require copying old versions everywhere).

Adding a commit involves considerably fewer steps since there isn't any pull/push and your local changes are always implicitly rebased on svn update.

Title: What does SVN do better than Git?


答:
The following code is nested:

```<code>if (someCondition) { /*doSomething*/ } else { while (someOtherCondition) { if (someSubCondition) { /*doSomethingElse*/ } else { /*doSomethingCompletelyDifferent*/ }}}
</code>```

Nested means, that some inner statements are nested within some outer statements. In fact, in most common programming languages, virtually all code is nested, because your code is nested with in functions, which are nested within modules. And in fact almost every statement nests other statements within itself.

Now the following code is indented:

```<code>doSomething();
      doSomethingElse();
      doSomethingElseYet();
doSomethingCompletelyDifferent();
</code>```

On it's own, indenting only means, that you add horizontal whitespaces (usually space or tab) after linebreaks.

Now proper indenting as a part of proper formatting is the process of giving code a visual structure, that makes it's (nested) structure apparent (which is definitely not the case for the first code example). So let's properly indent it (without wanting to restart the religious war on the different indenting styles):

```<code>if (someCondition) {
    /*doSomething*/
}
else {
    while (someOtherCondition) {
        if (someSubCondition) {
            /*doSomethingElse*/
        }
        else {
            /*doSomethingCompletelyDifferent*/
        }
    }
}
</code>```

Now the visual structure of the code represents it's nesting. By the number of tabs preceding a statement, you can directly see how deeply it is nested. You can easily distinguish inner from outer statements, and see where statements start and end.

So to summarize, code formatting (which includes indenting) is the technique of using (mostly) non-significant characters to give source code a visual structure. Proper code formatting means applying this technique to give the code a visual structure, that communicates it's semantic structure.

Title: What is a better word for aligning your nesting?

Body:
I was taught by an old-time programmer who called this nested code

```<code>if(condition){
  <div>
    <b>text <u>text</u></b><br/>
    <table>
      <tr>
         <td>a</td>
         <td>b</td>
      </tr>
    </table>
  </div>
} else {
  log();
}
</code>```

as opposed to this code which was considered to be not nested

```<code>if(condition){<div>
<b>text
    <u>text</u></b>
    <table><tr><td>a</td><td>b</td></tr></table>
    </div>
} else {log();}
</code>```

When I started reading tutorials I found early on that I had the wrong definition to nested.

Messy vs clean is not sufficient for this because messy code encompasses other problems that I am not talking about, for example confusing flow of logic, using static initializers inappropriately, poor use of variable names, using twice the code to get the job done in a more confusing manner, etc.

What is the right word for this, where the first example is ... and the second example is not ...?

Body:
The following code is nested:

if (someCondition) { /*doSomething*/ } else { while (someOtherCondition) { if (someSubCondition) { /*doSomethingElse*/ } else { /*doSomethingCompletelyDifferent*/ }}}

Nested means, that some inner statements are nested within some outer statements. In fact, in most common programming languages, virtually all code is nested, because your code is nested with in functions, which are nested within modules. And in fact almost every statement nests other statements within itself.

Now the following code is indented:

doSomething();
      doSomethingElse();
      doSomethingElseYet();
doSomethingCompletelyDifferent();

On it's own, indenting only means, that you add horizontal whitespaces (usually space or tab) after linebreaks.

Now proper indenting as a part of proper formatting is the process of giving code a visual structure, that makes it's (nested) structure apparent (which is definitely not the case for the first code example). So let's properly indent it (without wanting to restart the religious war on the different indenting styles):

if (someCondition) {
    /*doSomething*/
}
else {
    while (someOtherCondition) {
        if (someSubCondition) {
            /*doSomethingElse*/
        }
        else {
            /*doSomethingCompletelyDifferent*/
        }
    }
}

Now the visual structure of the code represents it's nesting. By the number of tabs preceding a statement, you can directly see how deeply it is nested. You can easily distinguish inner from outer statements, and see where statements start and end.

So to summarize, code formatting (which includes indenting) is the technique of using (mostly) non-significant characters to give source code a visual structure. Proper code formatting means applying this technique to give the code a visual structure, that communicates it's semantic structure.


答:
When you don’t need to branch and merge, SVN (with TortoiseSVN on Windows) is very easy to understand and use. Git is overly complex for the simple cases, as it tries to making branching/merging easy.

(A lot of small projects never have to branch if they are managed well. Git is aimed at the complex cases; therefore most Git documentation assumes you need to do complex operations like branching and merging.)

Title: What does SVN do better than Git?


问:
API Development - Sinatra?
I've been tasked to create a mobile application as well as an accompanying website. Both the application and website will interact with the same database. To make things easy, I figure creating an API would be best that way I can separate it out from the mobile application and website.

Would this be the preferable method? I'm thinking Sinatra would be best for this situation. I'm using Ruby on Rails for the website but feel it would be overkill for the API.

I just want to validate my thoughts regarding this issue.

Thanks!

答:
If you're already using Rails, there's isn't much gain in running Sinatra as well. To skip the Rails goodness and get a performance boost, use Metal to serve your API requests.

http://api.rubyonrails.org/classes/ActionController/Metal.html

Benchmark! If you find yourself adding lots of stuff back in just to make it work, you might chew through the performance boost and more.

Title: API Development - Sinatra?


答:
Well, my grandpa could use SVN on his Windows XP computer, but he'd have trouble using Git. Maybe this is more an accomplishment of TortoiseSVN over TortoiseGit, but I think it's rather tied to the fact, that Git is inherently more powerful and thus more complex, and it would be pointless to dumb it down to the same level.

Now it doesn't really matter for my grandpa, because he hasn't done any programming as of late. However, I was once on a team, where our graphic artists were using our source control as well.

And those are people who simply expect their tools to work (so do I, but I have a realistic chance to get them to work in case of failure) and be intuitive. Apart from the fact, that it would had been quite an effort to get them to get along with a DVCS, there was little to be gained. And with only two programmers in the team, it made sense for us to also just stick with SVN.

Title: What does SVN do better than Git?


问:
Using a SDK with crazy code
I recently had to work with an SDK that had a lot of crazy parts*. Not using the SDK was not an option as it had to talk to some third party software.

What is the best way to deal with the crazy code? I genrally used static methods to convert between sensible data types to the format they required (ie bool to yesNo). That method did however lead to lots of calls to very unintuative static methods (which one of the three dateToString methods should be called where?)

Would a better approach be to store almost everything as a string in the database? Or possibly convert each datatype inline so its clear (although with repeated code). Possibly there is some more elegent solution I hadent thought of?

*Certain methods required an enum called yesNo which contained "Yes","y","No" and "n". There were also multiple diffrent formats of string they wanted to represent datetimes used inconsistently. There were also other smaller bits of crazy code.

答: Trying to do the bare minimum to convert data types is just going be more grief.  Write the API as you wish they did, and implement it as a wrapper to theirs.  It's a little more typing up front, but a lot less work overall.</p>

Title: Using a SDK with crazy code


答:
If the size of the API is sufficiently small (i.e. it is either rather small or it is medium-sized, but you'll be using it for years), then you could write a proper wrapper for the API with sensible interface.

I.e. you could write the wrapper in a way that you don't need to call a single method of the original API to use it.

This approach has an additional benefit if you can make your wrapper "biased" (i.e. whenever frobnicating a foo you must frobnicate the associated bar as well) or "convert" between paradigm (for example producing an OO-wrapper around some non-OO-API).

It will involve significant effort, however, so make sure that it'll be worth the time first.

Title: Using a SDK with crazy code

Body:
I recently had to work with an SDK that had a lot of crazy parts*. Not using the SDK was not an option as it had to talk to some third party software.

What is the best way to deal with the crazy code? I genrally used static methods to convert between sensible data types to the format they required (ie bool to yesNo). That method did however lead to lots of calls to very unintuative static methods (which one of the three dateToString methods should be called where?)

Would a better approach be to store almost everything as a string in the database? Or possibly convert each datatype inline so its clear (although with repeated code). Possibly there is some more elegent solution I hadent thought of?

*Certain methods required an enum called yesNo which contained "Yes","y","No" and "n". There were also multiple diffrent formats of string they wanted to represent datetimes used inconsistently. There were also other smaller bits of crazy code.


答: This sounds like an appropriate use of the Adapter pattern. You could pass your "sane data" and make more appropriate methods calls. If you wanted to abstract away some calls to simplify the interface, rather than just transforming it, that would be an appropriate use of the Facade pattern.</p>

Title: Using a SDK with crazy code


答:
I wrote this as a comment on somebody else's answer, but I guess it deserves to be an answer in and of itself.

My company's carefully-chosen configuration for SVN requires file-level locking to edit content, and never ever ever uses merge. As a result, multiple developers contend for locks, and it can be a major bottleneck, and there's never ever any chance of a merge conflict.

SVN definitely does top-down managerial control better than Git. In my skunkworks migration to Git (asking forgiveness rather than permission) I've terrified my manager many times with the notion that there isn't any software-enforced central master controlling server to which we are all slaves.

Title: What does SVN do better than Git?


问:
Working as the sole programmer at a non-tech company
I work as the back-end developer, front-end developer, systems admin, help desk and all-around 'guy who knows computers' at a small marketing company of about 15 people.

I was wondering if others could share their experiences flying solo at companies that aren't necessarily inclined toward the technology industry.

I originally took the job in order to transition from front-end developer/designer to full-time coder. It's been a good experience to a point. I definitely get to occupy the role of 'rock star' programmer - because frankly, no one really understands my job.

Lately, it feels like a very solitary position. I rarely get to bounce ideas off of people, and everyone looks to me like I have magic powers that will make all the computers work and land us first on Google searches. I've also felt a strong disconnect versus between what we say we want (projects with large, months-long development schedules) versus what we actually do (copy-edit our sites over and over).

So who else finds themselves being the 'tech guy' in a company that thinks technology is all a bit magical, and what is your take on your situation?

答:
I have been in this situation most of my career.  Here are the pros and cons as I see it:

Pros

You usually dabble in more than just programming; you also act as a systems analyst, architect, and developer.

More exposure to the actual business, since you really need to know what's going on due to not having an analyst/architect to handle the design work

Cons

You've hit the glass ceiling in almost every instance of this scenario.  Unless you're in a rare company that plans to expand it's IT/Software department, you will never be promoted as there's nothing to be promoted to, and you probably will never get to hire people under you.

Probably overworked, possibly underpaid

Easy to get frustrated due to not having anyone to bounce ideas off of or brainstorm, you basically have to go with your gut instinct or spend a lot of time on sites like this or IRC or whatever talking to your peers.

Ultimately, I would say it's not a good career choice, unless you have a vested interest in the business, if it's a business you want to move into from IT, or if you are close friends/relative to the people running the company.  You will learn a lot about non-software, but your experience is largely discounted because you're always going to have a heap on your plate.  In all but the rarest of experiences, you're never going to be able to improve the company if their setup is bad (i.e. low-quality hardware, bad code/database), and you'll never be able to hire people under you and then become a true manager.

When I worked at a small six-person shop two years ago in exactly this role my title was "Director of IT" but I had no reports and was the sysadmin/developer/DBA all-in-one.  While I learned a bit about dealing with senior management on tech decisions, I was never given the resources to actually do anything (i.e. I had no reports, no budget, and was not authorized to make any decisions), and as such I would be laughed out of any real manager interview I would go for since I wasn't a real manager but an "IT Guy" with a grandiose title.  The stagnation ultimately did more harm than good and I ended up with a fair bit of health-related issues (ulcers) due to the stress of having to manage a dozen or more things on a shoestring budget with zero support or assistance.

Would I do it over again?  Only if I knew the company was solidly behind me taking the reins as an IT Manager, and would give me A) The resources I need to do my job, whether that's a budget for software/hardware, the ability to hire people, or at the least hire good contractors and B) The support to make educated decisions for the company; basically being treated like an executive/manager (because if you are the only IT person, you are essentially the CTO/CIO and are expected to confer almost daily with management about the technology direction of the company) and not like an employee.

Situations like this almost never turn out well unless you find a rare case with business owners who care about growing and want to grow their IT Department.  In a case like that, you are gold if you want to become a manager.  In most cases though you'll just get burned out and have nothing to show for it except a trumped-up title that no true manager will accept as valid.


答:
SVN repositories are more manageable from a manager's and administrator's point of view (ACL + authentication methods + hotcopy + mirrors + dumps)

SVN *-hooks are easier to implement and support

svn:external has more power and flexibility than submodules

Filesystem-based repository trees are easier to use than monolithic repositories with logical-only separation

SVN has more different client-tools

SVN has third-party usable web-frontends, much better than Git's

SVN doesn't break your brain

Title: What does SVN do better than Git?


问:
Is there really a relationship between number of people assigned to a project and the number of defects?
Here is a quote from a training manual at work regarding SLIM and software estimation:

Notice also, there is a correlation between Effort and Defects. This means, the more people there are assigned to a project of a given size, the more Defects there will be.

Effort is person-time (person-years, person-months) for the project. Defects is the count of defects detected at any point in the lifecycle. Size is defined as the use cases, function points, or SLOC that compose the project.

This seems counterintuitive, assuming a good process and capable engineers. For example, having more people means more eyes on all of the artifacts (requirements specs, designs, code, tests). Aside from having more eyes, my intuition suggests that there is little relationship between effort and defects on a project that utilizes appropriate quality techniques.

I haven't been able to find any documents, aside from those about the Putnam Model (which is used by SLIM), that suggest any kind of known relationship between defects and effort or defects and number of people on a project. Is this a known relationship, and is the assertion that "more people = more defects" valid?

答: It could just be a correlation.  Management tends to assign more people to help on projects they deem will be more complex, or projects that are falling behind due to lots of intransigent bugs, or projects that require a lot of coupling between various components.  If you could take management decisions out of the mix, I suspect that correlation would at least diminish, if not reverse.</p>


答:
At work I couldn't switch the developers from SVN to any DVCS for two reasons:

Partial checkouts (like only three folders from different depths in the project tree)

File locking (binary format reports)

Title: What does SVN do better than Git?


问:
Is this a ridiculous way to structure a DB schema, or am I completely missing something?
I have done a fair bit of work with relational databases, and think I understand the basic concepts of good schema design pretty well. I recently was tasked with taking over a project where the DB was designed by a highly-paid consultant. Please let me know if my gut intinct - "WTF??!?" - is warranted, or is this guy such a genius that he's operating out of my realm?

DB in question is an in-house app used to enter requests from employees. Just looking at a small section of it, you have information on the users, and information on the request being made. I would design this like so:

User table:

```<code>UserID (primary Key, indexed, no dupes)
FirstName
LastName
Department
</code>```

Request table

```<code>RequestID (primary Key, indexed, no dupes)
<...> various data fields containing request details
UserID -- foreign key associated with User table
</code>```

Simple, right?

Consultant designed it like this (with sample data):

UsersTable

```<code>UserID  FirstName   LastName
234     John        Doe
516     Jane        Doe
123     Foo         Bar
</code>```

DepartmentsTable

```<code>DepartmentID   Name
1              Sales
2              HR
3              IT
</code>```

UserDepartmentTable

```<code>UserDepartmentID   UserID   Department
1                  234      2
2                  516      2
3                  123      1
</code>```

RequestTable

```<code>RequestID   UserID   <...>
1           516      blah
2           516      blah
3           234      blah
</code>```

The entire database is constructed like this, with every piece of data encapsulated in its own table, with numeric IDs linking everything together. Apparently the consultant had read about OLAP and wanted the 'speed of integer lookups'

He also has a large number of stored procedures to cross reference all of these tables.

Is this valid design for a small to mid-sized SQL DB?

Thanks for comments/answers...

答:
Without full structure of needed information I can't say is it terrible or not. But at least shown piece is not of "WTF" designs. It's just seems as 3-rd Normal Form of data-structure (well, we have theoretically also 4-rd and 5-th also)

Some talks can have place for UserDepartmentTable between two schools of "natural" and "artificial" keys in shown piece. Nothing more, as I can see

Normalization is rule of good DB-developer/designer for a lot of reasons, *de*normalizations are used sometimes in the middle of developments for speed-win mostly


答:
My intuition goes like this:

The more people assigned to a project of given size, the bigger the communication overhead

=> the higher the chances of misunderstandings and all sorts of communication problems

=> the higher the number of resulting defects.

And

Good developers are rarer, thus harder to find and hire, than mediocre / bad ones

=> the more people assigned to a project of given size, the lower their average level of competence

=> the higher the number of resulting defects.

But these may be just my reasoning, I have no supporting evidence.

As a side note, your assumptions emphasized below are IMHO (sadly) quite strong, taking into account the state of our profession:

This seems counterintuitive, assuming a good process and capable engineers. [...] my intuition suggests that there is little relationship between effort and defects on a project that utilizes appropriate quality techniques.

Title: Is there really a relationship between number of people assigned to a project and the number of defects?

Body:
Here is a quote from a training manual at work regarding SLIM and software estimation:

Notice also, there is a correlation between Effort and Defects. This means, the more people there are assigned to a project of a given size, the more Defects there will be.

Effort is person-time (person-years, person-months) for the project. Defects is the count of defects detected at any point in the lifecycle. Size is defined as the use cases, function points, or SLOC that compose the project.

This seems counterintuitive, assuming a good process and capable engineers. For example, having more people means more eyes on all of the artifacts (requirements specs, designs, code, tests). Aside from having more eyes, my intuition suggests that there is little relationship between effort and defects on a project that utilizes appropriate quality techniques.

I haven't been able to find any documents, aside from those about the Putnam Model (which is used by SLIM), that suggest any kind of known relationship between defects and effort or defects and number of people on a project. Is this a known relationship, and is the assertion that "more people = more defects" valid?


答:
This seems counterintuitive, assuming a good process and capable engineers.

I do not think you can assume either of these in the real world. The more people on a project, the more likely you are to have bad apples who cannot keep up and will slow down the best developers. Even if you go with the assumptions there are a few other things that slow down projects and cause more defects as you increase the number of people:

communication overhead

code reading overhead (by this I mean that even the best devs take more time to read and consume other people's code than their own)

testing must be more thorough (We all shoot for 100% test coverage, but that rarely happens in the real world. The more people you put on a project, the scarier refactoring gets without extremely thorough automated testing, since you are just hoping your changes will not have side effects. Not all tests can even be automated in any reasonable manner, which takes even more time.)

In my experience the negative effects of projects loaded up with developers goes way down when the project is very modular and you have just 1 or 2 people per tier. I don't care what version control system you happen to be using, having 4 developers all auto-merging checkins to the same file at once will probably be a bad idea.


问:
JavaScript and the paradigm shift in web programming
If my memory serves me right, there was a time when using JavaScript for web development was hugely frowned upon, because among other things, it was a privacy and security concern for users and some people just had it off.

Nowadays, you can hardly see a major website that doesn't use JavaScript, and many websites will cease to function altogether without JS, graceful degradation be damned. Either that, or usability will be severely impacted, like on SE sites.

What has changed between then and now that made JavaScript practically ubiquitous in web development? Or is my assertion that JS was frowned upon a figment of my imagination and it has always been this way?

答: People invented remotely secure JavaScript sandboxes and learned to implement it more efficiently, along with a general increase in computing power making running it cheaper. Also, the advent of AJAX and stuff makes effects possible with JavaScript that you could never ever see possible with HTML alone- all of the most advanced web features simply require JavaScript. Thus, a website that runs without JavaScript is quite lifeless and inanimate, which is not what consumers want.</p>


答:
I think I see your point, but I suspect that there is also an opposite issue to consider.

Essentially, I believe you are suggesting that, because the UI is the element of the application 'in the face' of the end users, the UI developers enjoy a higher visibility than the team members working in deeper layers of the app.

Certainly I agree that there may be a higher visibility. For instance, developers working on the UI elements may get to interact with the end users more often (arguably, for good reasons, since they do focus on the Human/Computer Interaction aspect).

Yet, I think that the higher visibility comes in play even in cases when there is a problem. For instance, end users are very likely to report issues as 'GUI Issues' even when they are not.

It may all boil down to perception, and a mature organization should be able to recognize values, virtues and weaknesses of the various team members independently from which layer of the app they work on.  A mature organization may also have moved beyond distinctions like 'UI developer' and 'business layer developer', recognizing they are all team members anyway, with different expertise perhaps, but always trying to educate each other on those areas of expertise.

Title: Do GUI programmers have an undue advantage over others?

Body:
It is easy for managers and customers to appreciate what they can see.

I have seen many GUI developers who are average programmers with minimal knowledge of design principles or other programming idioms. However, these shortcomings often go unnoticed, specially by management and customers, if the programmer can create an impressive looking user interface. So much so that many GUI developers I know spend hours beautifying the GUI at the expense of writing bad, unmaintainable code.

On the other hand, middle tier programmers who develop APIs or business functionality or database code (SQLs etc.) are at a disadvantage as there is nothing tangible to showcase. Perhaps a code reviewer or an architect may appreciate the elegance, good design, scalability etc. of code but it means nothing to the outside world. Your code may run for years without breaking, may be very easy to maintain and have good performance, yet it never elicits the 'wow' that a slick looking GUI does.

In my opinion, a corollary to this is (and I am going to get heavily downvoted for this, I know) that there is less motivation for a GUI programmer to write good clean code.

EDIT: I must explain here that by GUI programmer, I don't mean a full-fledged web/GUI designer but a front-end programmer e.g., a java-swing programmer.

Does the rest of the community agree ?


问:
Using Jython and Tomcat in bundle - should we even try to?
Have you ever used Jython in bundle with tomcat in any serious, production-ready service?

What pros and cons can you name?
Is it worth trying if all guys in team has no problems with coding on Java, but know python as well?

答:
The problem with Jython is that it lags behind the latest versions of Python. It's currently at version 2.5, and a lot of good stuff has come in 2.6 and 2.7. I don't know when Jython will get to Python 3.

My recommendation would be to either go all Python, perhaps with Django, or if you want to stay in the Java world, consider Groovy/Grails. Both of these are well-beaten paths, with significant communities to help you when things go wrong.


答:
An interface is like a "purely" abstract class.  The class and all of its methods are abstract.  An abstract class can have implemented methods but the class itself cannot be instantiated (useful for inheritance and following DRY).

For an interface, since there isn't any implementation at all they are useful for their purpose: a contract.  If you implement the Interface then you must   implement the methods in the interface.

So the difference is an abstract class can have implemented methods whereas a interface cannot.

The reason they are separate is so a class can implement several interfaces.  Java and C# restrict a class to inherent from a single parent class. Some languages allow you to inherit from multiple classes and you could accomplish the work of an interface via a "purely" abstract class.  But multiple inheritance has its problems, namely the dreaded Diamond Problem


问:
Why isn't functional programming embraced more widely?

Possible Duplicate:

  Why isn't functional programming more popular in the industry? Does it catch on now?

I've been working as a J2EE developer for the past 3 years and wanted to learn something different, so I started learning about functional programming by going through lots of articles and books (SICP, Paul Graham's essays and other such articles).

I really like the concepts and elegance, but the thing that bothers me is if it's so good why isn't it catching up in the enterprise space? If some of the best people in the software industry (Paul Graham, Peter Norvig) recommend learning it, why aren't enterprises listening them? Several researchers have spent huge amounts of time doing research on FP but it doesn't seem to materialize. I am new to FP so please pardon me if my concerns are naive.

答:
The hardest thing about functional programming is using it. Most of us have been using imperative programming since - well, forever - and FP might be really a hard thing to wrap your head around if you are used to imperative programming.

All imperative languages basically work the same way. To learn a new programming language it's usually a matter of learning the syntax and its built-in libraries. Given a problem, you'll probably already have a way of approaching it, it's just a matter of working out the syntax and minor kinks.

This is not the case with FP. This is nothing like the shift to OOP. Good programmers who didn't know OOP were likely using many OOP concepts already. FP on the other hand is a whole new way to program. Trying to implement relatively simple algorithms requires a new approach. Statelessness can be a bit of b@#%!.

However, multithreaded processors are becoming practically ubiquitous, and thread safety is still a very hard thing to "get it right." FP can gain some ground here with its statelessness, which allows you to be more carefree about thread safety and concurrency.

In short, I'd say the first line of resistance against FP is its difficulty for most programmers. Then, enterprises are usually wary of new and/or unproven technologies. With languages like Java, C and C++ firmly entrenched in the enterprise world, it takes a lot of time for anything new (or perceived to be new) to gain market.

Also, large existing codebases are not likely to be touched. You'd be surprised at how many people still use languages like FORTRAN and COBOL nowadays. Some times the decisions like to use a new language lies with managers that don't have a technical background. Good luck convincing them they should switch to a language most people aren't comfortable with (ie: will likely cost them).


答:
It certainly viable yes, plenty of financials do it (and gain the power of the JVM and all of those lovely Java class libs and other Java based APIs).  As @Eric Wilson mentioned, it does lag behind.

It shouldn't take you too long to prototype this - try giving it a go and see!

Title: Using Jython and Tomcat in bundle - should we even try to?

Body:
Have you ever used Jython in bundle with tomcat in any serious, production-ready service?

What pros and cons can you name?
Is it worth trying if all guys in team has no problems with coding on Java, but know python as well?


答:
There's a difference between correlation and causation; the quote seems to be saying that the total number of defects tends to be higher for projects where larger numbers of engineers are allocated.  This makes perfect sense to me, I am sure MS Windows has more defects than the applications that I create, but that doesn't mean that my applications are superior quality.

To give another, more abstract example - if we took the total number of deaths per country and correlated that with the total number of doctors in the country, I am sure we could say "countries with more doctors had more deaths".  This would not be because the doctors caused the deaths, but rather that large numbers of doctors are indicative of a large population.


答:
Usability. It's not really Subversion's merit but rather TortoiseSVN's.. TortoiseGit exists, but it still has a long way to go to match TortoiseSVN.

If you asked what Git does better than SVN I would reply GitHub. It's funny how third-party tools make such a huge difference.

Title: What does SVN do better than Git?


问:
For what common problems is functional programming not a good fit?
Functional programming is a declarative paradigm. One of the strenghts with FP is that side-effects are avoided. It's said that for some problems FP isn't a good fit.

For what common problems isn't functional programming a good fit?

答:
I'd argue that GUI programming is not a good fit for functional programming. GUIs are generally very stateful, and it's a lot easier to model/manage them using state rather than using a side-effect free. It's certainly possible to use a functional programming language for GUIs...but it's probably not a good idea.

As noted in another answer, games are often easier to manage by tracking state, and while you can write a game in a functional language, it's often easier and more efficient to do so in a "stateful" language (i.e., an object-oriented language).


答:
JavaScript has had both terribly bad and amazing features.

Earlier, when there was no Ajax, masses weren't aware of those amazing features. Web pages were just documents with some design elements (colors, images, textures, fonts, etc.) adorning them. The sense of dynamism and asynchronicity were unknown for the most part. IE 6 was dominant and Microsoft was way too busy selling other things.

...What has changed between then and now that made JavaScript practically ubiquitous...

The inception of Ajax has changed everything. Everybody wanted to make their pages ajaxy and THAT forced them to give a second (and serious) look at JavaScript.

People like Doug Crockford, John Resig, Steve Souders, and others (forgive me if I forget other important names) started spreading the word on the goodness of JavaScript.

About the same time, browser vendors started honing their browsers and making JavaScript performance better. JIT was introduced and that made the competition even more lethal. Microsoft woke up again.

ECMA got serious about JavaScript's future and started working hard on next versions -- which resulted in ECMAScript 5.

HTML5, DOM3, CSS3 all are contributing to JavaScript's increasing reign.

JavaScript has embarked to take on other domains also. Thanks to CommonJS.

Title: JavaScript and the paradigm shift in web programming

Body:
If my memory serves me right, there was a time when using JavaScript for web development was hugely frowned upon, because among other things, it was a privacy and security concern for users and some people just had it off.

Nowadays, you can hardly see a major website that doesn't use JavaScript, and many websites will cease to function altogether without JS, graceful degradation be damned. Either that, or usability will be severely impacted, like on SE sites.

What has changed between then and now that made JavaScript practically ubiquitous in web development? Or is my assertion that JS was frowned upon a figment of my imagination and it has always been this way?


答:
I'd like to add a couple point form notes talking explicitly about some of the potential advantages of using a join table in the fashion that your highly-paid consultant did.

Properly indexed (e.g., if UserDepartmentTable indexes the two foreign keys), there is only a small performance loss of a join table like this due to the foreign keys not being unique. If the foreign keys are guaranteed to be unique, the by the little database theory I know, looking up UserDepartmentTable.Department is no "harder" than looking up any other column in the User table.

The join table gives you more flexibility to set up other information about the association between the user and the department (e.g., timestamps on creation).

The join table allows you to "version" the association fairly easily (e.g., when a user changes departments, trigger some index boolean flag like UserDepartmentTable.Active to false and create a new association that is active). It's also possible to have department association versioning with the two-table model (just User and Department), but it's tougher and necessitates adding at least one more column or doing database acrobatics in order to avoid duplicating primary keys.

It allows you to assign one-to-many or many-to-one or many-to-many associations pretty easily.

That being said, there are several reasons NOT to do what your highly-paid consultant did.

All the above benefits are all anticipatory of possible future needs, overcomplicating things for the present day. It is not YAGNI-compliant. It's of trivial difficulty later to write a migration that moves from your two-table model to a join table model. You can do that when the business need emerges. To do it before that can be confusing.

It confuses other developers. While, yes, I would say the expectation for a web developer of your stature (where you're reviewing consultants' decisions) would be to understand and recognize a join table, it's still more complicated than necessary and considering the lack of business need, it causes confusion.

Title: Is this a ridiculous way to structure a DB schema, or am I completely missing something?

Body:
I have done a fair bit of work with relational databases, and think I understand the basic concepts of good schema design pretty well. I recently was tasked with taking over a project where the DB was designed by a highly-paid consultant. Please let me know if my gut intinct - "WTF??!?" - is warranted, or is this guy such a genius that he's operating out of my realm?

DB in question is an in-house app used to enter requests from employees. Just looking at a small section of it, you have information on the users, and information on the request being made. I would design this like so:

User table:

```<code>UserID (primary Key, indexed, no dupes)
FirstName
LastName
Department
</code>```

Request table

```<code>RequestID (primary Key, indexed, no dupes)
<...> various data fields containing request details
UserID -- foreign key associated with User table
</code>```

Simple, right?

Consultant designed it like this (with sample data):

UsersTable

```<code>UserID  FirstName   LastName
234     John        Doe
516     Jane        Doe
123     Foo         Bar
</code>```

DepartmentsTable

```<code>DepartmentID   Name
1              Sales
2              HR
3              IT
</code>```

UserDepartmentTable

```<code>UserDepartmentID   UserID   Department
1                  234      2
2                  516      2
3                  123      1
</code>```

RequestTable

```<code>RequestID   UserID   <...>
1           516      blah
2           516      blah
3           234      blah
</code>```

The entire database is constructed like this, with every piece of data encapsulated in its own table, with numeric IDs linking everything together. Apparently the consultant had read about OLAP and wanted the 'speed of integer lookups'

He also has a large number of stored procedures to cross reference all of these tables.

Is this valid design for a small to mid-sized SQL DB?

Thanks for comments/answers...


答:
Disclaimer: I love FP. I do it in all programming languages to the extent possible. So this is not a putdown, it's the sad reality I'm fighting all the time:

From a business perspective it's a huge risk: it's not what everyone else is doing. You have a less numerous and competitive talent pool, able to drive wages high.
The benefits in common programming scenarios (anything but big data, really) are not regarded as business value (elegant, readable, maintainable code) even when they should be.

Title: Why isn't functional programming embraced more widely?

Body:
Possible Duplicate:

  Why isn't functional programming more popular in the industry? Does it catch on now?

I've been working as a J2EE developer for the past 3 years and wanted to learn something different, so I started learning about functional programming by going through lots of articles and books (SICP, Paul Graham's essays and other such articles).

I really like the concepts and elegance, but the thing that bothers me is if it's so good why isn't it catching up in the enterprise space? If some of the best people in the software industry (Paul Graham, Peter Norvig) recommend learning it, why aren't enterprises listening them? Several researchers have spent huge amounts of time doing research on FP but it doesn't seem to materialize. I am new to FP so please pardon me if my concerns are naive.


问:
What are good techniques for keeping your place in code?
I understand using bookmarks to remember a single point in your code. However, how does one keep track of the flow of the code they are investigating? Eg: multiple bookmarks and the order in which they were made.

Example:

Bug report: "Collisions aren't working on the corners of walls"

Reproduction of the bug puts it down to certain polygons not colliding.

The collision code was written by an unavailable dev. So investigation goes something like:

During the investigation, especially when reviewing non-code items such as Google, one may reasonably be expected to loose their place in the code (Have I already looked at this code path? or Which code path was I investigating? There are multiple that lead to this function, etc).  The same goes for unavoidable interruptions (Boss: I need [Lengthy Pointless Report] NOW, etc)

It would be useful to have a resource of techniques or tools for providing a way to keep track of one's place in the code.

Edit: The above example is meant as a potential illustration, not as an actual problem that needs answering.

Another way to phrase this question is:

When learning a new system, how do you keep track of where you are up to in learning the code? It's not about understanding why the code does what it does (which is what comments should be for), but how it does it (which is only learned through reading the code, not comments).

答:
Multiple ways that I keep track:

Write it down. Got a meeting in two minutes? Write down what you were doing and where. I always have pen and paper laying next to me to write things down as I code.

Bookmarks. I have 10 numbered bookmarks I can set.

Stacktrace. You can easily view the whole hierarchy of code you went through. My editor also allows me to copy the stack trace and save it. The next time I open my editor I can load the stacktrace for fast navigation.

Editor navigation. Go to base member, go to inheritor, find usages, go to reference,...

OwnerDisplayName: Jess Telford


问:
Premium and opensource
I am thinking about releasing my premium (commercial) project as an opensource project, but I am not sure how the user might benefit, how I will benefit and which license will I use.

I really need to know anything possible about this step...

答:
An important thing to remember is that if none of your users are programmers, and don't want to be programmers, and if they don't have access to/can't pay programmers, then your project isn't going to form any sort of community. Only programmers really care about the source. They're the only ones that can use it.

I've seen non-programmers in the maptool community, gamers, learn how to program just to help out. And that's pretty fantastic. But unless you have some zealous users, I wouldn't count on it.

Of course, it couldn't hurt, but unless you've had excited users asking for improvements or asking for the source, opening it up might not make that big of a splash.

Title: Premium and opensource


问:
How do I convince my employer to hire an additional developer without selling myself short?
I'm the only developer at a small company. I've slowly moved into development here; until ~4 months ago 50-75% of my time was spent on operations. Now, 50-75% of my time is spent on development, with the rest split between operations and various IT stuff. I regularly end up working 50+ hours a week.

I inherited some rather poorly-written applications (they were previously maintained by two people) that much of the business relies upon. Keeping these up and running, working on new, smaller applications, and my other responsibilities already take up all my time.

In order to be scalable, the existing software needs significant refactoring and additional functionality. I haven't had the pleasure to work on properly written or architected software before. The complexity of this task is well beyond anything I've done before (this is my first job out of college.) I know there's a feverish devotion to self-learning/learning by doing among many here, but this is so beyond my expertise that I wouldn't be doing my employer or myself any favors trying to tackle it alone.

I've been very direct about my inexperience, and in the past have mentioned that hiring another, more experienced developer will probably be necessary...if anything, just for the amount of time required for anyone to do the work as we grow and have more software to develop and maintain. I know that I would greatly benefit from hiring another developer; having someone to learn from and bounce ideas off of would be great. StackOverflow is great for determining approaches to individual coding problems or concepts, but is no replacement for discussions on a wider or more significant scale specific to a certain business domain. When mentioning hiring another developer in casual conversation recently, they didn't seem to think it was that important or necessary.

tl;dr: Current patch jobs and other responsibilities already take up all my time at work, work on existing applications that needs to be done is beyond my skillset, little chance of me having any time to work on new products that are being planned. Employer initially seems reluctant about hiring another developer.

How can I "sell" hiring another developer without sounding like I'm lazy or incompetent (I'd like to think I'm neither!)?

edit: Just wanted to clarify that I'm in no way interested in taking any kind of hostile action to prove a point (i.e. taking a vacation to show them they'd be screwed if I wasn't around.) I'm pretty content working here and consider myself to be fairly compensated, even figuring in the overtime, which is why I'm nowhere near considering a new job yet. That said, I accepted the 'no more overtime' answer - even if I don't mind working over too much I'm not doing anyone any favors by doing so (prone to more errors, wear myself out) and it's not really tenable in the short term much less the long term. I'll be stressing this when discussing the matter with my supervisor, and will probably suggest hiring a contractor part-time as an initial approach that's more financially palatable. Thanks for all the great answers.

答:
I suggest you explain them what you are explaining here. Those are valid arguments you should bring to your boss anyway.

Maybe you can suggest hiring a trainee, if they raise economic concerns.