问:
Standard -server to server- and -browser to server- authentication method
I have server with some resources; until now all these resources were requested through a browser by a human user, and the authentication was made with an username/password method, that generates a cookie with a token (to have the session open for some time).

Right now the system requires that other servers make GET requests to this resource server but they have to authenticate to get them. We have been using a list of authorized IPs but having two authentication methods makes the code more complex.

My questions are:

Is there any standard method or pattern to authenticate human users and servers using the same code?

If there is not, are the methods I'm using now the right ones or is there a better / more standard way to accomplish what I need?

Thanks in advance for any suggestion.

答:
Like @Ryanthal have pointed out, impersonate the server (I'll call it consumer-server) is a good shot. For me the method your are using is common, and I'm going to use a very similar one.

A little flow you can use to impersonate your server is:

The consumer-server post to the login page, the user and password (an account specifically created for that server)

The credentials are validated, and it replies with the authentication cookie (you already do that,for the browsers)

The consumer-server inspect the response and sto re the authentication cookie, in it's session/memory

Consumer-server pass the cookie in the following GETs

For a way  of reading/setting the cookie in the consumer-servers take a look here, the cookie is simply a argument passed in the response/request.

Pros:

Unified authentication for both users (browsers) and machines (consumer-servers)

If the server changes it's IP, you don't have to wory about

Easier to constraint the consumer-server permissions, relying on authorization mechanisms

Cons:

You may have to touch the consumer-servers, it may be off hand if you do not control it


问:
Problem Understanding the IEEE definition of Software Engineering
Background

Software engineering is the application of a systematic, disciplined, quantifiable approach to the design, development, operation, and maintenance of software, and the study of these approaches; that is, the application of engineering to software.

My instructor, when explaining this definition has told me that the terms "systematic", "disciplined" and "quantifiable" imply "one after another, structured", "repeatable", and "measurable" among various other possible interpretations. However, it's the second part of the definition that confuses me. When talking about what "operation" implies, he described it this way: "it's the process of maintaining the software, like updating or patching pieces of it. Earlier we used to remove the whole software and change the source, recompile it and install it back. This part of definition is more or less of historical significance - the way engineering was thought of in other disciplines like Mechanical Engineering."

Question

I am really confused about what the definition implies about SE.

If "operation" was just the process of maintaining the software, why include it in the definition independently?

If not, What do the terms "Operation" and "Maintenance" imply in the definition?

Don't maintenance and Operation and everything come under development?
Let's say we are developing an automatic updater component of a software for maintenance, doesn't that mean we are "developing" the "maintenance" part too? Why include the other two in definition then?

Please explain me what SE really means. Thank You!

答:
"Operation" has to do with deploying, configuring, starting/stopping, and monitoring the software.  For example, at my shop, development builds a tarball of the application and stages it to a specific location on the production server.  Another group takes the tarball, expands it into the target directory, sets up Kerberos credentials, adds entries to several databases, etc.  We have several utilities that monitor the applications; one gathers statistics, one issues an alert if an application has gone down, one bounces the app if a connection's been dropped or we need to get a new Kerberos ticket, one archives and rotates log files, one looks for and identifies core files, etc.  There's also a configuration file that can be updated if an IP address or port number changes, or if some application-specific configuration parameter needs to be enabled/disabled, etc.

None of these things involve touching the source code, so it's a separate activity from maintenance and development.  All of these activities have well-defined processes and procedures1 associated with them.

Software Engineering isn't about writing code.  Software Engineering is about developing processes and procedures that make the act of writing and running code more reliable and repeatable.

Edit

Maintenance (at least in my head) encompasses all the non-coding activities involved with managing an application over its lifetime.  This includes (but is not limited to) managing defect and incident reports, deciding which defects are fixed in the next patch, scheduling and staging patches, etc.  Some other examples from my shop are migrating applications from one server to another, migrating a customer from one backend application to another, doing performance and traffic analysis and spawning additional instances to handle increased traffic or minimize response times, etc.

Development (again, in my head, "official" definitions may vary) is anything that touches code, whether it's writing new code from scratch or patching existing code.

1 - Process == what you do, procedure == how you do it.

ContentLicense: CC BY-SA 3.0


问:
What is the best objective way to measure language popularity trends? (What's better than TIOBE?)
The best way to get data on computer language popularity that I know is the TIOBE index.  But everyone knows that TIOBE is hopelessly flawed.  (If someone provides a link to support this, I'll add it here.)

So is there any data on programming language popularity that is generally considered meaningful?  The only other option I know is to look at the trends at indeed.com, which is inherently flawed, being based on job postings.

It isn't like I would make a future language decision solely based on an index, but it might provide a useful balance to the skewed perspective one obtains by talking to ones friends and colleagues.

To illustrate that bias, I'll point out that based on the experience of those I personally know, the only languages used professionally today (in order of popularity) are Java, C#, Groovy, JavaScript, Ruby, Objective C, and Perl.  (Though it is evident that C, C++ and PHP were used in the past.)

So my question is, everyone bashes TIOBE, but is there anything else?  If so, can anyone explain how we know the alternative has better methodology?  Thanks.

答:
Here is one guy who has studied the correlation between number-of-code-repos-on-github.com vs #of-posts-tagged-with-"language" on stackoverflow.com. Data from 2010, ages ago. Long comments thread.

http://www.dataists.com/2010/12/ranking-the-popularity-of-programming-langauges/

Here's another data source, from a job-broker company, url accepts "q" param in query string, outputs a diagram

http://www.indeed.com/jobtrends

http://www.indeed.com/jobtrends?q=perl

ContentLicense: CC BY-SA 2.5


问:
Cost of setInterval in Javascript
I've got some code that I want to run when certain HTML elements are added to the page.

To do this, I have a "runOnRender" function:

```<code>runOnRender: function (func, args, interval) {
            var that = this;
            var guid = hb.getGuid().substr(0,7);

            var checkFunc = function () {
                if (that.$el.height() > 0 && that.$el.width() > 0) {
                    clearInterval(that[guid]);
                    that[guid] = 0;
                    func.call(that, args);
                }
            };

            this[guid] = setInterval(checkFunc, interval || 200);
        }
</code>```

Setting the interval to 200 is about as high as I can go before there is often a noticeable lag in the event firing.  The last thing I want is my users wondering why a button just got clicked or seeing a label text change, etc.

Here's the catch.  It is entirely possible that this "runOnRender" will be set up.....but the User never causes the action that makes the HTML element in question hit the DOM....which means that this code would just keep infinitely running as long as the page is open.

I'm on a nice, powerful, dev machine....so I'm wondering what the cost of this code is and whether there is a better way.

答:
Mostly, don't worry about it, you can run something like several million light lines of code per second. If you spend a few thousand of those doing some check, no worries. The overhead of the interval construction itself should be negligible.

If you want to be sure, put in a loop that runs the body of checkFunc 100 times, check with task manager how much CPU that eats, and verify that the page is still responsive. If that checks out good even a dated smart phone should do the normal job handily.

It is also worth noting that most modern browsers will slow script execution on inactive tabs by only letting them execute code something like once per second, so as soon as the tab is inactive it doesn't matter if you ask for once per 20 or 200 ms, you only get once per 1000 ms anyway, and intervals do not catch up.

Title: Cost of setInterval in Javascript


问:
Use of versioned objects/data to handle program version compatibility?
Is there a common name for the practice of keeping a version number on your data, so that different versions of your program can identify, for example, "current", "legacy", and "too-old-to-deal-with" versions of the same type of object?

As discussed here: Strategy for backwards compatibility of persistent storage.

答:
When used with databases, the term I run into the most is

(Database) Schema Version Number


问:
Low Latency Unix/Linux
Most low latency/high frequency programming jobs (based on job specs) appear to be implemented on unix platforms. In a lot of the specs they make particular request for people with "low latency linux" type of experience.

Assuming this does not mean a real-time linux OS, could people give me help with what this could be referring to? I know you can set CPU affinity to threads, but I am assuming they are asking for much more to it than that.

Kernel tuning? (although I heard manufacturers like solarflare produce kernel bypass network cards anyway)?

What about DMA or possibly shared memory between processes? If people could give me brief ideas I can go and do the research on google.

(This question will probably require somebody familiar with High Frequency Trading)

答:
I've done a fair amount of work supporting HFT groups in IB and Hedge Fund settings.  I'm going to answer from the sysadmin view, but some of this is applicable to programming in such environments as well.

There are a couple of things an employer is usually looking for when they refer to "Low Latency" support.  Some of these are "raw speed" questions (do you know what type of 10g card to buy, and what slot to put it in?), but more of them are about the ways in which a High Frequency Trading environment differs from a traditional Unix environment.  Some examples:

Unix is traditionally tuned to support running a large number of processes without starving any of them for resources, but in an HFT environment, you are likely to want to run one application with an absolute minimum of overhead for context switching, and so on.  As a classic small example, turning on hyperthreading on an Intel CPU allows more processes to run at once -- but has a significant performance impact on the speed at which each individual process is executed.  As a programmer, you're likewise going to have to look at the cost of abstractions like threading and RPC, and figure out where a more monolithic solution -- while less clean -- will avoid overhead.

TCP/IP is typically tuned to prevent connection drops and make efficient use of the bandwidth available.  If your goal is to get the lowest latency possible out of a very fast link -- instead of to get the highest bandwidth possible out of a more constrained link -- you're going to want to adjust the tuning of the network stack.  From a programming side, you'll likewise going to want to look at the available socket options, and figure out which ones have defaults more tuned for bandwidth and reliability than for reducing latency.

As with networking, so with storage -- you're going to want to know how to tell a storage performance problem from an application problem, and learn what patterns of I/O usage are least likely to interfere with your program's performance (as an example, learn where the complexity of using asynchronous IO can pay off for you, and what the downsides are).

Finally, and more painfully:  we Unix admins want as much information on the state of the environments we monitor as possible, so we like to run tools like SNMP agents, active monitoring tools like Nagios, and data gathering tools like sar(1).  In an environment where context switches need to be absolutely minimized and use of disk and network IO tightly controlled, though, we have to find the right tradeoff between the expense of monitoring and the bare-metal performance of the boxes monitored.  Similarly, what techniques are you using that make coding easier but are costing you performance?

Finally, there are other things that just come with time;  tricks and details that you learn with experience.  But these are more specialized (when do I use epoll?  why do two models of HP server with theoretically identical PCIe controllers perform so differently?), more tied to whatever your specific shop is using, and more likely to change from one year to another.

Title: Low Latency Unix/Linux


问:
Machine Learning With Categorical and Continuous Data
This question could go here or on S.O. perhaps...

Suppose that your training dataset contains both categorical and continuous data such as this setup:

```<code> Animal, breed,  sex, age, weight, blood_pressure, annual_cost
 cat,    calico, M,   10,  15    ,   100         , 100
 cat,    tabby,  F,   5,   10    ,   80          , 200
 dog,    beagle, M,   3,   30    ,   90          , 200
 dog,    lab,    F,   8,   75    ,   80          , 100
</code>```

And the dependent variable to be predicted is the annual vet cost. I'm a bit confused as to the specific techniques available to deal with such a dataset. What are the methods commonly used to deal with datasets that are a mixture of both continuous and categorical data?

答:
You should take a look at data pre-processing. It is prior to any machine learning technique. Here is a good introduction (found at Google).

Regarding the techniques, there are lots of different approaches. You can probably use most of them after pre-processing your data. You should try them and pick the one that best fits your needs.


答:
For each class (breed, gender...) of categorical attributes, you can add a number of components to your feature vector equal to the number of possible values in that class. Then, if a data point has the ith value, you set the ith one of those components to 1, and the rest for that attribute to 0.

In your example, for gender, you would add two new components to your feature vector. If the animal is male, you would set the first one to 1 and the second to 0, and vice versa if the animal is female. For animal, if your possibilities were cat, dog, and fish, then you would do the same with three components.

These would coexist side by side with the continuous attributes. You might want to adjust the magnitude of the "indicator value" (the value that you use when an attribute is "on") so that it's comparable to the magnitudes of the continuous values you're using, though.

If you chose this way of going about your problem, the next step would be to pick and algorithm such as a support vector machine and feed it your feature vector. Of course, some approaches like Decision Trees would not need the step I mentioned above to begin with.

Title: Machine Learning With Categorical and Continuous Data

Body:
This question could go here or on S.O. perhaps...

Suppose that your training dataset contains both categorical and continuous data such as this setup:

```<code> Animal, breed,  sex, age, weight, blood_pressure, annual_cost
 cat,    calico, M,   10,  15    ,   100         , 100
 cat,    tabby,  F,   5,   10    ,   80          , 200
 dog,    beagle, M,   3,   30    ,   90          , 200
 dog,    lab,    F,   8,   75    ,   80          , 100
</code>```

And the dependent variable to be predicted is the annual vet cost. I'm a bit confused as to the specific techniques available to deal with such a dataset. What are the methods commonly used to deal with datasets that are a mixture of both continuous and categorical data?


问:
Convert grammar into an LL(1) grammar which recognises the same language
I have the following sample question for a compilers exam and wanted to check my solution.

```<code>Convert the following grammar into an LL(1) grammar which recognises the same
language:

E -> E + T
E -> T
T -> id
T -> id()
T -> id(L)
L -> E;L
L -> E
</code>```

For my answer I have

```<code>E  -> T E'
E' -> + T | ε
T  -> id
T  -> id()
T  -> id(L)
L  -> E L'
L' -> ;E | ε
</code>```

Can anybody verify the answer?

Edit

Ok so would it be similar to...

```<code>E  -> T E'
E' -> + E | ε
T  -> id
T  -> id()
T  -> id(L)
L  -> E L'
L' -> ;E | ε
</code>```

答:
Close, but not quite.

Consider the sentence "a + b + c", where a, b, and c are all ids.

The original grammar recognizes this, courtesy of the E + T recursion.

Your grammar recognizes "a + b", then crashes, because you do not recur.

[added later] Now, consider "a(b;c;d;e)".  Your grammar crashes after "a(b;c", for a similar reason.


问:
What features should be tested via automated UI testing?
We recently had a consultant tell us that if a feature can only be tested via automated UI tests (e.g. Selenium, Coded UI), then there is an underlying architectural issue.  While this statement might be a bit extreme, it is along the same lines of the testing pyramid in that UI tests should make up a small portion of your overall automated test suite.

So, what kinds of features should have automated UI testing?  Will a system with a cogent architecture still have features that can only be verified through UI tests, or should these tests just serve as "back-up" for a suite of unit and service tests?

答:
Presumably you have some sort of architecture that connects buttons and other widgets to actions -- click on save and the save function should be called, etc.

Assuming you have good test coverage of the actions themselves via unit or integration tests, the goal of automated UI testing is to insure that the widgets are all making proper calls to the underlying actions, and correctly displaying the results of those actions.

In other words, they validate that the UI properly reflects the state of the model, and is properly hooked up to the controller.

The other component is when some business logic is in the UI code. For example, maybe you require certain characters in a password field. You need to test those features somehow, since it may be difficult or impossible to do that via unit tests.

ContentLicense: CC BY-SA 4.0


问:
How can I avoid mistakes using the same variable name again?
This isn't a rare case and occurs with me often and I spent countless time trying to debug the code.

Latest example, this PHP code where I used $email for the parameter and for object as well.

```<code>private function _mail( $email )
{
    if( filter_var( $email, FILTER_VALIDATE_EMAIL ) ):
        $email = new Zend_Mail();
        $email->setSubject( $this->request->post('subject') )
            ->setBodyHtml( $this->request->post('message') )
            ->setFrom( $this->request->post('from') )
            ->addTo( $email )
            ->send();
        unset($email);
    endif;
}
</code>```

It was throwing an error, strtr() expects parameter 1 to be an string object given and it was really frustrating to browse through zend libraries to see what obscure string statement was throwing this error.

How to avoid such mistakes?

答:
This isn't a rare case and occurs with me often and I spent countless time trying to debug the code.

Just that much tells me two things:

If it hurts, stop doing it. You say that this problem "occurs with me often," which means that you need to make a greater effort to avoid this kind of problem. Don't try to use two variables with the same name, ever, even when you're sure that it'll work. There are two possibilities: a) you're right and it works, but your code is a lot more difficult to understand than it should be; or b) you're wrong and, well, you've seen what happens when you're wrong.

Learn from experience. If you keep writing the same kind of bug, you should by now be pretty darn good at recognizing the symptoms and finding the problem. Knowing that you have a propensity for creating a certain class of bug, you should constantly be on the lookout for indications that you've done it yet again. Use assertions to check that a variable contains the type of data that you expect. Question your assumptions. Write some unit tests to test individual components.


答:
There is no such thing as a feature that can only be tested via automated UI tests.  Tools like Selenium just mimic the behavior of a human, without boring the human to the point of suicide.  Ask yourself (or your consultant) a question: "How would a program test UI aspects that a person cannot?"  The next question is: "If so, why would you care what they do?"

On the other hand if, you have such a feature, well, yeah, I'd say you have an underlying architectural issue. :-)

Title: What features should be tested via automated UI testing?

Body:
We recently had a consultant tell us that if a feature can only be tested via automated UI tests (e.g. Selenium, Coded UI), then there is an underlying architectural issue.  While this statement might be a bit extreme, it is along the same lines of the testing pyramid in that UI tests should make up a small portion of your overall automated test suite.

So, what kinds of features should have automated UI testing?  Will a system with a cogent architecture still have features that can only be verified through UI tests, or should these tests just serve as "back-up" for a suite of unit and service tests?


答:
What features should be tested via automated UI testing?

All ui features.

You should test:

All functions that users can do.

Functions that users do in all the browsers (and versions of) that they do them in.

Both happy (doing the right thing at every step) vs sad (user makes errors) paths.

Valid and invalid Data.

Large and Small numbers.

All roles and functions roles specific to role.

User and Admin interfaces.

Attempts to break-in.

Creating vs. Updating data works as intended.

Delete's work and delete associated database data in other tables.

Keyboard vs. Mouse style users.

Different devices or simulators of - pc's, phones, ipads, etc.


问:
Should I bother to develop for JavaScript disabled?
Should I bother to develop for JavaScript disabled?

I feel that my time is better spent developing for the majority.

答: Most of the answers here appear to highlight criticisms of standard websites using JavaScript in non-essential or hacky ways. But what about web apps? There are a ton of critical functions that cannot be achieved even remotely as effectively without JavaScript. Even something as simple as a basic word counter under a text area, or enabling/disabling an additional form question based on the answer to another. In this case is it not reasonable to build for the majority and degrade gracefully for the minority? Especially if you know that your user base is non-technical and unlikely to have JS disabled?</p>


问:
Dilemma of QA vs. iterations
In my company, we successfully working with agile practices - but without using iterations. The main reason is that we can't find a clean way to fit in QA in an iteration cycle.

We understand QA as an extra bit of verification to a certain build (release candidate) before this build gets deployed to the customer. The point is to avoid that a single malicious commit damages the whole release. Since you never know which one it is, QA has to wait until all features/commits for the release are in the build. (No famous last words "It was just a tiny change" allowed.)

If QA finds bugs in a release candidate, developers fix these bugs in the respective release branch (and merge it into trunk). When all bugs are fixed, a new build is deployed for QA to re-test. Only when no bugs are found in a certain release candidate, it's offered to the customer for verification.

This usually takes around two to three candidates, about one week, per release. The time to write the fixes is typically much lower than the testing efforts. So in order to keep the developers busy, they work on release N+1 while QA works on N.

Without using iterations, this is no problem because we can overlap the work for releases N and N+1. However, from what I understand, this is not compatible with iteration-based approaches like Scrum or XP. They demand an iteration to be releasable at its end with all testing effort to be incorporated in the iteration.

I find that this necessarily leads to one of the following unwanted results:

(A) Developers are idle at an iteration's end because QA needs time to verify a release candidate and bug fixing work is not fully keeping devs busy.

(B) QA starts working already before first release candidate is ready. This is what is mostly recommended on Stack Exchange. But it's not what my company understands as QA because there is no specific release candidate tested. And the "tiny change" that breaks everything can still be introduced unnoticed.

(C) Bugs are carried over to the next iteration. This is also recommended on Stack Exchange. I don't think it's a solution at all. It basically means that we are never getting a verified build because whenever bug fixes are made, new, unverified commits are added to the same branch as well.

Is there any way out of this dilemma?

答:
The very short-term solution is to give QA an extra period of time after your iteration to finalise testing. ie. If you have a two-week iteration, don't release til week 3. QA are going to have nothing to test towards the next iteration, during the first week of it, anyway.

But I'll warn you up front what will happen (having seen this in several teams): You'll end up in a situation where one iteration you get two week's work done, QA are overloaded, they're coming to you for that whole QA week and, the following iteration, you'll only get one week's work done. That iteration, QA will have nothing to do and you'll think you've solved the problem. But then the next iteration you'll start the cycle again.

So, as soon as you've added that week on, just to make sure your release is stable (cause one thing I've learned is that if you lose the faith of the business, Agile gets exponentially harder to implement), get straight onto the long-term plan.

Buy a copy of Jez Humble's Continuous Delivery, read it, cover-to-cover, pass it around the team. Get everyone inspired. Then implement everything you can from it.

Make the build process slick as you can. Implement a unit-test policy and get those running on every build. Make the deployment process the slickest thing you've ever seen. Three clicks? Not slick enough.

Once you've done all this, it won't matter so much if the occasional regression bug gets through. You know why? Cause you'll be able to (optionally) roll back, fix it, deploy again, before the business falls to pieces. In fact the night janitor will be able to rollback for you, the process will be so simple.

I know what you're thinking: We don't have time to do all that. Let me tell you, you do. If you're overloading QA, you're deploying too much per iteration. So don't. If you're not overloading them already then ask them why they don't have automated test suites yet. You soon will be.

Do all this with full visibility to the business. Estimate lower and inject some of this work into the iteration. Or, better still, break it into stories and get them to prioritise it, alongside everything else.

Explain to them that a) it'll improve the stability of the release and b) it'll improve your ability to respond to problems for them and c) it will buy them more velocity later. It's a rare company that doesn't want these things. It's certainly not an Agile company that doesn't want them so, if you get resistance, you'll know you have a different problem.

