答:
C, C++, Objective-C:

Blocks provide the binding feature that you're looking for.

In your example:

sum := a + b;

you're setting sum to the expression a + b in a context where a and b are existing variables. You can do exactly that with a "block" (a.k.a. closure, a.k.a. lambda expression) in C, C++, or Objective-C with Apple's extensions (pdf):

```<code>__block int a = 0, b = 0;           // declare a and b
int (^sum)(void);                   // declare sum
sum = ^(void){return a + b;};       // sum := a + b
</code>```

This sets sum to a block that returns the sum of a and b. The __block storage class specifier indicates that a and b may change. Given the above, we can run the following code:

```<code>printf("a=%d\t b=%d\t sum=%d\n", a, b, sum());
a = 10;
printf("a=%d\t b=%d\t sum=%d\n", a, b, sum());
b = 32;
printf("a=%d\t b=%d\t sum=%d\n", a, b, sum());
a++;
printf("a=%d\t b=%d\t sum=%d\n", a, b, sum());
</code>```

and get the output:

```<code>a=0      b=0     sum=0
a=10     b=0     sum=10
a=10     b=32    sum=42
a=11     b=32    sum=43
</code>```

The only difference between using a block and the "binding" that you propose is the empty pair of parentheses in sum(). The difference between sum and sum() is the difference between an expression and the result of that expression. Note that, as with functions, the parentheses don't have to be empty -- blocks can take parameters just as functions do.

Title: Why binding is not a native feature in most of the languages?

Body:
IMHO binding a variable to another variable or an expression is a very common scenario in mathematics. In fact, in the beginning, many students think the assignment operator(=) is some kind of binding.  But in most of the languages, binding is not supported as a native feature. In some languages like C#, binding is supported in some cases with some conditions fulfilled.

But IMHO implementing this as a native feature was as simple as changing the following code-

```<code>int a,b,sum;
sum := a + b;
a = 10;
b = 20;
a++;
</code>```

to this-

```<code>int a,b,sum;
a = 10;
sum = a + b;
b = 20;
sum = a + b;
a++;
sum = a + b;
</code>```

Meaning placing the binding instruction as assignments after every instruction changing values of any of the variable contained in the expression at right side. After this, trimming redundant instructions (or optimization in assembly after compilation) will do.

So, why it is not supported natively in most of the languages. Specially in the C-family of languages?

Update:

From different opinions, I think I should define this proposed "binding" more precisely-

This is one way binding. Only sum is bound to a+b, not the vice versa.

The scope of the binding is local.

Once the binding is established, it cannot be changed. Meaning, once sum is bound to a+b, sum will always be a+b.

Hope the idea is clearer now.

Update 2:

I just wanted this P# feature. Hope it will be there in future.

Body:
C, C++, Objective-C:

Blocks provide the binding feature that you're looking for.

In your example:

sum := a + b;

you're setting sum to the expression a + b in a context where a and b are existing variables. You can do exactly that with a "block" (a.k.a. closure, a.k.a. lambda expression) in C, C++, or Objective-C with Apple's extensions (pdf):

__block int a = 0, b = 0;           // declare a and b
int (^sum)(void);                   // declare sum
sum = ^(void){return a + b;};       // sum := a + b

This sets sum to a block that returns the sum of a and b. The __block storage class specifier indicates that a and b may change. Given the above, we can run the following code:

printf("a=%d\t b=%d\t sum=%d\n", a, b, sum());
a = 10;
printf("a=%d\t b=%d\t sum=%d\n", a, b, sum());
b = 32;
printf("a=%d\t b=%d\t sum=%d\n", a, b, sum());
a++;
printf("a=%d\t b=%d\t sum=%d\n", a, b, sum());

and get the output:

a=0      b=0     sum=0
a=10     b=0     sum=10
a=10     b=32    sum=42
a=11     b=32    sum=43

The only difference between using a block and the "binding" that you propose is the empty pair of parentheses in sum(). The difference between sum and sum() is the difference between an expression and the result of that expression. Note that, as with functions, the parentheses don't have to be empty -- blocks can take parameters just as functions do.


问:
What Part of Your Project Should be in Source Code Control?
A fellow developer has started work on a new Drupal project, and the sysadmin has suggested that they should only put the sites/default subdirectory in source control, because it "will make updates easily scriptable."  Setting aside that somewhat dubious claim, it raises another question -- what files should be under source control?  And is there a situation where some large chunk of files should be excluded?

My opinion is that the entire tree for the project should be under control, and this would be true for a Drupal project, rails, or anything else. This seems like a no-brainer -- you clearly need versioning for your framework as much as you do for any custom code you write.

That said, I would love to get other opinions on this.  Are there any arguments for not having everything under control?

答:
Hard won experience has taught me that almost everything belongs in source control. (My comments here are colored by a decade and a half developing for embedded/telecom systems on proprietary hardware with proprietary, and sometimes hard to find, tools.)

Some of the answers here say "don't put binaries in source control". That's wrong. When you're working on a product with lots of third party code and lots of binary libraries from vendors, you check in the binary libraries. Because, if you don't, then at some point you're going to upgrade and you'll run into trouble: the build breaks because the build machine doesn't have the latest version; someone gives the new guy the old CDs to install from; the project wiki has stale instructions regarding what version to install; etc. Worse still, if you have to work closely with the vendor to resolve a particular issue and they send you five sets of libraries in a week, you must be able to track which set of binaries exhibited which behavior. The source control system is a tool that solves exactly that problem.

Some of the answers here say "don't put the toolchain in source control". I won't say it's wrong, but it's best to put the toolchain in source control unless you have a rock solid configuration management (CM) system for it. Again, consider the upgrade issue as mentioned above. Worse still, I worked on a project where there were four separate flavors of the toolchain floating around when I got hired -- all of them in active use! One of the first things I did (after I managed to get a build to work) was put the toolchain under source control. (The idea of a solid CM system was beyond hope.)

And what happens when different projects require different toolchains? Case in point: After a couple of years, one of the projects got an upgrade from a vendor and all the Makefiles broke. Turns out they were relying on a newer version of GNU make. So we all upgraded. Whoops, another project's Makefiles all broke. Lesson: commit both versions of GNU make, and run the version that comes with your project checkout.

Or, if you work in a place where everything else is wildly out of control, you have conversations like, "Hey, the new guy is starting today, where's the CD for the compiler?" "Dunno, haven't seen them since Jack quit, he was the guardian of the CDs." "Uhh, wasn't that before we moved up from the 2nd floor?" "Maybe they're in a box or something." And since the tools are three years old, there's no hope of getting that old CD from the vendor.

All of your build scripts belong in source control. Everything! All the way down to environment variables. Your build machine should be able to run a build of any of your projects by executing a single script in the root of the project. (./build is a reasonable standard; ./configure; make is almost as good.) The script should set up the environment as required and then launch whatever tool builds the product (make, ant, etc).

If you think it's too much work, it's not. It actually saves a ton of work. You commit the files once at the beginning of time, and then whenever you upgrade. No lone wolf can upgrade his own machine and commit a bunch of source code that depends on the latest version of some tool, breaking the build for everyone else. When you hire new developers, you can tell them to check out the project and run ./build. When version 1.8 has a lot of performance tuning, and you tweak code, compiler flags, and environment variables, you want to make sure that the new compiler flags don't accidentally get applied to version 1.7 patch builds, because they really need the code changes that go along with them or you see some hairy race conditions.

Best of all, it will save your ass someday: imagine that you ship version 3.0.2 of your product on a Monday. Hooray, celebrate. On Tuesday morning, a VIP customer calls the support hotline, complaining about this supercritical, urgent bug in version 2.2.6 that you shipped 18 months ago. And you still contractually have to support it, and they refuse to upgrade until you can confirm for certain that the bug is fixed in the new code, and they are large enough to make you dance. There are two parallel universes:

In the universe where you don't have libraries, toolchain, and build scripts in source control, and you don't have a rock-solid CM system.... You can check out the right version of the code, but it gives you all kinds of errors when you try to build. Let's see, did we upgrade the tools in May? No, that was the libraries. Ok, go back to the old libraries -- wait, were there two upgrades? Ah yes, that looks a little better. But now this strange linker crash looks familiar. Oh, that's because the old libraries didn't work with the new toolchain, that's why we had to upgrade, right? (I'll spare you the agony of the rest of the effort. It takes two weeks and nobody is happy at the end of it, not you, not management, not the customer.)

In the universe where everything is in source control, you check out the 2.2.6 tag, have a debug build ready in an hour or so, spend a day or two recreating the "VIP bug", track down the cause, fix it in the current release, and convince the customer to upgrade. Stressful, but not nearly as bad as that other universe where your hairline is 3cm higher.

With that said, you can take it too far:

You should have a standard OS install that you have a "gold copy" of. Document it, probably in a README that is in source control, so that future generations know that version 2.2.6 and earlier only built on RHEL 5.3 and 2.3.0 and later only built on Ubuntu 11.04. If it's easier for you to manage the toolchain this way, go for it, just make sure it's a reliable system.

Project documentation is cumbersome to maintain in a source control system. Project docs are always ahead of the code itself, and it's not uncommon to be working on documentation for the next version while working on code for the current version. Especially if all your project docs are binary docs that you can't diff or merge.

If you have a system that controls the versions of everything used in the build, use it! Just make sure it's easy to sync across the whole team, so that everyone (including the build machine) is pulling from the same set of tools. (I'm thinking of systems like Debian's pbuilder and responsible usage of python's virtualenv.)

ContentLicense: CC BY-SA 3.0

ContentLicense: CC BY-SA 4.0


