答: This is really more of a business decision than a technical one.  Usually, this is done as part of a major release (e.g. going from version 3.5 to version 4.0), and often the two versions are supported in parallel for awhile.  This means you'll do maintenance on the old version but all new features will only appear in the new version.  The old version is supported as long as the company makes money off of it, or at least enough to offset the maintenance costs.  Be prepared to pitch this to management.</p>


问:
What's the most effective way to perform code reviews?
I've never found the ideal way to perform code reviews and yet often my customers require them. Each customer seems to do them in a different way and I've never felt satisfied in any of them.

What has been the most effective way for you to perform code reviews?

For example:

Is one person regarded as the gatekeeper for quality and reviews the code, or do the team own the standard?

Do you do review code as a team exercise using a projector?

Is it done in person, via email or using a tool?

Do you eschew reviews and use things like pair programming and collective code ownership to ensure code quality?

答:
I like code reviews, though they can be a pain.  The reason I like them is that they get more eyes on the code and a different perspective.  I believe that even with pair programming, code should be reviewed.  It's easy enough for two people working on the same code to collectively make the same mistake that a different set of eyes may not miss.

If done as a group with a projector, it really should be reviewed individually before the meeting.  Otherwise, it is just an annoying waste of time.

I've only done code reviews via email and in a group.  Generally speaking, I don't think they should be done in person.  You feel a little more pressure to rush through the code with someone looking over your shoulder.  I do believe that a tool designed for code reviewing would be a good asset, as it can help with some of the mundane aspects and it should make it easier to flag problem bits of code then it is via email.

The problem with having one person do all code reviews is that it can be a bottleneck.  With well documented and designed coding standards it should not be necessary.  Depending on the environment/release-schedule it may be a good idea to always have someone as a standby code reviewer.

I do believe that code ownership is a good idea as this person can make it their priority to understand that code and potentially play a gatekeeper role.

ContentLicense: CC BY-SA 2.5


问:
How managers choose programming languages
It's not a secret to anyone that managers can and often will impose the programming language that will be used for a project.

Being a programmer myself, I have never been able to understand this.

But now I think I do: I've just had a revelation when Joel Spolsky said on the podcast that they should use QuickBooks because "every accountant in the world knows it". This struck me as being very similar to "chose Java because every programmer in the world knows it".

Now that I've seen the same issue from another perspective,I don't know much about accounting, but I do know something about programming, I'm wondering how a programmer can help make sure the right programming language is chosen for a project?

答:
Become the manager.  (grin)

Seriously, you just need to discuss the matter with the decision maker in question, and put forward your arguments.  If they choose to stick with a really wrong decision, then their general competence probably isn't so hot and it might be worth looking for something else to do.

ContentLicense: CC BY-SA 3.0

OwnerDisplayName: womble


答: I think the difference between what you're talking about and what Joel was talking about is that programming is a core competency while accounting is not. The point using Quickbooks is, presumably, because you are not an accountant and accountants can help you with it. However, if programming is your core competency, and presumably it is if you are a programmer, then the rules of the game are a bit different.

Title: How managers choose programming languages

Body:
It's not a secret to anyone that managers can and often will impose the programming language that will be used for a project.

Being a programmer myself, I have never been able to understand this.

But now I think I do: I've just had a revelation when Joel Spolsky said on the podcast that they should use QuickBooks because "every accountant in the world knows it". This struck me as being very similar to "chose Java because every programmer in the world knows it".

Now that I've seen the same issue from another perspective,I don't know much about accounting, but I do know something about programming, I'm wondering how a programmer can help make sure the right programming language is chosen for a project?

OwnerDisplayName: BobbyShaftoe


答:
Every platform has good and bad sides. .NET is cool and powerful but you pretty much stuck with Windows servers. Ruby is cool but slow. It would be hard to find developers for Haskell.

The point is, language affect not how fast project will be done and how beautiful code will be but also those stuff managers care about. So if you want to influence them, you should now they preferences and find as much good sides in their perspective as you possibly can.

OwnerDisplayName: vava


答:
These are different concepts.

When accounting, you share your results: for taxes, law, investors etc. They need a tool to see the result of you labor, and this tool has to be well-know.

When programming, you use any tool you want — as long as it outputs an .exe file that you can run on Windows. This is the exactly the same as a Quick Books readable document in case of accounting.

So, if you develop a toaster, you a free to keep your internal documentation in Chinese but you'd better provide an English manual.

There is one more thing: if you company's rules assume that the result of your code is not a product itself, but a source code for it, then for sure they may decide what it will look like (by chosing the language they want).

What they choose depends on their goals: if they want easily replaceable programmers they choose Java; if they send it to another department it will be that department's requirement etc.

OwnerDisplayName: Quassnoi


答:
From what I've seem in my company: When managers choose a programming language, they usually do so very conservatively - taking into regard what kind of programming skills are currently available in the team (and if it would be easy to hire additional ones easily), whether it is a well established language, trying to choose something that will fit the current infrastructure and not cause large efforts to make it fit into what's already there. When programmers choose a programming language, things often tend to be a bit different - they often like to have a new challenge and would like to got with the latest hot trend and choose something where they can learn new things.

Ideally, it all comes down to discussing the pros and cons between the manager and the dev team and finding the solution that best fits the problem. This usually involves a lot of talking and convincing :-)

OwnerDisplayName: ISW


答:
It very much depends on the personality of the manager:

There are those that go for buzzwords. Just find out which buzzwords they like and use it when you talk to him in conjuction with the language you want to use.

Others will only trust things they know themselves (like VB 6.0 for example). Make your language of choice easy to understand for them ('you know, its just like in good old VB' - even if you are talking about Haskell...)

But in reality, most managers are not as stupid as we geeks like to think, and they can be reasoned with. What is important here is that you understand their point of view: They usually don't care about specific technical details, they care about results. So don't tell them that .net or Java or Delphi or whatever has this megacool terrific feature. Tell them that (enter your language here) is a good choice because it feature A makes for shorter development times in a project like this, or that feature B  makes for fewer bugs and therefore shortens the time needed for testing. Just make sure your argument is sound, don't lie to him.

In other words: treat him like an inteligent being (he probably is).

OwnerDisplayName: Treb


答: Think about the language you are being asked to use very very hard. Make sure that you know it's not a good language for the job, then ask the manager if you might make a suggestion as to another better language to use for the job. Supply any information you can that proves that the language wouldn't be good for the job and see what he says. It can't hurt. :)</p>

OwnerDisplayName: Rayne


答:
Choosing programming language is often a business decision. Customers/Users don't care. Here is short quote (from http://www.ericsink.com/bos/Geeks_Rule.html):

Programming languages are chosen mainly for business reasons. I spend most of my time working with languages that I don't really like because the languages that I'd like to work with carry business disadvantages that outweigh their technical merits. That's the nature of the game. I can accept the situation (my choice) or find a new employer. Whining about how I can't use Java or Python or whatever at work just isn't an option.

OwnerDisplayName: Peter Štibraný


答:
The mistake many programmers make is they will argue the point (or simply agree or disagree with it) based solely on technical merit.  With management--and the business as a whole--you have to argue the business case and the merits for the business first and technical merits second.

This goes beyond programming language choice and pervades virtually every technical decision.

Let me give you an example: PCs.  Joel argues (correctly) that developers should have top notch machines because developer time is expensive.  In this he's completely right.  But how do you argue this?  Simple:

Example: I do a build of the code roughly 20 times a day.  Each time it takes 3 minutes.  If I had a fast PC I could build it in 1.5 minutes.  So for an extra $1,000 every two years I can get an extra half hour a day, which for a programmer earning $100k (with on-costs of another 50% at least), that equates to roughly $10,000 per annum of time.

But arguing at the other end is HR deciding one size fits all when it comes to policy and PCs so a call centre worker earning $25k and a programmer earning four times that should for some reason have the same PC.

Technology platform and languages will have lots of factors going into the decision mix:

Strategic relationship with particular vendors.  If your company is a Microsoft Gold Partner (or whatever it's called now) then good luck getting Java or Python in;

The IT department arguing a particular config because the money for the PCs comes out of their budget;

IT deciding everyone should run Windows 2000 because they don't have people running Linux;

What other systems the company already has (eg if they use Java for everything else it makes sense to use it for this even though on its own it might not be the best choice);

Risk aversion to different platforms or languages simply from a lack of experience;

More interested in arguing risk with upper management than making developers happy;

Some managers make the decisions they do simply because their hands are tied;

Budgetary reasons although this can work in your favour too as it keeps expensive boondoggles out of your house like PVCS, anything produced by Rational, etc;

Legal department aversion to open source licenses;

Not involving the technical staff in planning and project estimation;

Familiarity on the manager's part with a particular platform (technical people are guilty of this too but in both cases it's not necessarily a bad thing -- with many tools that can do the job better the devil you know).

Experience of the technical staff.  If they're all from a C# background, why would they use Java, Python or Ruby?

Many other reasons