Once you've got Continuous Delivery down pat, you can start shortening the time QA get at the end of the iteration. It's in everyone's interest to bring the iterations back in parallel, as soon as possible. Maybe you'll have one day at the end of the iteration, where you need to fill in time. I've already answered what to do about that elsewhere.

Title: Dilemma of QA vs. iterations


答:
For most real life situations agile stops at delivery to QA/UAT or whatever its called.

The effort to move from QA to Production in a real life environment is often underestimated.
In many cases this involves real business users in testing, management sign off from the real line of business managers, scheduling the release with operations etc. etc. This is not trivial!

In extreme cases the software may need certification by outside agencies, or, be subject to rigorous security testing.

In these circumstances it is simply impossible to envisage more than one release per quarter except for bug fixes.

It gets worse for a serious software product. Documentation needs to be proofed and published. Marketing brochures need to be amended. Sales people need to be told what they are selling (no easy task!) etc. etc. You really don't want to put the business through this more than once a year.

Title: Dilemma of QA vs. iterations

Body:
In my company, we successfully working with agile practices - but without using iterations. The main reason is that we can't find a clean way to fit in QA in an iteration cycle.

We understand QA as an extra bit of verification to a certain build (release candidate) before this build gets deployed to the customer. The point is to avoid that a single malicious commit damages the whole release. Since you never know which one it is, QA has to wait until all features/commits for the release are in the build. (No famous last words "It was just a tiny change" allowed.)