问:
Is there a correlation between complexity and reachability?
I've been studying cyclomatic complexity (McCabe) and reachability of software at uni recently. Today my lecturer said that there's no correlation between the two metrics, but is this really the case?

I'd think there would definitely be some correlation, as less complex programs (from the scant few we've looked at) seem to have 'better' results in terms of reachability.

Does anyone know of any attempt to look at the two metrics together, and if not, what would be a good place to find data on both complexity and reachability for a large(ish) number of programs?

答:
There may be some statistics on this but I would say there's no correlation because one does not depend on the other and there is also choice in the design of a software system such that you can eliminate this.

In terms of real world data, there may be a strong correlation but that could be due to badly designed software systems that do not eliminate this correlation. It could be an accidental correlation because of lack of knowledge of graph theory.


问:
how to layout good documentation
I need to write out a documentation for developers to be able to use some API web software how should i lay out a documentation? What should always be included? And does it need to be really long or keep it simple and easy as possible for anybody to understand?</p>

答:
There's no really good way to get Doxygen to incorporate the reference docs it creates from code comments into a larger doc set.

You can include pages not in the source tree, but they have to be in the example folder.

In my current project I create a higher-level index and include the doxygen docs as a leaf node from there, ala:

```<code>        main index
           /\
          /  \
         /    \
       Guide  Ref (from Doxygen)
</code>```

The bugaboo then becomes how to create a single index with search. I've looked into Wrensoft's Zoom (it uses Php) and it seems to work okay. Another sticking point is allowing comments for feedback. I found some javascript a previous writer used, but it requires inserting a row for every topic/html file into a MySql DB. I see no point in doing that until the docs are quiescent.

Title: how to layout good documentation

Body:
There's no really good way to get Doxygen to incorporate the reference docs it creates from code comments into a larger doc set.

You can include pages not in the source tree, but they have to be in the example folder.

In my current project I create a higher-level index and include the doxygen docs as a leaf node from there, ala:

        main index
           /\
          /  \
         /    \
       Guide  Ref (from Doxygen)

The bugaboo then becomes how to create a single index with search. I've looked into Wrensoft's Zoom (it uses Php) and it seems to work okay. Another sticking point is allowing comments for feedback. I found some javascript a previous writer used, but it requires inserting a row for every topic/html file into a MySql DB. I see no point in doing that until the docs are quiescent.


问:
Is there a version control system that can show changes to a specific method or function?
Sometimes it would be nice to be able to say something like:

```<code>(git|svn|hg|etc) diff Foo.c:main
(git|svn|hg|etc) log log Foo.c:main
</code>```

to see the changes made to a specific function within a source file since the last commit, or the complete history of changes. My question is two-fold:

Does something exist that does this?

Would such a tool be practical? It would have to do some simple parsing of the code at each revision in order to compare different versions of the function; would the overhead be too much for it to be efficient?

答:
svn actually does something close to what you want.

You can use the command :

```<code>svn diff -x -p program.c
</code>```

The -x -p  provides 'C' function name on top of the change set. which looks like this.

```<code>@@ -97,6 +102,8 @@ int function1(int *x)
</code>```

It doesn't filter but you can grep/search to serve your purpose closely.

I guess this is only for 'C' (or C/C++). However, i guess, if there is a demand svn would make it available for other languages as well.

I don't quite subscribe to the argument that VCS should NOT do that. After all we want all IDEs or editors (like VIM,EMACS) to do syntax highlighting which is specific to each language and support many simultaneously. So VCS being a developer tool, should also support such functionality.

Of course, thanks to your question that i discovered it. I had never used it before.

Body:
svn actually does something close to what you want.

You can use the command :

svn diff -x -p program.c

The -x -p  provides 'C' function name on top of the change set. which looks like this.

@@ -97,6 +102,8 @@ int function1(int *x)

It doesn't filter but you can grep/search to serve your purpose closely.

I guess this is only for 'C' (or C/C++). However, i guess, if there is a demand svn would make it available for other languages as well.

I don't quite subscribe to the argument that VCS should NOT do that. After all we want all IDEs or editors (like VIM,EMACS) to do syntax highlighting which is specific to each language and support many simultaneously. So VCS being a developer tool, should also support such functionality.

Of course, thanks to your question that i discovered it. I had never used it before.


问:
booth multiplication algorithm
Is booth algorithm for multiplication only for multiplying 2 negative numbers (-3  * -4) or one positive and one negative number (-3 * 4) ? Whenever i multiply 2 positive numbers using booth algorithm i get a wrong result.

example : 5 * 4

A = 101 000 0   // binary of 5 is 101

S = 011 000 0   // 2's complement of 5 is 011

P = 000 100 0   // binary of 4 is 100

x = 3

y = 3

m = 5

-m = 2's complement of m

r = 4

After right shift of P by 1 bit 0 000 100

After right shift of P by 1 bit 0 000 010

P+S = 011 001 0

After right shift by 1 bit 0 011 001

Discarding the LSB 001100

But that comes out to be the binary of 12 . It should have been 20(010100)

答:
The problem is you are using 3 bits for m and r, and they must be represented using 4 bits to get unsigned values.  (Using just 3 bits, 101 = -3 and 100 = -4, and the result does = 12).

So redoing this with 4 bits, one gets:

```<code>example : 5 * 4

A = 0101 0000 0 // binary of 5 is 0101

S = 1011 0000 0 // 2's complement of 5 is 1011

P = 0000 0100 0 // binary of 4 is 0100

x = 4

y = 4

m = 5

-m = 2's complement of m

r = 4

1.    After right shift of P by 1 bit 0000 0010 0

2.    After right shift of P by 1 bit 0000 0001 0

3.    P+S = 1011 0001 0

      After right shift by 1 bit 0101 1000 1

4.    P+A = 0010 1001 0     (not 1010 1001 0, since overflow in MSB is ignored)

      After right shift by 1 bit 0001 0100 1

Discarding the LSB gives 00010100   which is 20
</code>```

which gives the correct answer.

Title: booth multiplication algorithm

Body:
The problem is you are using 3 bits for m and r, and they must be represented using 4 bits to get unsigned values.  (Using just 3 bits, 101 = -3 and 100 = -4, and the result does = 12).

So redoing this with 4 bits, one gets:

example : 5 * 4

A = 0101 0000 0 // binary of 5 is 0101

S = 1011 0000 0 // 2's complement of 5 is 1011

P = 0000 0100 0 // binary of 4 is 0100

x = 4

y = 4

m = 5

-m = 2's complement of m

r = 4

1.    After right shift of P by 1 bit 0000 0010 0

2.    After right shift of P by 1 bit 0000 0001 0

3.    P+S = 1011 0001 0

      After right shift by 1 bit 0101 1000 1

4.    P+A = 0010 1001 0     (not 1010 1001 0, since overflow in MSB is ignored)

      After right shift by 1 bit 0001 0100 1

Discarding the LSB gives 00010100   which is 20

which gives the correct answer.


问:
Is PHP suitable for downloading large amounts of data?
Is PHP suitable for downloading large amounts of data, usually via cron? Should I worry about the memory footprint when I am using PHP for downloading multiple zip files?</p>

答:
Should I worry about the memory footprint when I am using PHP for
  downloading multiple zip files?

Generally speaking, no, you probably dont have to be worried about the footprint of a PHP script.  Its just not that large.  So unless you are running a thousand concurrent instances of your script or something, the php footprint isnt likely to be an issue.

As others have pointed out, there are command line means of downloading files that dont require a PHP script if all you are doing is simply retrieving them. Though PHP or other scripting languages might certainly be useful if you are doing something to the data as its downloaded.

Conclusion: If PHP does the trick for you, knock yourself out.


问:
Hiring a Junior Developer, What should I ask?
We are currently hiring a junior developer to help me out, as I have more projects than I can currently manage. I have never hired anyone who wasn't a friend or at least an acquaintance. I have a phone interview with the only applicant that actually stood out to me (on paper), but I have never done this before.

Our projects are all high scalability, data intensive web applications that process millions of transactions an hour, across multiple servers and clients. To be language/stack specific, we use ASP.Net MVC2, WebForms and C# 4, MSSQL 2008 R2, all running atop Windows Server 2008 R2

What should I ask him? How should I structure the phone call?

答:
When you are on a one on one discussion with the developer, you can get to know him and then check if they are honest with you.

In order to do so, you can ask him the following question to know how honest he really is

If they have done any certifications, like a Microsoft Certification check with them to know whether they have genuinely studied for it and clear it.

Some junior developers who have done their final year projects, would have not done the project by themselves i.e their friends must have done it for them etc.

Being honest plays a very important role, when the junior developer is entrusted with confidential projects.

If you feel you can trust them, then you can give a questionnaire on which technologies they are being recruited followed by a practical text with some case scenario to check if they have the logical ability i.e to check whether they have constant touch in programming.

ContentLicense: CC BY-SA 2.5


问:
What version control system can manage all aspects?
A few months ago I dug into Subversion and GIT and was disappointed. They handle SOURCE CODE fine but not other aspects. For example, a web site under version control needs to manage file/directory ownership, file/directory read & write access, Access Control Lists, timestamps, database contents. and external links. Is there a version control system that can do as perfect a reversion as reloading from a month-old backup?</p>

答:
All of them and none of them.

It is a bad idea to get source control to manage those details directly, in the way your question intimates.

However, you can write a bash script (*nix) or powershell script (Windows), which achieves any or all of those goals. This script could be stored in source control.

Then you can make that script one of your build artefacts and run it as part of your deployment.


问:
When should complexity be removed?
Prematurely introducing complexity by implementing design patterns before they are needed is not good practice.