Whatever the case you need to understand the reason (and I guarantee you there'll be several reasons) and argue merits in those terms.  Some programmers are quite naive in this department and seem to think such decisions are made out of ignorance or even vindictivieness when nearly always many factors are in play.

OwnerDisplayName: cletus


问:
What are the biggest differences between F# and Scala?
F# and Scala are both functional programming langugages that don't force the developer to only use immutable datatypes. They both have support for objects, can use libraries written in other languages and run on a virtual machine. Both languages seem to be based on ML.

What are the biggest differences between F# and Scala despite the fact that F# is designed for .NET and Scala for the Java platform?

答:
Major Differences:

Both Scala and F# combine OO-imperative programming and functional programming into one language. Their approach towards unification of paradigms is vastly different though. Scala tries to fuse the two paradigms into one (we call it object-functional paradigm), whereas F# provides the two paradigms side by side. For example, algebraic data types in F# are purely functional constructs with no OO'ness in them whereas ADTs in Scala are still regular classes and objects. (Note: In the process of compilation to CLR bytecode, even F# ADTs become classes and objects but they are not visible to F# programmer at the source level.)

F# has full Hindley-Milner style type inference. Scala has partial type inference. Support for subtyping and pure-OO-ness makes Hindley-Milner style type inference impossible for Scala.

Scala is much more minimalistic language than F#. Scala has a very small orthogonal set of constructs that are re-used throughout the language. F# seems to introduce new syntax for every little thing, thus becoming very syntax heavy as compared to Scala. (Scala has 40 keywords, whereas F# has 97. That should tell you something. :-)

F# being a Microsoft language has an excellent IDE support in the form of Visual Studio. Things are not so good on the Scala side. Eclipse plugin is still not upto the mark. Same goes for NetBeans plugin. IDEA seems to be your best bet at the moment, though it doesn't even come close to what you get with Java IDEs. (For Emacs fans, there's ENSIME. I have heard a lot of good things about this package, but I haven't tried it yet.)

Scala has far more powerful (and complex) type system than F#.

Other Differences:

F# functions are curried by default. In Scala, currying is available but not used very often.

Scala's syntax is a mix of that of Java, Standard ML, Haskell, Erlang and many many other languages. F# syntax is inspired by those of OCaml, C#, and Haskell.

Scala supports higher kinds and typeclasses. F# doesn't.

Scala is much more amenable to DSLs than F#.

PS: I love both Scala and F#, and hope they become predominant languages of their respective platforms in the future. :-)


答:
By separating concerns. Business should be in charge of business decisions and tech in charge of tech decisions. I like the term "Accepted responsibility". If I'm to accept responsibility I also demand I get to make the choices that concerns my domain of the problem. Business gives me and my tech colleagues the business demands and we answer with one or two alternatives of how we can accept the responsibility to deliver. It should never be like "we'll do it in Python or C#". Rather;

"We can accept two different
  responsibilities here: If we go this
  way, we can deliver this fast and we
  meet these business demands really
  well and these are a bit harder. We
  also could do it this way and that
  gives these business demands the
  trump. Alternative A calls for these
  these resources and alternative B
  means we need to also do this and
  this..."

Then business chooses, but note that business chooses based on impact on business things, not technical things. And they don't get to choose among alternatives where tech isn't ready to accept the responsibility of the tech part.

OwnerDisplayName: PEZ


答:
In my experience it's always depended on:

Do we have the resources to use the language?

Do we have the resources to maintain the language?

If we do not have the resources to use and maintain the language how difficult/costly is it to get those resources?

What is the "future" of the language (Is it going to be around and in use for a while?)

Unless the project needs something that only a specific language/platform/technology/framework provides it comes down to what we already know and use.  Both hiring new people and training existing programmers is pretty costly for most companies.  When hiring we always consider the language and make sure candidates know what language(s) they will probably be using.

Hopefully you have a programmer who is also a manager and who can represent programmers in these types of decisions.  If not then that is a dangerous situation and you should talk with your manager if you know such a decision is being made.

OwnerDisplayName: metanaito


答:
Manager A goes to a summer retreat where he meets manager B.

A: So what language do you use in your company?
B: Oh we use CA Visual Objects, it makes the drones so much more productive than COBOL.

And this is how the decision was made. End of true story.

OwnerDisplayName: Spikolynn


答:
Late reply, but since there is no accepted answer yet, I'll give it a try. I take it as two questions and will attempt to answer them separately:

How do managers choose programming languages?

Heavily depends on the size of organisation and manager's experience, but generally will involve assessing current situation and future scenarios and requirements. This is usually done through PESTLE or similar analysis, and just to give a few samples in each category:

Political

"No one got fired for buying IBM" - safe choice.

CEO heard that Java is cool - hype.

Chief Architect loves .NET - pet project.

The language is controlled by a hostile competitor - why Google isn't relying on C#.

Economical

Licensing costs.

Cost of developer training.

Code base migration costs.

Social

Buy-in from the team.

Skill availability in house (training needs, continuity).

Skill availability on the market.

Threat to the existing status quo within the dev team.

Availability of sufficiently large community of practice.

Technological

Productivity improvement.

Quality improvement.

Ability to interoperate with existing code base.

Adherence to standards.

Maturity.

Legal

Licensing terms.

Technology control (Who owns and controls the technology? What is future licensing strategy is likely to be?)

Legal and regulatory compliance.

Environmental

Existing infrastructure within company.

Existing skills within company.

Integration with external partners.

Level of technology support by wider environment.

Then a bunch of languages matching the criteria may be further evaluated using SWOT, cost benefit analysis or similar.

The whole process can be rather complex, but as a bottom line most companies or project teams will go for the safest option given their current circumstances that can still deliver the capabilities they need. Quite often it might mean sticking to the current platform for longer.

How can a programmer help make sure the right programming language is chosen for a project

As it has been, hopefully, demonstrated a typical programmer would normally have just 1/6th of the total input into the decision making process. And as a rule she or he would mostly be interested in the language capabilities alone!

Well, the best way to influence the decision seems to have a broader picture of the selection process, make allies within and outside the team, create a good brief on technological side of things and try not to concentrate on the language capabilities alone.

And, of course, one needs to get into the position when a Project or Development Manager (or whoever else is in charge) sees the benefits of going through the entire evaluation process and is prepared to consider the risks and uncertainties of switching to a different language in the first place. For this to happen it needs to be demonstrated that:

Current platform is no longer adequate.

A new platform promises benefits that by far outweigh the hassle.

However, would you had asked "What is the best way to be able to use at work the language I like", the answer would have probably been "join a company that already uses the language or start your own".

OwnerDisplayName: Vlad Gudim - AKA Totophil


答:
First of all, programming is another form of art. A very logical form of art.
If your manager is keen on his extraordinary software projects, that are to some extend, works of masterpiece, then ask that keen manager the following:

How much energy and time would it cost Rembrandt extra to not paint with his favourite brush, but a brush that, after careful consideration of the management team, is handed to him, 400 years ago and prior to his works becoming famous. Will his painting be more or less worth you think?

Similarly, If you are telling a programmer what language should be used, then be consistent and also tell a painter what brush sizes should be used! OR, alternatively, just leave this choice to the folks who need to work with it every single day and (like most masterpieces) night!

OwnerDisplayName: Sam


问:
How do I go from being able to write code to being a good developer?
I'm frustrated by the lack of concrete explanations on how to go from being able to script (bash, awk) and write simple applications (c, php, python) to designing and developing larger, more complicated software. It seems that on one side there are programming language books and on the other side there are the software engineering/project management books designed for teams of programmers.

I've read plenty of both. I've read the XP/Agile classics and have a decent theoretical understanding of the software development process. I like to read other people's code and can follow it fairly well. But when I have an idea for a project or want to go from "here's the problem/need" to "here's the solution", my mind draws a blank and I don't know where to begin.

Do I just hack it out? Are there any structured workflows for individual developers that don't work in teams or for a big software house? I really don't have any desire to get a PMP or work for a software company. I'm just looking for an effective, efficient, practical workflow.

答: As others have said, experience comes from writing code.  But you should also have someone else review your code if possible.  A more experienced programmer can point out problems in your code and show you better ways of doing things.  Contributing to an open-source project will give you a chance to do both.</p>

OwnerDisplayName: Bill


问:
How relevant are Brainbench scores when evaluating candidates?
I've seen many companies using certification services such as Brainbench when evaluating candidates. Most times they use it as a secondary screen prior to interview or as a validation to choose between candidates.

What is your experience with Brainbench scores? Did you try the tests yourself, and if so do you feel the score is meaningful enough to be used as part of a hiring process?

Difficult choice.

Consensus seems to be that BB cert are not very good as a certification.  The biggest argument was around the fact that some of the questions are too precise to form a good evaluation.  This view can probably be tempered somewhat but still, to hold someone's future solely on the results of this evaluation would be irresponsible.

That said, I still think it is possible to use them properly to gain additional objective knowledge on a candidate's level of expertise provided the test is done in a controlled environment ensuring that all taking it stand on equal footing.

Thus I went with the answer that best reflected this view keeping in mind that it is still just an hour long 50ish multiple choice question to evaluate skills and knowledge that take years to acquire.  To be taken with a grain of salt !

In short, the tests have value but whether or not they are worth the money is another debate.

Thanks all for your time.

答: I took BrainBench tests for C# and Java some years ago and thought they were completely useless.  I scored well, but the questions were largely about details of syntax and the class library.  Incompetent programmers can memorize this information and pass these tests.  Competent programmers learn the features of the language (e.g. C# has delegates, Java has anonymous classes), and the general contents of the standard library, and look up the details as needed.  In my opinion, these tests measure exactly the wrong thing.  If you want to hire a programmer, you need to see them program.</p>


答:
I'm not a big fan of these tests because they more of a trivia contest than an actual test of programming ability. Some people simply don't perform well on these tests for various reasons not related to their programming ability. I tend to have trouble with them myself due to my vision problems and my typical programming thinking process.

I also think they're biased toward recent college grads who'll have trivia they learned in class not that long ago more clearly in mind and are used to taking tests on a regular basis than someone who graduated 10+ years ago or who is largely self-taught.

I would consider using such a test for a junior level developer position but I wouldn't necessarily use it as the sole determination of who gets an interview or not. I probably wouldn't use it for a mid-level or senior developer position. For these candidates, a phone or face-to-face interview where they are given an open-ended opportunity to discuss their previous projects and programming knowledge are more productive. I think asking such a programmer why they chose X over Y in developing a project is more revealing than their ability to regurgitate 40 multiple choice questions on programming that may not be relevant to the work you need them to do.

Title: How relevant are Brainbench scores when evaluating candidates?

Body:
I've seen many companies using certification services such as Brainbench when evaluating candidates. Most times they use it as a secondary screen prior to interview or as a validation to choose between candidates.

What is your experience with Brainbench scores? Did you try the tests yourself, and if so do you feel the score is meaningful enough to be used as part of a hiring process?

Difficult choice.

Consensus seems to be that BB cert are not very good as a certification.  The biggest argument was around the fact that some of the questions are too precise to form a good evaluation.  This view can probably be tempered somewhat but still, to hold someone's future solely on the results of this evaluation would be irresponsible.

That said, I still think it is possible to use them properly to gain additional objective knowledge on a candidate's level of expertise provided the test is done in a controlled environment ensuring that all taking it stand on equal footing.

Thus I went with the answer that best reflected this view keeping in mind that it is still just an hour long 50ish multiple choice question to evaluate skills and knowledge that take years to acquire.  To be taken with a grain of salt !

In short, the tests have value but whether or not they are worth the money is another debate.

Thanks all for your time.


答:
I had to take one not long ago and I think this type of test is more for weeding out candidates than to see whether you want to hire them or not.

I had 30 questions, 3 minutes for each and the test encouraged the use of references, like books or the Internet. Most of the questions were too specific and I would have not been able to answer them by myself, but with the use of references, I did very well. The test was great for deciding whether a candidate is great at quickly researching what they need to answer a multiple choice question, but nothing more.

I would definitely call someone in for an interview if they did well on the test. Would I reject someone who did really badly (below 60%?) Probably! Would I reject someone if they did mediocre? (70-85%) Probably not. So I guess it does have some weight in the decision making process, but not much.


答:
Brainbench is a good way for a non-technical person (e.g. recruiter) to provide a first screen before dropping a resume on a technical manager's desk. They shouldn't substitute for a true tech screen however.

Also, I've taken a few brainbench certs and found many of the questions are too mired in the minutiae of the framework. I passed nonetheless but don't think the questions asked really qualify a candidate as being proficient with development.


问:
How can I convince cowboy programmers to use source control?
I work on a small team of devs, 4 guys.  They have all used source control.  Most of them can't stand source control and instead choose not to use it. I strongly believe source control is a necessary part of professional development. Several issues make it very difficult to convince them to use source control:

The team is not used to using TFS.  I've had 2 training sessions, but was only allotted 1 hour which is insufficient.

Team members directly modify code on the
server.  This keeps code out of sync.  Requiring comparison just to be sure you are working with the latest code.  And complex merge problems arise

Time estimates offered by developers exclude time required to fix any of these problems.  So, if I say nono it will take 10x longer...I have to constantly explain these issues and risk myself because now management may perceive me as "slow".

The physical files on the server differ in unknown ways over ~100 files.  Merging requires knowledge of the project at hand and, therefore, developer cooperation which I am not able to obtain.

Other projects are falling out of sync.  Developers continue to have a distrust of source control and therefore compound the issue by not using source control.

Developers argue that using source control is wasteful because merging is error prone and difficult.  This is a difficult point to argue, because when source control is being so badly mis-used and source control continually bypassed, it is error prone indeed.  Therefore, the evidence "speaks for itself" in their view.

Developers argue that directly modifying server code, bypassing TFS saves time.  This is also difficult to argue.  Because the merge required to synchronize the code to start with is time consuming.  Multiply this by the 10+ projects we manage.

Permanent files are often stored in the same directory as the web project.  So publishing (full publish) erases these files that are not in source control.  This also drives distrust for source control.  Because "publishing breaks the project".  Fixing this (moving stored files out of the solution subfolders) takes a great deal of time and debugging as these locations are not set in web.config and often exist across multiple code points.

So, the culture persists itself.  Bad practice begets more bad practice.  Bad solutions drive new hacks to "fix" much deeper, much more time consuming problems.  Servers, hard drive space are extremely difficult to come by.  Yet, user expectations are rising.

What can be done in this situation?

答:
For your own sanity, I'd suggest setting up Git or another DVCS on your own machine so that you can track changes.  Import your co-workers' changes into your repository often.  Resolve conflicts as best you can.  This will partially shield you from your coworkers' insanity.

You've mentioned that management has said that developers should use source control.  If you want to be evil, you can enforce this by checking changes into TFS and periodically publishing the repository, thus clobbering any changes that aren't in TFS.  (If you're also maintaining your own DVCS, you should keep the two synchronized.)  Your justification for doing so is that you're following orders from management.  If your coworkers get tired of having their changes overwritten, invite them to use TFS.  And keep clobbering changes that haven't been checked in.  Continue until your coworkers relent or you get fired.

ContentLicense: CC BY-SA 4.0


问:
Is having your own website important?
How necessary or important is it? I try to keep a running list of blogs or sites to follow, but a lot of the time I pull up someone's profile and notice there isn't anything there. Is it really important?

I understand are different levels of programming (from C/C++ system programmers to Rails and even Haskell and J) and not everyone works in a language easily worked with for web based applications. Not everything is web-centric, however with the advent of many popular and sometimes free services I don't think it's unreasonable to expect a majority of programmers to have a personal site.

答: I'm a freelance consultant/contract programmer, and have a website mostly to publicly post my resume.  It's gotten me a fair share of business over time.</p>

Title: Is having your own website important?


答:
How can someone not want different versions of their files and the ability to see the differences? Forget branching and any of the complex stuff. They don't even get the basics. Directly modifying a production file without doing the most rudimentary change in a test environment is insane. I have worked with some individuals and thankfully we never worked on the same projects.

Your coworkers are too stupid to be lazy. That's a waste of time. All you can hope to do is train your manager. Management should like source control because they like all forms of control. Makes them feel important. Screw the others; fixing the leader is your only hope since you're not able to replace him. Start networking with other competent developers and either try to get them to join your team when you have an openning or get them to hire you at their shop.

Title: How can I convince cowboy programmers to use source control?

Body:
I work on a small team of devs, 4 guys.  They have all used source control.  Most of them can't stand source control and instead choose not to use it. I strongly believe source control is a necessary part of professional development. Several issues make it very difficult to convince them to use source control:

The team is not used to using TFS.  I've had 2 training sessions, but was only allotted 1 hour which is insufficient.

Team members directly modify code on the
server.  This keeps code out of sync.  Requiring comparison just to be sure you are working with the latest code.  And complex merge problems arise

Time estimates offered by developers exclude time required to fix any of these problems.  So, if I say nono it will take 10x longer...I have to constantly explain these issues and risk myself because now management may perceive me as "slow".

The physical files on the server differ in unknown ways over ~100 files.  Merging requires knowledge of the project at hand and, therefore, developer cooperation which I am not able to obtain.

Other projects are falling out of sync.  Developers continue to have a distrust of source control and therefore compound the issue by not using source control.

Developers argue that using source control is wasteful because merging is error prone and difficult.  This is a difficult point to argue, because when source control is being so badly mis-used and source control continually bypassed, it is error prone indeed.  Therefore, the evidence "speaks for itself" in their view.

Developers argue that directly modifying server code, bypassing TFS saves time.  This is also difficult to argue.  Because the merge required to synchronize the code to start with is time consuming.  Multiply this by the 10+ projects we manage.

Permanent files are often stored in the same directory as the web project.  So publishing (full publish) erases these files that are not in source control.  This also drives distrust for source control.  Because "publishing breaks the project".  Fixing this (moving stored files out of the solution subfolders) takes a great deal of time and debugging as these locations are not set in web.config and often exist across multiple code points.

So, the culture persists itself.  Bad practice begets more bad practice.  Bad solutions drive new hacks to "fix" much deeper, much more time consuming problems.  Servers, hard drive space are extremely difficult to come by.  Yet, user expectations are rising.

What can be done in this situation?


问:
Functional Low-Level language that can use a webkit view

TL;DR:

I need to develop an app which should look kind of the same on desktop and as a website incarnation.

Since I am a web dev and have never developed for desktop, I want to use a language that can embed a webkit view so I can use the same HTML/JS front-end for both usages, and minimize the learning curve for GUI at least.

C++ and Java can both use webkit, however, I am looking for alternatives where functions are first-class citizens, because I prefer prototype-based languages by far.

Long Version

I am mainly a web developer; I'm at ease with js/as3/php/python.

Lately however, I had ideas that need other languages to get done. Namely, I have an idea for a software that is part custom-database and part GUI. So I began tackling desktop oriented languages such as Java and C++.

I discovered Java is basically super-easy and C++ kind of ok (though it gets complex when I try to use GTK and the docs are sparse and dispersed). I can use this; one thing bugs me though: As fond as I am of PHP as a project and as a community, I've grown a dislike for imperative languages and find myself much more at home with ECMA-style languages. I was happy in web dev lately with the rise of node.js and how I could begin developing server-side functionality with javascript.

My question

I need a language that has the following features:

Functional. By "functional", I mean a large definition. This includes any language where functions are first-class citizens (where "actions" are more important than "actors").

Portable: I picked C++/GTK or Java because of easy portability and no license restrictions. So portability here means os-independent (with realistic limits) as well as open license.

Can use a webkit view:(like in GTK,or in Java) or similar; I intend to leverage my knowledge of web apps to build a beautiful, usable, gui in html5. The same interface will be used in the online version of the app. Therefore, I need the language to have a way to embed and interact with HTML5

Can use JS: ideally, through V8, although rhino or a similar tool is ok. If a window js object could be exposed to the js code (so I can use standard libs such as jQuery), it would be perfect.

Low-level: I need the database part to be fast. Could code my db in C and my GUI in whatever-language-it-will-be, but ideally, I'd like to use one toolset for both

Less important, but: if the language could be a derivative of ECMA script, so I can leverage my js skills, it would be cool.

My Current Options

Titanium, which has all the above features and uses js as it's primary code; However, I dislike being tied to a particular SDK and I'd rather use independent open-source libs that I can read.

Your suggestion?

答:
I propose Common Lisp.

Common Lisp is multi-paradigms so you can do functional
programming.

Common Lisp is portable, there is a lot of implementations that
works on various systems.

There is cl-webkit and
there is also many libraries to use
Gtk.

You can use
Parenscript to
translate Common Lisp to JavaScript.

Common Lisp can be really fast if you know how to use it, and if
you don't the implementations are good enough to produce
good code.

PS: I'm a new user so I can't post more links, but you can look at cliki.net to find the gtk libraries.


问:
A Project's Initial Commit to Source Control
I'm probably over-thinking this and it might not matter in the scope of things, but I'm wondering how people build up initial versions of their projects in source control? I'm talking about when you start with nothing but an idea, so no forking an existing project or anything.

When do you do your commits before having an official or even unofficial version?

At what point do you start branching for features, or do you this right away?

I'm so used to working with existing code bases that I'm not really sure I know if there's a "best" way to build up a project history.

答:
I start by committing some text file that outlines what I'm trying to accomplish, or even a rough-draft of that.  I continue committing frequently until I get to some point that is some useful milestone -- a point worth coming back to if I get off track.  At that point, I branch and continue development on the branch.  Once the branch gets to a useful milestone, I merge it and start another branch.

Some people argue that you don't commit until it compiles.  I argue that you commit all the time to a branch but don't merge to mainline until it is strictly better than mainline development.


问:
When would one give up backward compatibility in favor of new and improved interface implementation?
I have been working at the same software company for more than ten years. As a result, I have implemented a large code base using various object-oriented programming languages.  I was a beginner programmer when I first started my career and I didn't know much about good interface and class design principles. I would like to think that my design skills have improved over time, but I now face more and more difficulties in improving my earlier code because of backward compatibility concerns. My code is used by a large number of customers as part of the products that my company sells.

So my question is: when should one stop trying to keep backward compatibility of old interfaces and bite the bullet in favor of implementing a brand new design?

I think there comes a point where keeping backward compatibility becomes such a big burden that useful changes to interfaces become impossible. Has anyone experienced similar concerns, who can provide some feedback?

答:
I've been on the customer side of this one so I'd say that it really depends on what you plan to do about the transition.

We are currently upgrading our accounts system. The company doing the upgrade also supports the previous incompatible version. They plan to take the data and move it to the new system so that (in theory) all the old data will be there. We will be paying a couple of hundred pounds for the data conversion. No problem.

Compare to a previous situation at anothe rcompany I worked for. The supplier had no way to transition from the old to new systems. This put them in the same situation as every other supplier. In fact their situation was worse because we knew that they were not commited to helping us with the upgrades. They didn't get the new contract.

You've done the hard work in getting and keeping customers, how can you ease the transition?


答:
For me, it helps to break down a larger piece of software into smaller chunks. And then break those chunks into even smaller parts and so on. Every software program is a collection of small pieces of logic.

Consider a blog, for example. You want to be able to create and edit posts that others can read. Right away you can split the project into admin and public sections. At minimum, the admin will require admin users, a login page, and a section for managing the blog. The section for managing the blog can be broken down into a CRUD (Create, Read, Update, Delete) interface.   Creating a new blog post will require a check to make sure the admin user has the right privileges, a form, form validation, and the ability to save to the database. And so on.

The more that you break a problem or a feature down, the more manageable it becomes. It's divide and conquer. Once you've been able to map out your software like this, you can take a look at how different pieces of it interact with each other. Where might you repeat code? What can be abstracted? This should be an iterative process both as you plan and as you write the code itself.

I would recommend figuring out what your minimum feature set is to begin with and implementing that before adding other pieces to it. You'll want to code defensively so that future changes won't be too difficult, but at the same time, you don't want to implement half-features that may never get completed. It's a difficult line to walk between staying flexible and being willing to ruthlessly kill your darlings, to borrow a literary reference. Getting good at that particular balancing act only comes from experience.

And that's what it comes down to, as the other answers have mentioned: experience. The only way to get it is to just start. Don't worry so much about making it perfect from the outset. First make the code work, then make it beautiful, then make it fast.

Also, unlike this paragraph, don't tack security on at the end as an afterthought. You should have an idea about ways your software could be compromised, but as a start, never trust any user input.

Title: How do I go from being able to write code to being a good developer?

Body:
I'm frustrated by the lack of concrete explanations on how to go from being able to script (bash, awk) and write simple applications (c, php, python) to designing and developing larger, more complicated software. It seems that on one side there are programming language books and on the other side there are the software engineering/project management books designed for teams of programmers.

I've read plenty of both. I've read the XP/Agile classics and have a decent theoretical understanding of the software development process. I like to read other people's code and can follow it fairly well. But when I have an idea for a project or want to go from "here's the problem/need" to "here's the solution", my mind draws a blank and I don't know where to begin.

Do I just hack it out? Are there any structured workflows for individual developers that don't work in teams or for a big software house? I really don't have any desire to get a PMP or work for a software company. I'm just looking for an effective, efficient, practical workflow.


答:
What you're looking for is problem solving skills. I've noticed that it is assumed that the developer can already do this, which is silly. Luckily, problem solving is a general skill, used in math, research, everyday life and so on.

Primarily, you should end up following the scientific method, with some frills.

You have a problem (use tools and techniques to help define this)

You hypothesize a solution (patterns and experience help)

Test hypothesis (you might not even have code here)

Repeat steps 2 and 3 until hypothesis holds. You now have a theory (working program to solve problem)

Develop an experiment to stress theory, looking for holes (test cases!)

If test cases hold, you have a solution! Otherwise, rinse and repeat

Notice that this is rather high level. Each step typically involves several substeps, such as determining what the problem actually is. As an example, look at solving word problems in math. You collect facts (a tool), and determine what is actually wanted. Then, you examine your facts, attempting to map them to the solution.

This ends up becoming sub problems of the primary problem. So, follow the steps again. We need an intermediate item to get the final result, so it becomes our new problem. This decomposes the problem down into small, easily understood, sections. As each piece is solved, the solution is pieced together.


问:
Request Information from iPhone/Php developers
recently I hired a freelancer to develop an iPhone application for my website, this application will get information from the DB of the website, normally I should give to him the access to the DB to take the information needed. The question is, how to let him take the information needed without safely, i.e preventing the danger from hacking or accessing to the DB of the website or do some modifications on it... What can I do ?</p>

答:
Without knowing more about your site and iPhone app, here are a few questions you need to ask yourself:

Does the developer/iPhone app need direct access to the database? If you're concerned about security, is it possible for your website to expose the needed portions via an authenticated web service?

If it is necessary to provide direct access to the database, is it possible to mitigate the risk by having a read-only version for the application? Provide a userid that has access only to the portions of the database required for the app to work.

Are your database/web site/server's patches and security practices up to date? Do all that you can to ensure that your data can't be hacked by following best practices in this area.


问:
Is this a correct situation to use a constant?
So my professor was giving back some feedback on a project I've been working on. He docked a few marks for this code:

```<code>if (comboVendor.SelectedIndex == 0) {
  createVendor cv = new createVendor();
  cv.ShowDialog();
  loadVendors();
}
</code>```

This is in a combobox "index changed" handler. It's used when the user wants to create a new vendor, my top option (index 0, that never changes) opens the "Create a new Vendor" dialog. So the content of my combo box ends up looking like this:

```<code>Create New Vendor...
Existing Vendor
Existing Vendor 2
Existing Vendor 3
</code>```

His problem is with the first line code:

```<code>if (comboVendor.SelectedIndex == 0)
</code>```

He claims that the 0 should be a constant, and actually docked me marks because of that. He claims I shouldn't use literals in my code at all.

The thing is, I don't understand why I would want to make that code in that situation a constant. That index will never change, nor is it something that you would need to tweak. It seems like a waste of memory to keep a single 0 in memory that's used for a very specific situation and never changes.

答:
He claims that the 0 should be a constant, and actually docked me marks because of that.

I'd agree. The use of zero here is "magic". Imagine that you are reading this code for the first time. You do not know why zero is special, and the literal tells you nothing about why zero is special. If instead you said if(comboVendor.SelectedIndex == CreateNewVendorIndex) then it becomes extremely clear to the first-time reader what the code means.

He claims I shouldn't use literals in my code at all.

That's an extreme position; a realistic position would be to say that use of literals is a red flag that indicates that the code might not be as clear as it could be. Sometimes it is appropriate.

The thing is, I don't understand why I would want to make that code in that situation a constant. That index will never change

That it will never change is an excellent reason to make it a constant. That's why constants are called constants; because they never change.

nor is it something that you would need to tweak.

Really? You can't see any situation in which someone might want to change the order of things in a combo box?

The fact that you can see a reason why this might change in the future is a good reason to not make it a constant. Rather it should be a non-constant readonly static integer field. A constant should be a quantity that is guaranteed to stay the same for all time. Pi and the atomic number of gold are good constants. Version numbers are not; they change every version. The price of gold is obviously a terrible constant; it changes every second. Only make constant things that never, ever change.

It seems like a waste of memory to keep a single 0 in memory that's used for a very specific situation and never changes.

Now we come to the crux of the matter.

This is perhaps the most important line in your question because it indicates that you have some deeply flawed understanding of (1) memory, and (2) optimization. You're in school to learn, and now would be a great time to get a correct understanding of the fundamentals. Can you explain in detail why you believe that "it is a waste of memory to keep a single zero in memory"? First off, why do you believe that optimizing the usage of four bytes of memory in a process with at least two billion bytes of user-addressible storage is relevant?  Second, precisely what resource do you imagine is being consumed here? What do you mean by "memory" being consumed?

I am interested in the answers to these questions first because they're an opportunity for you to learn how your understanding of optimization and memory management is incorrect, and second because I always want to know why beginners believe bizarre things, so that I can design better tools to lead them to have correct beliefs.


答: I am not sure , how does it work in Iphone app,  but I prefer the JSon calls When I use PHP. I think there is any method to call JSON from an Iphone application if it is HTML based.  </p>

Title: Request Information from iPhone/Php developers

Body: recently I hired a freelancer to develop an iPhone application for my website, this application will get information from the DB of the website, normally I should give to him the access to the DB to take the information needed. The question is, how to let him take the information needed without safely, i.e preventing the danger from hacking or accessing to the DB of the website or do some modifications on it... What can I do ?</p>


问:
What are the personal benefits from writing a boost library
Among the reasons for a developer to publish a self-written library as open source library, there is definitely fame.

Now when it comes to Boost Libraries, they are available and promoted in a very anonymous and  impersonalized form. The name of the author will be readable in the documentation and source files, but be honest:

How many of you could tell me the names of the authors of boost::shared_ptr, ... without looking?

And its not just about the names. Even if you do not know the name of the author of something your using, you still somehow identify it with "the author" and other stuff he did or maybe his website, where you found it.

All these authors' identities are eradicated by the acceptance to Boost. (At this point I really want to thank all boost authors for their selfless and extremely professional efforts.)

I know, they had there reasons, but what about the following case:

Suppose, I had a marvelous and elegant solution to a C++ problem, that had bugged whole generations of programers. The implementation:
 - standard compliant

No use of Macros

type-safe

requires the user to write the minimum possible boilerplate code with no - I repeat: NO - code repetion

zero memory footprint

NO runtime overhead

fits in a header file of about 100 lines of code.

What should I do with it? Should I bother going the burdensome path of the Boost acceptance process? If yes, what's in there for me?

While this sounds selfish, in the end everything you do should have some positive cost/benefit ratio.

答:
Well proposing it as a Boost library will for sure make it be recognized as a C++ standard more easily if this library is that good.

As Boost requirements are very hard to meet, it ensures that your library is a really good one if it is accepted. Then as Boost libraries are regularly added to the standard, yours can make it faster than trying to get in there by your own means.

I think that having written a library which is in the C++ standard will be the best reason.

And the authors of the libraries are apparently all here. If you go on specific classes too, like the example you gave for the shared_ptr, you can see at the bottom:

```<code>Copyright 1999 Greg Colvin and Beman Dawes. Copyright 2002 Darin Adler. Copyright 2002-2005 Peter Dimov.
</code>```

So your name will be there and visible.

Body:
Well proposing it as a Boost library will for sure make it be recognized as a C++ standard more easily if this library is that good.

As Boost requirements are very hard to meet, it ensures that your library is a really good one if it is accepted. Then as Boost libraries are regularly added to the standard, yours can make it faster than trying to get in there by your own means.

I think that having written a library which is in the C++ standard will be the best reason.

And the authors of the libraries are apparently all here. If you go on specific classes too, like the example you gave for the shared_ptr, you can see at the bottom:

Copyright 1999 Greg Colvin and Beman Dawes. Copyright 2002 Darin Adler. Copyright 2002-2005 Peter Dimov.

So your name will be there and visible.


问:
Are type and scope prefixes worthwhile naming conventions?
Recently starting my first job as a software developer, I was a little thrown to be told that I did not have to follow any naming conventions in my code. Code written by groups working on other, larger projects followed naming conventions, but since I was brought in to write a new, stand-alone, application, the feeling was that it did not especially matter. It was the last of my worries, so I just took that existing convention and ran with it.

```<code>int nTickCount  <br>bool bConnected  <br>object[] m_aItems  <br>fSum += fWeight * fValue  <br>class cManager  <br>enum etSystemStates  <br>etSystemStates eState   <br>cManager.cs<br></code>```

But is it actually worthwhile? I find it hard to judge the net effect that following this kind of naming convention has on comprehension and detection of errors, but, visually, it just looks kind of ugly. Plus, having every class and file in the project called cSomething seems pretty asinine.

I'm not under the illusion that it's a remotely big deal when compared to things that make an obvious difference, like the algorithms and architectures that you employ. But any convention that affects every line of code that I write seems worth getting right.

What do you find the most elegant and effective naming convention, if one need be used at all? Does it denote type and/or scope?

答:
There are a few different "styles" of naming convention out there, and most of them have some value in making code understandable.

What is FAR more important is: use descriptive names for variables and functions.  In your example with "sum", "weight" and "value", you might want to give more meaningful names: "totalCost", "lumberWeight", "lumberValuePerOunce" (I'm making some assumptions here)

I find conventions like prepending variable names with a character signifying the type to be quite distracting in most modern languages.

OwnerDisplayName: Justin Standard


答:
What you're describing is called Hungarian notation.  It was once considered best practice, but is generally frowned upon now.

The Wikipedia article contains a section on its pros and cons.

Title: Are type and scope prefixes worthwhile naming conventions?

Body:
Recently starting my first job as a software developer, I was a little thrown to be told that I did not have to follow any naming conventions in my code. Code written by groups working on other, larger projects followed naming conventions, but since I was brought in to write a new, stand-alone, application, the feeling was that it did not especially matter. It was the last of my worries, so I just took that existing convention and ran with it.

```<code>int nTickCount  <br>bool bConnected  <br>object[] m_aItems  <br>fSum += fWeight * fValue  <br>class cManager  <br>enum etSystemStates  <br>etSystemStates eState   <br>cManager.cs<br></code>```

But is it actually worthwhile? I find it hard to judge the net effect that following this kind of naming convention has on comprehension and detection of errors, but, visually, it just looks kind of ugly. Plus, having every class and file in the project called cSomething seems pretty asinine.

I'm not under the illusion that it's a remotely big deal when compared to things that make an obvious difference, like the algorithms and architectures that you employ. But any convention that affects every line of code that I write seems worth getting right.

What do you find the most elegant and effective naming convention, if one need be used at all? Does it denote type and/or scope?

OwnerDisplayName: Dave Ward


答: I find that, for the most part, Google's coding style guide is pretty good. Since you were told that you can use any style you like, I think you should start by looking this over, and picking and choosing from it.</p>

OwnerDisplayName: Ryan Fox


答:
I've always been prone to using a 2 to 4 character abbreviation for the type in front of the variable itself. At times it seems tedious, but when you're working with complex data types or situations, it becomes beneficial. I think it falls into the lower camel case category.

Looking at your example above, it would be slightly retooled to be:

```<code>int intTickCount;<br>bool boolConnected;<br>object[] aobjItems;<br></code>```

Arrays always have an a in front of the type to designate the array. This also allows me to group similar variables instances together. For instance, I can use...

```<code>taStore.Fill(dtStore);<br></code>```

...which indicates that my Store TableAdapter is filling into the Store DataTable.

Body:
I've always been prone to using a 2 to 4 character abbreviation for the type in front of the variable itself. At times it seems tedious, but when you're working with complex data types or situations, it becomes beneficial. I think it falls into the lower camel case category.

Looking at your example above, it would be slightly retooled to be:

int intTickCount;
bool boolConnected;
object[] aobjItems;

Arrays always have an a in front of the type to designate the array. This also allows me to group similar variables instances together. For instance, I can use...

taStore.Fill(dtStore);

...which indicates that my Store TableAdapter is filling into the Store DataTable.

OwnerDisplayName: Dillie-O


答:
Most .NET developer follow Microsoft's Design Guidelines (
http://msdn.microsoft.com/en-us/library/ms229042.aspx), which is pretty similar to Java's (main difference is Microsoft favors Pascal Case for member names, while Java favors camel Case).

Aside from that, I'd say your code sample is far less readable because of the extra noise you've added.

OwnerDisplayName: Karl Seguin


答:
In my view, it depends on the language and the size of the project.  I've never actually gone so far as to use type prefixes on all of my variables, but you do want to name them in a clear manner.

In a statically typed language, like the one you're using, the more comfortable I feel with the type system, the less important Hungarian Notation becomes.  So in Java or C# and especially in Haskell I wouldn't even think about adding those prefixes, because your tools can tell you the type of any given expression, and will catch most mistakes resulting from misunderstanding a type.

OwnerDisplayName: Peter Burns


答:
Joel Spolsky wrote an article about why Hungarian notation exists and what it was intended for that may help answer your question.

Prefixes like tbl for a database table, int for an integer etc. are generally not useful - it is trivial to work out what is what from context or from your development tools in those cases.  Something like imp for imperial measurements and met for metric makes a lot more sense because otherwise you can only see that they are floating point numbers.

```<code>area = width * height<br></code>```

looks perfectly fine while

```<code>impArea = metWidth * impHeight<br></code>```

shows you straight off that something is wrong.

Personally I just use descriptive variable names.  $number_of_items is obviously an integer count.  $input_file_handle, $is_active and $encrypted_password have obvious types both in terms of language data type and semantic type.

Body:
Joel Spolsky wrote an article about why Hungarian notation exists and what it was intended for that may help answer your question.

Prefixes like tbl for a database table, int for an integer etc. are generally not useful - it is trivial to work out what is what from context or from your development tools in those cases.  Something like imp for imperial measurements and met for metric makes a lot more sense because otherwise you can only see that they are floating point numbers.

area = width * height

looks perfectly fine while

impArea = metWidth * impHeight

shows you straight off that something is wrong.

Personally I just use descriptive variable names.  $number_of_items is obviously an integer count.  $input_file_handle, $is_active and $encrypted_password have obvious types both in terms of language data type and semantic type.

OwnerDisplayName: Mat


答:
Yes, prefixes can be useful, but I have a couple of suggestions:

If your entire team is using the same conventions, they become much more useful. Using them on your own is less helpful.

In strongly, statically typed languages, don't just copy the type of a variable. E.g. "bSubscribed" is a bad name for a boolean variable in C# or Java, because your IDE already knows what type it is. In C on the other hand, which lacks a boolean type, this would be useful information.

In C# and Java, you might consider a prefix to show that an object may be null. Or that a string has been html-escaped. Or that it represents a regular expression, or a sql statement. Or that an array has been sorted. Use your imagination.

Basically it's a question of asking yourself what you'd like a variable name to tell you, and that depends a lot on the domain and the language you're working in.

OwnerDisplayName: Michiel de Mare


答:
Prefixing variable names with data types (especially primitive data types) increases visual noise, as well as the risk that an otherwise small change will become a big-bang renaming.

Re the first point, is "intStudentCount" really any clearer than e.g. "numberOfStudents"? Wouldn't  "invoiceLineItems" be at least as informative as "aobjItems". (The data type should be about the meaning of the data in the problem domain, not the low-level representation.)

As for the second point, what happens when e.g. a premature selection of int is replaced by long or double? Even worse, what happens when a concrete class is refactored into an interface with multiple implementing classes? Any practice which increases the burden of realistic maintenance scenarios seems questionable to me.

OwnerDisplayName: Joel Neely


答:
I've always tried to adhere to the basic principle that prefixes and/or suffixes should be inserted only when it make the code more readable (as in plain English).

The less cryptic, the better...

Why have a method like this:

```<code>public boolean connect( String h, int p );<br></code>```

When you can have something like this:

```<code>public boolean connect( String hostName, int port );<br></code>```

Moreover, the IDEs today really have powerful tool for refactoring (Especially Java) variables, method names, classes, etc... The idea to say the maximum information with the least amount of character is just old fashioned.

Body:
I've always tried to adhere to the basic principle that prefixes and/or suffixes should be inserted only when it make the code more readable (as in plain English).

The less cryptic, the better...

Why have a method like this:

public boolean connect( String h, int p );

When you can have something like this:

public boolean connect( String hostName, int port );

Moreover, the IDEs today really have powerful tool for refactoring (Especially Java) variables, method names, classes, etc... The idea to say the maximum information with the least amount of character is just old fashioned.


答:
It might also depend on why you are prefixing the name, as opposed to just what you prefix it with.

As an example, I tend to use a 1-2 letter prefix for the names of controls on a form. It isn't because I don't know that the compiler will easily find the right class for the button (as an example), but I tend to design large forms first, then write most of the code afterwards.

Having a prefix of bt for the buttons makes it easily to find the right button afterwards, instead of having lots of names jumbled together.

I don't use prefixes for naming variables though, neither for the type (which is generally not that useful anyway), nor for the meaning, context or unit (which is the original idea behind Hungarian Notation).

OwnerDisplayName: Lasse V. Karlsen


答:
Prefixes often make sense for objects, for instance in a form where you might have 20 text boxes calling them all tbSomething makes sense.

However, mostly I don't think it's worthwhile, especially for value types.

For instance, suppose you had:

```<code>short shortValue = 0;
//stuff happens
</code>```

Months later you find you need to change it - a short isn't big enough. Now you have:

```<code>int shortValue = 0;
//stuff happens
</code>```

Unless you also now change the name of the variable (more risk of breaking code than changing the type in this case) you now have confusing code.

You're better off having a name that describes what it holds:

```<code>int loopCounter = 0;
//stuff happens
</code>```

If later that needs to change to a long: no problem.

There's maybe more argument for these conventions in dynamically typed languages or those without an IDE.

Body:
Prefixes often make sense for objects, for instance in a form where you might have 20 text boxes calling them all tbSomething makes sense.

However, mostly I don't think it's worthwhile, especially for value types.

For instance, suppose you had:

short shortValue = 0;
//stuff happens

Months later you find you need to change it - a short isn't big enough. Now you have:

int shortValue = 0;
//stuff happens

Unless you also now change the name of the variable (more risk of breaking code than changing the type in this case) you now have confusing code.

You're better off having a name that describes what it holds:

int loopCounter = 0;
//stuff happens

If later that needs to change to a long: no problem.

There's maybe more argument for these conventions in dynamically typed languages or those without an IDE.

OwnerDisplayName: Keith


问:
Should exceptions of a subclass extend the superclass exceptions or my own namespace?
Our library extends another (third-party) library. When we create a child class in our library, and want to throw exceptions, should those exceptions extend the exceptions from the parent class or from our own namespace? For example:

```<code>class Their_Exception extends Exception {}

class Their_Class {}
class Their_Class_Exception extends Their_Exception {}

class Our_Exception extends Exception {}

class Our_Class extends Their_Class {}
class Our_Class_Exception extends Our_Exception {} // or Their_Class_Exception?
</code>```

Is it better to keep our code as above, and extend our own namespace? The way I see it, we have these alternatives:

Extend our own namespace, catching all possible Their_Class_Exception cases and throwing Our_Class_Exceptions in their place (complete encapsulation, but in general could be a fair amount of rework)

Extend our own namespace, but only don't catch Their_Class_Exception in Our_Class (probably means multiple catch blocks)

Extend Their_Class_Exception (seems counter-intuitive, could introduce bugs by catching the wrong exceptions)

Which of these is the best approach in general, in order to keep our code consistent?

答:
If there is any chance of replacing this API with another at some point in the future, go with option 1, catch and wrap their exception in your own.

Generally, the less you refer to third-party APIs in your own code, the better, unless your code is intrinsically tied to the API (eg. the JVM or .NET Framework).

If that's not the case, or if it just is too much work, then ask yourself: Is Our_Class_Exception actually an extension of Their_Class_Exception? i.e. Is it another form of the same exception.

If so then extend it (option 3), because you'll end up with double-catches everywhere if you don't. But if that is the case, why not just use their exception?

If not or if you're still not sure then play safe and extend your own namespace (option 2).


答:
I know you say you don't want to work for a software company, but that's a good place to get the experience many of the other answers talk about. And whether or not you want to work on big projects, exposure to other peoples' work and work styles are good things to have.

You can't try out Pair Programming by yourself, for example.  And if you're paired with someone smarter than you, you get the added benefit of earning better practices from them while getting experience in that methodology.

BTW, I've made it my practice to try to work with groups where I feel I'm below the average in experience, skill, and the like.  It raises my game tremendously.  It's much harder to do that alone or where you're the "experienced" guy.


问:
What makes one language any better than another when both are designed for the same goals?
I'm in the process of creating a grammar for a scripting language but as I'm working on it I started to wonder what makes a language good in the first place. I know the goals for my script but there are always 1000 different ways to go about doing things.

Goals:

Easy to use and understand (not my grandma could do it easy, but the
secretary at the front desk could do it or the VP of marketing could
do it type of easy)

No user defined functions or subroutines.

Its use would be in events of objects in a system similar to HyperCard.

Conceptually I was thinking of a language like this:

```<code>set myVariable to 'Hello World'
set counter to 0
repeat 5 times with x
begin
    set counter to counter add x
end
set myVariable to myVariable plus ' ' plus counter
popup myVariable

set text of label named 'label' to 'new text'
set color of label named 'label' to blue
</code>```

The end result would popup a dialog with the contents Hello World 15 it would also change the text of a label and make it blue.

But I could do the same thing 1000 different ways. So what makes one language any better than another when both are designed for the same goals?

答:
There's no right answer here. Different languages are designed for different things and different styles of programming. This is clear from the design principles of even popular languages. From the Zen of Python:

There should be one-- and preferably only one --obvious way to do it.

Perl was designed using the opposite principle:

There's more than one way to do it

Neither one of these languages did it "right". Some people prefer one style over the other, but it ultimately comes down to stylistic preferences and the goals of the language.


答:
Ideally, you'll be providing only indirect access to secured data via a service. This service will handle security such as identity authentication and security/access levels.

A quick Google and StackOverflow search will reveal several different service design options for connecting to a web service from an iOS device.


答: the only thing that matters for a language is that is solves the problem it was designed to solve. what makes a language better than another is that is solves the problem better.  In your case it looks like you are stuck on how much like written English should the language be, you could try writing something like in your question several ways you think are pretty good and asking someone which they like the best (preferably someone who is intended to use the language if they exist). if you pick something and stay consistent and try to avoid creating special cases whatever you decide will work quite well.</p>

Title: What makes one language any better than another when both are designed for the same goals?

Body:
I'm in the process of creating a grammar for a scripting language but as I'm working on it I started to wonder what makes a language good in the first place. I know the goals for my script but there are always 1000 different ways to go about doing things.

Goals:

Easy to use and understand (not my grandma could do it easy, but the
secretary at the front desk could do it or the VP of marketing could
do it type of easy)

No user defined functions or subroutines.

Its use would be in events of objects in a system similar to HyperCard.

Conceptually I was thinking of a language like this:

```<code>set myVariable to 'Hello World'
set counter to 0
repeat 5 times with x
begin
    set counter to counter add x
end
set myVariable to myVariable plus ' ' plus counter
popup myVariable

set text of label named 'label' to 'new text'
set color of label named 'label' to blue
</code>```

The end result would popup a dialog with the contents Hello World 15 it would also change the text of a label and make it blue.

But I could do the same thing 1000 different ways. So what makes one language any better than another when both are designed for the same goals?


问:
How do you create a software process for a project?
As I've written about in other questions here, the project that I'm working on now has no software process. That means no documentation (including hard copy requirements or specification), no source control, no bug database, bugs are "fixed" (hopefully) and new code is added at the same time, and no formal testers - we would fail the Joel Test so bad, it's not even funny.

Yesterday, my manager asked me to write a document about how to begin to fix these shortcomings. Note that I'm just an intern, here for 6 months. I'll be leaving around Thanksgiving in November to return to school. However, I think that I can perhaps get this project moving in the right direction, but I'm not sure where to even begin. I'm currently using CiteSeer and Wikipedia to attempt to find some papers and such that describe software processes and implementing them, but any advice, personal experiences, or links to blogs, papers, wiki articles, or anything else would be greatly appreciated.

答:
Check out these articles on Continuous Integration for .NET programming using MSBuild, CruiseControl.NET, FxCop, NUnit, NCover and Subversion...

From the software development trenches

OwnerDisplayName: Thomas Owens

OwnerDisplayName: Zack Peterson


答: We use Prince2 for the processes of project management, and it works very well. I would suggest it would seem tortuous for a company with no project management in place, though!</p>

Title: How do you create a software process for a project?

Body:
As I've written about in other questions here, the project that I'm working on now has no software process. That means no documentation (including hard copy requirements or specification), no source control, no bug database, bugs are "fixed" (hopefully) and new code is added at the same time, and no formal testers - we would fail the Joel Test so bad, it's not even funny.

Yesterday, my manager asked me to write a document about how to begin to fix these shortcomings. Note that I'm just an intern, here for 6 months. I'll be leaving around Thanksgiving in November to return to school. However, I think that I can perhaps get this project moving in the right direction, but I'm not sure where to even begin. I'm currently using CiteSeer and Wikipedia to attempt to find some papers and such that describe software processes and implementing them, but any advice, personal experiences, or links to blogs, papers, wiki articles, or anything else would be greatly appreciated.

OwnerDisplayName: ColinYounger


答:
I would suggest that you look into Agile programming.

There's lots of variants, but they tend to have a few things in common:

Regular review and re-prioritisation of features.

Continuous integration and automated unit tests.

Focus on communication over documentation (in practise this means wiki-style documentation as you go over huge inflexible specs written in advance).

Flexible estimates resulting in burn-down charts and velocity metrics.

Regular prototypes that are reviewed over 200 page specs with sign-offs.

Quality at source, or as close as possible.

Regular stakeholder review - an extension of understanding your customers.

Get software out to market (and making money) ASAP.

Direct communication as much as possible.

A good place to start would be MSF Agile or Scrum.


答:
We adapted the development pipeline outlined in this video to our own needs, using TeamCity as our CI server.

http://channel9.msdn.com/shows/ARCast.TV/ARCastTV-Tuning-The-Development-Process-at-Spot-Runner/

TC is the only CI system I'm aware of that does a repository-push rather than pull, which means (theoretically) no more broken builds ever!

OwnerDisplayName: Duncan


答:
Given the situation, you being gone in 6 months and the team starting from no process whatsoever, I would limit the scope of what you introduce to one or two things that can be reasonably implemented and take hold in the time you are there. If it were me I would take a look at a source control tool and a bug tracker.

The reason I would start there is because getting these tools in place will help you to establish a baseline for the teams current performance and possibly identify recurring issues. Process changes are nice but these are basic foundation items that should be in place first.


答: Just to echo the sentiments of some of the above, those teams who have no structure will fit better with an agile structure.  Get source control today just start putting your changes into SVN and show some of your developers a diff when you are bug hunting. Start adding revision logs. If they can't see the benefits and ease of use of SVN then they are doomed.</p>

OwnerDisplayName: John Nolan


答: Unless you are an experienced language designer, it might be better to take an existing programming language that has already proven itself useable, useful, and/or perhaps even popular, among some similar target audience, and prune that language's syntax to meet your needs.</p>


问:
Which (programming) specialities are needed in a good web development team?
At first glance, I'd say a good programming team needs to understand the following matters:

The details of the core language / framework

HTML, (asynchronous) javascript

SQL / data model

Usability / UI design

Security

Project management.

If this team is not complete: what is needed?

答: A programming savvy Graphic Designer. A graphic designer for web needs to understand the limitations of web graphics and concepts like graceful fallback. HTML5 and CSS3 are making a big push, but until those are here, your graphic designer needs to understand the limits of CSS2 and XHTML.</p>


问:
VB.Net vs C# debate
I've been in workplaces where, at the start of a project, the "Should we use VB.Net or C#" question has been raised.

Granted, it's probably less common to have to make that decision now than it was in the early days of .Net, particularly given the trend towards language convergence, but it can still be a heated debate.

So, between VB.Net and C#, Which language do you prefer and why?

答:
I hate VB.NET. The days I still spend using it are the days I regret. That said, my tastes are a part of my situation and experience, and don't necessarily have any relevance to what you're doing...

I think it is important, when comparing continually-evolving languages like C# and VB.NET, to look back at their history and see how they arrived at their current state:

The original advantages of BASIC on microcomputers included size and simplicity (small, easy-to-parse syntax made for small, reasonably fast interpreters and left room in memory for the actual program and data), an interactive environment that enabled experimentation, and a syntax that eschewed terse symbols and structures for a reasonably clear, English-like syntax. It was poorly-suited for large, structured programs however, and tended to encourage spaghetti code. Still, its availability and simplicity made it an excellent choice for an introduction to programming.

QuickBasic updated the syntax to allow for large more structured programs, and added compilation for faster execution.

VisualBasic provided a powerful, easy-to-use form builder to enable rapid construction of GUI applications, while adopting the QB syntax for use in scripting these UIs. It worked best when used to create UIs for low-level logic provided as pre-built components (usually written in some other language). Over time, the syntax became increasingly large and inconsistent as new features were tacked on. The focus on drawing up a UI first and then filling in bits of script worked well for small, UI-centered apps, but tended to encourage copy-paste programming and a variation on spaghetti code while discouraging re-use, complex data structures, and separation of concerns. In the minds of many, "VB code" became synonymous with "big ball of mud"; "VB programmer" with "inexperienced hack".

VB.NET is a VB-like language on the .NET platform, an attempt (not entirely successful) to clean up and modernize the overgrown VB syntax. It was not perfectly compatible with existing VB code, and made no effort to provide compatibility with VB forms (arguably the most important part of VB) whatsoever. This left many VB product owners with the unpleasant choice of effectively re-writing their applications in VB.NET (dealing with subtle incompatibilities in every routine that wasn't carefully examined) or actually re-writing their applications in C# (dealing with an unfamiliar syntax in addition to the new runtime library and forms designer). Most VB.NET users were VB users who stuck with it for the syntax alone, many using it as a crutch while learning C#. As a result, it immediately took on a reputation as a haven for programmers who had become stuck in their ways, unwilling or unable to expand or improve their skills.

At this point in time, VB.NET continues to evolve, slowly shedding baggage while picking up new and interesting syntax (LINQ, XML literals). Still, it retains almost none of the original advantages of BASIC: it is a large, complex language with a fairly steep learning curve and limited opportunity for interactive experimentation.

For old programmers who have stuck with it over the past 30+ years, it's not a bad choice, provided they don't limit themselves to it.

For new programmers, the increasingly-vague resemblance of VB programs to English is hardly worth the bizarre nods to backwards compatibility and social stigma.

For new projects, VB.NET is a strange choice unless the project is heavily involved with one of the few tasks the language is optimized for: integration with poorly-typed COM components (Office...) (though C# 4.0 reduces this advantage considerably), or inline XML generation.

Title: VB.Net vs C# debate


问:
How often do you use Formal UML?
I used ad-hoc MUML (made-up modeling language) to design and explain system fairly frequently.  It looks similar to UML and tends to be pretty well understood.

However, I've had a professor or two that harped on the use of strict, formal UML, as close to the spec as possible.  I always suspected that strict UML wasn't really as common as they claimed.  So, how 'bout it- how often do you actually draw out complete diagrams that use all the proper line endings, multiplicity, member type symbols, etc?

答:
However, I've had a professor or two
  that harped on the use of strict,
  formal UML, as close to the spec as
  possible.

Ask your professor when was the last time he used that approach on a real system. Seriously.

I try to be as formal as possible when it comes to UML, but only if/when it makes sense. Zealots on both side of the spectrum (from cowboys to uptight formalists) fail to understand that.

There are contexts in which a less rigid approach (like the one you personally use) is the best approach to follow. A good example is for small systems or changes, where requirements are small and not fully defined; the group in charge is efficient and effective; it is more important to get it out than to get it perfect. It is done iteratively and some deficiencies are acceptable.

Or maybe you are in a stage where you are doing guestimation and sketching as opposed to a full formal modeling phase. Those are examples that would come to mind.

At other times, you need a rigid formal UML approach. For example, you might be contractually bound; you have a very large number of developers in multiple teams (possibly distributed); the scope of the project might be in years; it is a very large system (including software and hardware components); the cost of failure is high, etc.

At other times, you have to use something else instead/in addition to UML (actual mathematical formal models like petri nets, CSP or temporal logic.) Example of this are real-time systems, systems where failures are catastrophic (medical devices) or where you are contractually bound (.ie. as in Europe when developing transportation systems.)

It all depends on the circumstances and what we expect to gain from each approach. A professor that harks on sticking to formality is simply being a blind zealot. The world of engineering is not a black-n-white, right/wrong dichotomy. It is a world of intelligent trade-offs.

If you are intelligent enough to use a casual, informal model in a manner that is effective and appropriate to get the job done, then so be it. By the same token, you will be expected to recognize when NOT to use an informal approach and/or when NOT to use a formal one.

Having said that, you have to play it by ears with professors. Give them a bone so that they give you a grade, and if that means to finally bow to their zealot mantra, that's fine. You know what works for you, and hopefully, you will know when to use what and how in the real world.

Title: How often do you use Formal UML?


问:
Passing a dependency to a controller class
I'm looking for an approach to the following problem:

I have a reusable library. It contains a controller class, in the MVC sense. Let's say it's called UserAdministrationController, and it's for editing users. This class requires an object implementing IUserStorage, for storing its data. The library doesn't need to know the details of how this object works.

Now I want to write an application that includes the library. In it, I'll provide an implementation of IUserStorage. To instantiate this, I'll need to pass it some dependencies, like a database object, and other things that my application only knows about at runtime.

But how would I then pass this object from my application to the library? I'm not instantiating the UserAdministrationController directly from my application; it gets created by the library itself.

Hope this makes sense. I'm trying to keep my description abstract and not specific to a particular framework or language.

答: The specific answer is fundamentally language specific. The general answer is you'll need to look into dependency injection which handles the job of injecting dependencies (IUserStorage) into your UserAdministrationCntroller.</p>


问:
ASP.NET MVC - should the MVC's M, V and C be explicitly aware of domain entities?
Since this question seems to be pretty subjective, I'm posting it here.

Let's say you're writing your own version of Stackoverflow using ASP.NET MVC, so there are classes like Question, Answer, User, etc. Since you're lazy, you decided to use entity framework. So, all the classes mentioned above have navigation properties: Question knows its Answers, Answer knows the User who posted it, etc.

You've read a lot of Martin Fowler's books, so for sure you're going to have a service layer to implement all the business logic there. You're going to use ASP.NET MVC only for the UI and application logic related functionality.

There are 2 questions:

Will you directly expose objects of Question, Answer and others to the controllers?

Will you do the same for views?

I'm basically neither going to provide a REST API to my application, nor I'm too conservative to just have any fears like "hey, MY VIEW is aware of what the Question is, I don't know if it's bad or not, I just don't like it!".

I'm especially curious about the case when the Question class has a field like TimePosted and you bind your PostNewQuestion view to that class. I know that in case I'm not binding that field to any control on the page, it won't be posted, so I'll have that field set to null when I got the object on my controller side. Is it considered fine or is it bad idea? 2 opposite approaches I'm thinking of are "using DTOs/ViewModels everywhere" and "wtf, less classes is always better!"

What do you think is a right approach? (I know there's no direct answer, so the question in fact is "what should one consider to decide whether using DTOs/ViewModels/Whatever else is good for its app's architecture?")

Also please note we're considering a very simplified clone of Stackoverflow, so:

It's a web-only project (we're not going to expose REST API or whatever else)

There are users, questions, answers, tags and search functionality (no outstanding business logic)

There are like 100 active users per day (no special performance requirements)

The code should be readable and there should be no surprises or places of special interest in case a new member joins the dev team.

You may also express your thoughts in case any of first 3 points get changed - "the customer now wants our service to allow 10000 simultaneous users" or "we now need to only allow every single user to post once per 15 minutes", etc.

Thanks!

答:
I haven't worked much with MVC, however I have worked a lot with MVVM and here's my take on it:

Question, Answer, and User are all data objects. Its OK for them to know of each other, but they should not be aware of anything outside of the data object layer, such as Views, Controllers, ViewModels, etc.

In an ideal world, your View only references the Models. They might know of the Controller, but they shouldn't have to reference it directly. The ViewModel only knows of other Models. The Controller knows about Models and ViewModels. It doesn't care about the View at all, even though it supplies the View with ViewModels or Models.

So your objects end up looking like this:

M odels come in two varieties: Models and ViewModels.

Models are simple data objects that simply exist to hold data, and are generally a reflection of database data. They do not access the database or contain any sort of business logic that is unrelated to them.

ViewModels are data objects that contain data that the View needs, not necessarily what the database needs. They can contain Models, although Models should not contain ViewModels.

C ontrollers contain your business logic. They control the data access calls, creating Models/ViewModels to pass to the View, advanced business logic such as permissions, etc. They basically control the entire code layer.

V iews are just used to give the users a user-friendly interface. They accept either a ViewModel or Model, and display it in some way that looks nice to the user.


答:
You'll need to open up the library so that there's a Seam that allows the consumer to (re)define how UserAdministrationController instances are created. This could, for example, be an Abstract Factory that consumers can implement. This doesn't prevent you from providing a default implementation in your library, but enables consumers to extend or change the behavior if they need to.

Here are more details about writing DI frindly libraries: https://stackoverflow.com/questions/2045904/dependency-inject-di-friendly-library/2047657#2047657

(...and in case you get other answers that tell you that a DI Container is the answer: applications use DI Containers; libraries absolutely should not. A DI Container is part of an application's infrastructure, so should not be allowed to invade any library. It's perfectly possible to do DI without a container, so by implementing a library using only the patterns and principles of DI, you leave it up to various applications if the want to use a container at all, and if so, which one.)

Title: Passing a dependency to a controller class

Body:
I'm looking for an approach to the following problem:

I have a reusable library. It contains a controller class, in the MVC sense. Let's say it's called UserAdministrationController, and it's for editing users. This class requires an object implementing IUserStorage, for storing its data. The library doesn't need to know the details of how this object works.

Now I want to write an application that includes the library. In it, I'll provide an implementation of IUserStorage. To instantiate this, I'll need to pass it some dependencies, like a database object, and other things that my application only knows about at runtime.

But how would I then pass this object from my application to the library? I'm not instantiating the UserAdministrationController directly from my application; it gets created by the library itself.

Hope this makes sense. I'm trying to keep my description abstract and not specific to a particular framework or language.


问:
What should you include in a development approach document?
I'm in the middle of co-producing a "development approach" document for off-shore resources as they ramp up onto our project.

The most recent (similar) document our company has used is over 80 pages, and that does not include coding standards/conventions documents.

My concern is that this document will not be consumable and will therefore fail.

What should be in a development approach document?
Are there any decent guidelines on this topic?

EDIT: The development approach document should detail the practices and techniques that will be used by software developers while software is designed, built, and tested.

答:
Keep the document short.
Use newspaper style structuring - start with high level detail and follow with specifics.
Instead of including standard practices - just reference them and detail deviations from the standard.</p>