If QA finds bugs in a release candidate, developers fix these bugs in the respective release branch (and merge it into trunk). When all bugs are fixed, a new build is deployed for QA to re-test. Only when no bugs are found in a certain release candidate, it's offered to the customer for verification.

This usually takes around two to three candidates, about one week, per release. The time to write the fixes is typically much lower than the testing efforts. So in order to keep the developers busy, they work on release N+1 while QA works on N.

Without using iterations, this is no problem because we can overlap the work for releases N and N+1. However, from what I understand, this is not compatible with iteration-based approaches like Scrum or XP. They demand an iteration to be releasable at its end with all testing effort to be incorporated in the iteration.

I find that this necessarily leads to one of the following unwanted results:

(A) Developers are idle at an iteration's end because QA needs time to verify a release candidate and bug fixing work is not fully keeping devs busy.

(B) QA starts working already before first release candidate is ready. This is what is mostly recommended on Stack Exchange. But it's not what my company understands as QA because there is no specific release candidate tested. And the "tiny change" that breaks everything can still be introduced unnoticed.

(C) Bugs are carried over to the next iteration. This is also recommended on Stack Exchange. I don't think it's a solution at all. It basically means that we are never getting a verified build because whenever bug fixes are made, new, unverified commits are added to the same branch as well.

Is there any way out of this dilemma?


问:
How do you explain the importance of using a [distributed] version control system to someone who's not in the CS field?
A good example of someone who fits that description might be a project manager.

I was asked by my boss the other day, "what this Github thing is and why it's important?"  He has some proprietary projects so he would need private hosting and I found myself struggling to explain beyond the usual: VCSs make collaboration trivial, provide a history and "backup" of all your data, and allow you to record atomic changes in a code base.  In my mind I was thinking, "it's almost as if you have to use a DRVS to really understand how beneficial it is".

I ended up pointing him to BitBucket because they give you unlimited private repositories (I even had to explain what a repository was).

Does anyone have ay really good concrete examples of how a VCS has saved their ass or made life easier, etc -- basically, how would you sell a DVSC to someone who's not unfamiliar with programming, but not a programmer by profession?

答:
When choosing open source software/libraries, having DVCS repository is definitely an advantage in the selection criteria.

1) We can clone the whole repository, don't need to worry about the project or its website is dead.

2) People are more willing to submit bug fix via pull request, result in faster bug fix for urgent issues.


问:
php - auto populate the model member variable from database table
I am stuck with a very old large website which I need to do some modifications. I can't use or integrate a new MVC framework due to current site is outdated with some custom coding done long time ago.

I am writing custom reflection class for the user table in the database, but I find it easy to work on the model creating when the parameter passed or primary key and populated the member variables , then use them in the code. for example

```<code>$user= new User($user_id);
</code>```

and then if I need the age I can use

```<code>if($user->age > 18)
</code>```

To do this you might say it's easy just create a constructor method and do a select and assign them to the member variables .. however tricky part is

I want to