But if you follow all (or even most of) the SOLID principles and use common design patterns you will introduce some complexity as features and requirements are added or changed to keep your design as maintainable and flexible as needed.

However once that complexity is introduced and working like a champ when do you removed it?

Example. I have an application written for a client. When originally created there where several ways to give raises to employees. I used the strategy pattern and factory to keep the whole process nice and clean. Over time certain raise methods where added or removed by the application owner.

Time passes and new owner takes over. This new owner is hard nosed, keeps everything simple and only has one single way to give a raise.

The complexity needed by the strategy pattern is no longer needed. If I where to code this from the requirements as they are now I would not introduce this extra complexity (but make sure I could introduce it with little or no work should the need arise).

So do I remove the strategy implementation now? I don't think this new owner will ever change how raises are given. But the application itself has demonstrated that this could happen.

Of course this is just one example in an application where a new owner takes over and has simplified many processes. I could remove dozens of classes, interfaces and factories and make the whole application much more simple. Note that the current implementation does works just fine and the owner is happy with it (and surprised and even happier that I was able to implement her changes so quickly because of the discussed complexity).

I admit that a small part of this doubt is because it is highly likely the new owner isn't going to use me any longer. I don't really care that somebody else will take this over since it has not been a big income generator.

But I do care about 2 (related) things

I care a bit that the new maintainer will have to think a bit harder when trying to understand the code. Complexity is complexity and I don't want to anger the psycho maniac coming after me.

But even more I worry about a competitor seeing this complexity and thinking I just implement design patterns to pad my hours on jobs. Then spreading this rumor to hurt my other business. (I have heard this mentioned.)

So...

In general should previously needed complexity be removed even though it works and there has been a historically demonstrated need for the complexity but you have no indication that it will be needed in the future?

Even if the question above is generally answered "no" is it wise to remove this "un-needed" complexity if handing off the project to a competitor (or stranger)?

答:
In some ways, I think this is largely a business decision and not necessarily based on the code itself. Some things to consider:

Are you getting paid to make the changes?

Does the code currently function as expected?

Are there any security or performance issues with the code as is?

Does the amount of technical debt outweigh the cost of fixing it?

What is realistically likely to happen if you leave the code as is?

What are future problems that could crop up with or without a refactoring?

How much of a liability is the code to you and your business?

You're in the best position to answer those questions. However, based on your description, I don't know if I would bother refactoring and simplifying things as it doesn't sound like it's going to be worth your time. If it currently works, the client is happy, and you're not like to get paid for updating everything, then let it be and work on a revenue-producing activity.

In short, do a cost-benefit analysis and a risk assessment of both paths and take the safest, most efficient, and most profitable course of action.

Title: When should complexity be removed?


答:
IMHO a version control system in itself is not intended to be used in that way.

But what I tend to do is to make sure that you can get a version from source control you only need to run one build file/powershell file and everything is up and running again.

For this you need to :

all libraries that you app depends upon in source control

a build file that sets your environment

