问:
Which spoken languages should I try to support in my android application?
I'm developing a small android app, which is regional independent.
I'm curious, which language should I try to support? At the moment I'm only sure to support the languages I speak fluently. This is German and English.

But what about French, Spanish or Japanese...? Are there any statistics out there to help determine which to support?

P.S.: Should I use maybe crappy automatic translation, if I don't know a native speaker, or should I forget about it otherwise?

答:
Like most things in life, it depends.

Who do you expect to use your application?

Who do you want to support?

Do you know what percentage of people use Android in various countries that speak different languages? (You can probably find different articles that talk about this)  You may not want to spend the time and money translating where there is little to gain.

If someone uses your application that natively speaks a language that you automatically translated, would they find it offensive?

Do you care if they find it offensive?

It really depends on what your goals are and who your audience is for your application.  Once you figure that out, then you will be able to narrow down language specifics much easier.

Viel Glück!


问:
MPL 1.1 and APL 2.0 License compatibility
I am working a project that is licensed under the MPL 1.1 and would like to incorporate some code that is licensed under the APL 2.0.

I know in 2010 Mozilla announced they were updating the MPL to make it more "Apache compatible" among other things.

I'm no lawyer. Exactly what part(s) of the MPL 1.1 don't jive with the APL 2.0 and vice versa? The project has very few of its original contributers still actively involved so I doubt I'd be able to contact all of them to get permission to change the license.

答: As Diphan said, APL 2.0 is less restrict than MPL 1.1 so you wouldn't have problems probably. See the Wikipedia table: Comparison of free and open source software licenses</p>

ContentLicense: CC BY-SA 3.0


问:
When should one read 'Code Complete'?
I'm pretty sure about who, but when?

The one with proficient knowledge of programming and software development or the one who's just a beginner in programming?

I'm pursuing bachelors right now, when is it preferable for folks like me to read this Must read for programmers book?

答:
When one is considering a career in programming.

When one is a programmer.

That means it's OK to read it more than once.

ContentLicense: CC BY-SA 4.0

Title: When should one read 'Code Complete'?

ContentLicense: CC BY-SA 2.5


答:
Building off Ek0nomik's answer of "it depends" -- which is true! -- here's some additional information.

If your internationalized application is ready for localization, prioritization often goes like this:

European languages such as German, French, Spanish, Italian,
Portuguese (although many go for Brazilian Portuguese first).

Asian languages such as Chinese, Japanese, Korean (CJK).

Whatever your user population dictates.