Even the database table design is changed I want them to be reflected in the coding without altering the code, ie. if we add a new field to the database table I want it to be called using  $user->new_field; without touching the code. (I know Yii can do this but I can't use Yii as I have to write all functionality of the website if I have to move to a framework)

if possible assign them to the member variables with the data type i.e Strings, Int etc reading them from the database

How to build a model base on above (actually constructor method)?

答:
Something along the lines of...

```<code>foreach ( $db_rec as $db_field=>$db_val) {
    $this->$db_field = $db_val;
}
</code>```

classes can create their own properties on the fly.

PHP isn't strictly typed. (If memory serves, one can only typecast as arrays and objects anyway) But if you really to determine types from database, I suppose you could pull it out of DESC myTable;

This doesn't smell like a good idea though.

Body:
Something along the lines of...

foreach ( $db_rec as $db_field=>$db_val) {
    $this->$db_field = $db_val;
}

classes can create their own properties on the fly.

PHP isn't strictly typed. (If memory serves, one can only typecast as arrays and objects anyway) But if you really to determine types from database, I suppose you could pull it out of DESC myTable;

This doesn't smell like a good idea though.


问:
How to create Button/Switch-Like Tile where you can step on it and change its value?
If the player steps on a Button-Tile when its true, it becomes false. If the player steps on a Button-Tile when it is false, it becomes true.

The problem is, when the player stands on (intersects) the Button-Tile, it will keep updating the condition. So, from true, it becomes false. Because its false and the player intersects it, it becomes true again. True-false-true-false and so on.

I use ElapsedGameTime to make the updating process slower, and the player can have a chance to change the Button to true or false.

However, it's not the solution I was looking for. Is there any other way to make it keep in False/True condition while the Player is standing on the Button tile?

答:
When the player enters the tile, set an Entered flag for that tile to true. As long as this flag is true, don't update the Button-tile status.

When the player exits the tile, set the Entered flag to false.


问:
Which string search algorithm is actually the fastest?
I have been stuck for some time on which is the fastest string search algorithm, heard many opinions, but in the end I'm not sure.

I have heard some people saying that the fastest algorithm is Boyer-Moore and some saying that   Knuth-Morris-Pratt is actually faster.

I have looked up for the complexity on both of them but they mostly look the same O(n+m). I have found that in the worst case scenario Boyer-Moore has an O(nm) complexity compared to Knuth-Morris-Pratt which has O(m+2*n). Where n=length of text and m=length of pattern.

As far as I know Boyer-Moore has a linear-worst case-time if I would use the Galil Rule.

My question, Over all which is actually the fastest String search algorithm (This question includes all possible sting algorithms not just Boyer-Moore and Knuth-Morris-Pratt).

Edit: Due to this answer

What I'm exactly looking for is:

Given a text T and a pattern P I have to find all the appearances of P in T.

Also the length of P and T are from [1,2 000 000] and the program has to run under 0.15 sec.

I know that KMP and Rabin-Karp are enough to get a 100% score on the problem but I for one wanted to try and implement Boyer-Moore. Which would be best for this type of pattern search?

答:
It depends on the kind of search you want to perform. Each of the algorithms performs particularly well for certain types of a search, but you have not stated the context of your searches.

Here are some typical thoughts on search types:

Boyer-Moore: works by pre-analyzing the pattern and comparing from right-to-left. If a mismatch occurs, the initial analysis is used to determine how far the pattern can be shifted w.r.t. the text being searched. This works particularly well for long search patterns. In particular, it can be sub-linear, as you do not need to read every single character of your text.

Knuth-Morris-Pratt: also pre-analyzes the pattern, but tries to re-use whatever was already matched in the initial part of the pattern to avoid having to rematch that. This can work quite well, if your alphabet is small (f.ex. DNA bases), as you get a higher chance that your search patterns contain reuseable subpatterns.

Aho-Corasick: Needs a lot of preprocessing, but does so for a number of patterns. If you know you will be looking for the same search patterns over and over again, then this is much better than the other, because you need to analyse patterns only once, not once per search.

Hence, as usual in CS, there is no definite answer to the overall best. It is rather a matter of choosing the right tool for the job at hand.

Another note on your worst-case reasoning: Do consider the kinds of searches required to create that worst-case and think thoroughly about whether these are really relevant in your case. For example, the O(mn) worst-case complexity of the Boyer-Moore algorithm stems from a search pattern and a text that each use only one character (like finding aaa in aaaaaaaaaaaaaaaaaaaaa) - do you really need to be fast for searches like that?


问:
Temporary variables vs line length requirements
I've been reading Martin Fowler's Refactoring. It is generally excellent but one of Fowler's recommendations seems to be causing a little trouble.

Fowler recommends that you replace temporary variables with a query, so instead of this:

```<code>double getPrice() {
    final int basePrice = _quantity * _itemPrice;
    final double discountFactor;
    if (basePrice > 1000) discountFactor = 0.95;
    else discountFactor = 0.98;
    return basePrice * discountFactor;
}
</code>```

you pull out into a helper method:

```<code>double basePrice() {
    return _quantity * _itemPrice;
}

double getPrice() {
    final double discountFactor;
    if (basePrice() > 1000) discountFactor = 0.95;
    else discountFactor = 0.98;
    return basePrice() * discountFactor;
}
</code>```

In general I agree except that one reason I use temporary variables is when a line is too long. For example:

```<code>$host = 'https://api.twilio.com';
$uri = "$host/2010-04-01/Accounts/$accountSid/Usage/Records/AllTime";
$response = Api::makeRequest($uri);
</code>```

If I tried inlining that, the line would go longer than 80 characters.

Alternately I end up with chains of code, which are themselves not that much easier to read:

```<code>$params = MustacheOptions::build(self::flattenParams($bagcheck->getParams()));
</code>```

What are some strategies for reconciling the two?

答:
How To

1. Line length restrictions exist so you can see + understand more code.  They are still valid.

2. Emphasize judgement over blind convention.

3. Avoid temp variables unless optimizing for performance.

4. Avoid using deep indentation for alignment in multi-line statements.

5. Break long statements into multiple lines along idea boundaries:

```<code>// prefer this
var distance = Math.Sqrt(
    Math.Pow(point2.GetX() - point1.GetX(), 2) + // x's
    Math.Pow(point2.GetY() - point1.GetY(), 2)   // y's
);

// over this
var distance = Math.Sqrt(Math.Pow(point2.GetX() -
    point1.GetX(), 2) + Math.Pow(point2.GetY() -
    point1.GetY(), 2)); // not even sure if I typed that correctly.
</code>```

Reasoning

The main source of my (debugging) problems with temp variables is that they tend to be mutable.  Namely, I'll assume they are one value when I write the code, but if the function is complex, some other piece of code changes their state halfway through.  (Or the converse, where the state of the variable remains the same but the result of the query has changed).

Consider sticking with queries unless you are optimizing for performance.  This keeps any logic you've used to calculate that value in a single place.

The examples you've given (Java and ...PHP?) both allow for multi-line statements.  If the lines get long, break them up.  The jquery source takes this to extremes.  (The first statement runs to line 69!)  Not that I necessarily agree, but there are other ways to make your code readable than using temp vars.

Some Examples

1. PEP 8 Style Guide for python (not the prettiest example)

2. Paul M Jones on the Pear Style Guide (middle of the road argument)

3. Oracle line length + wrapping conventions (useful stratagems for keeping to 80 chars)

4. MDN Java Practices (emphasizes programmer judgement over convention)

Body:
How To

1. Line length restrictions exist so you can see + understand more code.  They are still valid.

2. Emphasize judgement over blind convention.

3. Avoid temp variables unless optimizing for performance.

4. Avoid using deep indentation for alignment in multi-line statements.

5. Break long statements into multiple lines along idea boundaries:

// prefer this
var distance = Math.Sqrt(
    Math.Pow(point2.GetX() - point1.GetX(), 2) + // x's
    Math.Pow(point2.GetY() - point1.GetY(), 2)   // y's
);

// over this
var distance = Math.Sqrt(Math.Pow(point2.GetX() -
    point1.GetX(), 2) + Math.Pow(point2.GetY() -
    point1.GetY(), 2)); // not even sure if I typed that correctly.

Reasoning

The main source of my (debugging) problems with temp variables is that they tend to be mutable.  Namely, I'll assume they are one value when I write the code, but if the function is complex, some other piece of code changes their state halfway through.  (Or the converse, where the state of the variable remains the same but the result of the query has changed).

Consider sticking with queries unless you are optimizing for performance.  This keeps any logic you've used to calculate that value in a single place.

The examples you've given (Java and ...PHP?) both allow for multi-line statements.  If the lines get long, break them up.  The jquery source takes this to extremes.  (The first statement runs to line 69!)  Not that I necessarily agree, but there are other ways to make your code readable than using temp vars.

Some Examples

1. PEP 8 Style Guide for python (not the prettiest example)

2. Paul M Jones on the Pear Style Guide (middle of the road argument)

3. Oracle line length + wrapping conventions (useful stratagems for keeping to 80 chars)

4. MDN Java Practices (emphasizes programmer judgement over convention)


问:
algorithm for project euler problem no 18
Problem number 18 from Project Euler's site is as follows:

```<code>By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23.

3
7 4
2 4 6
8 5 9 3

That is, 3 + 7 + 4 + 9 = 23.

Find the maximum total from top to bottom of the triangle below:

75
95 64
17 47 82
18 35 87 10
20 04 82 47 65
19 01 23 75 03 34
88 02 77 73 07 63 67
99 65 04 28 06 16 70 92
41 41 26 56 83 40 80 70 33
41 48 72 33 47 32 37 16 94 29
53 71 44 65 25 43 91 52 97 51 14
70 11 33 28 77 73 17 78 39 68 17 57
91 71 52 38 17 14 91 43 58 50 27 29 48
63 66 04 68 89 53 67 30 73 16 69 87 40 31
04 62 98 27 23 09 70 98 73 93 38 53 60 04 23

NOTE: As there are only 16384 routes, it is possible to solve this problem by trying every route. However, Problem 67, is the same challenge with a triangle containing one-hundred rows; it cannot be solved by brute force, and requires a clever method! ;o)
</code>```

The formulation of this problems does not make clear if

the "Traversor" is greedy, meaning that he always choosed the child with be higher value

the maximum of every single walkthrough is asked

The NOTE says, that it is possible to solve this problem by trying every route. This means to me, that is is also possible without!

This leads to my actual question: Assumed that not the greedy one is the max, is there any algorithm that finds the max walkthrough value without trying every route and that doesn't act like the greedy algorithm?

I implemented an algorithm in Java, putting the values first in a node structure, then applying the greedy algorithm. The result, however, is cosidered as wrong by Project Euler.

```<code>sum = 0;

void findWay(Node node){
    sum += node.value;
    if(node.nodeLeft != null && node.nodeRight != null){
            if(node.nodeLeft.value > node.nodeRight.value){
                findWay(node.nodeLeft);
            }else{
                findWay(node.nodeRight);
            }
        }
}
</code>```

答:
Greedy approach is definitely not the approach you should consider for this problem.
Think of a solution that exhaustively checks all possible routes and find the maximum. Then optimize it using Dynamic programming.


问:
I hate one of our coding standards and it drives me insane, how to process it?
Disclaimer: Not as exaggerated as the title suggests, but it still makes me uncomfortable. I'm just going to express honestly, so take it with a grain of salt. Just pretend that I'm talking about that coding standard that you don't like working with.

Edit: The fact that I don't like it, doesn't mean I don't use it or enforce it.

I decided to ask this question in the spirit of how to get over a standard you don't like, not to get help on how to better argue how it can be changed (although any comments regarding this last part is appreciated). Besides, I work in a big company and such a change of something that has lived for so long and that matters so little is unlikely.

The standard is the opening-curly-brace-on-dedicated-line standard:

```<code>somefunction()
{
    //...
}
</code>```

Instead of the *clearly superior* (note the joking/frustrated tone):

```<code>somefunction() {
    //...
}
</code>```

My personal arguments against the standard:

It bloats code: extra unnecessary lines

Harder to type: although probably this is just me struggling with the standard, I know one extra keystroke isn't that bad.

Not easier to read: I start reading a function declaration, if statement, or any other scope-stacking statement and I already don't have to look for an opening brace. Nested blocks with this standard just make me angry for some reason.

Used by people who come from a Microsoft IDE background: I think there should be an argumented reason (or more) behind a standard, not just take it in by paradigm.

Their arguments (and my way of internally retorting to them):

Easier to read because you can see where blocks start and end right away: I cannot understand this, what good is the block if you don't know what it is owned by, so then you have to read backwards.

I used it in a Microsoft IDE and I liked it: Uhh... ok?

It is in the standard: *cringes*

Am I the only one that struggles with an opinionated stance against a specific standard?, how have you gotten over these?, what is your opinion on what this particular standard should be (just for fun)?

答: Some people like it your way and other people don't. Either way someone is going to be annoyed. It is just your turn this time. Suck it up and get on with the job.</p>


问:
algorithm to print the digits in the correct order
I've been trying to write an algorithm that will print separately the digits from an integer. I have to write it in Pseudocode. I know how to write an algorithm that reverse the digits.

```<code>digi(n):
  while n != 0:
    x = n % 10
    n = n // 10
    print (x)
</code>```

But I don't know how to write an algorithm to print the digits in the correct order. For example, the input is integer 123467 and the output is: 1 2 3 4 6 7. The numbers will be input from the user, and we cannot convert them to a string. I need help getting started on writing algorithms.

答:
Recursive method</p>

```<code>function print_straightforward
if(N<10)
  print N
else
  print_straightforward(N/10);
  print N%10
</code>```

Body:
Recursive method

function print_straightforward
if(N<10)
  print N
else
  print_straightforward(N/10);
  print N%10


答:
Is the team's standard documented?  If it is, are there any reasons in the style guide? Honestly, I've had to suck it up a ton of times and get real work done.  There are worse problems to have, but I feel you — it still rankled (I agree with you on the style, by the way).

What helped me get through it:

Realized that there are real benefits to a single style (no matter what it is). Or at least a bunch of people think so.

Exactly what you just did, write out why it feels wrong, so you can posit the argument well in the future.

Use a styling tool for god's sake, it will save your sanity.  Resharper, CodeMaid, StyleCop, JSLint, CheckStyle, etc. ... even Visual Studio will do it for you.

Kick ass on this project and be ready for the next when you can set the standards.

Title: I hate one of our coding standards and it drives me insane, how to process it?

Body:
Disclaimer: Not as exaggerated as the title suggests, but it still makes me uncomfortable. I'm just going to express honestly, so take it with a grain of salt. Just pretend that I'm talking about that coding standard that you don't like working with.

Edit: The fact that I don't like it, doesn't mean I don't use it or enforce it.

I decided to ask this question in the spirit of how to get over a standard you don't like, not to get help on how to better argue how it can be changed (although any comments regarding this last part is appreciated). Besides, I work in a big company and such a change of something that has lived for so long and that matters so little is unlikely.

The standard is the opening-curly-brace-on-dedicated-line standard:

```<code>somefunction()
{
    //...
}
</code>```

Instead of the *clearly superior* (note the joking/frustrated tone):

```<code>somefunction() {
    //...
}
</code>```

My personal arguments against the standard:

It bloats code: extra unnecessary lines

Harder to type: although probably this is just me struggling with the standard, I know one extra keystroke isn't that bad.

Not easier to read: I start reading a function declaration, if statement, or any other scope-stacking statement and I already don't have to look for an opening brace. Nested blocks with this standard just make me angry for some reason.

Used by people who come from a Microsoft IDE background: I think there should be an argumented reason (or more) behind a standard, not just take it in by paradigm.

Their arguments (and my way of internally retorting to them):

Easier to read because you can see where blocks start and end right away: I cannot understand this, what good is the block if you don't know what it is owned by, so then you have to read backwards.

I used it in a Microsoft IDE and I liked it: Uhh... ok?

It is in the standard: *cringes*

Am I the only one that struggles with an opinionated stance against a specific standard?, how have you gotten over these?, what is your opinion on what this particular standard should be (just for fun)?


答:
Think back to a time when you were sure that you were right about something and over a period of time realized that you were wrong, or at least that you were overreacting all those years ago.  Consider the possibility that you might be wrong again, and give the new coding standard or process time to convince you.

My own standards rage when I was fairly new to coding (say five years into my career) was whether multiword identifiers should be WrittenLikeThis or written_like_this.  I won't even say which one I lked, but the point is that after some time I changed sides and after some more time I didn't care either way.


答:
The standard difference you're describing with the curly braces is largely arbitrary. Both ways are equally good ways and for a company, as long as everyone does it the same it's all good.

The "clearly superior" you're are talking about is the kind of superior that people talk about when they talk about things "they're used to".

You'll get used to it soon enough and in a year or so, the other way will be "clearly superior".

So in short: deal with it.


问:
Pair programming when driver and observer have different skill level and experience
I know pair programming is an agile software development technique in which two programmers work together at one workstation. One, the driver, writes code while the other, the observer, reviews each line of code as it is typed in.

But I just wonder the strategy still work in the case. For example

if they have a very different programming skill level.

if one never experience in the problem domain while another have.

Is it still OK if they have low programming skill level?

Could you suggest the pair programming strategy in the case above?

答:
I'll describe my experience and try to get some "strategy" out of it.

I've once pair-programmed with a complete non-programmer. He was expert on the subject matter of the software product we developed. On the contrary, I had no experience in the problem domain. And he also was my supervisor at the moment (I know this may sound strange :)

Major benefit of this methodology was that I had to explain implementation of many things from his knowledge domain, thus ensuring the exactness of implementation and his understanding of the process, which meant he understood why it took this time.

Another benefit is easy focus on the task, no distractions (ha-ha, imagine opening Twitter before the nose of your boss).

It was quite intimidating at times, however, since even a tea break became quite a "distraction from work" (not from his point of view; it was just inconvenient to ask for break and so on).

So, this isn't really a pair-programming since he pretty much couldn't review the code as it was typed in. However, it seemed to be a sane strategy (at least for some time). It ultimately worked at all because of relative simplicity of both development methodology (I mean, no complex software design techniques like OOP Patterns were involved) and subject matter. This would't work in case we had to develop a compiler I think. I believe it still could work in case non-programmer observer is participating in the process of development of small clearly defined pieces. Say, it's ok to have him watch programming of a function "compute the parameter X from Y and Z by given algorithm", but may be not so ok to have him watch overall system design process (meaning development of software architecture, i.e. hierarchy of classes, since it's too abstract).

I think it would work even better in case he would have some basic programmer skills, as I would't have to explain "what's an array is".

Hope it helps :)


问:
How to increase the efficiency of an Immutable Queue in java?
I have been developing an Immutable queue in java, but the version I have developed is supposedly slow and I have been suggested to create a faster version of the same and I have no idea as to how to accomplish that.

```<code>import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;
public class ImmutableQueueImpl<E> implements ImmutableQueue<E>
{

    private List<E> queue;
    public ImmutableQueueImpl()
    {
       queue=new ArrayList<E>();
    }

    public ImmutableQueueImpl(List<E> queue)
    {
       this.queue=queue;
    }

    public ImmutableQueue<E> enqueue(E e)
    {
            if(e==null) throw new IllegalArgumentException();
            List<E> clone = new ArrayList<E>(queue);
            clone.add(e);
            return new ImmutableQueueImpl<E>(clone);
    }

    public ImmutableQueue<E> dequeue()
    {
            if(queue.isEmpty())
            {
              throw new NoSuchElementException();
            }
            List<E> clone = new ArrayList<E>(queue);
            clone.remove(0);
            return new ImmutableQueueImpl<E>(clone);
    }

    public E peek()
    {
            if(queue.isEmpty()) throw new NoSuchElementException();
            return queue.get(0);
    }

public int size()
{
    return queue.size();
}
}
</code>```

Please suggest any improvements in the implementation or the libraries used .

We remove elements from immutable lists all the time and dequeue is just a special case of that. The point is that the result is not really the element, but another immutable list without it. The point of this design is mutation safety and way better in parallelized settings than mutable data structures.

答:
You should read up on structure sharing for immutable datatypes. Obviously, when your enqueue involves creating a complete clone of that list, then your enqueue is O(n). The whole idea of structure sharing is that you return a new object, that in some way reuses the original object such as to avoid this duplication.

For your queue implementation in particular, you cannot simply rely on a mutable Java ArrayList. Take a look at some functional language and cons-cells for constructing immutable list datastructures. They allow you to simply keep track of start and end elements of your queue and derive a new queue object by reusing all cons-cells and simply adding a new one. The new object reuses the original cons-cells, but has a different end-pointer to the newly added cons cell.

Long story short: When writing immutable datastructures avoid copies and share structures instead.

In response to the comment about Java: All of this is language-agnostic. It is just that functional languages have been working with immutable datastructures for decades, whereas it is a relatively recent trend to add immutability to OO languages. All of this structure sharing, cons-cells, etc. is implementable in any programming language (well, Turing-complete that is).


答:
Just go ahead and use the style you want. Then use some code beautifier to change the code in standard format, or right your own small application which will convert the code from your style to the given standard style. Use the beautifier before checking in the code.

You can also do the reverse to change the checked in code from the standard format to your format, when you are working on it.


答:
The superiority of one convention over the other is *clearly arbitrary*.

The readability issues you face, or your team mates would face with your standard, are only a psychological resistance to change.

The objective readability argument is in favour of *consistency* over the whole code base.


答:
This particular subject amounts to a Religious War between those who prefer one style over the other. Very few people are ambivalent...

Ultimately, neither is right and neither is wrong.

Style guides and coding standards exist for a number of reasons - and one key aspect is to ensure uniformity of layout, which aims to reduce the number of obvious errors, and improve maintainability.

Am I the only one that struggles with an opinionated stance against a
  specific standard?

The short answer is "No" you are not the only one.  But there are more important things to worry about.  Even in standards that one has input to, there will always be compromise - witness some of the aspects that have made it into C99 and C12 that make no sense to me.

Even MISRA-C (which I have direct influence over) contains items that personally I don't agree with - but I can understand why others feel the justification for.

how have you gotten over these?

And that therein lies the answer - rather than focus on why you don't personally like it, try and understand why the person/people who agreed it did so.

Rules are usually introduced (in a closing stable door after horse has bolted kind of way) to address a previous problem.  And if the rule is still nonsensical, talk to the standard owner and try and "educate" them.


答:
Your particular example is unfortunate as it is one that some will agree with and some won't. I disagree with your arguments against for example and I am sure so will many others, just as I am sure many others will agree with them. It nearly makes me think the question should be closed as it is so subjective.

However the question on how to deal with a standard you don't agree with is possible more answerable. I think the answer is that where styling guidelines exist and are agreed and have been used then the answer is just to grin, bear it and just deal with it. Consider that having consistency is more important. If the guideline is inaccurate or wrong there can be an argument for change but this is stylistic so there is no argument really apart from personal preference.

I came from a Java background originally so followed the standard you mentioned. I then moved to more C++ and C# where the style you hate is used. But it has no right or wrong answer. What is more important is having a standard followed by everyone. If a coding standard is stylistic like this and isn't clearly wrong then trying to argue it will just cause friction in the team.


答:
If you want to get over this — there was a quote by Torvalds:

Bad programmers worry about the code. Good programmers worry about data structures and their relationships.

Now consider, where does it put programmers who worry about such a minor thing like bracing style enforced by their code standard? Is your codebase otherwise so pristine that bracing is the only issue worth the time to argue about?


问:
What does this mean: Expression<Func<TModel, TValue>>
In ASP.Net MVC, in the razor view, you can type this kind of code:

```<code>@Html.EditorFor(model => model.Name)
</code>```

(in this case, it creates a textbox for the field Name of the object which is defined as the type of the model)

Now when i see the definition of the EditorFor method, it is this:

```<code>EditorFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression);
</code>```

So i tried implementing that kind of method myself, but i realy don't see what this means
Expression<Func<TModel, TValue>>

Who can explain to me what an expression is, and the Func, and the Expression of type Func?

The explanations i found where all so abstract it didn't give me a clue....

答:
The Expression<T> class:

Represents a strongly typed lambda expression as a data structure in the form of an expression tree.

And:

The System.Linq.Expressions namespace contains classes, interfaces and enumerations that enable language-level code expressions to be represented as objects in the form of expression trees.

The abstract class Expression provides the root of a class hierarchy used to model expression trees.

The classes in this namespace that derive from Expression, for example MemberExpression and ParameterExpression, are used to represent nodes in an expression tree. The Expression class contains static (Shared in Visual Basic) factory methods to create expression tree nodes of the various types.

The enumeration type ExpressionType specifies the unique node types.

The Func<TResult> (and family) of delegates:

You can use this delegate to represent a method that can be passed as a parameter without explicitly declaring a custom delegate. The encapsulated method must correspond to the method signature that is defined by this delegate.

The family basically encapsulates delegates for functions that have a return value.

Taken together, these are expressions that take func delegates typed take a parameter of the model type and return whatever value the lambda returns.


答:
I think you just need to get on with it. I will try to address your notes with my own opinions:

Bloats Code

One extra line of code is not bloating code at all, unless you are writing 100's of methods in a single class, that will add hundreds of extra lines.  Then again if you have hundreds of methods in a single class you have another problem altogether.

Harder to Type

I can't disagree with you any more about this, you have to press the return key to get to the next line anyway. What about it is harder to type?

Harder to read

I feel like each line in a piece of code should have a specific function. Following this you would need to define the method name in one line, then the open and close braces on their own separate lines.

Used by people who come from a MS IDE background

Uhh.....ok?

In summary it seems like you are nitpicking about being a .Net developer as opposed to any other type of developer as if its inferior because they used an IDE which defaults to this standard.


答:
Live with it.

This is clearly cosmetics and does not change anything about the quality of the code or your productivity as a developer. Nothing worth starting an argument over.

For that kind of coding standard, I'd pick consistency across the code base and readability over any particular (even well-reasoned) "religious" approach any day.

Thinking of it as a democratic decision of a majority of the team members about a not-so-important problem may help you get over it.


答:
Am I the only one that struggles with an opinionated stance against a specific standard?

Of course not. Meetings to determine coding standards are horrible! They drag on for hours and participants become personally invested in getting their own favorite (and invariably wrong, except for mine) idiosyncrasies enshrined in the standard. By the end, nobody is happy with the result. If anything can be worse than the coding standards meeting, it's the formal code review meetings in the several months that follow the determination of the standard: some people try to adopt the standard, while others (intentionally or not) ignore it, and you get hours of feedback like: On lines 132, 142, 145, 181, 195, and 221 of SillyFileConverter.cpp you put the opening brace on the same line when the coding standard clearly says that it should be on the following line!

how have you gotten over these?

In their own way, the meetings help. Even if you sympathize entirely with the guy who left the opening brace on the same line as the conditional, or whatever, you will nevertheless become annoyed at him for wasting your time by not just sucking it up and following the stupid standard. If the guy is a curmudgeon and does the same thing over and over again, it becomes even more annoying. Being annoyed at that behavior makes it that much easier to justify writing in a style that's a little different from what you'd prefer -- you certainly don't want to be that guy, after all.

Even if you're not subjected to interminable formal code reviews, you can try to review your own code specifically for compliance with the standard. It doesn't matter what you think of the standard, you're just comparing what you've written to what the standard says. If you ding yourself every time you fail to comply, that may provide some of the negative feedback that you need to help you adopt the standard.


答:
Expression is a class that enables you to take a lambda expression and transform it into a syntax tree. It is used by Linq (for example) to convert Linq queries into actual SQL queries. It is highly extensible so you could do other things with it.

http://msdn.microsoft.com/en-us/library/bb335710(v=vs.90).aspx

Have a look at http://en.wikipedia.org/wiki/Abstract_syntax_tree if you aren't familiar with AST's.

Title: What does this mean: Expression<Func<TModel, TValue>>

Body:
In ASP.Net MVC, in the razor view, you can type this kind of code:

```<code>@Html.EditorFor(model => model.Name)
</code>```

(in this case, it creates a textbox for the field Name of the object which is defined as the type of the model)

Now when i see the definition of the EditorFor method, it is this:

```<code>EditorFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression);
</code>```

So i tried implementing that kind of method myself, but i realy don't see what this means
Expression<Func<TModel, TValue>>

Who can explain to me what an expression is, and the Func, and the Expression of type Func?

The explanations i found where all so abstract it didn't give me a clue....


问:
How do you interview someone with more experience than you?
The company I'm working for is looking to hire a senior developer with more experience than me, and they expect me to do the technical part of the interview. I've only been programming a few years and am not sure I have the knowledge needed to evaluate the coding skills of someone who has greater understanding/experience than I do.

Can anyone recommend some technical interview questions to ask that are a good means for evaluating higher-level programming skills, but still be ones I can understand?

I would say I'm past the jr. programmer level, but nowhere near senior. Most of what I've done is built small apps (web and desktop), some of them fairly complicated, but all of them have been meant to be used by no more then a handful of users. I feel I have a decent understanding of most programming concepts and am capable of learning/teaching myself just about anything, however I lack experience. As my boss is fond of telling me, "You don't know what you don't know".

In particular, things we'd like the person we hire to have experience with (that I don't have) is: Multi-tier development, multi-user environment, large-scale application development, two-way messaging, shared sessions, and Multi-threading/BackgroundWorkers.