an instruction on the requirements of your environment (you don't want to put a sql server install in your source control)

Title: What version control system can manage all aspects?

Body: A few months ago I dug into Subversion and GIT and was disappointed. They handle SOURCE CODE fine but not other aspects. For example, a web site under version control needs to manage file/directory ownership, file/directory read & write access, Access Control Lists, timestamps, database contents. and external links. Is there a version control system that can do as perfect a reversion as reloading from a month-old backup?</p>


问:
Why should I use Zend_Application?
I've been working on a Zend Framework application which currently does a bunch of things through Zend Application and a few resource plugins written for it.

However, looking at this codebase now, it seems to me that using Zend_Application just makes things more complicated; and a plain, more "traditional" bootstrap file would do a better job of being transparent. This is even more the case because the individual components of Zend -- Zend_Controller, Zend_Navigation, etc. -- don't reference Zend_Application at all. Therefore they do things like "Well just call setRoute and be on your way," and the user is left scratching their head as to how to implement that in terms of the application.ini configuration file.

This is not to say that one can't figure out what's going on by doing spelunking through the ZF source code. My problem with that approach is that it's to easy to depend on something that's an implementation detail, rather than a contract, and that all it seems to do is add an extra layer of indirection that one must wade through to understand an application.

I look at pre ZF 1.8 example code, before Zend_Application existed, and everywhere I see plain bootstrap files that setup the MVC framework and get on their way. The code is clear and easy to understand, even if it is a bit repetitive. I like the DRY concept that Application gets you, but particularly when I'm assuming first people looking at the app's code aren't really familiar with Zend at all, I'm considering blowing away any dependence I have on Zend_Application and returning to a traditional bootstrap file.

Now, my concern here is that I don't have much experience doing this, and I don't want to get rid of Zend_Application if it does something particularly important of which I am unaware, or something of that nature. Is there a really good reason I should keep it around?

答:
For a single, existing project that works fine, there is probably a fair argument about not bothering to migrate to Zend_Application.

On the other hand, one of the nice things about Zend_Application is that you can create standalone application resource plugins that are then usable across projects.

In addition to custom application resource plugins that I write myself for use in projects, I have also found many resources that are packaged/published this way. The best example of this is the Doctrine2 application resource written by Guillherme Blanco.

Title: Why should I use Zend_Application?


问:
Any tips to learn how to program with severe ADHD?
I have a difficult time trying to learn how to program from straight text-books. Video training seems to work well for me in my past experiences with PHP. I am trying my hardest to stay focussed and push through. Specifically I am looking to start indie game development.

Over the last two weeks I have been trying to pick the "right" language and framework to develop with. I started going through Python, but I am not really enjoying the language so far. I am constantly looking through this website to compare this language to that, and keep getting distracted.

Aside from all of this, is it possible to become a programmer when you have trouble focussing? Has anyone been through this that can recommend some advice?

答:
A lot of people have given great suggestions / answers and I wish to be a part of that!

The problem with me is, I get distracted with the slightest noise or conversation and it takes quiet some time to get back. In order to counter this and attain high levels of concentration, I use noise cancellation headphones when very I program and it has worked for me and I definitely think it will work for you but there is a flip side to it.

Bottom line - If you use it too much, you could be addicted to it.


答:
You are confused about the role of a version control system.  It is not and never was intended to be a backup system for a running web site.   It does an extremely good job of managing static content so that it moved into production in a controlled manner.  With proper use of tagging and automated checkouts, even fast changing sites can be kept in a version control system.

A version control system will be able to tell you how you got from what the site looked like last month to what it looks like today (at least for those components that are under source control).  It should include everything you need to rebuild the website (excluding dynamic content).  As other have noted, any changes to permissions and ownership should be scripted, and that script included in version control.

Access permissions for web sites are typically quite simple.  (Basically, you need to ensure that the webserver can read all content and write very little of it.)  With the exception of directory ownership of the few directories that need to be writable by the web-server subversion, and possibly git, can certainly handle permissions.  Directories which are writable by the web-server typically contain dynamic content (created and updated from the web-site), which is managed separately from the web-sites source.

If I were ask to work with a web-site with complicated permissions and ACLs on your web-site, I would have serious concerns about the process used to manage the web-site.  Implementing a version control system and moving the ACLs to it would be one of the solutions I would seriously consider.

Dynamic content, such as blog entries or comments, is typically contained in a database or other datastore rather than the version control used to build the site.  The data store may be arranged to provide version control of it content (as is this software).  Many Wikis use a version control system to track revisions.

EDIT:

The fix I am using is (a) No version control at all, (b) The production site is the master site, (c) Archive every time anything changes, (d) The archive script removes junk like ACL, and (e) the install script fixes other junk like file permissions.

These problems can be handled by importing the site into a version control system and changing your process so that the master site is updated through that system.  (a), (b), and (c) are handled directly by version control. You may want to tag releases to make (c) work better.  (d) generally isn't an issue if you only have the deployment system changing your site.  I have never needed ACLs on the site content.

(e) should only need to be run on initial creation and major changes.  It might also include the script that updates the site from version control and runs frequently.  These scripts tend to be quite simple when you keep you site in aversion control system.

But why hasn't anyone built a general system to do this?

Because it isn't needed if you use a version control system.

A version control system COULD track all this stuff, but none does.

Both CVS and Subversion track what you need to track if you are using them.  They won't track the thing you need to track because you are not using a version control system, nor should they.  They track what you need to track when you are using a version control system.

I've worked with several sites that managed their content using version control.  All had different requirements for staging sites, deployment frequency, and completeness of updates.  Once the sites were in version control meeting the rest of the requirements were relatively easy to meet.  Documentation for both CVS and Subversion make suggestions for possible update methods.

You may need ACLs to limit access to particular areas within the version controlled content.  However, I tend to work on a trust basis.  Version control makes it easy to see who did what when.  If you don't reformat files it is easy to get an annotated history of a file showing who added which lines when.


答:
I too was diagnosed with ADHD. At some point it even made me quit school (didn't graduate). I couldn't focus on the studies. The reason was that I couldn't keep being interested in it after the introductory or base parts.

But then at some miraculous moment in my life I realized that the problem wasn't that things I generally wanted to know weren't interesting enough (or interesting all around).

The problem was that I didn't have a proper base knowledge that would let me understand something at the minimum level required for being interested in it. If you're like I was - what you need to do is this:

Find a well-reviewed book about a topic that interests you.

Start reading that book.

If you encounter a term you don't understand, that isn't covered by the book, get some info (wikipedia, articles, other books) about that term. Understand it first, and then continue reading that book.

Repeat the process until you finish or at least read a good part of the material.

Another thing that could help - get interested in math. Most (if not all) programming languages use mathematical concepts inherently and a syntax that's rooted in math in one way or another.

I first learned how to program and only then started studying math (I knew nothing about math, didn't even know what the nth root of a number even meant, didn't know that division is inverse multiplication). So I had a hard time getting used to some of the basic concepts.

But once I got into math a bit everything started to make sense, and I wished I had learned it first, because it would have saved me lots of frustration and mistakes.

On a final note... Just by being here and seeking advice, you're already on the right track. It's important not to stray and keep heading straight, even (and especially) when it gets hard!

Title: Any tips to learn how to program with severe ADHD?

Body:
I have a difficult time trying to learn how to program from straight text-books. Video training seems to work well for me in my past experiences with PHP. I am trying my hardest to stay focussed and push through. Specifically I am looking to start indie game development.

Over the last two weeks I have been trying to pick the "right" language and framework to develop with. I started going through Python, but I am not really enjoying the language so far. I am constantly looking through this website to compare this language to that, and keep getting distracted.

Aside from all of this, is it possible to become a programmer when you have trouble focussing? Has anyone been through this that can recommend some advice?


问:
How can I permute pairs across a set?
I am writing a bet settling app in C# and WinForms. I have 6 selections, 4 of them have won. I know that using the following formula from Excel:

```<code>=FACT(selections)/(FACT(selections-doubles))/FACT(doubles)
</code>```

This is coded into my app and working well: I can work out how many possible doubles (e.g., AB, AC, AD, AE, BC, BD, BE, etc.) need to be resolved.

But what I can't figure out is how to do the actual calculation. How can I efficiently code it so that every combination of A, B, C, and D has been calculated?

All my efforts thus far on paper have proved to be ugly and verbose: is there an elegant solution to this problem?

答:
I don't speak C#, but here's the general idea in C-like pseudocode:

```<code>items = {A, B, C, D, E}
for (i = 0; i < items.count-1; i++)
    for (j = i+1; j < items.count; j++) {
        doSomethingWithPair(items[i], items[j])
    }
}
</code>```

In English, pick the first item and combine it with all the subsequent items. Then pick the next item and combine it with all subsequent items, and so on until you've combined the penultimate item with the ultimate item.

If order were important, i.e. you wanted permutations instead of combinations, pick both members of each pair from the full range of items. Change the outer loop so that it goes all the way to the end and the inner loop so that it starts from the beginning. Remember to check that i != j if you don't want permutations with replacement:

```<code>for (i = 0; i < items.count; i++) {
    for (j = 0; j < items.count; j++) {
        if (i == j) continue;        // avoid AA, BB, etc.
        doSomethingWithPair(items[i], items[j]);
    }
}
</code>```

Title: How can I permute pairs across a set?

Body:
I don't speak C#, but here's the general idea in C-like pseudocode:

items = {A, B, C, D, E}
for (i = 0; i < items.count-1; i++)
    for (j = i+1; j < items.count; j++) {
        doSomethingWithPair(items[i], items[j])
    }
}

In English, pick the first item and combine it with all the subsequent items. Then pick the next item and combine it with all subsequent items, and so on until you've combined the penultimate item with the ultimate item.

If order were important, i.e. you wanted permutations instead of combinations, pick both members of each pair from the full range of items. Change the outer loop so that it goes all the way to the end and the inner loop so that it starts from the beginning. Remember to check that i != j if you don't want permutations with replacement:

for (i = 0; i < items.count; i++) {
    for (j = 0; j < items.count; j++) {
        if (i == j) continue;        // avoid AA, BB, etc.
        doSomethingWithPair(items[i], items[j]);
    }
}


答:
Isn't removing this code and replacing it with something simple for future ease of coding a feature the client needs to consider and pay for?

You may have something useful another developer could learn from, but the odds of finding another client's app to plug it into, is not likely.

Gossiping about competitor's code isn't something you can prevent. They will look foolish trying to negatively recruit clients.

Title: When should complexity be removed?

Body:
Prematurely introducing complexity by implementing design patterns before they are needed is not good practice.

But if you follow all (or even most of) the SOLID principles and use common design patterns you will introduce some complexity as features and requirements are added or changed to keep your design as maintainable and flexible as needed.

However once that complexity is introduced and working like a champ when do you removed it?

Example. I have an application written for a client. When originally created there where several ways to give raises to employees. I used the strategy pattern and factory to keep the whole process nice and clean. Over time certain raise methods where added or removed by the application owner.

Time passes and new owner takes over. This new owner is hard nosed, keeps everything simple and only has one single way to give a raise.

The complexity needed by the strategy pattern is no longer needed. If I where to code this from the requirements as they are now I would not introduce this extra complexity (but make sure I could introduce it with little or no work should the need arise).

So do I remove the strategy implementation now? I don't think this new owner will ever change how raises are given. But the application itself has demonstrated that this could happen.

Of course this is just one example in an application where a new owner takes over and has simplified many processes. I could remove dozens of classes, interfaces and factories and make the whole application much more simple. Note that the current implementation does works just fine and the owner is happy with it (and surprised and even happier that I was able to implement her changes so quickly because of the discussed complexity).

I admit that a small part of this doubt is because it is highly likely the new owner isn't going to use me any longer. I don't really care that somebody else will take this over since it has not been a big income generator.

But I do care about 2 (related) things

I care a bit that the new maintainer will have to think a bit harder when trying to understand the code. Complexity is complexity and I don't want to anger the psycho maniac coming after me.

But even more I worry about a competitor seeing this complexity and thinking I just implement design patterns to pad my hours on jobs. Then spreading this rumor to hurt my other business. (I have heard this mentioned.)

So...

In general should previously needed complexity be removed even though it works and there has been a historically demonstrated need for the complexity but you have no indication that it will be needed in the future?

Even if the question above is generally answered "no" is it wise to remove this "un-needed" complexity if handing off the project to a competitor (or stranger)?


答:
There are plenty of good interview tips already written, but I don't think you can fill this position until you know exactly what they are going to do on a day to day basis. If your first thought was, "Whatever I need them to do." just stop. Find a specific chunk of code for them to review. Pick the best and worst code for them to look at and see if they know the difference. Give them areas to work on for a first quick project that may have been neglected.

Hopefully you've hired the best programmer, but everyone has areas they are better/more experienced at than others. Take advantage of it and define their role accordingly.

Oh, and hire someone with a history of getting things done.

Title: Hiring a Junior Developer, What should I ask?

Body:
We are currently hiring a junior developer to help me out, as I have more projects than I can currently manage. I have never hired anyone who wasn't a friend or at least an acquaintance. I have a phone interview with the only applicant that actually stood out to me (on paper), but I have never done this before.

Our projects are all high scalability, data intensive web applications that process millions of transactions an hour, across multiple servers and clients. To be language/stack specific, we use ASP.Net MVC2, WebForms and C# 4, MSSQL 2008 R2, all running atop Windows Server 2008 R2

What should I ask him? How should I structure the phone call?


答:
First of all, if the app was already once taken over by a new owner, it may happen again. And the next owner may again start using that complexity which is not benefited from at the moment.

Apart from this, non-trivial changes to working code always entail a risk, thus (as others noted) the client should agree with (and pay for) them. If the current "extra" complexity does not cause any noticeable, measureable drawback (such as performance issues), there is no strong reason to remove it.

(Potential) clients who (don't) hire you based solely on competitors' rumours are IMHO not worth having anyway, unless you are in a desperate need of income. You have good and logical reasons why you implemented the app the way you did, and any serious client is likely to understand that. Someone who doesn't - or doesn't even bother to ask you about - would be likely to cause you more trouble along the way than the job's worth anyway.

Title: When should complexity be removed?


答:
To be able to remove the complexity the following must be true:

The removed piece must be independent of the program. If there are any dependencies from the surrounding program to the code in question, just removing the complexity will not work

Unfortunately, if it looks like complexity, then it's very likely that the pieces are not independent and the dependencies are going to break your program when you remove the piece

Removing all the dependencies are going to take time, so that time needs to be considered when you estimate if the operation is worth the effort

Most of the time it's not worth the effort, but you'll just decide to not make any new code use the old one

Title: When should complexity be removed?


答:
To show what revision and author last modified each line of a file:</p>

```<code>git blame filename
</code>```

Title: Is there a version control system that can show changes to a specific method or function?

Body:
Sometimes it would be nice to be able to say something like:

```<code>(git|svn|hg|etc) diff Foo.c:main
(git|svn|hg|etc) log log Foo.c:main
</code>```

to see the changes made to a specific function within a source file since the last commit, or the complete history of changes. My question is two-fold:

Does something exist that does this?

Would such a tool be practical? It would have to do some simple parsing of the code at each revision in order to compare different versions of the function; would the overhead be too much for it to be efficient?

Body:
To show what revision and author last modified each line of a file:

git blame filename


答:
One thing I did not see here in my quick read is the need to ask them about:

1 - Willingness to learn

2 - Ability to self teach vs. formal training

3 - Example of something they learned themselves in the past

4 - An example of areas they are not comfortable with

5 - General high level question like "if your are tasked with building a web application about ... what tasks that need to occur and who should do them" - This should give you an idea about their current knowledge about the development process - It does not have to be accurate, but at least you will get to know their view as is today.


答:
I think there is something bigger at work here... Scalability

What you are talking about is called Scalability. It doesn't matter whether to code is complex it matters whether the application can evolve based on new business rules or changed business rules. What happens if the next owner wants something totally different.

So, I say keep the code and document it. It's a feature of how the application can be utilized.

Title: When should complexity be removed?


答:
Stuff I would not put in source control:

Secret keys and passwords

The SDK even though it's the same directory and if I make a patch to the SDK then a should make it another project since it would be per framework instead of per app

3rd-party libraries such as
. Leftovers from migration, backups, compiled code, code under other license (perhaps)

So I don't do a hg addremovefor instance since a make a new clone every once in a while when the SDK updates. That also makes me do a complete backup every time the SDk updates and check that a new version cloned from the repository is well.

Title: What Part of Your Project Should be in Source Code Control?

Body:
A fellow developer has started work on a new Drupal project, and the sysadmin has suggested that they should only put the sites/default subdirectory in source control, because it "will make updates easily scriptable."  Setting aside that somewhat dubious claim, it raises another question -- what files should be under source control?  And is there a situation where some large chunk of files should be excluded?

My opinion is that the entire tree for the project should be under control, and this would be true for a Drupal project, rails, or anything else. This seems like a no-brainer -- you clearly need versioning for your framework as much as you do for any custom code you write.

That said, I would love to get other opinions on this.  Are there any arguments for not having everything under control?


答: Without going into specifics, ... but you might check out Semantic Designs site and their products range. They offer some tools which are language sensitive, so to say, in lack of a better term.


答: There is an ultimate version control system that manages all aspects of all digital documents. It's called Xanadu and was created by Theodor Holm Nelson in 1960, even before things like file systems were common. So in theory everything is perfectly solved. In practice, Xanadu has never been implemented as envisioned by Nelson, but it inspired many more specialized systems, including the Web and version control systems. Nelson's works are still worth a fresh read - and they may answer the question why there is no general VCS that manages all aspects.


答: Monticello can do this (e.g. http://wiresong.ca/monticello/v2/docs/changes-browser.html) but this is of course cheating outrageously because it only works for Smalltalk.</p>


答:
I believe what you need in your case is a configuration management tool. The one that I've used is puppet.

Quoting you:

manage file/directory ownership, file/directory read & write access,

I have done that with one line (ensure user exists, ensure directory exists, etc)...

Access Control Lists,

If this is windows ACLs then there are specific CM tools for windows...

timestamps,

again the touch unix command in one line in a puppet script could do this for you.

database contents.

That's build in many frameworks, a cron job that ensures everything is there otherwise?

and external links.

Do not know anything about that.

Of course after you write your Configuration Management code, you might want to put it (or retrieve it in the systems involved) on a version control system. You will not get away from those :-).


问:
HTTP events? Is there a standard / precedent for this?
Our architecture is HTTP servers (custom written) whereby custom clients send a HTTP request for some information and information is returned just as HTTP works. Now we need a special custom 'extension' which is a request which is a subscription for receiving asynchronous 'events' on a resource.

For example, the client sends an http request subscribing for events on some entity. As the 'entity' generates events they are passed to the http server and the http server must then lookup subscriptions for that entity and send the event message to all subscribed clients. Hope that makes sense.

So my questions are:

Has this been done before / or is there a standard I should be looking at?

If no standard, any suggestions on how to implement?

How does a http server send an unsolicited 'message' to a client?

答:
There is a draft for such a standard in HTML5, called "Server Sent Events"

Read all about it here: http://dev.w3.org/html5/eventsource/


问:
Software for requirements and use cases
I am looking into some UML modeling software, which there is plentiful of on the market, but only a few I found support recording of requirements and written use cases (not the diagrams yet).

Are there any tools or methods I should check out for making requirements and use cases? Or should I just fire up Word and create a separate document for each use case?

答:
You might be interested to take a look at Cucumber, http://cukes.info/.
It doesn't have any UML, but it probably beats writing up stuff in word documents.</p>

Title: Software for requirements and use cases


答:
Documenting information about Use Case outside of a tool could lead to inconsistencies, say the 'customer' class changes name to 'party', this requires not-so-easy change.

The CaseComplete (CaseComplete) tool helps with this and also provides more features. See video at:

CaseCompleteVideo

Title: Software for requirements and use cases

Body:
I am looking into some UML modeling software, which there is plentiful of on the market, but only a few I found support recording of requirements and written use cases (not the diagrams yet).

Are there any tools or methods I should check out for making requirements and use cases? Or should I just fire up Word and create a separate document for each use case?


答:
Talk me through a project you've worked on in the past

Describe the overall architecture of the project.  High level is fine.

What's one thing you liked about the project.

What's one thing you disliked about the project.

What's something that, in hindsight, you would have done differently?

This is a great question for interviews in my opinion, phone or otherwise.  If they can talk intelligently about a project they've worked on, chances are they "get it".  You're hiring a junior level developer, so it isn't important that they be an expert yet, but they should at least understand their field well enough to talk about it.  Usually the people you will want to hire will have no trouble running with this, while the people you may want to stay away from will answer in a couple of sentences or less.

What do you do to stay current?

What blogs do you read?

What books have you read / are you reading?

Anything else?

In an industry that's changing constantly, I think it's important for them to be staying current.  This isn't the most important question I ask in an interview, but if they can't come up with anything to say, it's not a great sign.

Tell me how you would write a Bicycle class

Maybe a better question for an in person interview so they can actually write some pseudo code, but I think it could work for a phone interview as well...  Describe a bicycle (it has handle bars, wheels, etc.  Someone rides it.) and have them describe how they would model the class(es).  Nothing ground breaking here, but if they struggle with this question, they likely are still TOO junior to be an asset.


答: I recommend Enterprise Architect. With it you can write requirements, use cases and all the UML artifacts. You can get more info at  Sparxsystems web page</p>

Title: Software for requirements and use cases


答:
My advice is to shy away from use case diagramming tools. To quote Martin Fowler, from UML Distilled, Third Edition, on the use of Use Case Diagrams:

Nothing in the UML describes how you should capture the content of a use case. What the UML describes is as use case diagram, which shows how use cases relate to each other. But almost all the value of use cases lies in the content, and the diagram is of rather limited value.

A use case diagram can be included in a requirements document to provide a high-level visualization of the relationships between actors and requirements. Typically, use cases are best captured in a textual form. This could be stored on a wiki, on note cards kept in the team space, or in a document that is easily accessible to the team.

My recommendation is to first choose how you want to manage your requirements. If you can, I would prefer a wiki - it's easy to keep up-to-date and it's incredibly easy to get the latest and most accurate documentation into the hands of the people who need it. If a wiki is not an option, I do recommend having the ability to version and track changes. Word has a change tracking feature built in, so encourage its use. Alternatively, something like SharePoint could also work, which can lock files during editing, and help track versioning.

If you want a use case diagram, include it in the image, but remember that it's one more thing that needs to be maintained (and out of date use case diagram is worse than not having one). Since a use case diagram is simple, tools such as Dia or Visio can easily be used to create the image. If you are using a word processor that has the capabilities, consider creating the use case diagram from inside the word processor. In the case of using Microsoft Office, you can always embed Visio artifacts into a document and easily edit them from inside Word.

I would not recommend using a separate document for each use case, especially if it's an offline document produced in a word processor, such as Microsoft Word. If you are going to be keeping them electronically, such as in a wiki, then a separate page per use case might be appropriate, especially from a change-control and revision history perspective, as long as they are linked to appropriately and it's easy to navigate the pages.

For additional resources, I not only recommend UML Distilled for all of your needs, but also Software Requirements and More About Software Requirements: Thorny Issues and Practical Advice by Karl Wiegers. All of these books cite Alistair Cockburn's Writing Effective Use Cases.

Title: Software for requirements and use cases


问:
Are there any language agnostic unit testing frameworks?
I have always been skeptical of rewriting working code - porting code is no exception to this.  However, with the advent of TDD and automated testing it is much more reasonable to rewrite and refactor code.

Does anyone know if there is a TDD tool that can be used for porting old code? Ideally you could do the following:

Write up language agnostic unit tests for the old code that pass (or fail if you find bugs!).

Run unit tests on your other code base that fail.

Write code in your new language that passes the tests without looking at the old code.

The alternative would be to split step 1 into "Write up unit tests in language 1" and "Port unit tests to language 2", which significantly increases effort required and is difficult to justify if the old code base is going to stop being maintained after the port (that is, you don't get the benefit of continuous integration on this code base).

EDIT: It's worth noting this question on StackOverflow.

答:
Methodologies vary, but in my case a big part of my TDD tests tend to the 'integration test' style, as opposed from 'unit test'.  That is, most of my them test the whole program in nearly-real-life queries, checking for appropriate responses.

In a few cases, when I wrote network driven programs (mostly application-specific protocols), I didn't have a full test framework handy that felt easy for the job, so I did most of the testing 'across the network', in short, I wrote a very simple client in another language with a common and simple test framework, and most of the tests checked the server's responses.

Still, even in those cases, I injected a few hand-rolled tests in the real application to test some non-network parts.


问:
How to increase the bus factor and specialize at the same time?
In agile pair programming it is recommended to switch pairs every now and then so as to increase the bus factor of the team. That means, most people in the team should work on different parts of the system at different times so that everyone has an understanding of it.

Now it is impssible that everyone has an expert level of understanding of each part of the system. That's because people are urged to specialize in one area of expertise. If you are an expert database admin, what's the point of working on the user interface of the system when you switch pairs? You will not be able to do such a high quality job as someone who has extensive experience in UI design.

How can you increase the bus factor and make sure that you have specialization in your team?

答:
Mix 'em up

Specialization is only a means to gain expertise.

Expertise does not have to come from formal training.  It is most often gained by self-study and experience.  And it is possible for programmers to be expert in multiple areas.  By pairing people with differing experience, you can spread expertise throughout the team.  After a while, instead of one database expert, and one UI expert, you will have several people who are highly capable in both.  This is good for the team, and good for the team members.


问:
Explaining technical things to non-technical people
I often have to explain technical things and technical decisions to my extremely non technical manager and I'm pretty awful at it. What are good ways to essential dumb things down for the rest of the world who don't have a passion for programming?

Example questions I've been asked:

Why are you using Django instead of Java (Didn't accept that it was cheaper either)

Asking me to rephrase things in non technical words, my sentence was "Certain HTML tags are not allowed". How can I possibly dumb that down?

Other stuff that makes perfect sense to me, but is just so basic I don't know how to explain it

Why this, why that, why everything!

Also, how do I tell my manager to look the basic stuff up on Google, like "What is Pylons?"

答:
You're doing yourself an emotional and career disservice by getting upset in having to explain technical details to non-technical people. The fact that non-technical people need you to translate technical processes to non-technical business processes and vice-versa is what got you employed. The more proficient you are at translating between the two problem domains, the more valuable you become to an employer.

Familiarize yourself with manufacturing techniques, and explain the development process in terms of assembly line processes.

For example, explaining the processing of html tags (and thus the inability to use them) can be expressed in terms of extrusion dies, popularly known in play-doh.

Explain the problems of development process, such as changing requirements, updating interfaces, product defects, etc., in terms of the cost of shutting down the line, the time & expense spent building the line and having to modify it when requirements or conditions change, etc.

I went into more detail in another answer.


问:
How to mark an empty conditional block in Java
In C++ when I wanted to mark that if is empty by design I added NULL; as statement:

```<code>if (cond1) {
    ...
} else if (cond2) {
    NULL;
} else {
    ...
}
</code>```

However in Java it seems to be impossible to have null; as statement. What is the correct way of marking empty by design if in Java (is it just comment)?

答:
That's a bad practice altogether and you shouldn't have this block in the first place. If you don't react on a condition then don't code it. It's a code smell and contains hardly any useful information. Using it to design a program flow is even worse, as this can always be expressed more elegantly.

The correct way of handling this is to remove the unecessary else if or to rewrite your conditions instead of having a marker for an empty block.

In your example that would be:

```<code>if (cond1)
{
    ...
}
else if(!cond2)
{
    ...
}
</code>```

If the conditions are tedious to write or too difficult to read, then encapsulate them in a method or evaluate them once and save them to a variable.

If you really really want to communicate why you did not handle a certain condition, write a comment above the method or the statement.

Body:
That's a bad practice altogether and you shouldn't have this block in the first place. If you don't react on a condition then don't code it. It's a code smell and contains hardly any useful information. Using it to design a program flow is even worse, as this can always be expressed more elegantly.

The correct way of handling this is to remove the unecessary else if or to rewrite your conditions instead of having a marker for an empty block.

In your example that would be:

if (cond1)
{
    ...
}
else if(!cond2)
{
    ...
}

If the conditions are tedious to write or too difficult to read, then encapsulate them in a method or evaluate them once and save them to a variable.

If you really really want to communicate why you did not handle a certain condition, write a comment above the method or the statement.


问:
Any good reason to open files in text mode?
(Almost-)POSIX-compliant operating systems and Windows are known to distinguish between 'binary mode' and 'text mode' file I/O. While the former mode doesn't transform any data between the actual file or stream and the application, the latter 'translates' the contents to some standard format in a platform-specific manner: line endings are transparently translated to '\n' in C, and some platforms (CP/M, DOS and Windows) cut off a file when a byte with value 0x1A is found.

These transformations seem a little useless to me.

People share files between computers with different operating systems. Text mode would cause some data to be handled differently across some platforms, so when this matters, one would probably use binary mode instead.

As an example: while Windows uses the sequence CR LF to end a line in text mode, UNIX text mode will not treat CR as part of the line ending sequence. Applications would have to filter that noise themselves. Older Mac versions only use CR in text mode as line endings, so neither UNIX nor Windows would understand its files. If this matters, a portable application would probably implement the parsing by itself instead of using text mode.

Implementing newline interpretation in the parser might also remove some overhead of using text mode, as buffers would need to be rewritten (and possibly resized) before returning to the application, while this may be less efficient than when it would happen in the application instead.

So, my question is: is there any good reason to still rely on the host OS to translate line endings and file truncation?

答:
While Unix (MacOS-X is Unix for the purpose of this) and Windows consider files as a stream of bytes and differs only in some little details about what is a text file and what isn't, when other OS come into play you have more variety.  Three examples:

in some OS, text file are a set of fixed width lines and lines are padded with spaces up to the fixed width (and you know understand why C and C++ don't guarantee that spaces at the end of a line are conserved)

others OS have a notion of permanent line numbers and the C runtime has to skip in,

the system call (to use a Unix terminology) used to open a text file may be different than the one used to open a binary one.

You could probably imagine a way not to specify it, you'd have to drop the interoperability for your C or C++ programs with those abiding the OS convention.


问:
How one could use a live editor
I was thinking about a live editing environment where code / a source file is synchronized so that changes made by one user would be carried across to all others editing the file.
Something like Google Wave, but for code.

Could this kind of an environment be better for the code, as changes are shared instantly?
(with revision-control, of course)

Has anyone tried (or has had a need for) using a shared environment for code?
I'd love to hear from someone who has used such an editor.

答:
I've used a VCS in which you saw immediately the check in of others if you hadn't modified the files.  It was a mixed blessing.  It was beneficial enough that I seem to synchronize my workspace far more often that those who haven't used such system but problematic enough that I appreciate the possibility to delay the synchronization at a time convenient for me.

Real time merging the file I'm currently modifying with what my colleagues are doing now on the same file would be nightmarish.  How could you work without being sure that the strange behavior comes from my changes (that's already sometimes difficult to admit and to find) instead of their? What about them introducing a dependency on a modification on a file I'm not modifying?

Title: How one could use a live editor


答:
I can think of just one use-case where such behaviour would be a benefit: Pair programming in a geographically separated team. And then the file should be lockable and one should be able to grant editing permission only to the people you want to work with in this session. But this scenario can already be handled better, with other tools like TeamViewer for example.

For most other use cases this scenario is horrible. There'd be plenty of collisions between people who are editing the code simultaneously. Have you ever experienced probems while merging code into source control? And now you want to have these problems while working live on a file? In real time? Your code gets messed up and you cannot compile it because someone else just hit the save button? Or even worse, your changes get lost! Congrats, you just lost two hours of work just because someone decided to save his version.

Title: How one could use a live editor

Body:
I was thinking about a live editing environment where code / a source file is synchronized so that changes made by one user would be carried across to all others editing the file.
Something like Google Wave, but for code.

Could this kind of an environment be better for the code, as changes are shared instantly?
(with revision-control, of course)

Has anyone tried (or has had a need for) using a shared environment for code?
I'd love to hear from someone who has used such an editor.


问:
What factors should be evaluated when determining a desktop software price?
What factors should be evaluated when determining a desktop software price?</p>

答:
Pick your positioning strategy. Do you want to be:

pricier but comes with richer features software provider?

or cheaper and lesser features software provider?

or be a sticky competitor, i.e. always following your nearest competitor foot steps in terms of selling price and product features. You could be slightly cheaper/pricier than others. Features imitation are always feasible, unless there are patents/legal barriers.


问:
Licensing issue for RSA and Rijndael algorithms
I'm using .Net to build a commercial application, i.e. a secure chat application. This application is using RSA and Rijndael algorithms.

Do we need licenses for using RSA and Rijndael algorithms for commercial product?

答:
For RSA algorithm, no license required for any products developed after September 6, 2000. The date is important.

BEDFORD, MA.— RSA® Security Inc. (NASDAQ: RSAS) today announced it has
  released the RSA public key encryption algorithm into the public
  domain, allowing anyone to create products that incorporate their own
  implementation of the algorithm. This means that RSA Security has
  waived its rights to enforce the patent for any development activities
  that include the RSA algorithm occurring after September 6, 2000.


答:
In general should previously needed complexity be removed even though
  it works and there has been a historically demonstrated need for the
  complexity but you have no indication that it will be needed in the
  future?

No.

Even if the question above is generally answered "no" is it wise to
  remove this "un-needed" complexity if handing off the project to a
  competitor (or stranger)

No. Why wasting your time for fixing the low priority works like this? No harm for the code staying there.

As for your question: When should complexity be removed?

My take is, if it ain't broke, don't fix it.

Title: When should complexity be removed?


答:
I try to find an analogy to something similar in the real world.  Like, when I mentioned a stack and someone asked what that was:

"Well, you've got kids.  Do they ever play with those little wooden blocks with letters on them?"

"Yeah."

"Ever see them make a big tower by stacking one block on top of another?"

"Yeah."

"OK, and when you've got a tower like that, it's only safe to touch the top of the tower, right?  You can put another block on, or you can take the block on top off, but if you move anything underneath the top block, the whole thing's gonna fall down, right?"

Laughing. "Yep!  They love to smash the tower and make them all fall down!"

"Well, a stack is basically like doing that with data.  You set up a data structure in a way that you can only add things to the top or remove the element on top.  It's useful for keeping track of things that you're partway through doing, but you need to do something else first, and then before you finish that you need to do something else, and so on."  (Thus introducing the idea of a call stack.)  "Except that you don't want to knock the tower down in this case."

"Oh, I get it now.  Cool!"

Title: Explaining technical things to non-technical people

Body:
I often have to explain technical things and technical decisions to my extremely non technical manager and I'm pretty awful at it. What are good ways to essential dumb things down for the rest of the world who don't have a passion for programming?

Example questions I've been asked:

Why are you using Django instead of Java (Didn't accept that it was cheaper either)

Asking me to rephrase things in non technical words, my sentence was "Certain HTML tags are not allowed". How can I possibly dumb that down?

Other stuff that makes perfect sense to me, but is just so basic I don't know how to explain it

Why this, why that, why everything!

Also, how do I tell my manager to look the basic stuff up on Google, like "What is Pylons?"


答:
A common saying is: "If it ain't broke, don't fix it".

There are several rationals behind this rule.  Some of those might be that the "simplification" will risk introducing new, different and possibly bigger bugs, could take an expanding amount of development time away from other more valuable endeavors, and could be completely the wrong change for some unexpected future business opportunity that arises.

If there is sufficient business value for this code to be portable and more maintainable, then decide if that value is really enough to consider the current code "broken".  It could well be, if there is a major business expansion planned, or you suspect a latent bug hidden in the complexity that could bring down the business.

Title: When should complexity be removed?


答:
Firstly, how is this:

```<code>if (cond1) {
    ...
} else if (cond2) {
    NULL;
} else {
    ...
}
</code>```

Better than:

```<code>if (cond1) {
    ...
} else if (cond2) {

} else {
    ...
}
</code>```

The NULL;-statement doesn't tell anything, or does it?

Secondly, as others pointed out, you don't have to have that empty block, unless you need to say something about the condition or possibly leave space to handle it.

So this makes perfect sense:

```<code>if (cond1) {
    ...
} else if (cond2) {
    //cond2 is not handled, because 2 is the smallest prime number
} else {
    ...
}
</code>```

Or this:

```<code>if (cond1) {
    ...
} else if (cond2) {
    //TODO: investigate whether/how this condition needs to be handled
} else {
    ...
}
</code>```

However an undocumented empty consequence serves no purpose, whether you write NULL; in there or not.

Lastly, if you feel like you are having too many conditions, then you should investigate how behavioral patterns and polymorphism in general could help you clean up your code.

Title: How to mark an empty conditional block in Java

Body:
In C++ when I wanted to mark that if is empty by design I added NULL; as statement:

```<code>if (cond1) {
    ...
} else if (cond2) {
    NULL;
} else {
    ...
}
</code>```

However in Java it seems to be impossible to have null; as statement. What is the correct way of marking empty by design if in Java (is it just comment)?

Body:
Firstly, how is this:

if (cond1) {
    ...
} else if (cond2) {
    NULL;
} else {
    ...
}

Better than:

if (cond1) {
    ...
} else if (cond2) {

} else {
    ...
}

The NULL;-statement doesn't tell anything, or does it?

Secondly, as others pointed out, you don't have to have that empty block, unless you need to say something about the condition or possibly leave space to handle it.

So this makes perfect sense:

if (cond1) {
    ...
} else if (cond2) {
    //cond2 is not handled, because 2 is the smallest prime number
} else {
    ...
}

Or this:

if (cond1) {
    ...
} else if (cond2) {
    //TODO: investigate whether/how this condition needs to be handled
} else {
    ...
}

However an undocumented empty consequence serves no purpose, whether you write NULL; in there or not.

Lastly, if you feel like you are having too many conditions, then you should investigate how behavioral patterns and polymorphism in general could help you clean up your code.


问:
Mobile Web Framework that will only control rendering and page transitions
I have been using jQueryMobile for a bit now, and there are some things I like about it and others I do not.

First I will give a bit of background.

I have a light weight mobile application that has a few configurations and 6 pages. Ideally I Would like to load all pages into the DOM (they interact with each other quite often and pages will be switched in the same frequency). The application will post for some JSON every n seconds and refresh the values on the page (yes it is primarily a information display app).

with the jQuery Mobile framework the only real thing I like is how easy it is to have a standardized UI a crossed all devices and browsers, I'm really not using too much else out of the framework other than the basic page navigation (if you are familiar with the framework; a bare-bone multi-page design is all i need).

Why I want to step away from jQueryMobile is how weighty it is. Not only do you need to include the mobile library, but also the base jQuery libraries. This I do not like because I'm not using jQuery anywhere else on the site.

Any suggestions on light-weight mobile frameworks that have a similar rendering as jQueryMobile?

答:
Here is a great (but slightly out of date) break-down of mobile development frameworks.

You should remember that "weight" is just one variable impacting your goal--that goal is almost certainly an app that "feels responsive."  So you have other variables, such as "touch response," "transition fluidity," and "impact on other code."  If you use a framework that takes an extra second to download on a 3G network but the app responds 20% faster you're going to be way ahead.  Also, if you're considering deploying with PhoneGap, you should probably choose something that's developed to take advantage of PhoneGap (jQuery Mobile is, as is Sencha Touch.  I don't know for certain on others)

(In my personal opinion, jQuery Mobile does NOT respond as well as some of its competitors.)


问:
Differences between programming in school vs programming in industry?
A lot of students when they graduate and get their first job, feel like they don't really know how to program even though they may have been good programmers in college.

What are some of the differences between programming in an academic setting and programming in the 'real world'?

答:
Scale & Focus

From my experiences, in an academic setting, generally the scale of the application you are working on is much smaller, something that can be completed in a day or week, or perhaps as long as the semester by one or two progammers--typically everything you write will be throw-away code that is discarded after the term. In the real world, you may find yourself working on an application that a larger team has taken months, if not years, to fully develop. You spend a lot more time and debugging other people's code, and trying to understand a codebase's infastructure, juggling not breaking the existing parts to add some new or modified requirement.

Requirements, Integration, Customers

Also, there are aspects to developing code, such as requirements analysis, integration testing, etc. that tend to be less represented in academic projects. For the sake of fair grading, typically the requirements are already established for you by the instructor, and it's not collaboratively decided in meetings. You don't tend to have to "sell the customer" on a particular approach that isn't quite what they wanted, but unlike their desires is actually feasible from a techical standpoint. In an academic setting your customer (the grader or instructor) tends to have a pretty concrete idea what they want, in the real world, you may encounter customers who don't really know what they want and have to pick their brain to understand what should be built.


问:
Examples of limitations in IT due to different bit length by design
I am teaching the course "Introduction in Programming" for the first-year students and would like to find interesting examples where the datatype size in bits, chosen by design, led to certain known restrictions or important values.

Here are some examples:

Due to the fact that the Bell teleprinter used 7-bit-code (later accepted as ASCII) until now have we often to encode attachments in electronic messages to contain only 7 bit data.

Classical limitation of 32-bit address space leads to the 4Gb maximal RAM size available for 32-bit systems and 4Gb maximal file size in FAT32.

Do you know some other interesting examples how the choice of the data type (and especially its binary length) influenced the modern IT world.

Added after some discussion in comments:

I am not going to teach how to overcome limitations. I just want them to know that 1 byte can hold the values from -127..0..+127 o 0..255, 2 bytes cover the range 0..65535 etc by proving examples they know from other sources, like the above-mentioned base64 encoding etc. We are just learning the basic datatypes and I am trying to find a good reference for "how large" these types are.

答: IPv4 is a very good example where a limited spec size caused a very expensive problem down the line. 4.3 billion addresses just aren't enough anymore. Now ISPs around the world are desparately rolling out IPv6 with a 128-bit address space which translates into an address for every atom in your body or something like that.</p>


答:
With reading in text mode, you have something like 'characters', binary knows only bytes.

At least in Ruby 1.9 you can define an encoding, when you read a file in text mode.

Examples:

```<code>File.open('sample.txt', 'r') # Read in default encoding
File.open('sample.txt', 'r:utf-8') # Read a utf-8 file
File.open('sample.txt', 'r:utf-8:cp1251') # Read a utf-8 file and convert it to cp1252
</code>```

Doing this, you have a possibility to make differences between bytes and characters. When you read binary, you have only bytes.

Title: Any good reason to open files in text mode?

Body:
(Almost-)POSIX-compliant operating systems and Windows are known to distinguish between 'binary mode' and 'text mode' file I/O. While the former mode doesn't transform any data between the actual file or stream and the application, the latter 'translates' the contents to some standard format in a platform-specific manner: line endings are transparently translated to '\n' in C, and some platforms (CP/M, DOS and Windows) cut off a file when a byte with value 0x1A is found.

These transformations seem a little useless to me.

People share files between computers with different operating systems. Text mode would cause some data to be handled differently across some platforms, so when this matters, one would probably use binary mode instead.

As an example: while Windows uses the sequence CR LF to end a line in text mode, UNIX text mode will not treat CR as part of the line ending sequence. Applications would have to filter that noise themselves. Older Mac versions only use CR in text mode as line endings, so neither UNIX nor Windows would understand its files. If this matters, a portable application would probably implement the parsing by itself instead of using text mode.

Implementing newline interpretation in the parser might also remove some overhead of using text mode, as buffers would need to be rewritten (and possibly resized) before returning to the application, while this may be less efficient than when it would happen in the application instead.

So, my question is: is there any good reason to still rely on the host OS to translate line endings and file truncation?

Body:
With reading in text mode, you have something like 'characters', binary knows only bytes.

At least in Ruby 1.9 you can define an encoding, when you read a file in text mode.

Examples:

File.open('sample.txt', 'r') # Read in default encoding
File.open('sample.txt', 'r:utf-8') # Read a utf-8 file
File.open('sample.txt', 'r:utf-8:cp1251') # Read a utf-8 file and convert it to cp1252

Doing this, you have a possibility to make differences between bytes and characters. When you read binary, you have only bytes.


问:
Is there a language that allows this syntax: add(elements)at(index);

Possible Duplicate:

  Is there a language out there in which parameters are placed inside method name?

Does a language exist with such a syntax? If not, what are some of the limitations/disadvantages to this syntax in case I want to write a language that supported it?

Some examples:

```<code>sort(array, fromIndex, toIndex);
</code>```

vs

```<code>sort(array)from(index1)to(index2);
</code>```

Method signature would like this:

```<code>sort(SomeType[] arr)from(int begin)to(int end){
...
}
</code>```

Update:

Because there might be some confusion, I'd like to clarify...
I meant this question as a general idea like this (not specific to sorting and possibly using keywords like from and to):

In JAVA(like language):

```<code>void myfancymethod(int arg1, String arg2){
...
}

myfancymethod(1, "foo");
</code>```

In imaginary language:

```<code>void my(int arg1)fancy(String arg2)method{
...
}

my(1)fancy("foo")method;
</code>```

答:
TeX has this kind of functionality: you can define for example:

```<code>\def\say #1 to #2.{#2 said: ``#1.''}
</code>```

And use it:

```<code>\say Hello to Mike.
</code>```

To get:

```<code>Mike said: ``Hello.''
</code>```

This allows for some nice syntactic tricks.

Body:
TeX has this kind of functionality: you can define for example:

\def\say #1 to #2.{#2 said: ``#1.''}

And use it:

\say Hello to Mike.

To get:

Mike said: ``Hello.''

This allows for some nice syntactic tricks.


答:
Without the translation, every Unix text-processing program would recognize just '\n' as an end-of-line marker, and every Windows text-processing program would recognize '\r' followed by '\n'.  (And pre-OSX Mac programs would recognize '\r'.)  And any program that writes text would have to explicitly write the local end-of-line marker, which means it would have to be aware of what OS it's running on.

And that just covers the relatively simple cases where an end-of-line is indicated by a sequence of characters.  Other schemes are common (though less so these days); see IBM mainframes and VMS, for example.

With the translation, programs can just treat text as text, and we don't need three or more different "hello, world" programs.

This does sometimes cause problems when you need to process a foreign file (a Windows text file that's been copied to a Unix system, or vice versa).  Cygwin, a Unix-like environment running under Windows, is a rich source of such issues.  But usually the best solution is to translate the file before processing it.  And most of the time, programs deal with text files that were created on the same OS anyway.

It's better to write one program that can translate between formats, than to require every program to deal with all different formats.  And inevitably someone would write a tool that understand Unix and Windows formats, but breaks when confronted with an old Mac text file, and someone else would get the interpretation just a little bit wrong because the wheel they reinvented wasn't perfectly round.


问:
Python: Future as a major programming language?
After reading some Python material and seeing some Python code a few years back I decided to give it a whirl.  I decided to start with Python to solve the problems on Project Euler and was throughly impressed with the language.  Since then I've went on to learn Django, and now use it primarily for my web applications.  I would love to have a career programming in this language, however I fear the future of the language is currently in a state of uncertainness.  With Google and other major companies embracing it there may be some hope, what are your thoughts on Python, do you see many job opportunities out there? </p>

答:
Python is a great language and has a brilliant ecosystem. The popularity of python is due to ease of use, multiplatform readiness and a huge set of libraries. Python is slow, like all interpreted languages, but easily extensible with the ctypes module. There's enormous academic investment in python and it's many scientific libraries means it will be an excellent alternative to MATLAB and MAPLE in universities.
In terms of product develoment, Python shines on the web. It's one of many good platforms. For reasons I don't agree with, many big companies and hospitals still use JAVA and ASP for the web rather than Python. To some extent that limits Python's employment opportunities. While individual developers are enormously attracted to Python/Django, especially for deployment on the google app engine, teams of programmers often use these more complex tools.
The big con of Python is that it's not the best for making "apps" to sell for the iphone, windows phone, tablet PCs, etc. It seems like the big push in programming these days is to write apps that can be distributed for iOS, windows mobile or android. And that's not Python's domain.
I vastly prefer to hack python than objective C for example, a real mess of a language if you ask me, but the frenzie around iphone apps makes objective C the more popular and perhaps more employable language.  </p>


答: You don't have to choose between Python and some other language.  Languages come and go.  I have been paid to program in FORTRAN, C, C++, Ada, Emacs-LISP, Tcl, Java, Perl, Python, Ruby, Javascript, Groovy, and a few others.  There are plenty of teams just looking for good people, assuming that good people will quickly be productive in any language.  I have found such teams to be more fun than the folks trying to hire an <insert-popular-language> programmer.

Title: Python: Future as a major programming language?

Body: After reading some Python material and seeing some Python code a few years back I decided to give it a whirl.  I decided to start with Python to solve the problems on Project Euler and was throughly impressed with the language.  Since then I've went on to learn Django, and now use it primarily for my web applications.  I would love to have a career programming in this language, however I fear the future of the language is currently in a state of uncertainness.  With Google and other major companies embracing it there may be some hope, what are your thoughts on Python, do you see many job opportunities out there? </p>


问:
Diagram that could explain a state machine's code?
We have a lot of concepts in making diagrams like UML and flowcharting or just making up whatever boxes-and-arrows combination works at the time, but I'm looking at doing a visual diagram on something that's actually really complex.

State machines like those that parse HTML or regular expressions tend to be very long and complicated bits of code.

For example, this is the stateLoop for FireFox 9 beta. It's actually generated by another file, but this is the code that runs.

How can I diagram something with the complexity of this in a way that explains flow of the code without taking it to a level where I draw every single line-of-code into it's own box on a flowchart?

I don't want to draw "Invoke loop, then return" but I don't want to explain every last detail.

What kind of graph is suitable to do this? Is there already something out there similar to this? Just an example of how to do this without going overboard in complexity or too-high-level is really what I want.

If you don't feel like looking at the code, basically it's 70 different state flags that could occur, inside an infinite loop that exists to a label based on some conditions, each flag has it's own infinite loop that exists to a label somewhere, and each of those loops has checks for different types of chars, which then runs off into various other methods.

答:
a simple state diagram would do if it doesn't become too large

however you can simplify it a bit when by making actions that are nearly the same but for some small difference visually similar in the diagram

you can check the wiki article on UML state diagrams for further reading


答:
The year 2000 problem was similar, except that people used decimal numbers instead of binary, and encoded just two last digits. This can be a useful example if explaining to someone who has little experience with binary.

FAT12/FAT16/FAT32 were adapted to cover for bigger and bigger storage.

TeX has some interesting properties when representing dimensions (from The TeXBook):

TEX represents all dimensions internally as an integer multiple of the tiny
  units called sp. Since the wavelength of visible light is approximately 100 sp,
  rounding errors of a few sp make no difference to the eye. [...]

TEX will not deal with dimensions whose absolute value is 2^30 sp or more. In
  other words, the maximum legal dimension is slightly less than 16384 pt. This is a distance of about 18.892 feet (5.7583 meters), so it won’t cramp your style.

(pt is a typographic unit approximately equal to 1/72 of inch)

Title: Examples of limitations in IT due to different bit length by design

Body:
I am teaching the course "Introduction in Programming" for the first-year students and would like to find interesting examples where the datatype size in bits, chosen by design, led to certain known restrictions or important values.

Here are some examples:

Due to the fact that the Bell teleprinter used 7-bit-code (later accepted as ASCII) until now have we often to encode attachments in electronic messages to contain only 7 bit data.

Classical limitation of 32-bit address space leads to the 4Gb maximal RAM size available for 32-bit systems and 4Gb maximal file size in FAT32.

Do you know some other interesting examples how the choice of the data type (and especially its binary length) influenced the modern IT world.

Added after some discussion in comments:

I am not going to teach how to overcome limitations. I just want them to know that 1 byte can hold the values from -127..0..+127 o 0..255, 2 bytes cover the range 0..65535 etc by proving examples they know from other sources, like the above-mentioned base64 encoding etc. We are just learning the basic datatypes and I am trying to find a good reference for "how large" these types are.


答:
There's popular, and then there's the most popular. Have no doubt, Python is a popular language. It's just not the most popular. Picking a language because it is the most popular is an OK strategy, but it's not the only strategy. Consider:

In my city (Seattle) you can see
dozens of advertisements a month asking for a background in Python.
That means there are probably thousands of Python jobs worldwide.

That said, there are orders of magnitude more jobs for
PHP, C#, or Java.

However, there are also orders of magnitude more PHP, C#, and Java programmers competing for those jobs.

If you are an average or below average junior programmer, working in a market that only supports line-of-busines type software development, then yeah, you may want to focus on PHP, Java, or C#. However, if you are an above average programmer in a large market, you may want to distinguish yourself from the crowd by adding languages like Python to your toolkit. If you are a brilliant programmer with a long and successful track record, you can specialize in MUMPS or FORTRAN II, or INTERCAL, and still find work.


答: Microsoft Excel - try to graph more than 32K items.  There's got to be a signed 16 bit field in there somewhere. (although they round the limit down to 32000 even for some reason).</p>


答:
Maintenance & Maintainability

In academia (at least at the undergraduate level), software is built with short-term goals in mind, usually to complete some homework assignment or term project. Once the assignment is completed, the code is thrown away and never seen again.

In a professional setting, most software is written with long-term use in mind; software is intended to be used for at least a few years and needs to be built to be easily maintained and updated over time.

Related to this is the work of maintenance. The majority of professional programming work involves updating or maintaining existing software. So-called "green-field" projects are the exception, rather than the norm.

Title: Differences between programming in school vs programming in industry?

Body:
A lot of students when they graduate and get their first job, feel like they don't really know how to program even though they may have been good programmers in college.

What are some of the differences between programming in an academic setting and programming in the 'real world'?