You'll note that leaves a lot out, and that's where "it depends" comes in to play, such as OS usage, relevance to the region, etc. (See also: https://softwareengineering.stackexchange.com/questions/50806/what-languages-do-you-support-when-localizing)

The question in your PS is pretty important, and here I'll put a plug in for crowdsourced translation services.  I know several open source projects that use services such as Transifex.  There are others (search "crowdsourced translation" in Google), and the costs range from some variation of free to monthly fees that might be out of your budget range.  However, a quality localization will win you users while a bad localization (relying solely on automatic translators without quality control) will not only not win you any users, it will "win" you negative press.

Title: Which spoken languages should I try to support in my android application?

Body:
I'm developing a small android app, which is regional independent.
I'm curious, which language should I try to support? At the moment I'm only sure to support the languages I speak fluently. This is German and English.

But what about French, Spanish or Japanese...? Are there any statistics out there to help determine which to support?

P.S.: Should I use maybe crappy automatic translation, if I don't know a native speaker, or should I forget about it otherwise?


问:
What are the monetary benefits of going agile?
Why go agile? This is the first question that comes to my mind when I think of going agile. What are the possible financial benefits one can achieve from going agile?

Most of us certainly like to think of customers and clients as someone who doesn't know what they wants. So why help them at all? Why not suck their money being a parasitic company and make them stupider by the day. Traditional software development isn't bad and are probably (mostly as far as I have seen) a lot easier environment to work in rather than agile projects.

So why go agile at all? What can agile give extra (I mean financially) that traditional software development can't?

答:
There is a demonstration I saw that is a pretty good analogy of the benefits of Agile over more traditional methods. It's based on the game Battleship. You and the other player sit down to the normal Battleship grid. You both have 20 shots, each costing $5,000 for a total initial expense of 100,000. Here's the catch; you have to plan ALL your shots before firing a single one. Your opponent will fire his shots "normally"; take a shot, see what happens, take another shot.

At the end of 20 shots, guess who scored more hits?

The analogy translates to Agile vs Waterfall pretty cleanly; In Agile, you are able to take the sum total of everything you have already done into account when planning what you're going to do next. You will have some basic idea of the areas that will be difficult and the areas that will be easy based on difficulties or lack of difficulty you have already experienced. You also have gotten feedback from your client in smaller chunks, stating that they liked this or didn't like that, and are able to incorporate that knowledge quickly, without having built a lot of additional code on top of something the client says is wrong.

In traditional Waterfall methodologies, the entire system and the development schedule is planned out before coding ever begins. This is the "plan all shots before firing one" approach; you may be able to deliver exactly what the client asked for, but they could take a look at it and say "that's not what we need". Yeah, you get your money because you delivered according to the terms of the contract, but your developers have wasted their time, your client has wasted their money, and neither are happy with the result. Agile is designed to help with this, by allowing the requirements of the project to change while development is underway. Anything you haven't done yet is open to change; anything you HAVE already done can also change, by adding additional stories to the backlog incorporating the amendments to the current product.

Also, because the client gets to decide what you work on first, and with you delivering small chunks of completed work more often, the client could conceivably have a system they can use sooner. That's visible ROI to your client, which usually makes the client more willing to buy in to this more involved development process.


问:
How many user stories per person should be completed per sprint?
Just ran across this figure, and wondering if there's another well know source than would help confirm these numbers:

Based on data I analyzed on successfully finished sprints, I
determined that a team should average around 1 to 1-1/2 user stories
(product backlog items of any sort, really) per person per sprint.

SOURCE: Mike Cohn's Blog on "Should the Daily Standup Be Person-by-Person or Story-by-Story?"

答:
I think at a fine grained level saying "everyone should complete 1.5 stories per sprint" is the risky interpretation of the analysis. What I've found is that over time, the team settles on specifying stories of similar complexity. It forms a baseline by which you can appropriately plan going forward. In other words velocity. I never like measuring velocity by number of stories but rather by story points. In general though it washes out because of the difference in size between stories (smaller stories offset larger stories).

It's nice to see that he discusses differences in sprint length (longer sprints tend to tackle larger stories) and team size in the impact here. Also pulling back the curtain (i.e. having detailed tasks related to the stories) provides more visibility into what goes into completing the story (which is ultimately what that post is about -- visibility).

So as a rule of thumb, Cohn is saying target around 1-1.5 stories per developer per sprint. Much more than that, and you risk not hearing progress of a story until you're deep within a sprint. Lean addresses this by leaving stories in the backlog until they're ready to be pulled into development. What Mike is saying is that your effective Work In Progress for development should be limited to 1.5X where X is the size of the development team.


问:
How to determine the priority and severity of a "code improvement"?
We have "priority" and "severity" fields in our bug tracking system. We define severity as "how it impacts the user" and priority as "how it impacts the product".

My question is about how to categorize a "code improvement" task in severity and priority. Suppose the improvement does not change any behavior but makes it a "better code". We anticipate a long term maintenance improvement overall but it's hard to quantify.

When we use our definitions for priority and severity, a code improvement gets the lowest values for both unless you introduce some hard to predict long term benefits into the picture. Therefore it implies that code improvement is a frivilous task and should never be attempted.

However I believe it's cruical to constantly improve and refactor the code, because:

Software development is itself a continuous learning process and without improving the code you can't get better at it.

A team should be proud of their code.

Future maintenance will take less time and over the long run savings will be significant.

Or do you think such tasks should never be created and such improvements performed only "on demand", "when associated with a bug"? Even if it's associated with a bug, wouldn't that be a discussion point on a code review, e.g. "why did you do this drastic change in structure?".

答:
What is missing is verifying your assumptions about the existing code: less time and significant savings can be achieved if we improve the code. Is this cosmetic or are there serious issues?

Check your debugging and enhancement estimates. If they are taking longer and there are continuous comments about having to refactor the code first or clean it up, that may be your best measurement. Then you can identify your code base as: Good, needs minor rework or serious refactoring required.

All of this is relative. It is difficult to give this high priority when there are customers wanting more features and willing to pay immediately for the billable hours.


问:
Modularity vs Single class simplicity
I have been part of the organization I work in for the past year and a half or so. The company basically writes Perl code and they have large amounts of legacy code which originally prevented the company from moving forward with any code changes. My first observation with the existing code was non existence of Modularity.

Over the time I worked here I, with the help of a few (who left the company), did a lot of hardwork Modularizing all the core sections of the application. I believe that we now have about 70% of the core systems modularized, coherent and layered. At this point in time I am accused of complicating the system design and everything I try to do is sort of looked at with suspicion.

To design these systems I applied all the best design approaches(patterns) and methodologies(SOLID) available or known to me. When I wrote it, it was all appreciated but now the developers want to revert back to what they believe as simpler methodologies(which basically involves having large single classes, doing 100's of things). I still do not believe that those approaches are actually going to lead to simpler design but no one is actually ready to listen.

To give an example, our code basically loads a bunch of files during its lifetime. Traditionally the class handled a lot of things like loading the file, repeatedly checking if the file has changed, is the right version of the file loaded etc. We also load a different set of files for test cases to ensure that it is working fine. All this was done very un organized fashion earlier. Every one created their own version of the file. There were lots of versions of these files and they were un manageable. I introduced a subsystem that will load you the right file(do the version verifications) given a name and a configuration that will tell all the versions of the file available. It eventually ensured that only two to three versions of the files are used across all the test cases. It basically follows a facade and factory pattern where the loader will create the right file object, which will have interface to load, save and should_reload. It was eventually even used to load contents from CouchDB as they only represent a document. This is now too complicated for the developers and no one really reads the code or the documentation I wrote. I do agree that going back to our old system will remove one sub system but will bring back the problem of un manageable number of files.

At this juncture I find myself quite unsure of all the things I have learnt. I find myself not really interested in suggesting any improvements as my solution will only be accused of being too complicated.

What do you think I can do at this point in time?

答:
It's just entropy.

If you keep your objects--or at least their external view, the methods, properties, etc.--as small and as simple as possible, there is no limit to what you can do and to what you can maintain and enhance.  Systems of near-infinite capabilities and complexity become possible.  But it can take extra work and self-discipline to stick to this on a day-to-day basis.

Consider a display table (Class DT).  You want to know which row is selected.  If all your classes are small, you will need to use one of DT's few methods to get a Row object.  Then you will need to use one Row's few methods to get a Selection object.  A Selection method will finally tell you which row is selected.  Your typical developer will want to add a DT method, "getSelectedRow".  It's easy to add.  Saves time in use.  Can be spotted in documention far more quickly.  All in all it's a win-win idea and you can't argue against it.  There are no flaws.

Of course, once DT has 500 methods, etc., finding that one method can get real tricky.  When it's got 1000+ it can be impossible.  But it's impossible to explain that to people.  First they're only going to add one new method/property/whatever.  When there's too many, they have no idea what's wrong, so they're not going to fix it even if they would pay the cost--which they won't.  I think some people like this situation because they've memorized all 500, and there won't be so much competition for their job--they're one of very few people who can use the class effectively.

Every now and then someone does something right and great software is produced.  But the usual trend is to bury the simplicity that makes useful complexity possible beneath all kinds of enhancements that, indidividually, make life easier and, collectively, make a system unfixable and unenhancable.  I have seen, in both small companies and in immense, core IT companies, a continuing need to scrap old systems and build entirely new ones because no further work could be done on the old ones.  I have seen both individual programmers who had to get new jobs because they could no longer make sense of their old code and major software companies that had to produce brand new systems because they could do no more work on their old ones.

I think all you can do is:  Keep your own code clean.    Try to sell your ideas to one or two of the other programmers.  Hope management notices that your stuff has fewer bugs, gets produced faster (in the long term), and is enhancable.  And if management becomes too oblivious to what you are accomplishing, get another job and hope it works out better.

Title: Modularity vs Single class simplicity


问:
When checking for transposed day and month values between two Dates - should comparing 11/11/2000 and 11/11/2000 return true or false?
Assuming a function with a signature of

```<code>boolean isTransposed(Date date1, Date date2);
</code>```

Example outcomes:

```<code>date1   date2           Outcome
06/02/2000  02/06/2000  true
02/06/2000  06/02/2000  true
02/06/2000        null  false
06/02/2000  02/06/1987  false
11/11/2000  11/11/2000  true
04/04/2001  04/04/2000  false
</code>```

Granted the behavior can be documented but what are your thoughts on isTransposed('11/11/2000', '11/11/2000') returning true verse false?

答:
A boolean is not a sufficient return value to return the comparison. If you are writing generic code, you want something thats tri state. Probable an enum like

```<code>enum TransposeResult
{
   notTransposed,
   transposed,
   inputIdentical,
};

TransposeResult calcTransposeState(...)
</code>```

Then leave it up to the user to figure out what to do when they're already identical.

OwnerDisplayName: Brian

Body:
A boolean is not a sufficient return value to return the comparison. If you are writing generic code, you want something thats tri state. Probable an enum like

enum TransposeResult
{
   notTransposed,
   transposed,
   inputIdentical,
};

TransposeResult calcTransposeState(...)

Then leave it up to the user to figure out what to do when they're already identical.


答:
Let's start with two assumptions here.

For every new story, you write your code to the best of your ability, possibly shored up with the ambient knowledge of your team.

Whenever you have a story that changes the functionality of existing code, you use your new knowledge of the system and better skills to improve the code in the process of implementing the new story.

Given those two assumptions, there is never a need for an explicit "code improvement" effort. Your code improves as you write the system. This means that not all of the code is up to your latest and greatest standards for maintainability but "If it ain't broke don't fix it." I consider refactoring code that doesn't need to be changed to be "gold plating" as much as adding unneeded visible functionality. If the code is broken in some way, write a valid test that fails; log a bug; and then refactor to address that bug.

Title: How to determine the priority and severity of a "code improvement"?

Body:
We have "priority" and "severity" fields in our bug tracking system. We define severity as "how it impacts the user" and priority as "how it impacts the product".

My question is about how to categorize a "code improvement" task in severity and priority. Suppose the improvement does not change any behavior but makes it a "better code". We anticipate a long term maintenance improvement overall but it's hard to quantify.

When we use our definitions for priority and severity, a code improvement gets the lowest values for both unless you introduce some hard to predict long term benefits into the picture. Therefore it implies that code improvement is a frivilous task and should never be attempted.

However I believe it's cruical to constantly improve and refactor the code, because:

Software development is itself a continuous learning process and without improving the code you can't get better at it.

A team should be proud of their code.

Future maintenance will take less time and over the long run savings will be significant.

Or do you think such tasks should never be created and such improvements performed only "on demand", "when associated with a bug"? Even if it's associated with a bug, wouldn't that be a discussion point on a code review, e.g. "why did you do this drastic change in structure?".


问:
Would you allow your programmers to use Messenger and social networks like Facebook?
I had many bosses, each one had a different approach about allowing or not use of Windows Live Messenger, Facebook, and many other Internet sites.

Of course Internet is really needed to research about the best way to solve a specific task. Sometimes you could have a friend online, also a programmer, who knows better about something.

For some managers, internet access would slow down project progress, and on the other hand, allow people to interact and find out brand new solutions.

What would you do?

答:
Yes, as long as I still do my work.  Developers need to be treated with a degree of trust, unless you want to spend all your time watching them, which means you don't do your work and you have unhappy devs.

If a developer just isn't turning in the work then discuss it with him, and if necessary request his internet history from IT.  If he's failing to turn in work in a timely manner and you see that he's spending all his time on YouTube, then it's time to have a quiet little word.

You also have to understand that sometimes a developer will just be blocked from doing work, through no fault of his own.  I was a build engineer at a small company, where the build machine was (you guessed it!) my desktop.  A build would last up to half an hour, and would max out the machine for most of that (it wasn't a very powerful machine - actually an old dev box from a previous employee who had left).  I would then go and test the install, which would take about 20 minutes.  I normally took a book to work.


答:
As far as I'm concerned, if your function is called isTransposed, then checking the values of 11/11 and 11/11 should yield true.

The definition of transpose is:

Cause (two or more things) to change places with each other.[1]

...it doesn't have anything to do with input and output being identical.

Think of it as:

```<code>/**
 * Check whether date2 is the same as date1 with the month and day
 * transposed.
 */
boolean isTransposed(Date date1, Date date2);
</code>```

However, having:

```<code>/**
 * Determine whether or not the month and day of date1 have been
 * transposed in date2.
 */
boolean hasBeenTransposed(Date date1, Date date2);
</code>```

Then it could fail, because it would not have a reasonable way to figure out whether or not they really were successfully transposed.

Update:
After receiving numerous comments about how "I can only guess what the expected result would be", let me clear it all up once and for all.

The question is:

When checking for transposed day and month values between two Dates - should comparing 11/11/2000 and 11/11/2000 return true or false?

And the function is:

```<code>boolean isTransposed();
</code>```

Now, this function contains two words: is and transposed. We all know what is refers to: to be. Not may be: to be. You can find the definition for tranposed above.

There is no context whatsoever, and none of these two words are up to interpretation: they each have their own clear definition.

The question is not "Is this function name appropriate?" or "What should this function check for?". If one thinks otherwise, then he is the one guessing.

Body:
Assuming a function with a signature of

```<code>boolean isTransposed(Date date1, Date date2);
</code>```

Example outcomes:

```<code>date1   date2           Outcome
06/02/2000  02/06/2000  true
02/06/2000  06/02/2000  true
02/06/2000        null  false
06/02/2000  02/06/1987  false
11/11/2000  11/11/2000  true
04/04/2001  04/04/2000  false
</code>```

Granted the behavior can be documented but what are your thoughts on isTransposed('11/11/2000', '11/11/2000') returning true verse false?

Body:
As far as I'm concerned, if your function is called isTransposed, then checking the values of 11/11 and 11/11 should yield true.

The definition of transpose is:

Cause (two or more things) to change places with each other.[1]

...it doesn't have anything to do with input and output being identical.

Think of it as:

/**
 * Check whether date2 is the same as date1 with the month and day
 * transposed.
 */
boolean isTransposed(Date date1, Date date2);

However, having:

/**
 * Determine whether or not the month and day of date1 have been
 * transposed in date2.
 */
boolean hasBeenTransposed(Date date1, Date date2);

Then it could fail, because it would not have a reasonable way to figure out whether or not they really were successfully transposed.

Update:
After receiving numerous comments about how "I can only guess what the expected result would be", let me clear it all up once and for all.

The question is:

When checking for transposed day and month values between two Dates - should comparing 11/11/2000 and 11/11/2000 return true or false?

And the function is:

boolean isTransposed();

Now, this function contains two words: is and transposed. We all know what is refers to: to be. Not may be: to be. You can find the definition for tranposed above.

There is no context whatsoever, and none of these two words are up to interpretation: they each have their own clear definition.

The question is not "Is this function name appropriate?" or "What should this function check for?". If one thinks otherwise, then he is the one guessing.


问:
Which applications have driven the mass spread of floating point units?
Floating point units are standard on CPUs today, and even desktops might use them today (3D effects). However, I wonder which applications have initially driven the development and mass adoption of floating point units in history.

Ten years ago, I think most uses of floating point arithmetics constituted in either

Engineering and Science applications

3D graphics in computer games

I think for any application where decimal numbers might have appeared at those times, fixed point arithmetic has been sufficient (2D graphics) or even desirable (finance). Usage of integers would have been sufficient then.

I think these two applications have been the major motivation to establish floating point arithmetic in hardware as a standard. Can you name others, or is there a compelling reason to disagree?

答:
I worked on PC's during a time where a floating point co-processor was an optional extra. You had to pay a significant extra cost to have an 80x87 chip added to an 80x86 system and few programs took advantage of it.

One exception was the first real killer-app for the IBM-PC, the ubiquitous spreadsheet program Lotus 1-2-3. This supported floating-point operations in hardware from relatively early on, substantially speeding up certain operations if you had an FPU.

When Intel got to the 80486, they started integrating the floating point unit onto the CPU, but even then they offered the 486SX variant with the FPU present but disabled. This was substantially cheaper than the 486DX chip and many people took that option to keep costs down.

By this point, the incremental cost in silicon terms must have been lower than the additional costs of the R&D and tooling to create separate 486SX, 487SX and 486DX chips. In fact, if you bought a 486SX system and later added a 487SX co-processor, you effectively had two whole 486DX CPU's both with different halves of the chip disabled!

By the time the Pentium came around, floating point units were expected, and it's infamous FDIV bug caused quite a storm, not just in the scientific community, but in the business community too.


问:
Library/Framework usage guidelines
At my core, I'm a structural, Computer Science sort of programmer (in college I was required to do a lot of programming using C, C++ and even COBOL(!)) and I'm finding more and more conflict with the core fundamentals I developed in my CS degree as opposed to the modern web development world that I'm currently immersed in.  One of those conflicts I'm having is the place of libraries/frameworks in web development.

I've been discovering and experimenting with several libraries/frameworks for some web application development I've been doing.  Some that I've used and/or experimented with include jQuery, jQueryUi, TinyMCE, CodeIgniter, Struts, Spring and GWT.  I have a slight fear of using these libraries/frameworks too extensively because of the rapidly changing nature of web technology.  It seems about every other minute there's some new library/framework available to use in web development, whether it's a new framework or enhancement to an existing technology.  This really rubs against the academic world I was in as we generally spent an entire semester learning the language/concept with the expectation we would later use that knowledge effectively in the workplace.  My fear is that a lack of good understanding of a library/framework will lead to me to a dead end path where I will have more problems than the one that I set out to solve initially.

Sorry for rambling, but I'm wondering if anyone else has experienced such a fear?  I'm also wondering what could be some general guidelines for implementing libraries/frameworks into a web application.  i.e. Should there be a limit of how many libraries/frameworks are used when developing a web application?  Should a developer spend a week (or 2 or 3...) really getting to know the library/framework before attempting to implement it into their web application?

Ultimately looking for answers in the context of libraries/frameworks which (loosely) includes anything that is implemented in a web application outside of the core technology (Java, JSP, PHP, HTML, CSS and JavaScript are core technologies that I personally use).

答:
It depends a lot on the nature of the project. Often I've used less-than-ideal plugins when dealing with time pressure. For example, a new product promo site had to be launched two weeks from the day I was given it. The requirement for an interactive product gallery meant I had to use a plugin that had some limitations and I didn't have time to do modifications.

If I had a longer project timeline I would have done it differently, either improving the plugin or building something better. The push to get it done now can be annoying when you want to do everything right. But, you have to learn to live with the chaos to some degree, especially in web development.

I've found it best to have some "go to" techniques and plugins that allow me to work with tight schedules. One of them is to use a grid based CSS to help handle placement of various elements. I also have my own C#, Javascript and PHP libraries/plugins that I'll use when I can as well as some components written by others that I've used successfully in the past. Occasionally, I'll have to bring in something new and I'll have to trust what I can find out about it via Google and Stackoverflow.

Title: Library/Framework usage guidelines


答:
If creating better software doesn't make you more money, you have a business problem and not a development methodology problem.

Why not suck his money being a parasitic company and make him
  stupider by the day.

Why not provide an actual benefit to the company where they make the connection from your services to their profitability?

Title: What are the monetary benefits of going agile?

Body:
Why go agile? This is the first question that comes to my mind when I think of going agile. What are the possible financial benefits one can achieve from going agile?

Most of us certainly like to think of customers and clients as someone who doesn't know what they wants. So why help them at all? Why not suck their money being a parasitic company and make them stupider by the day. Traditional software development isn't bad and are probably (mostly as far as I have seen) a lot easier environment to work in rather than agile projects.

So why go agile at all? What can agile give extra (I mean financially) that traditional software development can't?


问:
Should we check in Setup Project of Visual Studio
From what I understand, the ideal way to prepare builds using Visual Studio is to use a single build machine. That means, while the developers go through development process using their respective machine, the build isn't prepared from any of those machines and a build PC is used instead.

Under this condition, is it necessary to check-in(using TFS as example here) the setup project. There isn't any version controlling on that particular project as any required change would be done in the build machine itself, and this isn't of any concern to others.

答:
Setup projects are configurable (install location, shortcuts, etc.) and therefore a likely candidate for source control.

That information is all stored in the Setup project and you may one day need to revert to a previous version.

Note that the binaries whose source code you control that the Setup project targets should NOT be in source control.


答:
Anything you require to build your software application should be stored in source control, whether it's used by developers or by a build server. This way you can track any changes that are necessary to build your application. Also, if something happens to your build machine you may lose the setup project you depend on if it is not under source control.

So in short, yes, add your setup project to source control.

Title: Should we check in Setup Project of Visual Studio

Body:
From what I understand, the ideal way to prepare builds using Visual Studio is to use a single build machine. That means, while the developers go through development process using their respective machine, the build isn't prepared from any of those machines and a build PC is used instead.

Under this condition, is it necessary to check-in(using TFS as example here) the setup project. There isn't any version controlling on that particular project as any required change would be done in the build machine itself, and this isn't of any concern to others.


答:
Definitely Yes Yes Yes.

Apart from the normal SCCS reasons of being able to build an old version it's invaluable for discovering why something suddenly won't build because some option flag 10 levels down in a menu tree changed.

In the paranoid old days we used to have the projectfile and the MFC resource files checked in automatically after every successful build - just because things would randomly corrupt and it was the only way to know what had actually changed when the gui claimed nothing had.

ps. on VS2010 you need to check in the .sln .vcxproj and vcxproj.filters


问:
Communicating from lower level components to GUI?
What is the recommended way for a lower level software component/module to communicate with the GUI?  I'm using C++.

I have a service layer class that if some conditions occur needs to notify the user, but still continue processing.  In the case of an unrecoverable error I understand that I can use exceptions to bubble up to the GUI, but what about in the case of a simple message that needs to be communicated to the user where the lower level component continues executing?

UPDATE

Just to clarify the service layer (aka business logic, compute layer, etc) does not "know" about the GUI nor do I want it to.

答:
Depends on if the compute layer 'knows' about the gui.

If the compute layer can use the gui toolkit then you can post windows custom events or send Qt signals or whatever your gui toolkit uses.

If you have more separation, eg. your compute thread is written in pure c and doesn't have any gui hooks, then you typically either supply a 'c' callback function from the gui that the compute thread calls. If the compute thread is a separate process or you are monitoring many of them then some IPC mechanism like a named pipe or in the worst case your compute thread writes a status file that the gui periodically checks for,


问:
Avoiding inline JavaScript with dynamic content
I read here that you should avoid coding JavaScript inline (see item #1).

It sounds like a great idea; however, I'm not sure how to use js to select dynamic content without setting the id in the function call inline.

For example, I have a simple blog. The comments are hidden, but can be displayed by clicking an anchor (generated dynamically) that calls a JavaScript function to toggle the comments for that specific post:

```<code>$commentsButton = "id . "' href='#comments" . $post->id . "'> comments (" . count($comments) . ")";
</code>```

toggleComments() function:

```<code>function toggleComments(id) {
    $('#' + id + ' .commentsContainer').toggle(500);
}
</code>```

How do you keep from doing this kind of thing? Is it always appropriate to avoid inline JavaScript? Or is this a case where it's necessary?

Update:

I ended up using this:

```<code>$('.commentButton').each(function() {
    $(this).click(function() {
        $(this).parents('.post').find('.commentsContainer').toggle(500);
    });
});
</code>```

with this:

```<code>$commentButton = " comments (" . count($comments) . ")";
</code>```

答:
The solution you ended up with is a good one. In truth the only place you should have Javascript be generated in a server side template like you were talking about is for exporting data from the server to the browser. So for example code like this is a pretty reasonable thing to do, but not actual logic </p>

```<code>window.countries = <?php echo json_encode($countries); ?>;
</code>```

Body:
I read here that you should avoid coding JavaScript inline (see item #1).

It sounds like a great idea; however, I'm not sure how to use js to select dynamic content without setting the id in the function call inline.

For example, I have a simple blog. The comments are hidden, but can be displayed by clicking an anchor (generated dynamically) that calls a JavaScript function to toggle the comments for that specific post:

```<code>$commentsButton = "<a name='comments" . $post->id . "' href='#comments" . $post->id . "'> comments (" . count($comments) . ")</a>";
</code>```

toggleComments() function:

```<code>function toggleComments(id) {
    $('#' + id + ' .commentsContainer').toggle(500);
}
</code>```

How do you keep from doing this kind of thing? Is it always appropriate to avoid inline JavaScript? Or is this a case where it's necessary?

Update:

I ended up using this:

```<code>$('.commentButton').each(function() {
    $(this).click(function() {
        $(this).parents('.post').find('.commentsContainer').toggle(500);
    });
});
</code>```

with this:

```<code>$commentButton = "<a class='commentButton'> comments (" . count($comments) . ")</a>";
</code>```

Body:
The solution you ended up with is a good one. In truth the only place you should have Javascript be generated in a server side template like you were talking about is for exporting data from the server to the browser. So for example code like this is a pretty reasonable thing to do, but not actual logic

window.countries = <?php echo json_encode($countries); ?>;


问:
Is it a bad practice to use GUI designer tools with code generation for application programming in Java/C++?
In a stackOverflow question I have read that using a GUI designer program can generate lots of messy code and is considered to be a bad practice unless you're making smaller programs.

My question is why and how. Is it bad to use a GUI designer program? Why?

Additional details:

Programming on a Windows platform;

Only programming in C++/Java for windows programs.

For IDE I've been using visual studio 2010 (Not the express edition) since it comes with the GUI designer.

答:
It is not bad practice to use GUI designer to design your forms, GUI. Esp in Visual Studio. They are there for this purpose and are extensively used.

In web development, it is a different story. It is a bad practice to use GUI designer (for example Microsoft Front Page now superseded by WebMatrix). The reason

They provide a lot of extra code that you do not really need. They basically create junk.

They increase the size of the html document. Which is HIGHLY undesirable for high end site which a large number of hits.

They are hard to maintain because of a lot of extra junk code

So as far as your question, it is not bad practice to use GUI in design forms esp in Visual Studio. Not at all.


答:
In general, I don't think GUI designers are a bad practice. The main benefit I think you would get from using a good GUI designer:

Faster GUI development and modification time.

You get to see what the UI will look like without having to compile and execute the program.

Potential problems you could run into:

Dynamic UI elements that are generated/managed at run-time are probably not possible with GUI designers

I've had problems with more complex GUI controls such as custom generic Controls in VisualStudio.

Generated code could also be a potential source of much pain and problems and if you try to modify it by hand the GUI designer might not be able to let you designe it anymore.

Of course, if you don't know how to properly use such a tool, then it could lead to problems very quickly.

Title: Is it a bad practice to use GUI designer tools with code generation for application programming in Java/C++?

Body:
In a stackOverflow question I have read that using a GUI designer program can generate lots of messy code and is considered to be a bad practice unless you're making smaller programs.

My question is why and how. Is it bad to use a GUI designer program? Why?

Additional details:

Programming on a Windows platform;

Only programming in C++/Java for windows programs.

For IDE I've been using visual studio 2010 (Not the express edition) since it comes with the GUI designer.


问:
How do programmers quit a job?
I'm thinking about leaving my current employer and wondering how one goes about that process in the programming world. We have a lot of projects on the go at the moment and I'm the only developer. We have 4-5 projects that are fairly big and need to be done in the next few months and even a few longer than that.

I'm leaving because I'm the only employee and that's doing me no good. I'm young and want to learn, so a team would be nice. It's also too much work and the company is managed horribly.

I have no contract to worry about so I could theoretically quit and just not come back without notice. Just wondering how this is normally handled.

Should I write a resignation letter

How much notice should I give

Should I give a reason for leaving

Should I go to my boss who is the main reason I'm leaving or go to his boss?

Overview of replies

From the feedback here, it looks as though it's best to give 2-4 weeks of notice, and present a written resignation. Don't go into detail explaining why you're leaving in most cases. Don't burn bridges. Be professional.

答:
Should I write a resignation letter

Yes. Make it short and to the point, giving thanks for the opportunity to have worked with your employer (even if employment there is horrible.)

How much notice should I give

A month is typically the expected as a professional courtesy. Now if you have this hot opportunity that you must take now, then you do what you have to do. But in general, you should tell any prospective employer that you need to give your current employer about a month to clean things up.

Should I give a reason for leaving

In this case, no. Talk to your boss or HR about the reasons if there are questionable practices that compel you to quit (.ie. harassment and such.) But terrible management is not one of those (despite what many people will tell you.) There are always management and operational problems of one type or another. Putting it in writing is just pouring salt on the wound, and would do no good.

Either they know things are bad and either don't care or are not currently capable of fixing, or they are too dumb to know. So putting horrible management as the reason of leaving in writing doesn't help that much. Just write that you are leaving for better opportunities or because you are pursuing a different direction in your career (without implying that the company is too crappy to pursue that career direction there.)

Should I go to my boss who is the main reason I'm leaving or go to
  his boss?

You have to ask yourself: what are you trying to do here? Are you trying to leave to pursue something better, or are you trying point the finger (even if the finger is pointing in the right direction)?

What does it get you?

Does it make you a better professional?

Will it help the company you are leaving?

Is the company capable of using your observation in a positive matter?

Do you think it will actually improve things, for you and your soon-to-be former employer?

More importantly, will you ever be in a situation where you might have to work with them again?

Don't do the things you want to, only the things you need to. Two different things buddy.

Title: How do programmers quit a job?


答:
For a big and medium project, they should not be used, because the code they generate is not very nice to maintain. Unless you don't plan to clean up the code generated by a GUI designer, you are better without it.

However, they are very good in next cases :

to create something quick and dirty (maybe for a prototype)

to try new things out, and see how it would look like


问:
Why is it suggested stories be sized to 2-3 days?
If sprints are on average 10 days, why is it often suggested stories be sized to 2-3 days?

Related Question: How to handle backlog-items that are longer than one sprint?

答:
When estimating, longer tasks have more room for variability. Variability means a lot of things - someone gets sick and takes a day off, someone gets pulled into meetings, someone has to support another project, you need to timeshare resources with other people or teams...the list goes on. By reducing the timeframe for a given task, you are trying to reduce the time in which the people doing the work can be pulled away or blocked from doing the work that you are estimating.

This idea isn't unique to Scrum (or any Agile methods), either. It's a part of any good estimation technique for any engineering projects. Having finer grained tasks tends to yield more accurate estimates, and this accuracy bubbles up.


答:
Do you have any references for the "often suggested stories be sized to two days on average"?

I have seen some people suggest that tasks should take at most one day to finish. The main point is that we are bad at estimating and the longer you estimate it will take to finish the task, the more likely you will be to make a mistake.

You can find more at:

http://www.xqa.com.ar/visualmanagement/2009/02/one-day-tasks

and

http://www.amazon.com/Agile-Estimating-Planning-Mike-Cohn/dp/0131479415

Title: Why is it suggested stories be sized to 2-3 days?

Body:
If sprints are on average 10 days, why is it often suggested stories be sized to 2-3 days?

Related Question: How to handle backlog-items that are longer than one sprint?


问:
Is it significantly costlier to fix a bug at the end of the project?
In a blog post by Andrew Hay, the following axiom was posited:

It costs significantly more to fix a bug at the end of the project that it does to fix the same bug earlier in the project.

However, this doesn't seem certain, especially after reading a blog post on Less Wrong, and the data I've seen to back it up is extremely old.

Is this still axiom accurate today?

答:
No statistical data, but personal experience:

The rocket motor control code I was working on had a line like  powerCutoff = someCondition && debugOptions.cutoffIsAllowed;.  The default option was no cutoff allowed. The 'final' build was supposed to remove all the debug options, so the line got modified to powerCutoff = someCondition;.

Did you catch the bug during code review?  We didn't.  The first time the trigger condition occurred in test causing an unexpected cutoff was just a few months before the first flight.

This bug would have cost less than an hour had it been caught during review.   It might have cost a day or two if it was caught during integration, causing a single test repeat.  If it was caught during formal qualification, it could have cost a week or two by causing a complete test series restart with a new build.

As it was, the cost balooned. First we designed and ran tests to determine if the flight unit could even trigger the condition.  After it was determined to be a real possibility, there was cost for engineering, management and customer analysis of the best fix, releasing the new build, creating and executing a new regression test plan, system testing in multiple units and simulators.  All in all it cost thousands if not tens of thousands of man-hours.  Plus the original 15 minutes to actually make the right code change.


答:
You ask what the code should do, I ask back what does the customer want it to do.

Any other answer is a bad answer even it is correct, as at best it's a guess, not requirements based.

Requirements is where significant numbers of software projects fail, and this is a clear example of a requirements problem. It's insignificant and won't derail your project on it's own, just one more one hole in the proverbial Swiss Cheese. Put away you compiler and get out you requirements management tool and resolve the requirements problem.

Title: When checking for transposed day and month values between two Dates - should comparing 11/11/2000 and 11/11/2000 return true or false?


答:
Computers are that computers. Scientific applications, starting from table computations, which need floating point (or carefully manual usage of a scale with fixed point) has always been an important aspect.

AFAIK, the first computer with floating point -- in hardware -- was the Zuse Z4 mid 40's. The first "common" machine with FP capability is probably the IBM 704 about mid 50's.

For the Intel x86 family, the 8087 co-processor was announced in 80 and until the FPU was integrated with the rest of the processor (which happened early 90's), there always has been co-processor available, even third-party one. At that time, serious scientific applications weren't done on PC, but spreadsheets were among the programs to benefit from having a math coprocessor.

Title: Which applications have driven the mass spread of floating point units?

Body:
Floating point units are standard on CPUs today, and even desktops might use them today (3D effects). However, I wonder which applications have initially driven the development and mass adoption of floating point units in history.

Ten years ago, I think most uses of floating point arithmetics constituted in either

Engineering and Science applications

3D graphics in computer games

I think for any application where decimal numbers might have appeared at those times, fixed point arithmetic has been sufficient (2D graphics) or even desirable (finance). Usage of integers would have been sufficient then.

I think these two applications have been the major motivation to establish floating point arithmetic in hardware as a standard. Can you name others, or is there a compelling reason to disagree?


答:
why is it often suggested stories be sized to 2-3 days?

I really wonder where did you get this suggestion because it is wrong. There are generally two problems with this suggestion:

The estimation is done in days.

The suggestion dictates how much should your average story take.

Both these problems violate simple principle of estimation used in agile methodologies: you don't know upfront how much time you need to complete a story. You are only trying to compare size (complexity) of stories in your backlog and during planning meeting you commit to few most prioritized stories you believe you can complete during sprint. After the sprint completion you will review how many user stories did you completed and you can make assumption about the time needed to complete other stories - the more sprints you do the more precise the assumption become. As your assumption about real time needed to complete story improve your commitment will improve as well.

Because of that people use relative measures to estimate stories like story points or t-shirt sizes and compute average time needed to deliver a story point or other unit. With consistent estimation you should stabilize your average time to delivery a story point within 3-4 sprints.

Because the unit is relative you also don't need to use same scale for all projects. You usually start with a single user story you are most certain about its content and take it as etalon with some size. You will then continue estimating other stories by comparing them to your etalon and other already estimated stories to select expected size. In case of story point you will usually use some sequence of expected sizes like Fibonacci because as your story gets bigger in complexity it is more hard to estimate and contains much more uncertainty. Big stories should be decomposed as described in linked question.


问:
Why do people still say Java is slow?
For a long time in SO and in other places Java has the reputation of being slow. From jokes to many comments in questions and answers, people still believe Java is slow based solely on experience with it in the 90s.

This is my issue: we have disproved (most) of the reasons that people believe Java is slow. Outside of small things, Java is pretty fast.

So why is it that people still refuse to believe Java is fast now? Is it part of their mindset that anything thats not C/C++ is slow? Is it because people don't check over time? Is it because people are just biased?

答:
This question operates on false premises: where it counts, Java is still slow. Where it counts are computation-heavy algorithms on large data sets. Granted, these can be optimized, sometimes to be on par with C/C++ code, but only at the cost of modularity and genericity. Efficient C++ code can be designed to be generic and usable as a general-purpose library. Java code can’t. Just look at the heavily optimized Array.sort method, which uses different implementations for all fundamental types, and whose object variant is still much slower than C++’ generic sort because these objects have to dispatch equality comparisons dynamically.

Granted, just in time optimizations as performed by the HotSpot engine can actually predict the target of these virtual calls and attempt inlining. But this is still slower than the directly inlined call that is dispatched inside C++’ sort method.

A former colleague of mine has done comparative benchmarks of a problem on huge data sets (q-gram counting using dynamic shapes) with a templated C++ implementation and an object-oriented Java implementation. The Java code was orders of magnitude slower than the C++ code.

Of course this is comparing apples with oranges.
But the point is that the Java implementation was the best possible implementation (in terms of performance, given the degree of modularity required for a library), and so was the C++ implementation.

Unfortunately, the benchmark data is not freely available but others have found similar numbers when comparing the overhead of runtime abstraction. For instance, Scott Meyers writes in Effective STL about the overhead of C’s generic qsort function:

C++’s sort virtually always embarrasses C’s qsort when it comes to speed. […] At runtime, sort makes inline calls to its comparison function … while qsort calls its comparison function through a pointer. […] In my tests on a vector of a million doubles, [sort] ran up to 670% faster …

Title: Why do people still say Java is slow?


问:
How to rewrite a TCP MMOG server designed to run in a single machine, in a distributed way?
I have a MMOG server running on C++, using winsockets. My server won't support more than 200 players. I had the idea of redesigning it so it will use multiple servers instead of one, so, maybe, for example, each server could take care of a number of players, and, if it was too laggy, it could transfer the responsability of that player to other server. I'm not sure of how to program a consistent game logic like that, though. Are there techniques for this?</p>

答:
You have 2 questions here.

The first what do i need to do to convert from a single server to a distributed computing environment?

You need to learn to program distributed computing applications.  There are quite a few books on this out there.  There are even college classes that teach this skill.  Your can find some online classes as well.
Once you have learned that you will need to redesign your game to work in a distributed system.  Will probably require a nearly complete overhaul of your code.

Second how do I deal with my DDOS attacks from my competitors?  This is off topic here but is a good question for IT Security SE


答: I'd use an event queue or something similar.  Your business logic layer can simply push a "something broke" message onto the queue and any other layers that are monitoring that queue can take whatever action is appropriate for them.</p>

Title: Communicating from lower level components to GUI?

Body:
What is the recommended way for a lower level software component/module to communicate with the GUI?  I'm using C++.

I have a service layer class that if some conditions occur needs to notify the user, but still continue processing.  In the case of an unrecoverable error I understand that I can use exceptions to bubble up to the GUI, but what about in the case of a simple message that needs to be communicated to the user where the lower level component continues executing?

UPDATE

Just to clarify the service layer (aka business logic, compute layer, etc) does not "know" about the GUI nor do I want it to.


问:
How would you represent an object that can be of multiple types, when storing it as a document in MongoDB?
Somewhat related to this question, say that I have an object category which, depending on which type of object I have, has different restrictions on what it contains.  (if you can reword the previous sentence to make more sense I'd appreciate it)

For example

```<code>var SomeSchema = new Schema({
  _id: ObjectID,
  [... large number of common fields ...]
  type: //Restricted somehow to members of a fixed array
  data: //depending on type, this might be restricted - sometimes an integer, sometimes array, etc...
});
</code>```

What's the idiosyncratic method for defining this type of schema? Is it appropriate to define a single schema, and handle the types inside of it's members, or am I better off with separate schema for each type?

答: Do you mean how to store a class hierarchy in MongoDb? This question shows how to do it using the C# library. I'd say map it simply and let your domain model handle restrictions and the like. Just as if you were doing it with a relational DB.</p>


问:
What is best practice on ordering parameters in a function?
Sometimes (rarely), it seems that creating a function that takes a decent amount of parameters is the best route.  However, when I do, I feel like I'm often choosing the ordering of the parameters at random.  I usually go by "order of importance", with the most important parameter first.

Is there a better way to do this?  Is there a "best practice" way of ordering parameters that enhances clarity?

答: Order it in whatever way you think currying will most likely benefit from. For example, function parameters first.</p>


问:
Low Level vs High Level Development
I really want to start working in OS development, particularly kernel development, with the Open Source Darwin Project - building my own Mac-like operating system, however I am simply not experienced enough to work in the black art of kernel development - I'm constantly deterred by comments : "your code has to be close to spectacular" , "You need to be a programming veteran to write in kernel space"

So I Have tried to find other projects. I am working at CryENGINE 3 at the moment, but I just can't get into the API's as I'm constantly wanting to start kernel development.

I have no experience in user-land programs, however I have researched and created small assembly based programs.

Note: I'm 17 years old.

Are there any projects you can recommend me starting, so I can get some experience for user-land applications? I find it almost impossible to build something revolutionary.

I have Experience with C, C++ , C# , Java , Haskell , Ruby , Lua and ASM.

Plus: What's the chance of creating a business out of software development?

答:
Yes, you really do have to be that good to make real contributions to a serious, consumer-grade kernel.

However, that doesn't mean that you have to be that good to play around with the kernel code and learn how it works.  You can start on that at any time, and it'll be a good learning experience.  Just don't expect it to be easy to understand, especially at first.

Title: Low Level vs High Level Development


问:
Where to define view-specific data objects in Rails
Background: there are several places in our app where we want to display date-oriented information on a calendar. The event_calendar gem looks nice and has lots of reviews, so it's what I'm planning to use. However, it's designed to work with a model. I'm not going to update our existing models to meet its needs, so will create a DTO class and a helper function to construct an array of instances from our existing models.

My question is: where should that DTO class live? It seems like it should be defined inside ViewHelper, but that will violate DRY as soon as I use the calendar for two models (note: the helper functions will differ, it's just the DTO class that will remain the same).

So, is there a standard place in the Rails directory tree where non-model-related classes live?

Or is there a better/more idiomatic way to do this? One thought that I had was to make my helper function decorate the existing model instances with the methods that event_calendar wants to see.

答:
I think the equivalent of the Data Transfer Object you mention is called a presenter in the Rails ecosystem.

On projects with few presenters, I have seen them placed in the /lib directory, but you might as well create an /app/presenters directory.

Also check out this blog post on presenters by Steve Klabnik.


答:
It depends what type & quantity of data are you using:

Example 1.

Showing one line of text, at a time, from a text file or table, on a text control.

Example 2.

Showing a single record / entity from a table, in a panel with several controls,
 in which each control is a property or field from an entity. The entity has several fields or properties.

Example 3

Showing a list of entities / records, in a control, like list, treeview or gridview.

Example 1.

You may have a function in your app., where another function is called, with a single reference variable, where the value is going to be stored.

Example 2.

You may have a function in your app., where another function is called, with a single reference variable, where, the variable may be a pointer / reference to a "struct" or "object" that the values are going to be stored.

Example 3.

For example 3, there are 2 ways.

(3.1) you may have a function in your app., where another function is called, with a single reference variable, where the variable is collection / list / open array, where each element is an entity or object.

(3.2) you may have a function in your app., where a function is called, in a loop, each time, a single reference variable, where, the variable may be a pointer / reference to a "struct" or "object" that the values are going to be stored. Each time the loop is called the recovered object is displayed in the G.U.I., or added to a collection, and, later, displayed in the G.U.I.

Cheers.


答:
It depends a lot, on the tool or programming enviroment, you are going to use.

Most of times, a good GUI designer (a kind of code generator) is good, where allows you to automate as much code as possible, and, at the same times, allows you to code, manually, special code, than cannot be automated.

G.U.I. designers, usually allow you to automate stuff related to position, color, format, style, and leave the logic or programming of the controls to the programmer.

Additional comment: The same goes for O.R.M. tools, they are code generators, too.


问:
Bugs that can be avoided with coding standards
I am looking for statistics (or estimations) that backup the claim that coding standards help reduce bugs.  Hard-numbers would be nice, although I haven't had much look finding any.  I've even looked at bug tracking for various open-source projects, but have not been very successful finding what I need.  Does anyone out there know of any place I might be able to find this?  Or do any of you contribute to any open-source projects that have had bugs that may have been avoided with better coding standards?</p>

答:
Coding "standards"... There are a lot of areas of development that can be standardized. Are we talking about coding conventions, like naming standards etc? Or are we talking about something deeper, like TDD/BDD, CI, etc?

I can tell you that adherence to a "test-first" methodology, with CI enforcing passing tests  and good code coverage, does reduce the number of bugs found by the client. Automated testing, both by the developer and QA, is also a relatively "cheap" way to find bugs because they generally have very short feedback times. You can know that you didn't write what you thought you wrote by running about 45 seconds' worth of unit tests. A couple hours of integration tests will find places where plugging things together didn't go as planned, and end-to-end and automated UI testing can quickly spot functional faults in the software at very high levels.

They also prevent regression. You found a bug. You write a test that will prove that behavior no longer occurs, you code until the test passes, and now you have a test that from this point forward will ensure that bug is never a problem again. This is, in my experience, a major source of new bugs; fixing one thing breaks something else, and your developer testing of the fix may not cover that other situation that's now broken. Breaking stuff that used to work is a HUGE red flag to your clients.

Lastly, this automated testing structure you build as part of this methodology will very easily give you an environment where you can release a new build of the software at literally a moment's notice. "Hey, that bug you just fixed has been causing some real headaches; when will you have that ready in a new version?" click "Oh, in about 5 minutes when the build server finishes publishing it to the download page".

As far as basic coding conventions, like standardizing variable names etc, I have found most of that to be less useful and more irritating. Those are the kinds of standards that are "wonderful, because there are so many to choose from". What you perceive as the difference between a PascalCased and camelCased identifier may not be what someone else thinks. Leading underscores, name length limits (or requirements that method/field names tell a story); other than conventions enforced by the compiler or that are commonly seen in language-specific library code, the modern IDE can tell you everything you need to know about a variable or function including whether you should or shouldn't try to use it in a particular circumstance. In addition, running a code convention check will often return problems with code you can't or don't want to change, like a third-party library that used a different set of standards, or interop code which may conform to Win API naming standards instead of your native language's standards. You end up adding cruft to your code to tell your tool to ignore the cruft in your code.


答:
Coding standards on their own don't reduce bugs. Coding standards as part of a sound software development process reduce bugs.

Here are two papers that study the statistical impact of sound software engineering process on defect reduction that you can use as a starting point:

Software Defect Reduction Top 10 List, which surveys
improvements in empirically based software engineering since 1987

A Critical Analysis of PSP Data Process, which studies
statistics collected from the Personal Software Process, and the
impact of PSP on common causes of software errors

Title: Bugs that can be avoided with coding standards

Body: I am looking for statistics (or estimations) that backup the claim that coding standards help reduce bugs.  Hard-numbers would be nice, although I haven't had much look finding any.  I've even looked at bug tracking for various open-source projects, but have not been very successful finding what I need.  Does anyone out there know of any place I might be able to find this?  Or do any of you contribute to any open-source projects that have had bugs that may have been avoided with better coding standards?</p>


问:
What are the warning signs of impending doom to watch out for on a project?
Having worked on a failed project is one of the few things that most programmers have in common, regardless of language used, industry or experience.

These projects can be great learning experiences, soul-crushing disasters (or both!), and can occur for a multitude of reasons:

upper management change of heart

under-skilled / under-resourced team

emergence of superior competitor during dev cycle

over/under management

Once you've worked on a couple of such projects, is it possible to recognise at an early stage exactly when a project is doomed to fail?

For me, a big sign is having a hard & fast external deadline combined with feature creep. I've seen projects which were well planned out and proceeding right on schedule go horribly off the rails once the late feature requests started to roll in and get added to the final "deliverable". The proposers of these requests earned the nickname of Columbo, due to rarely leaving the room without asking for "just one more thing".

What are the warning signs you look out for that set off the alarm bells of impending doom in your head?

答:
Well, the best way to answer this is with an example:

Bob starts a project by coming up with a genius idea. He begins by creating a plan for the software project that begins with specific steps that need to be completed. However, the steps do not lead to the end-result, but only go a portion of the way there.

In the end, the project fails because the plans were incomplete. It's not so much lack of planning as it is insufficient planning.


问:
Are code reviews necessary for junior developers?
I've worked at two companies, who each had a different methodology when it came to code reviews:

In the first company, a code review was conducted by the team leaders and was required after the completion of every module.

However, in the second company, team leaders weren't required to conduct any code reviews, and just checked for functionality and design issues.

So I am confused. Is the code review process really needed? If it is, why? And if it isn't, why not?

答: I think code reviewing ALL CODE is overkill.  The amount of time it takes to review all code could be better spent elsewhere.  Alterntivley I think critical code and or particularly complex pieces need code review but certainly not every line of code.</p>


答:
You can try a signals-slots library:

sigslot

libsigc++

Boost.Signals2 (this is the thread-safe version of Boost.Signals)

If you don't yet have a preference for a GUI library, you can also try Qt. It has a very flexible and powerful signals-slots system as well. A minor downside is that Qt uses a custom preprocessor, moc, so it's not 100% C++.


问:
Communicating details of method result?
I have code like this (pseudocode)

```<code>foreach(Box box in boxes)
{
    if(boxFilter.PassesFilter(box))
    {
      // do something useful
    }
    else
    {
      Log.Log(format("Box %s was rejected", box.BoxId))
    }
}
</code>```

But now I'm thinking I'd like the log message to have more information such as "Box 1 rejected because too tall" or 'Box 549 rejected: 25" height exceeds Max height of 24"'.

What's the best idiom to get this information into the log?  Do I have to create a FilterResult object that is returned from the PassesFilter method? Or I guess I could also throw an exception and catch it and log it? Or something else?

I happen to be using C++.

Update

In addition to logging I might want to also present a message to the user in the UI.

答:
I can see two main options here; an enum could be returned, or you could use an exception.

Personally, I would use an exception, but I'm not an experience C++ programmer, so I'm not sure if it fits the common idiom of the language.

Title: Communicating details of method result?


答:
Ultimately, logging is instrumentation; something a bit more humane than debugging symbols or profiling instrumentation;  the logging should not have an effect on program flow, it should only faithfully report on it.

Do I have to create a FilterResult object that is returned from the PassesFilter method?

If you want to have logging at that level, then it should be the PassesFilter method that actually logs a message.  To associate the filter result with a particular box, just emit a log message with the box identifier just before (or after) the filter method is called.   It is then up to the logging system to associate the two messages and do something fancy with them, or not.

Or I guess I could also throw an exception and catch it and log it?

I wouldn't do this;  At least, not for the purposes of logging.  Exceptions are great, if they represent meaningful program flow.  It's also OK to instrument exceptions in a log file, but the step of creating an exception for the purposes of instrumentation is not going to make your code any better.

```<code>bool BoxFilterClass::PassesFilter(const Box & box){
    if (box.height > BoxFilterClass::MAX_HEIGHT) {
        Log.Debug(format("Box %s to tall, expected %s, actual: %s", box.id, BoxFilterClass::MAX_HEIGHT, box.height));
        return false;
    }
    else if (box.weight > BoxFilterClass::MAX_WEIGHT) {
        Log.Debug(format("Box %s to heavy, expected %s , actual: %s", box.id, BoxFilterClass::MAX_WEIGHT, box.weight));
        return false;
    }
    // and so on
    return true;
}
</code>```

Title: Communicating details of method result?

Body:
I have code like this (pseudocode)

```<code>foreach(Box box in boxes)
{
    if(boxFilter.PassesFilter(box))
    {
      // do something useful
    }
    else
    {
      Log.Log(format("Box %s was rejected", box.BoxId))
    }
}
</code>```

But now I'm thinking I'd like the log message to have more information such as "Box 1 rejected because too tall" or 'Box 549 rejected: 25" height exceeds Max height of 24"'.

What's the best idiom to get this information into the log?  Do I have to create a FilterResult object that is returned from the PassesFilter method? Or I guess I could also throw an exception and catch it and log it? Or something else?

I happen to be using C++.

Update

In addition to logging I might want to also present a message to the user in the UI.

Body:
Ultimately, logging is instrumentation; something a bit more humane than debugging symbols or profiling instrumentation;  the logging should not have an effect on program flow, it should only faithfully report on it.

Do I have to create a FilterResult object that is returned from the PassesFilter method?

If you want to have logging at that level, then it should be the PassesFilter method that actually logs a message.  To associate the filter result with a particular box, just emit a log message with the box identifier just before (or after) the filter method is called.   It is then up to the logging system to associate the two messages and do something fancy with them, or not.

Or I guess I could also throw an exception and catch it and log it?

I wouldn't do this;  At least, not for the purposes of logging.  Exceptions are great, if they represent meaningful program flow.  It's also OK to instrument exceptions in a log file, but the step of creating an exception for the purposes of instrumentation is not going to make your code any better.

bool BoxFilterClass::PassesFilter(const Box & box){
    if (box.height > BoxFilterClass::MAX_HEIGHT) {
        Log.Debug(format("Box %s to tall, expected %s, actual: %s", box.id, BoxFilterClass::MAX_HEIGHT, box.height));
        return false;
    }
    else if (box.weight > BoxFilterClass::MAX_WEIGHT) {
        Log.Debug(format("Box %s to heavy, expected %s , actual: %s", box.id, BoxFilterClass::MAX_WEIGHT, box.weight));
        return false;
    }
    // and so on
    return true;
}


问:
Using php functions, reserved words as local identifiers
I'm thinking of some of the array functions. "key", "each", "pos", "range". These are often very useful as local identifiers! I have also seen code that (ab)uses $return, $list, $array, $string. What are other PHP programmers views on this?

Local identifiers only! I wouldn't use them as members or method names of a class, even less global variables.

答:
From your perspective it may seem like they 've stolen your favorite symbol names - and in many occassions this can be said for most programming languages. From a seasoned PHP developer's viewpoint however, these symbols are a solid foundation on which he can be based to produce code with a well - defined behavior - at least to the extent that these functions have a well - defined behavior.

I personally consider it very distasteful that PHP 's reserved word space is extended with so many common words but this decision was made well into the past, and so it 's now part of the language 's actual as well as conceptual vocabulary, more or less.

Besides that, I think that programming is as much about coding instructions as it is about writing, especially given that other programmers may need to review and maintain your code, and that you yourself may come to forget that particular piece of code you may have written a few months back. In that vein, well - named symbols immensely increase the readability of your code, and by extension help everyone working on it.

It may take a little more work and creativity, but there 's nothing more rewarding than a handsomely crafted piece of code which can be read and understood with minimal effort.


答:
Using names such as $key, $value and $list is such a common practise when iterating array that it could be seen to be part of the PHP way.

One new thing to consider.  Although not extensively used in PHP, the language has supported a form of closure/anonymous function since 5.3.  As functions can thus be assigned to variables,  it would be sensible to avoid some of the more confusing combination.

For example, node developers will often use "next" for a return function which is an existing array method.  Similarly, if a closure ended with $return(); instead of return; that may also confuse.  Using $callback which has no equivalent would seem safe.

In general, names such as $list, $array, $string or $number, shouldn't be used except for the innermost loops, as they only reflect type rather than purpose.

Regarding method names for a class, if the class has array type behaviours it would be completely appropriate to use them, or even enforce it using the ArrayIterator or ArrayAccess interfaces.

Title: Using php functions, reserved words as local identifiers

Body:
I'm thinking of some of the array functions. "key", "each", "pos", "range". These are often very useful as local identifiers! I have also seen code that (ab)uses $return, $list, $array, $string. What are other PHP programmers views on this?

Local identifiers only! I wouldn't use them as members or method names of a class, even less global variables.


答:
Since you don't have a formal contract you could in theory flip them the bird and walk out, but then you would probably lose any pay they owe you, and you can forget about good references.

The normal (better) way to leave a company is to write a termination (or resignation) letter and give it to your boss.  This is the formal notice, and it's normally 1 month before you're due to quit.  Make it formal but to the point.  However, if you really don't like your boss you can go to the boss's boss, but ultimately it makes little difference.

You don't have to give a reason to leave, but you can if you like.  Often, people will already know the reason if it's due to a conflict in the workplace.

Title: How do programmers quit a job?

Body:
I'm thinking about leaving my current employer and wondering how one goes about that process in the programming world. We have a lot of projects on the go at the moment and I'm the only developer. We have 4-5 projects that are fairly big and need to be done in the next few months and even a few longer than that.

I'm leaving because I'm the only employee and that's doing me no good. I'm young and want to learn, so a team would be nice. It's also too much work and the company is managed horribly.

I have no contract to worry about so I could theoretically quit and just not come back without notice. Just wondering how this is normally handled.

Should I write a resignation letter

How much notice should I give

Should I give a reason for leaving

Should I go to my boss who is the main reason I'm leaving or go to his boss?

Overview of replies

From the feedback here, it looks as though it's best to give 2-4 weeks of notice, and present a written resignation. Don't go into detail explaining why you're leaving in most cases. Don't burn bridges. Be professional.


答:
It seems that you would like to use repetitive non model functionality. If I am right, then you can wrap it with Module and put it within app\models folders

You might have a look at the following article
http://www.codercaste.com/2011/02/11/10-ruby-on-rails-3-tips-that-will-make-you-a-better-rails-programmer/

Title: Where to define view-specific data objects in Rails

Body:
Background: there are several places in our app where we want to display date-oriented information on a calendar. The event_calendar gem looks nice and has lots of reviews, so it's what I'm planning to use. However, it's designed to work with a model. I'm not going to update our existing models to meet its needs, so will create a DTO class and a helper function to construct an array of instances from our existing models.

My question is: where should that DTO class live? It seems like it should be defined inside ViewHelper, but that will violate DRY as soon as I use the calendar for two models (note: the helper functions will differ, it's just the DTO class that will remain the same).

So, is there a standard place in the Rails directory tree where non-model-related classes live?

Or is there a better/more idiomatic way to do this? One thought that I had was to make my helper function decorate the existing model instances with the methods that event_calendar wants to see.


答:
The bigger the stories are, the less accurate your estimates are likely to be.

Personally, I would break them down even smaller than that.


答:
Every SQL injection vulnerability is a defect that could have been prevented with a coding standard. Statistics on SQL injection vulnerabilities are, AFAIK, available.

Every buffer overflow vulnerability could have been prevented with a coding standard. Statistics on those are probably available too.


问:
Eclipse runs my java program 6 times faster... Can I achieve this performance without using it?
I've written a java program that generates all repetitive permutations based on the characters and the length given.

When I execute my code in Eclipse, it generates a file with 1,000,000 permutations in only 15 seconds. Yet if I run the program on the same machine in the command prompt using "java permutation" It takes 1 minute 35 seconds to generate the same 1M permutations..

Why is this? And is there anyway I can get this type of performance without using eclipse?

Edit: Added Java VisualVM results

www.craftboom.co.uk/jvm.png - The CPU usage is higher when running in eclipse. Both CPU and memory usage seem to drop to 0 ocassionally in the shell o_O

EDIT2: Turns out it is a problem printing to the screen. Didn't mention it in my original post, but the program prints each permutation to the console.. Commented that out and saved to a file instead.. now running equally fast in both shell and eclipse. :-)

Thanks to all for replies.

答:
Check the settings in eclipse.ini in your installation (it will contain JVM settings).  It's possible that they are configuring the JVM to make more efficient use of it than you are when you run the program.

http://wiki.eclipse.org/Eclipse.ini

http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html


问:
What Are Some Advantages/Disadvantages of Using C over Assembly?
I'm currently studying engineering in Telecommunications and Electronics and we have migrated from assembler to C in microprocessor programming.  I have doubts that this is a good idea.  What are some advantages and disadvantages of C compared to assembly?

The advantages/disadvantages I see are:

Advantages:

I can tell that C syntax is a lot easier to learn
than Assembler syntax.

C is easier to use for making more complex programs.

Learning C is somehow more productive than learning assembler cause there is more developing stuff around C than Assembler.

Disadvantages:

Assembler is a lower level programming language than C,so this makes it a good for programming directly to hardware.

Is a lot more flexible alluding you to work with memory,interrupts,micro-registers,etc.

答:
C is easier to program in, compared to Assembly. There are obvious
reasons not worth rehashing.

Being easier to use, C allows you to write programs faster. Generally these programs are           also easier to debug and easier to maintain. Furthermore, it's easier to manage large, complex programs in C.

Often times, code generated by a compiler is equally as good (in
terms of speed and efficiency) as hand-written assembler - if not
better.

C is pretty darn low-level, and it's rare that you'll want to go much
lower. Having an added layer of abstraction is rarely a bad thing.

When you do need to go lower, you can use Assembly, otherwise you can
use C.

You can write Assembly in C-code, but not C in Assembly-code.


答:
Longer running times indicate a memory issue.  Either you swap to disk or you have many more garbage collections than inside Eclipse (because you have a smaller heap).

Run using a profiler, and see where the time is spent.  For Java start with jvisualvm in the JDK.

Title: Eclipse runs my java program 6 times faster... Can I achieve this performance without using it?

Body:
I've written a java program that generates all repetitive permutations based on the characters and the length given.

When I execute my code in Eclipse, it generates a file with 1,000,000 permutations in only 15 seconds. Yet if I run the program on the same machine in the command prompt using "java permutation" It takes 1 minute 35 seconds to generate the same 1M permutations..

Why is this? And is there anyway I can get this type of performance without using eclipse?

Edit: Added Java VisualVM results

www.craftboom.co.uk/jvm.png - The CPU usage is higher when running in eclipse. Both CPU and memory usage seem to drop to 0 ocassionally in the shell o_O

EDIT2: Turns out it is a problem printing to the screen. Didn't mention it in my original post, but the program prints each permutation to the console.. Commented that out and saved to a file instead.. now running equally fast in both shell and eclipse. :-)

Thanks to all for replies.


答:
Here are some stack overflow answers that may help you (these are the the top response, accepted answers):

Advantages

https://stackoverflow.com/questions/143561/is-there-a-need-to-use-assembly-these-days (for 10K users only), or Archive

Assembly is used in the earliest stages of the bootloader. When the CPU powers on the stack isn't available, and its tough to keep the C compiler from trying to save things to the stack. The bulk of the bootloader is nonetheless written in C, once the earliest initialization is done.

Assembly is used to write mutex locking primitives. It is essentially impossible to get a C compiler to emit memory barrier instructions at the required places.

Routines like memset() or memcpy() are often done in assembly. For example, I wrote a memset() with a large unrolled loop, which dynamically computes a branch address to jump into the middle of that loop for one final iteration. A C routine would have generated more code, taking extra I$ misses. Likewise, CPU instruction sets often include cache line load or other instructions which can dramatically speed up memcpy(), which the C compiler will not utilize.

Disadvantages

https://stackoverflow.com/questions/2684364/why-arent-programs-written-in-assembly-more-often

ASM has poor legibility and isn't really maintainable compared to higher-level languages.

Also, there are many fewer ASM developers than for other more popular languages, such as C.

Furthermore, if you use a higher-level language and new ASM instructions become available (SSE for example), you just need to update your compiler and your old code can easily make use of the new instructions.

Example

The last post below is a Stack Overflow post outlining a scenario which will show an assembly example that is faster than C (when performing the same function).

https://stackoverflow.com/questions/577554/when-is-assembler-faster-than-c

Title: What Are Some Advantages/Disadvantages of Using C over Assembly?

Body:
I'm currently studying engineering in Telecommunications and Electronics and we have migrated from assembler to C in microprocessor programming.  I have doubts that this is a good idea.  What are some advantages and disadvantages of C compared to assembly?

The advantages/disadvantages I see are:

Advantages:

I can tell that C syntax is a lot easier to learn
than Assembler syntax.

C is easier to use for making more complex programs.

Learning C is somehow more productive than learning assembler cause there is more developing stuff around C than Assembler.

Disadvantages:

Assembler is a lower level programming language than C,so this makes it a good for programming directly to hardware.

Is a lot more flexible alluding you to work with memory,interrupts,micro-registers,etc.


答: A C program can be compiled to different microprocessor architectures.</p>


问:
Does giving a developer a slower development machine result in faster/more efficient code?
Suppose I give my developers a screaming fast machine.  WPF-based VS2010 loads very quickly.  The developer then creates a WPF or WPF/e application that runs fine on his box, but much slower in the real world.

This question has two parts...

1) If I give a developer a slower machine, does that mean that the resulting code may be faster or more efficient?

2) What can I do to give my developers a fast IDE experience, while giving 'typical' runtime experiences?

Update:

For the record, I'm preparing my even-handed response to management. This isn't my idea, and you folks are helping me correct the misguided requests of my client.  Thanks for giving me more ammunition, and references to where and when to approach this.  I've +1'ed valid use cases such as:

- specific server side programming optimizations

- test labs

- the possibly buying a better server instead of top of the line graphics cards

答:
The problem isn't the developer building inefficient code on a fast machine, the problem is that you haven't defined performance metrics that must be measured against.

There should be defined, as part of the product requirements, a specific target that can be measured on all computers based off of the required customer experience. There are many websites (Check SpecInt) that allow you to relate your computer to other types of computers.

This is good for many reasons. It allows you to define minimum supported hardware more easily so you can limit the number of customer complains - we all know most software runs on most computers, it's just a matter of performance - if we set our specs so that people in the minimum requirements range has reasonably acceptable performance, you limit customer complaints - and then when a customer calls in, you can use the benchmarks to determine if there really is an issue, or if the customer is just not happy with how the product is supposed to work.


问:
Is there a useful correlation between choice of web-browser/search engine and good quality programmers?
After a round of interviews earlier this year, which included some practical questions with access to a computer, I noticed that, at least for the applicants we were seeing, there was a high inverse correlation between quality of applicant and the explicit choice of Bing/IE as the stack for search/browsing the web. That is, a large number of applicants specifically searched for IE to use as a browser when browsing the web, and specifically used Bing as the search engine (even typing in Bing in the Google search box, before starting a search)

Is this just an outlier, a fluke, or is there some sort of information I can obtain from this observation? So far, my best candidates are:

Yes, there is a high correlation between good programmers and choice of web browser/search engine

There is some training program, or community, which advises using IE/Bing during interviews, and I just happened to run into a poor selection from that group

Something else is going on, that I don't know about, but someone here might know.

So, to repeat, the question is: is there more than coincidence at work here, and, if there is, what's going on?

答:
I'm surprised there's hasn't been an avalanche of replies of web developers, to the effect of: "When we develop web pages, half the effects don't work in various versions of IE, especially the older ones without adding various tricks and hacks.  The other browsers - Firefox, Opera, Chrome, etc have been much better about adhering to and supporting the standards.  So a serious web developer pretty quickly gets tired of IE and looks on it unfavorably.  IE has been getting better in this area, but still wants to be different for the sake of product differentiation.

Still, IE is now something like 1/4 or 1/3 of the browser market.  Long gone the days of 98.1% of users."

As for bing, sheesh I remember when folks were using "ask Jeeves" in 2002 and I was running around saying "Google is THE answer".  If only I'd bought stock ;) go LNKD ;) ;)


问:
How to determine the priority and severity of a "code improvement"?
We have "priority" and "severity" fields in our bug tracking system. We define severity as "how it impacts the user" and priority as "how it impacts the product".

My question is about how to categorize a "code improvement" task in severity and priority. Suppose the improvement does not change any behavior but makes it a "better code". We anticipate a long term maintenance improvement overall but it's hard to quantify.

When we use our definitions for priority and severity, a code improvement gets the lowest values for both unless you introduce some hard to predict long term benefits into the picture. Therefore it implies that code improvement is a frivilous task and should never be attempted.

However I believe it's cruical to constantly improve and refactor the code, because:

Software development is itself a continuous learning process and without improving the code you can't get better at it.

A team should be proud of their code.

Future maintenance will take less time and over the long run savings will be significant.

Or do you think such tasks should never be created and such improvements performed only "on demand", "when associated with a bug"? Even if it's associated with a bug, wouldn't that be a discussion point on a code review, e.g. "why did you do this drastic change in structure?".

答:
I would steal voting from the Agile movement:

Enter the bug, make rough guesses for severity and priority,

Then, daily, weekly or monthly review all the new bugs, and vote on their ratings.  Ideally you do this during a sprint planning meeting with end users.  Then you can talk about the next features at that time too and be positive,