UPDATE:

In response to Thor's comment below, we hired someone a few months ago and I think it has been working out great. I am learning a lot, not just about coding but also about things like design patterns, software architecture, documentation, and how other larger programming teams get stuff done. Its not always easy having someone come in and point out better ways to do things you have done, but if you can swallow your pride and be willing to try out new things you can learn a lot.

The interview process went better than I expected. I started asking questions about things I was familiar with, then asked some questions about some things I was struggling with. Whenever the interviewee said something I didn't understand, I'd ask them to explain it to me and then write it down so I could look it up later on. Overall, I felt I was able to get a pretty good idea of the applicant's skill level, intelligence, and what they'd be like to work with.

答:
Remember that just because they have more experience than you, they may not be be a better developer than you. The phrase "One year of experience repeated n times." comes up because you do see this happen in industry. Thus, your first task during the interview should be to establish that they do indeed have the relevant experience and can present themselves as someone one that knows what they are doing. Likewise, just because someone has had n years of experience in industry, it doesn't mean they have a ton of experience in a given language, library, or framework so they might still come to you from time to time asking questions while they are learning something.

Next, remember that a good senior developer is someone that you should be able to approach and asking about something that you have having problems with. This is a good time to asking them some design questions that you have had problems and see how they response and what their reasoning is in their explanation. Have they seen something similar before somewhere else, are they making an educated guess based upon experience, did they read an article online or in a journal?

Finally, another thing to look at is how they approach debugging code. In my own experience, I have found that regardless of the language, certain debugging techniques tend to be applied universality. Given the candidate an example of one of the more esoteric bugs you have encountered and have them walk you through how they would approach the bug. Do they have some insight into the problem that is not immediately obvious?

In summary, interviewing a candidate with an impressive interview can be intimidating, but there are something that you need to cover regardless of what level they will be (i.e. do they actually know what they are doing) and once that is complete you can start probing them to see how they are applying their experience. How the candidates are applying their previous work experience is going to be what is going to make one candidate standout more than another.


答:
This is an untested sketch of the usual functional implementation. First you need immutable Lists:

```<code>import java.util.Iterator;
import java.util.NoSuchElementException;

public class ImmutableList<T> implements Iterable<T> {
    @SuppressWarnings("unchecked")
    private final static ImmutableList NIL = new ImmutableList(null, null);

    public final T head;
    public final ImmutableList<T> tail;

    public ImmutableList(T head, ImmutableList<T> tail) {
        this.head = head;
        this.tail = tail;
    }

    public ImmutableList<T> add(T t) {
        return new ImmutableList<T>(t, this);
    }

    public boolean isEmpty() {
        return this == NIL;
    }

    public ImmutableList<T> reverse() {
        ImmutableList<T> result = nil();
        for (T t : this) {
            result = result.add(t);
        }
        return result;
    }

    @SuppressWarnings("unchecked")
    public static <T> ImmutableList<T> nil() {
        return NIL;
    }

    @Override
    public Iterator<T> iterator() {
        return new Iterator<T>() {
            private ImmutableList<T> list = ImmutableList.this;

            @Override
            public boolean hasNext() {
                return !list.isEmpty();
            }

            @Override
            public T next() {
                if (!hasNext()) throw new NoSuchElementException();
                T t = list.head;
                list = list.tail;
                return t;
            }

            @Override
            public void remove() {
                throw new UnsupportedOperationException();
            }
        };
    }
}
</code>```

Then you take two lists. The front one is for enqueueing items, the back one is for dequeueing. If the back one gets empty, the reversed front becomes the new back.

```<code>import java.util.NoSuchElementException;

public class ImmutableQueue<T> {

    private final ImmutableList<T> front;
    private final ImmutableList<T> back;

    private ImmutableQueue(ImmutableList<T> front, ImmutableList<T> back) {
        this.front = front;
        this.back = back;
    }

    public static <T> ImmutableQueue<T> empty() {
        return new ImmutableQueue<T>(ImmutableList.<T>nil(), ImmutableList.<T>nil());
    }

    public boolean isEmpty() {
        return front.isEmpty() && back.isEmpty();
    }

    public ImmutableQueue<T> enqueue(T t) {
        return new ImmutableQueue<T>(front.add(t), back);
    }

    public DequeueResult<T> dequeue(T t) {
        if (isEmpty()) throw new NoSuchElementException();
        if (back.isEmpty()) {
            ImmutableList<T> tnorf = front.reverse();
            return new DequeueResult<T>(tnorf.head, new ImmutableQueue<T>(ImmutableList.<T>nil(), tnorf.tail));
        } else {
           return new DequeueResult<T>(back.head, new ImmutableQueue<T>(front, back.tail));
        }
    }

    //Sorry, no tuples in Java land...
    public static class DequeueResult<T> {
        public final T t;
        public final ImmutableQueue<T> queue;

        public DequeueResult(T t, ImmutableQueue<T> queue) {
            this.t = t;
            this.queue = queue;
        }
    }
}
</code>```

AFAIK you can't get it much faster with immutable data structures.

Title: How to increase the efficiency of an Immutable Queue in java?

Body:
I have been developing an Immutable queue in java, but the version I have developed is supposedly slow and I have been suggested to create a faster version of the same and I have no idea as to how to accomplish that.

```<code>import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;
public class ImmutableQueueImpl<E> implements ImmutableQueue<E>
{

    private List<E> queue;
    public ImmutableQueueImpl()
    {
       queue=new ArrayList<E>();
    }

    public ImmutableQueueImpl(List<E> queue)
    {
       this.queue=queue;
    }

    public ImmutableQueue<E> enqueue(E e)
    {
            if(e==null) throw new IllegalArgumentException();
            List<E> clone = new ArrayList<E>(queue);
            clone.add(e);
            return new ImmutableQueueImpl<E>(clone);
    }

    public ImmutableQueue<E> dequeue()
    {
            if(queue.isEmpty())
            {
              throw new NoSuchElementException();
            }
            List<E> clone = new ArrayList<E>(queue);
            clone.remove(0);
            return new ImmutableQueueImpl<E>(clone);
    }

    public E peek()
    {
            if(queue.isEmpty()) throw new NoSuchElementException();
            return queue.get(0);
    }

public int size()
{
    return queue.size();
}
}
</code>```

Please suggest any improvements in the implementation or the libraries used .

We remove elements from immutable lists all the time and dequeue is just a special case of that. The point is that the result is not really the element, but another immutable list without it. The point of this design is mutation safety and way better in parallelized settings than mutable data structures.

Body:
This is an untested sketch of the usual functional implementation. First you need immutable Lists:

import java.util.Iterator;
import java.util.NoSuchElementException;

public class ImmutableList<T> implements Iterable<T> {
    @SuppressWarnings("unchecked")
    private final static ImmutableList NIL = new ImmutableList(null, null);

    public final T head;
    public final ImmutableList<T> tail;

    public ImmutableList(T head, ImmutableList<T> tail) {
        this.head = head;
        this.tail = tail;
    }

    public ImmutableList<T> add(T t) {
        return new ImmutableList<T>(t, this);
    }

    public boolean isEmpty() {
        return this == NIL;
    }

    public ImmutableList<T> reverse() {
        ImmutableList<T> result = nil();
        for (T t : this) {
            result = result.add(t);
        }
        return result;
    }

    @SuppressWarnings("unchecked")
    public static <T> ImmutableList<T> nil() {
        return NIL;
    }

    @Override
    public Iterator<T> iterator() {
        return new Iterator<T>() {
            private ImmutableList<T> list = ImmutableList.this;

            @Override
            public boolean hasNext() {
                return !list.isEmpty();
            }

            @Override
            public T next() {
                if (!hasNext()) throw new NoSuchElementException();
                T t = list.head;
                list = list.tail;
                return t;
            }

            @Override
            public void remove() {
                throw new UnsupportedOperationException();
            }
        };
    }
}

Then you take two lists. The front one is for enqueueing items, the back one is for dequeueing. If the back one gets empty, the reversed front becomes the new back.

import java.util.NoSuchElementException;

public class ImmutableQueue<T> {

    private final ImmutableList<T> front;
    private final ImmutableList<T> back;

    private ImmutableQueue(ImmutableList<T> front, ImmutableList<T> back) {
        this.front = front;
        this.back = back;
    }

    public static <T> ImmutableQueue<T> empty() {
        return new ImmutableQueue<T>(ImmutableList.<T>nil(), ImmutableList.<T>nil());
    }

    public boolean isEmpty() {
        return front.isEmpty() && back.isEmpty();
    }

    public ImmutableQueue<T> enqueue(T t) {
        return new ImmutableQueue<T>(front.add(t), back);
    }

    public DequeueResult<T> dequeue(T t) {
        if (isEmpty()) throw new NoSuchElementException();
        if (back.isEmpty()) {
            ImmutableList<T> tnorf = front.reverse();
            return new DequeueResult<T>(tnorf.head, new ImmutableQueue<T>(ImmutableList.<T>nil(), tnorf.tail));
        } else {
           return new DequeueResult<T>(back.head, new ImmutableQueue<T>(front, back.tail));
        }
    }

    //Sorry, no tuples in Java land...
    public static class DequeueResult<T> {
        public final T t;
        public final ImmutableQueue<T> queue;

        public DequeueResult(T t, ImmutableQueue<T> queue) {
            this.t = t;
            this.queue = queue;
        }
    }
}

AFAIK you can't get it much faster with immutable data structures.


答:
Without using iterations, this is no problem because we can overlap the work for releases N and N+1.

There seem to be a problem with the way how you decided on what exactly constitutes work for release N.

For some strange reason (I can only guess there's some misunderstanding of particular Agile recipes) you somehow decided that agile approach mandates all QA team efforts to be incorporated in the iteration.

If that would be really the case, I suppose Agile popularity wouldn't be even close to what we see now. I can not imagine many projects that could "survive" mandatory syncing of dev team  iterations with QA test cycles.

There's a bit more on agility below but first, let's sort out work for release N...

Look, there is just no compelling reason for development team to define work that way. Quite the opposite, from your description it is clear that instead of monolithic "unit of work", there are several such units, with milestones that are easy to feel...

Eg, first "unit" is indicated by distinct milestone when candidate build is passed to testers, and further milestones correspond to changes involved in test cycles performed by QA etc.

Note also that the way you define  work for release N is not forced by QA work flow either. From what you describe things looks like they have their own (and pretty reasonable) schedule.

Given above, more realistic way to define work units in your case could be like as follows:

Development activities up to the moment the build is passed to QA

Release Candidate N

Development activities related to first QA test cycle

Release Candidate N patch 1

Development activities related to second QA test cycle

Release Candidate N patch 2

etc, until the final build

Above are your work units, no matter if you do Agile or whatever.

These are natural and convenient to define, follow and track. This also blends well with QA schedule, allowing for a convenient coordination odf dev and QA efforts.

However, from what I understand, this is not compatible with iteration-based approaches like Scrum or XP. They demand an iteration to be releasable at its end with all testing effort to be incorporated in the iteration.

Above understanding of compatibility with Agile looks fundamentally wrong and here is why...

Assumption you made has nothing to do with Agile, if we take its philosophy at the face value as indicated by its very name, that is an approach that favors and practices agility.

From that perspective, sticking with particular "fixed" workflow and ignoring whether it is convenient or not simply contradicts the spirit of Agile. Slavishly following the "procedure" leads to practices denigrated so eloquently in Half-Arsed Agile Manifesto "...we have mandatory processes and tools to control how those individuals (we prefer the term ‘resources’) interact".

You can find more about this in an answer to another question, quoted below. Take a look at the note on "shippable release", it looks like back then OP has been confused in a similar way:

one should be agile about very application of agile principles. I mean, if the project requirements aren't agile (stable or change slowly), then why bother? I once observed top management forcing Scrum in projects that were doing perfectly well without. What a waste it was. Not only there were no improvements in their delivery but worse, developers and testers all became unhappy.

For me, one of the most important parts of Agile is having a shippable release at the end of each sprint. That implies several things. First, a level of testing must be done to ensure no showstopping bugs if you think you could release the build to a customer...

Shippable release I see. Hm. Hmmm. Consider adding a shot or two of Lean into your Agile cocktail. I mean, if this is not a customer/market need then this would mean only a waste of (testing) resources.

I for one see nothing criminal in treating Sprint-end-release as just some checkpoint that satisfies the team.

dev: yeah that one looks good enough to pass to testers; QA: yeah that one looks good enough for the case if further shippable-testing is needed - stuff like that. Team (dev + QA) is satisfied, that's it.

Title: Dilemma of QA vs. iterations


问:
TFS SQL Deployment Data Script
We are using TFS and SQL Server 2005 (looking to upgrade to SQL Server 2012 if that makes a difference). We store our database schema in a Visual Studio Database project (VS 2010).

When code is released to live we currently use the Visual Studio Database Project to build a script for all our schema changes. The problem we have been getting is having to alter or add to that script to add/fix data for the deployment. For example if we add a new non-nullable column to an existing table we need to populate that column with data during the insert. Other times we may want to create new records in transactional tables (e.g. assign specific users to a new security access).

Do Visual Studio Database Projects have a way to store these scripts that only need to be run once and somehow include them in the build? Does it know which scripts need to be run (for example if we are inserting default data we don't want to do that again a second time)?

OR

Is there a better way to manage these scripts?

答:
You could consider a branching strategy in TFS. Create a branch from the main, adding your one off's into that which you can deploy. Then create a new branch from the main again, deleting or flagging the previous branch. Your new branch from main will not have the once off's from the previous branch.

Read up on Branch and Merge strategies.

Title: TFS SQL Deployment Data Script


问:
What should be tested in Javascript?
At work, we've just started on a heavily Javascript based application (actually using Coffeescript, but still), of which I've been implementing an automated test system using JsTestDriver and fabric.

We've never written something with this much Javascript, so up until now we've never done any Javascript testing. I'm unsure what exactly we should be testing in our unit tests. We've written JQuery plugins for various things, so it's quite obvious that they should be verified for correctness as much as possible with JsTestDriver, but everyone else in my team seems to think that we should be testing the page level Javascript as well.

I don't think we should be testing page level Javascript as unit tests, but instead using a system like Selenium to verify everything works as expected. My main reasoning for this is that at the moment, page level Javascript tests are guaranteed to fail through JsTestDriver, because they're trying to access elements on the DOM that can't possibly exist.

So, what should be unit tested in Javascript?

答:
I used to work with Java and from what I see unit testing Java is easier than unit testing JavaScript because Java is more rigid.

I'm sold on that test-driven development is the best thing so I'm also exploring how to unit test JavaScript. In Java I've mocked out the code that made connection to the database, the Data Access Objects, and I compare that to the code in JavaScript that changes the DOM and the code that makes AJAX calls to the server.

What I'm getting at is that it seems to me that what should be tested is the logic explicitly. For example, you don't want to make an AJAX call when you run unit tests because (a) you need the server to be running and (b) it is slow and one of the guidelines of unit testing is that it needs to be super fast so that the developers don't avoid running them like every minute.

Another guideline is for the continuous integration process to send an e-mail saying that it found a unit test that failed.

Title: What should be tested in Javascript?


答:
A formatter + check in hook is a good start.  But it's not enough, since what you write is not as important as what you stare at all day.  In some situations, the approach of Emacs' Glasses mode - keep files in their style but display closer to your style - is attractive.

My experience with it - facing exactly the issue it was written for, CamelCaps vs underscore_separated - was that it quickly became more annoying than helpful, but for a couple weeks it smoothed my transition to (grudgingly) accepting the company's style, as well as provided an outlet to channel my anger ("ah I hate it, let me adjust the settings again... there, at least I did something") ;-)

Anyway, Glasses mode doesn't handle brace placement, you likely don't use Emacs, and don't read code exclusively in your editor :-(

But the last point is also an opportunity - if you read code most of the time in a separate tool, you can hack that to convert styles without worrying about round-trip reformatting noise - because it's read-only!  Specifically, if you read code in some web interface(s), use Greasemonkey.

Here are some easier ideas for mild mitigation:

Choose a wider but not so high font, to reclaim the lost screen lines.

Use full-screen more often, if available.

Set up braces to be highlighted in a subtle color (and smaller font?), making them less visible than the rest of the code.  Indentation should be enough for reading, esp. with the empty space from { lines...

Make sure your editor highlights matching opening brace when you're over } - might help a bit when your eyes instinctively go to the wrong place.

Re "harder to type": get a real editor, configure it to open a new line automatically when you press {.


答:
With this kind of thing I remember Gulliver in Lilliput. The Lilliputians had been fighting a war over which end to open a boiled egg. (The original big endian, little endian fight).

Take it as an opportunity to laugh at yourself, they don't really come often enough in business.


答:
It's the standard:

http://doh-san.blogspot.com/2005/10/five-monkeys.html

Most of the one's saying "its the standard" are following the "five monkeys" principle.


答:
We understand QA as an extra bit of verification to a certain build (release candidate) before this build gets deployed to the customer.

There is nothing inherently incompatible between this form of QA and iteration-based methodologies like Scrum.

Within Scrum, the team delivers a deliverable on an X-weekly cycle it its customer. The important part here is that, if the development team is doing Scrum, then their customer is the QA team, not the end-user of your product.

As a developer, I would consider a product shippable to QA if it has a fighting chance of passing all their tests. This probably means that some of the QA-tests have already been executed on the daily builds, but how that affects the official release tests by the QA team is up to your organisation.

Title: Dilemma of QA vs. iterations


答:
The really significant thing is that you make sure he is the right kind of experienced developer for what you need.

As people move on through their careers they tend to go in different directions in terms of what they do. You may be interviewing people who are experts in running large teams of programmers or working with convoluted legacy code and quite brilliant at what they do without them being the person who is right for your role. So try have an idea of what exactly you are looking for in advance and think of questions that will differentiate exactly the kind of developer for your job from other people.

Title: How do you interview someone with more experience than you?

Body:
The company I'm working for is looking to hire a senior developer with more experience than me, and they expect me to do the technical part of the interview. I've only been programming a few years and am not sure I have the knowledge needed to evaluate the coding skills of someone who has greater understanding/experience than I do.

Can anyone recommend some technical interview questions to ask that are a good means for evaluating higher-level programming skills, but still be ones I can understand?

I would say I'm past the jr. programmer level, but nowhere near senior. Most of what I've done is built small apps (web and desktop), some of them fairly complicated, but all of them have been meant to be used by no more then a handful of users. I feel I have a decent understanding of most programming concepts and am capable of learning/teaching myself just about anything, however I lack experience. As my boss is fond of telling me, "You don't know what you don't know".

In particular, things we'd like the person we hire to have experience with (that I don't have) is: Multi-tier development, multi-user environment, large-scale application development, two-way messaging, shared sessions, and Multi-threading/BackgroundWorkers.

UPDATE:

In response to Thor's comment below, we hired someone a few months ago and I think it has been working out great. I am learning a lot, not just about coding but also about things like design patterns, software architecture, documentation, and how other larger programming teams get stuff done. Its not always easy having someone come in and point out better ways to do things you have done, but if you can swallow your pride and be willing to try out new things you can learn a lot.

The interview process went better than I expected. I started asking questions about things I was familiar with, then asked some questions about some things I was struggling with. Whenever the interviewee said something I didn't understand, I'd ask them to explain it to me and then write it down so I could look it up later on. Overall, I felt I was able to get a pretty good idea of the applicant's skill level, intelligence, and what they'd be like to work with.


问:
Should I spend time prettifying unit tests?
The company I used to work for before we had automated unit tests to test our work. However the coding standards and architecture was not very important for tests. Of course you had to indent code correctly and put your braces where you are supposed to put your braces, but no one would go nit picking through your tests code. This seemed reasonable to me as the tests were usually changed frequently and the idea was to quickly write a test and then start seriously writing the code.

The new company has just got the hang of unit testing our work, but they expect you to spend time making sure the test code looks as pretty and well thought out as the code it is testing. I personally think it a waste of time since tests are internal and while test code should be neat, it does not have to be as perfectly engineered as the code that goes out the door to the customer.

Am I wrong in my belief? What is the right thing to do here fellow programmers?

Frequency of how often our programmers have to modify / extend / reuse existing unit tests varies, some more often and others less often. We are using Python Django and most of the test architecture is built-in and most tests are just simple functions. Very less setup/teardown needed.

答: You should strive to build quality software. Unit tests are software.</p>