答:
The most important features in a langage you learn are:

principle of least surprise (PASCAL)

readability (Ada)

In my opinion, the second trumps the first, since reading code is even more important than writing it.

Now again, I write C#, Java, Objective-C and Javascript for a living, all of which have horrible quirks :D

Still if I had to choose one langage to start with, I'd go for C#. It's relatively easy to read, has few serious surprises in itself (they are most often hidden in MS tools/frameworks...) and a massive amount of code to be read and documentation, both of which are essential to learning well.


问:
Any best practices for a distributed agile team?
Our scrum teams are split geographically (not ideal I know!) due to specific knowledge only being available in certain countries.
So one team of say 7 members, has the business person in one city, 2 devs in another, 2 other devs in another and 2 qa's in another.

Any suggestions for how to manage this type of graphically dispersed team? Any best practices?

How do you do standups? via skype video? do we ensure that people travel every 6 weeks (the half time of trust apparently)? how do we do the task board? Virtually or via video?
would kanban work better in this setup?

答:
Try to have as much working time overlap as possible between the different sites. Delivery needs rapid communication.

Use GoogleDocs/Spreadsheet to share the offer template during release and sprint planning, allowing various teammembers to edit concurrently.

Desktop share using skype and use its video conference or Google+ hangouts. Use IRC or similar to allow for frequent comms from the entire team. Theme chatrooms for bugs, builds, impediments to help teammembers find the right place to help and get help.

Have a shared IssueTracker for tracking the sprints and releases - Jira.

Have online burndowns and information repositories that are kept up to date, preferably visible by big screens in each site.

Everyone goes home ensuring builds are green and progress is reported. Each site would benefit from a scrummaster who will communicate frequently the outcome of standups and who can assist removing impediments from the remote team.

See Craig Larman's lessons described here.

ContentLicense: CC BY-SA 3.0


问:
Why do programmers use or recommend Mac OS X?
I've worked on both Mac and Windows for awhile. However, I'm still having a hard time understanding why programmers enthusiastically choose Mac OS X over Windows and Linux?

I know that there are programmers who prefer Windows and Linux, but I'm asking the programmers who would just use Mac OS X and nothing else, because they think Mac OS X is the greatest fit for programmers.

Some might argue that Mac OS X got the beautiful UI and is nix based, but Linux can do that. Although Windows is not nix based, you can pretty much develop on any platform or language, except Cocoa/Objective-C.

Is it the applications that are only available on Mac OS X? Does that really make it worth it?

Is it to develop iPhone apps?

Is it because you need to upgrade Windows every 2 years (less backwards compatible)?

I understand why people, who are working in multimedia/entertainment industry, would use Mac OS X. However, I don't see what strong merits Mac OS X has over Windows. If you develop daily on Mac and prefer Mac over anything else, can you give me a merit that Mac has over Windows/Linux? Maybe something you can do on Mac that cannot be done in Windows/Linux with the same level of ease?

I'm not trying to do another Mac vs. Windows here. I tried to find things that can be done on Mac but not on Windows with the same level of ease, but I couldn't. So, I'm asking for some help.

答:
For people coming from linux and the college it looks just like Linux with a sexy UI.

Given enough years they start to understand the differences, and the drawbacks, and the complete arbitrariety of the many roadblocks the vendor is imposing on them and grow out of that. So, if they're enthusiastic, they're probably just a tad bit too young.

...and then there are those gamedev that just buy a Mac (and detract the cost off taxes) to run Windows on it and boot into MacOS only when they have to iPhone things up. But that's a small segment.

So the real question should be: "why young programmers straight out of college know no better than recommending OSX?"

...maybe because they got locked in with ObjC+Cocoa.


答: my workplace gave option of laptop: windows or mac. I chose mac but only because I mostly do linux dev and I prefer the unix-y environment (nice unix terminal and all). But I would pick a linux laptop if that was an option.</p>

Title: Why do programmers use or recommend Mac OS X?

Body:
I've worked on both Mac and Windows for awhile. However, I'm still having a hard time understanding why programmers enthusiastically choose Mac OS X over Windows and Linux?

I know that there are programmers who prefer Windows and Linux, but I'm asking the programmers who would just use Mac OS X and nothing else, because they think Mac OS X is the greatest fit for programmers.

Some might argue that Mac OS X got the beautiful UI and is nix based, but Linux can do that. Although Windows is not nix based, you can pretty much develop on any platform or language, except Cocoa/Objective-C.

Is it the applications that are only available on Mac OS X? Does that really make it worth it?

Is it to develop iPhone apps?

Is it because you need to upgrade Windows every 2 years (less backwards compatible)?

I understand why people, who are working in multimedia/entertainment industry, would use Mac OS X. However, I don't see what strong merits Mac OS X has over Windows. If you develop daily on Mac and prefer Mac over anything else, can you give me a merit that Mac has over Windows/Linux? Maybe something you can do on Mac that cannot be done in Windows/Linux with the same level of ease?

I'm not trying to do another Mac vs. Windows here. I tried to find things that can be done on Mac but not on Windows with the same level of ease, but I couldn't. So, I'm asking for some help.


问:
How can one manage thousands of IF...THEN...ELSE rules?
I am considering building an application, which, at its core, would consist of thousands of if...then...else statements. The purpose of the application is to be able to predict how cows move around in any landscape. They are affected by things like the sun, wind, food source, sudden events etc.

How can such an application be managed? I imagine that after a few hundred IF-statements, it would be as good as unpredictable how the program would react and debugging what lead to a certain reaction would mean that one would have to traverse the whole IF-statement tree every time.

I have read a bit about rules engines, but I do not see how they would get around this complexity.

答:
Please, use software/computer languages that are fit for the task. Matlab is used very often to model complex systems, where you can have indeed literally thousands of conditions. Not using if/then/else clauses, but by numerical analysis. R is an open source computer language that is filled with tools and packages to do the same. But this means you also have to restate your model in more mathematical terms, so you can include both the main influences and the interactions between influences in models.

If you didn't already, please follow a course about modelling and simulation. The last thing you should do, is considering writing a model like that in terms of if - then - else. We have monte carlo markov chains, support vector machines, neural networks, latent variable analysis, ... Please don't throw yourself 100 years back by ignoring the wealth on modelling tools you have available.


答:
It's suddenly dawned on me:

You need to use a Decision Learning Tree (ID3 Algorithm).

Its highly likely that's someone has implemented it in your language. If not you could port an existing library

Title: How can one manage thousands of IF...THEN...ELSE rules?

Body:
I am considering building an application, which, at its core, would consist of thousands of if...then...else statements. The purpose of the application is to be able to predict how cows move around in any landscape. They are affected by things like the sun, wind, food source, sudden events etc.

How can such an application be managed? I imagine that after a few hundred IF-statements, it would be as good as unpredictable how the program would react and debugging what lead to a certain reaction would mean that one would have to traverse the whole IF-statement tree every time.

I have read a bit about rules engines, but I do not see how they would get around this complexity.


问:
When are Getters and Setters Justified?
Getters and setters are often criticized as being not proper OO. On the other hand, most OO code I've seen has extensive getters and setters.

When are getters and setters justified? Do you try to avoid using them? Are they overused in general?

If your favorite language has properties (mine does) then such things are also considered getters and setters for this question. They are the same thing from an OO methodology perspective. They just have nicer syntax.

Sources for Getter/Setter Criticism (some taken from comments to give them better visibility):

http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html

http://typicalprogrammer.com/?p=23

http://c2.com/cgi/wiki?AccessorsAreEvil

http://www.darronschall.com/weblog/2005/03/no-brain-getter-and-setters.cfm

http://www.adam-bien.com/roller/abien/entry/encapsulation_violation_with_getters_and

http://www.yegor256.com/2014/09/16/getters-and-setters-are-evil.html

To state the criticism simply: Getters and Setters allow you to manipulate the internal state of objects from outside of the object. This violates encapsulation. Only the object itself should care about its internal state.

And an example

Procedural version of code:

```<code>struct Fridge
{
    int cheese;
}

void go_shopping(Fridge fridge)
{
     fridge.cheese += 5;
}
</code>```

Mutator version of code:

```<code>class Fridge
{
     int cheese;

     void set_cheese(int _cheese) { cheese = _cheese; }
     int get_cheese() { return cheese; }
 }

void go_shopping(Fridge fridge)
{
     fridge.set_cheese(fridge.get_cheese() + 5);
}
</code>```

The getters and setters made the code much more complicated without affording proper encapsulation. Because the internal state is accessible to other objects we don't gain a whole lot by adding these getters and setters.

The question has been previously discussed on Stack Overflow:

https://stackoverflow.com/questions/565095/java-are-getters-and-setters-evil

https://stackoverflow.com/questions/996179

答: You may want to change your internals to whatever while keeping the interfaces the same. If your interfaces don't vary, them you code won't break. You still can change your internals as you wish.</p>

ContentLicense: CC BY-SA 4.0

Title: When are Getters and Setters Justified?


问:
What's the better way to charge for a cloud platform, simple but more expensive, or complicated but cheaper for most?
I'm working on a cloud platform, and was curious what people prefer in terms of paying for web services.

There's the option of very simple pricing (tiers and such), which is easy to project costs on, easy to compare, but (possibly significantly) more expensive for the average user, because you're always either underpaying or overpaying.

The other option is a complicated pricing structure with many different factors, a lot harder to project costs on, but you're literally paying only for what you use, so it comes out to a lower price for the average user.

Which do you prefer?

答:
I like simple and cheap. $20 a month is simple for what you get. Which is a 256MB VPS with a blank install of your choice of Linux. (This is Slicehost).

Simpler in my mind is always better, and I'm willing to pay for the simplicity. That same server from Rackspace costs $0.0015 an hour, 24 x 30 = ~$11 a month. What do I get for the extra $9 from Slicehost? No bandwidth charges. I get simple hosting for what I pay for.

ContentLicense: CC BY-SA 2.5


问:
How large non-OO code bases are managed?
I always see abstraction is a very useful feature the OO provides for managing the code-base. But how are large non-OO code bases are managed? Or do those just become a "Big Ball of Mud" eventually?

Update:

It seemed everyone is thinking 'abstraction' is just modularization or data-hiding. But IMHO, it also means the use of 'Abstract Classes' or 'Interfaces' which is a must for dependency-injection and thus testing. How non-OO code bases manage this? And also, other than abstraction, the encapsulation also helps a lot to manage large code bases as it define and restrict the relation between data and functions.

With C, it is very much possible to write pseudo-OO code. I don't know much about other non-OO languages. So, is it THE way to manage large C code bases?

答:
Though dependency injection based on interfaces or abstract classes is a very nice way of doing testing, it isn't necessary.  Don't forget that almost any language has either a function pointer or an eval, which can do anything you can do with an interface or abstract class (the problem is that they can do more, including many bad things, and that they don't in themselves provide metadata).  Such a program can actually achieve dependency injection with these mechanisms.

I have found being rigorous with metadata to be very helpful.  In OO languages the relationships between bits of code are defined (to a degree) by class structure, in a way standardized enough to have things like a reflection API.  In procedural languages it can be helpful to invent those yourself.

I've also found code generation is much more helpful in a procedural language (compared to an object oriented language).  This guarantees meta-data is in synch with the code (since it is used to generate it) and gives you something a bit like aspect oriented programming's cut points - a place were you can inject code when you need it.  Sometimes it's the only way to do DRY programming in such an environment that I can figure out.


问:
Quality vs Time
I have heard of developers who work with code which is a complete mess because originally the code was quickly developed and the quality was not there in the first place.

Its always good to get maintainable, reusable code but I was wondering if it was best to sacrifice some of this due to time constraints. A common problem I come up against is over engineering something and wasting a lot of time. We all know in the real world due to time constraints its going to be very difficult to get near perfect code.

I was wondering if there was a general rule for getting good quality if there is not much development time? Do you find this a common problem in development balancing code quality and time?

答:
The problem with over-engineering is that, just like with optimizations, developers tend to over-engineer completely irrelevant pieces. And those are usually never going to be touched through 10 revisions of the product.

While if the business requirements change, the over-engineered solution needs an extra engineering anyway.

So you really need to find a balance to write extensible, stable and readable code. Striving to implement every thing you've ever read in the books is, IMHO, bad.

And this is where architectural planning phase comes in. Find core objects, find core relations, find what are the likely business changes in the near future, and design an extensible skeleton from what you have found.

Title: Quality vs Time


答:
One of our engineers at work is a fairly strong adherent to the 80/20 principle.  If you can gain 80% of the benefit for about 20% of the effort, then it's important to stop and think about whether you are gaining something that you really want by expending more time and effort.

That is, you shouldn't compromise on something important, but for more general items, you'll get most of the benefit without going to an extreme, chasing details.

My own experience also tells me that the way a software project goes, how much of a mess it is, and how much revision it needs after you meet the deadline to convert it into something more maintainable is a function of experience.

As you gain more experience as a developer (so long as you are working on improving), projects come together naturally with less effort.

Another way of saying it, a good solution today beats the perfect solution tomorrow (with the addendum that tomorrow never comes :-)

Title: Quality vs Time

Body:
I have heard of developers who work with code which is a complete mess because originally the code was quickly developed and the quality was not there in the first place.

Its always good to get maintainable, reusable code but I was wondering if it was best to sacrifice some of this due to time constraints. A common problem I come up against is over engineering something and wasting a lot of time. We all know in the real world due to time constraints its going to be very difficult to get near perfect code.

I was wondering if there was a general rule for getting good quality if there is not much development time? Do you find this a common problem in development balancing code quality and time?


问:
When developing a piece of software, when do you start thinking/designing the concurrent sections?
Following along with the principle of not optimizing too early, I'm wondering at what point in the design / development of a piece of software do you start thinking about the concurrency opportunities?

I can well imagine that one strategy would be to write a single threaded application, and through profiling identify sections that are candidates to run in parallel.  Another strategy I've seen a little of is to consider the software by groups of tasks and to make the independent tasks parallel.

Part of the reason for asking is that of course, if you wait until the end and only refactor the software to operate concurrently, you may structure things in the worst possible way and have a major task on your hand.

What experiences have helped to determine when you consider parallelization in your design?

答:
The thing about thread tasks is you want high cohesion, low coupling, and good encapsulation.  Interestingly enough, those happen to be worthy design goals for single-threaded applications as well.  I had a task today that I didn't originally plan on parallelizing, but when I did, it involved little more than renaming a function to run() and changing how it was called.

Not optimizing too soon means don't put everything in a thread "just in case," but neither should you paint yourself into an architectural corner so it will be too difficult to optimize should the need arise.


问:
Is functional decomposition really an antipattern?
While I was reading The worst anti-patterns you have came across, I clicked on the link in this post to land on the web site about anti-patterns.

And the http://sourcemaking.com/antipatterns/functional-decomposition page got me wondering.

How bad this anti-pattern is, and is it an anti-pattern at all? Because, although I am doing mostly OOP programming nowadays, I still feel a reluctance against pure OOP-everything languages like Java, and also the design practices that they bring. And I guess, I still have some traits of the functional programming while I write the code.

And this brought up a question, am I doing wrong by sticking to OOP+Functional style, or is it common in industry and is not actually that bad.

What I do know from experience, is that OOP+Functional style is not completely compatible with pure OOP developers. But at the same time, while OOP developers have problems with OOP+Functional development, the counterargument is that OOP solutions are quite often over-engineered and too hard to use, and from my experience, were not even a single bit easier, and actually introduced some blind spots for VERY serious bugs to hide.

So, even though I had discussion with my colleague about these topics, I came to conclusion that none of the ways is actually perfect. And I still have the question unanswered.

The OOP problem was also reinforced by a link from another post in the same thread. The link looks at the Java style OOP http://chaosinmotion.com/blog/?p=622

So what is the general attitude toward mixing functional programming with OOP? And what is the balance a developer should strive to achieve?

答:
First of all, functional programming is currently what all the cool kids are doing.  The Anti-Pattern was talking about procedural programming really (it would be clearer if the technique were called "procedural decomposition" but it's not), and I think you were too.

The anti-pattern talked about bad ways of writing procedural code in an object oriented language, the other page talked about bad was of writing Java - in truth there is no language so fantastic that you can do everything you want to do but can't write bad code.

In practice, I've seen a little more engineering in object oriented code than procedural -a little less under engineering and a little more over engineering.

In your case, it would depend on the specifics, and I'm not sure what you actually do in a procedural style.  Is it correct, clear, testable, easy to modify, etc?  The criteria to judge the code should be based on such practical concerns, and not on purity of one particular style.  It sounds like in your case reasonable and knowledgeable people could disagree (and do!) about those concerns, and if so there is probably no objective way to determine the truth of the matter.


答:
My Rule: QUALITY BEFORE QUANTITY OR TIME!

Why? Because I hate when people show me messy code that has no comments. If someone gives you 2 weeks to get the job done, take two weeks. There is no rush.

It is not hard to balance time and quality. Especially if you always use Best Practices, and you are just use to having good quality. Here is my rule for quality:

When writing a program, type like the guy who will be maintaining it will get a chainsaw on you if there is something he doesn't understand! :-)

Title: Quality vs Time


问:
What is the best way to exchange files via authenticated web service?
I'm not so much looking for code (although if you want to link to tutorials it would be appreciated) as I am trying to get an idea of what people in the know are doing. Our system is written in PHP.

As part of an Electronic Medical Record System, I need to be able to securely exchange documents (Word, PDF, etc.) with business partners. I also need to transmit identifying information with the documents (patient name, medical record number, etc.)

If I Google exchanging files in a web service, I am given a bunch of information about a variety of methods. But, what's not easy to see is how old the information is, how commonly the methods are used, and if there is something out there that if I just knew what I was looking for, would blow my socks off.

TLDR - If you were going to use a web service to exchange files, and your system was written in PHP, how would you go about doing it, and why?

答:
Although you can secure any service, SOAP is really the only specification which actually has a standardized, configurable, built-in security model, that being WS-Security. Services secured this way will not be as easy to work with as REST services, but the support is there for all major platforms including .NET, Java, and C++.  PHP support is also available through Apache Rampart/C.

As far as attachments go, you have two options: The first, and preferred option, is MTOM. Some Google hunting brings up a few libraries/frameworks for PHP that apparently support it, but I can't speak from direct experience. The other option, if you can't get MTOM to work, is old-school Base64 encoding. It's crude, but it does the job.

Obviously, WS-Security works over SSL if you want it to, although SSL is actually unnecessary because the specification provides for message-level encryption. Most people who use SSL for SOAP services do it simply because it's easier to configure and administer than (for example) mutual certificate authorization, which usually requires a PKI.

The disadvantage of SOAP and WS-Security is that it's very difficult to use in languages/platforms that don't have built-in support for it (e.g. JavaScript). Obviously you have to know who your clients are going to be.


答:
To me this is kinda true. There is a threshold amount of time a task needs before its called complete. If less than allocated time was spent then it tends to be too little engineered if more was spent it would be over engineered. It is very complicated mathematics to find the exact threshold. So a manager in reality can almost never know if it was over engineered or under.

About over engineering, I believe a manager can set the expectation on what one can over engineer on. I would set very high priority to covering almost every single line of code with test cases. This means for every line of code written the developer has to spend 4-10 times as much time to just write test cases. This will eventually add to the product quality. If you have truly good developers they will over engineer despite this.

Also, I dont consider a little over engineering is a waste of time

A developer who over engineers often is doing the task with a lot of interest taken.

Gives a little satisfaction to the developer, so he is likely to stay longer with the company

Over a long term developer gets to learn on aligning his over engineering with that of the business(as no one likes to write a piece of code no one wants to use).

Sturdier over engineered code is faar better than a week code that needs a visit to the bug fix department every week.

Over engineering often allows developers to express their newly learned concepts, so basically he will teach the whole team what he learnt through the code.

Allowing developers to over engineer gives you real power to ask them to quickly develop a few things. They will consider this a serious request.

It eventually comes down to what your company is doing. If its a company consuming its own code then its not such a problem but if its a company who is developing for others at $/hour rates then you might want to set your priorities with the paying company.

Edit: My idea of over engineering seems to be that developer spends more time with the code than actually needed after completing it the simplest possible way he thinks it can be done.

Title: Quality vs Time


答:
I would say that threading is a part of the architecture of the application. So it is one of the first things I need to think of.

E.g. when I do a GUI application, the GUI code is single threaded so long running tasks (e.g. XML processing) would block the GUI, and should be run in a background thread instead.

E.g. a server would either be thread-based, where each request is handled by a new thread, or the server could be event-driven and use only one thread per cpu-core, but then again, long running tasks should be run in a background thread or be divided into smaller tasks.

Title: When developing a piece of software, when do you start thinking/designing the concurrent sections?

Body:
Following along with the principle of not optimizing too early, I'm wondering at what point in the design / development of a piece of software do you start thinking about the concurrency opportunities?

I can well imagine that one strategy would be to write a single threaded application, and through profiling identify sections that are candidates to run in parallel.  Another strategy I've seen a little of is to consider the software by groups of tasks and to make the independent tasks parallel.

Part of the reason for asking is that of course, if you wait until the end and only refactor the software to operate concurrently, you may structure things in the worst possible way and have a major task on your hand.

What experiences have helped to determine when you consider parallelization in your design?


答: You must design concurrency into your application from the beginning. Normally as an optimization I would agree that it should be left until later if not inherently obvious. The problem is that concurrency may well require re-architecting your application from scratch in the worst case- some systems are virtually impossible to have concurrency tacked-on. An easy example of this is systems which share data- for example, the simulation and rendering aspects of a game.</p>


问:
What "business things" should a programmer know about their company and team?
I spend a fair amount of time reading programming blogs, and it seems to be a popular belief that having business knowledge adds value to a programmer.  I can see the reasoning for this:

Understanding the business helps programmers make wise decisions

Might encourage less "taking too long making everything perfect" and more "getting things done"

etc.

I'm currently an intern at a major company.  I've learned loads of great technical things during my time here and I've definitely developed as a programmer.  However, I feel like I don't understand my team's place in the ecosystem as well as I understand the technical stuff I'm actually doing.  To remedy this problem, I'm planning a meeting with my manager.  This seems like a great opportunity to learn about my company/team and become a more valuable contributor.

I'm trying to come up with a list of questions to ask.  So far I'm thinking of things like:

Who are all of our customers?

Could you describe our company's relationship with other companies?

I want to make the most of this time to learn about the company and my team's role in it.  So, what "business aspects" of my team are most important for me to learn about?  What kinds of things should I ask about?

Notes about my team:

Much of my team's work is for internal use in the company

Not a "customer oriented" team in that sense, though our customers are other teams in the company

Much of my team's work consists of enhancing tools (adding features rather than developing whole new products)

p.s - this question is similar to this question, but is different in the sense that I'm not asking what I need to know about business in general, but what I should learn about my specific company and team

答: Some questions I'd ask: How does your company get new business? How does your project do customer relations? What are the factors that guide things like deciding what business to try for or when to say yes or no to a customer? How are contractor and consultant decisions made?</p>


问:
Developers Terms and Conditions
I've recently been approached to do some development work for a start up.

The fellow has requested my terms and conditions.

Being new to the industry, what sort of information would/should I include in this?

Obviously pay rate and maybe information about ownership of Intellectual Property perhaps.

Is there anything I'm missing?

答: I would determine maintenance up-front: Are you expected to maintain the code once you've completed your tasks? Along with that, cost of maintenance (i.e., if you're charging a lump sum for the project and would be charging hourly for maintenance).</p>

Title: Developers Terms and Conditions


答:
Firstly can I say - kudos to you for thinking about this.

For me it's about the question 'Why do we have this deliverable?'

Say you deliver a product (or a service, or some docs or whatever).

Ask yourself these questions:

What does it contain and Why?

Who is the target Audience?

What are their concerns?

What language (think of their business areas, e.g. retail banking Accounts/Loans/Deposits etc ) do they use to express their ideas?

Why are their concerns important?

How do they (generally) make money?

Next think about your company

Which of the above does it care about?

Which areas of the company cover the customers concerns?

How do they do it - products/services/something else?

Which of the other parts of your company are involved in this process (say marketing or sales or support)

Do they make money directly? How? If not - why are they still important?

Which concerns do your team concern itself with?

Now think about the team

Which concerns are important to the audience and which are important to your team?

Are they the same? If not why not? Do you serve many masters?

Who are key people in your team?

Are these people stakeholders/owners of the respective audience/team concerns? Sometimes more than one person owns problem areas.

By now you're building a map of what and why the business is. You can keep redoing this over and over to get more meat on the bones. Think about how much easier it will be participate in technical discussions when you have this knowledge.

This should give you the some questions you can ask your manager and perhaps get them to maybe introduce you to other people in other parts of the organisation who may be happy to help.

Title: What "business things" should a programmer know about their company and team?

Body:
I spend a fair amount of time reading programming blogs, and it seems to be a popular belief that having business knowledge adds value to a programmer.  I can see the reasoning for this:

Understanding the business helps programmers make wise decisions

Might encourage less "taking too long making everything perfect" and more "getting things done"

etc.

I'm currently an intern at a major company.  I've learned loads of great technical things during my time here and I've definitely developed as a programmer.  However, I feel like I don't understand my team's place in the ecosystem as well as I understand the technical stuff I'm actually doing.  To remedy this problem, I'm planning a meeting with my manager.  This seems like a great opportunity to learn about my company/team and become a more valuable contributor.

I'm trying to come up with a list of questions to ask.  So far I'm thinking of things like:

Who are all of our customers?

Could you describe our company's relationship with other companies?

I want to make the most of this time to learn about the company and my team's role in it.  So, what "business aspects" of my team are most important for me to learn about?  What kinds of things should I ask about?

Notes about my team:

Much of my team's work is for internal use in the company

Not a "customer oriented" team in that sense, though our customers are other teams in the company

Much of my team's work consists of enhancing tools (adding features rather than developing whole new products)

p.s - this question is similar to this question, but is different in the sense that I'm not asking what I need to know about business in general, but what I should learn about my specific company and team


问:
Does it violate the license to use Windows XP Mode with Virtual Box?
I am working on a team developing a client-side application. We work in a Linux environment, but the server we work with can only be run from a Windows environment. As such, each developer is being set up with a virtual machine, running on Oracle VM Virtual Box.

Would it violate the terms of use or licensing for the developers to use the virtual hard drive from Windows XP Mode with Oracle VM Virtual Box?

答:
Always consult a lawyer.

That said:

Best case: Purchase a Windows XP Volume License and install it on as many machines as you need.

Worst case: Purchase an Individual License for EACH computer.


答:
Currently, everyone is focusing on the enterprise corporate market for the high ticket items. For some reason the pricing always seems to get complicated. Not really sure there is a market for average user at this point. Cable TV and Cell phones still are a billing mess for the average user; I have no idea what company plans are like.

With extended usage, these contracts will continue to get renegotiated. Eventually they'll get easier.

Title: What's the better way to charge for a cloud platform, simple but more expensive, or complicated but cheaper for most?

Body:
I'm working on a cloud platform, and was curious what people prefer in terms of paying for web services.

There's the option of very simple pricing (tiers and such), which is easy to project costs on, easy to compare, but (possibly significantly) more expensive for the average user, because you're always either underpaying or overpaying.

The other option is a complicated pricing structure with many different factors, a lot harder to project costs on, but you're literally paying only for what you use, so it comes out to a lower price for the average user.

Which do you prefer?


问:
Mahout's Flexibility for generating recommendations
I am currently working on a system that will generate product recommendations like those on Amazon: "People who bought this also bought this.."

This is how I plan to do it:

Process the data using Apache Mahout and generate recommendations(data is stored in MySQL), currently item based only.

Apply a clustering algorithm to make cluster of users and then apply the association rules subjective to each cluster.

My questions are:

Will Mahout provide me enough flexibility to tweak the existing algorithms according to my needs. If yes, how?

Is there a better alternative like R?

答:
Yes you can do this.  You will need to train several recommenders on each audience segment and have to build your business rules for each segment.

Usually, but not always, this will be a bad idea.

I would also recommend that you go to the Mahout mailing list with these questions.  You will find many more Mahout user there.

OwnerDisplayName: samridhi


答: Focus on how customers are obtained and ways you can create technology to help make it easier for them to buy from your company. Avoid the temptation to separate developers from customers. Get to know them. Sit in on conference calls or visit their sites if possible. Even if you just manage to simplify billing. Ask the questions to enable you to do this.</p>


答:
I have found the most valuable thing about knowledge of the business is knowing what they will ask before they ask it. There is nothing more satisfying than to have them say  "Now we need it in blue, how soon can you do that?"....and telling them you can have it done quickly.

After a while you get to see where a product or initiative or sales idea will be going and you can program accordingly.  The beauty of it is that by using good programming practices like modular code, well defined classes and overloading you can look brilliant while just doing the right thing.


答:
These are some guidelines that are vague, but this isn't an exact science:

If you say to yourself, "I hope I never have to look at that code again." Fix it to the point it is tolerable.

Beware of the desire to spend time on things you like to avoid those you don't. You'll over do it.

Find out what is important to the user. They may not mind waiting for a large form to load if they can enter data faster. Even if the overall task takes the same amount of time, it's about perception not logic.

Following best practices doesn't always mean they take longer. When you establish good habits, you gain fluency.

If you obsess to the point of getting nothing done, get help.

Title: Quality vs Time


问:
Performance vs. Laziness: Why use setters from within a class?
I notice that web related code uses setter methods to set class fields instead of setting them directly since they are in scope.  I find this to be a bit odd.  Using setters is certainly safer, but if unit tests are implemented then bugs will be found.  And it's not worth the extra stack call, imo.

Does any production code do this or is this just what you see in sample code online?

Edit:  I have to make clear that I'm only talking about the case whereby the setter consists solely of a single assignment expression and nothing more.

答: Never, ever, depend on unit tests when you can not depend on them. Safety 101: Guarantee it at compile-time instead of hoping, testing, or checking for it at run-time. If you have a setter for a variable, it's for a good reason, and you should not circumvent it without an even better reason.</p>


答:
A lot of it goes back to Bertrand Meyer's book and his Uniform Access Principle, or else with the Bean standard.

If we aren't filtering or massaging the data in our getter/setters I don't see a lot of point in writing getter/setter methods. If you have 'int getX()' and you change the implementation to double, you still will lean on the compiler to find the places to change. Likewise if you want to add an edit to an old public member.

Most people follow the rule slavishly. Why don't you try breaking it sometimes and seeing what it teaches you? Think about what situations would warrant additional wrapping, and when it is wasted effort. Keep notes.

Title: Performance vs. Laziness: Why use setters from within a class?

Body:
I notice that web related code uses setter methods to set class fields instead of setting them directly since they are in scope.  I find this to be a bit odd.  Using setters is certainly safer, but if unit tests are implemented then bugs will be found.  And it's not worth the extra stack call, imo.

Does any production code do this or is this just what you see in sample code online?

Edit:  I have to make clear that I'm only talking about the case whereby the setter consists solely of a single assignment expression and nothing more.


问:
PHP framework most similar to ASP.NET MVC3?
I've done a bit of work with CodeIgniter and a lot with straight PHP...

I had the opportunity to use asp.net mvc3 recently and was absolutely blown away with my productivity. Despite not "knowing" the framework, the combination of scaffolding + intellisense + code generation through the context menus left me feeling just as productive with asp.net as with PHP.

I've evaluated YII, CakePHP, symfony (a long time ago, pre 2.0), and Kohana... and while YII seems most promising none quite matched up to my experience with mvc3.

答:
I havent used aspmvc but ive done a lot with codeigniter. It really increases my productivity and cut the development time short. I cannot call it the most greatest framework but however for a typically shared hosting application which needs to be delivered quickly with a great many features codeigniter seems to be the best option.

Pros ive found

Excellent documentation ive ever seen in frameworks

Has a good amount of authentication libraries that works right out of the box

Lots of 3rd party plugins which also works right out of the box

Easy to extend upon the core classes and implement your own functionalities

Very easy url routing

Comes with a wide variety of Helpers

Doesnt assume too much about a programmer and hence doesnt end up resulting stuff into its own hands

Comes with caching

and many more

Cons ive found

No native support for ajax

No command line generators to build stubs

File upload class which is native isnt of much help(it can however be extended and there are lots of 3rd party plugins for that)

THis is my assesment of codeigniter.


答:
It's a lie. Rushing code makes for bad code, which impedes the progress of everyone who tries to work with it and increases the chance of bugs.

We try to keep code clean, especially that which makes you money or that which costs you money. Recent work on "churn" and "heat map" show us that a fairly small amount of our code is highly volatile, a difference more severe than the 80/20 rule would predict.

Know, clean, improve your code. Don't gold-plate it. Don't over-engineer it. Use the rules of simple design:  1) passes all tests, 2) no duplication, 3) clearly expresses intent, 4) has no superfluous parts.

Please look at code virtues: http://pragprog.com/magazines/2011-08/how-virtuous-is-your-code

Title: Quality vs Time


答: Our team has a similar setup. We have an entire team of analysts working in one time zone, the core developers of whom two in one zone and one in another zone. Stand up is via skype. We use pivotal to manage the projects and assembla to keep track of everyday activities. Company policy is push to git every day and each of us has to go through the commits.</p>

Title: Any best practices for a distributed agile team?

Body:
Our scrum teams are split geographically (not ideal I know!) due to specific knowledge only being available in certain countries.
So one team of say 7 members, has the business person in one city, 2 devs in another, 2 other devs in another and 2 qa's in another.

Any suggestions for how to manage this type of graphically dispersed team? Any best practices?

How do you do standups? via skype video? do we ensure that people travel every 6 weeks (the half time of trust apparently)? how do we do the task board? Virtually or via video?
would kanban work better in this setup?


答:
Some useful heuristics.

We came up with a few rules that help us to make decisions about how we'll tailor (or how we will NOT tailor) our environment to make it work with distributed teams.

I've been on teams with distributed members, and I also spent two years as a remote developer.  I found that pair programming through tools like webex helped a lot, but these rules were extra-helpful in making remote membership work.


问:
Classes naming: singular or plural?
It is always difficult for me to choose between singular and plural forms for classes names:

```<code>CustomerRepository vs. CustomersRepository
CustomerService vs. CustomersService
CustomerController vs. CustomersController
</code>```

And for composite names it is even more difficult:

OrderCustomerRepository vs. OrderCustomersRepository vs.
  OrdersCustomersRepository

What approach do you prefer and why?

答:
Definitely singular. You don't create an object of People, you create a collection of Person objects.
The only time I would use plurals would be for static classes, i.e. SupportServices, StringUtils, etc. However in this case, the class acts more as a namespace than anything else.

Title: Classes naming: singular or plural?


问:
why are all the functional programming tutorials so mathy?
I've been trying to learn functional programming and most tutorials I have found use math as examples for the more complicated constructs (even the simple ones in some cases). Why is this? I would imagine something easier could be used. Its making it difficult to learn.

Background Info:
I have been writing software for 12 years. I understand some of the concepts such as closures, functions as first class citizens, and generics. I may be having problems with higher-order functions at some advanced level, but I would like to believe I have a basic grasp. Monads are biting me in the butt, and at this point I haven't gotten past that (I'm sure I will eventually, because I'm persistent).

答:
They use math because Functional Programming is very good at modelling mathematical constructs and is very tied into mathematical concepts, particularly Lambda Calculus. Also since I/O is typically a fairly thorny and advanced subject in a lot of languages of the functional paradigm mathematics via the REPLs of the various languages becomes a good way of teaching the language at first.

Because Functional Programming treats Functions as first class constructs within the programming language, function generation becomes very important. Therefore higher math becomes fairly important particularly graph theory.

Imperative Languages are just as mathy but it's all arithmetical at base since they are closer to the machine which can only add anyway. Functional languages with their higher abstraction tend more toward mathematics. The general use in academia doesn't help either as they get used and thus taught by people who know a lot of math and are teaching people who are expect to learn a lot of math. So it's possible to "dumb it down" so to speak but it is unlikely given these factors.

http://learnyouahaskell.com/ - Is probably one of the gentlest introductions to Functional Programming, I double checked and there's nothing beyond basic algebra and graph theory in there.


问:
Is it acceptable to deploy web app to production directly from SVN
Question

Is there a legitimate reason NOT to use SVN for production deploys, or is this merely a case of personal preference and there is no real case against SVN?

Background

My workplace has a culture of tagging release in SVN and then deploying those releases directly to the various web servers using svn co or svn switch including directly to production.

I personally have a problem with this as I believe that without using a build and deploy script or some form or automated deploy you lose integration environment settings as they're undocumented.  However more than that I have a gut feeling that there may be a hidden danger to doing that which has been overlooked, something which has yet to rear its ugly head.

I've brought up my concerns with the operations staff who are responsible for deploying code to our various environments (staging, pre-prod, production) etc.  Their arguments were pretty much that it's worked pretty well so far, no reason to change.

Edit:

What I mean about build and deploy:

For example, if a developer requires a web.config setting added for a particular environment. Web.config is generally not kept in svn and so these files are updated manually without any form of automated build script. So if they're lost or OPS forget to add a field to the web.config for a release then you have issues.

A build script that say uses XMLPoke to automatically generate a web.config appropriate for a particular environment is ideal in that you have a versionable script which documents all changes necessary for each of your environments.

Current Build and Deploy Method

For the project in question a developer builds a release manually, other projects have the build step automated either with NANT, or MSBuild which is OK.

Database migrations for most projects are via DB scripts, or migration scripts (Migrator.NET), or CMS Packages.

CI is usually done by Team City on a per checkin basis, we have a code review process that all tickets are done in branches and then peer reviewed for validation and correctness/quality prior to checking into trunk (works well).

However actual code deploy is pretty much always via SVN, either via a checkout of a tagged release or more generally an SVN Switch.  This is something that sticks odd with me that we're using our repository as part of the deploy process.

Configuration doesn't generally change very often, the only things that will be in config files are environment specific information.  Everything else is in the db.

Don't get me wrong this works, it works well.  However I want to try and push for an automated build and deploy.  I've used this with Rails and Capistrano, and for personal projects using Cygwin, Nant and SSH.

More importantly I would need very specific valid arguments to get my colleagues to change to using an Automated build and deploy.

Or are there NO real valid arguments against using SVN specifically to deploy to production?

答:
Ensure that you have the appropriate checkin controls on SVN. For example, consider this -

Features are checked in for a release

Code is deployed into staging, QA does its job

Bugs are fixed, another round of testing (however it works in your team)

Ditto for pre-prod

Deploy to production

If somebody accidentally makes checkins after the pre-prod stage, there's a risk of breaking something. If this is controlled - as in no checkins allowed during pre-prod except for bug fixes - I don't see any risks.

Update: You have a problem waiting to happen if you don't checkin your configuration files. I can't really offer any advice for this other than "please do, and fast!"


问:
Why the decline in search traffic for popular programming languages?
Is there any solid evidence behind the reasons for decline in search volume for popular programming languages?

Could this possibly be due to improvements in finding necessary information (no need to search 10 times to find something) and quality of information?

答:
I can think of at least four factors that might be underway here:

As you say - resources are improving all the time, and less searching is required to find useful information

People search at specific sites more (such as stackoverflow) rather than a broader search through Google

People are searching for solutions which use specific frameworks/libraries which have grown (such as jquery rather than javascript, and drupal or zend rather than php)

People are adopting other languages - python and ruby, for example


问:
What is a "powerful" language?
I have often seen people fighting over that their favorite language is more "powerful" than others. When it comes to describing a programming language, I can understand what an object oriented language is or what a dynamic language is, but I still can't figure out what exactly a "powerful" language is. What are your thoughts?</p>

答:
Programming languages are tools - nothing more, nothing less.  Some tools are extremely specialized and well suited for particular purposes; others are generalized and simplified to the point of near uselessness.

I would argue that the most "powerful" language is the one which allows you to achieve your goals with a minimum investment of time, energy and other researces; that is, the language which provides the greatest ROI.  In some situations it could be C; in others, Java; in still others, Haskell.

The best thing to do would be to familiarize yourself with a wide variety of languages and what they're useful for.  Then, when the time comes to begin a new project, you can make an informed decision about which would be the most appropriate.

Title: What is a "powerful" language?


答:
I think your point about the search engine queries being more precise might be the possible explanation.

Another one would be that people perhaps use this site or their favourite forum/site/blog to ask the "big questions".

One more reason, people are using paper books or ebooks with the information.

Interesting question

Title: Why the decline in search traffic for popular programming languages?

Body:
Is there any solid evidence behind the reasons for decline in search volume for popular programming languages?

Could this possibly be due to improvements in finding necessary information (no need to search 10 times to find something) and quality of information?


问:
How can one manage thousands of IF...THEN...ELSE rules?
I am considering building an application, which, at its core, would consist of thousands of if...then...else statements. The purpose of the application is to be able to predict how cows move around in any landscape. They are affected by things like the sun, wind, food source, sudden events etc.

How can such an application be managed? I imagine that after a few hundred IF-statements, it would be as good as unpredictable how the program would react and debugging what lead to a certain reaction would mean that one would have to traverse the whole IF-statement tree every time.

I have read a bit about rules engines, but I do not see how they would get around this complexity.

答:
I would suggest you use a rules engine.  In case of Java, jBPM or the Oracle BPM can be useful.
Rules engines basically allow you to configure the application through XML.</p>


问:
Thoughts on Development using Virtual Machines
I'll be working as a development lead for a startup and I've suggested that we use VMs for development.  I'm not talking about each developer having a desktop with VMs for testing/development, I mean having a server rack where all VMs are managed and have the developers work from a microPC (ChromeOS anyone?) locally, or even remotely from their home computer.

To me, the benefits are the fact that it's extremely scalable, cheaper in the long run, easier to manage and that we utilize the hardware its maximum potential.  As for cons, I can't think of any particular showstoppers other than we'll need someone to setup/maintain said setup.

I was hoping that some of you might of had a similar setup at your place of employment and be able to weight in with your opinions.  Thanks.

答:
I don't think you want to go with a remote VM solution. The network connection will be the bottleneck and even on a fast connection, it can be enough to cause frustration. We are moving away from this technique to using local development environments.

We develop on iMacs, which is really nice, but our web applications are running on a Linux environment in Production. The problem with this is that eventually, we may run into an issue that only happens on Linux and could be difficult to troubleshoot. That's where the power of virtual machines come in. However, I don't even like the idea of using a VM 100% of the time.

I recently learned about Vagrant (http://vagrantup.com/docs/getting-started/why.html) and Chef for making working with VirtualBox super easy. Vagrant gives you the ability to easily start up a VM when you need it, and tear down a VM when you don't. So I could do all my development using my Mac. Then when I'm ready to test my code, I can start up a VM to test it out, and only keep it around as long as i need it. Vagrant also gives you the ability to easily share VMs with your co-workers so that you all can be sure you are working in the same environment.

I would recommend checking out Vagrant so that you are at least aware of the options available when it comes to developing on and working with VMs.


答:
Remember, a class is a template for an object.
So think about the object that you are referring to.

Often it is a singular entity, especially when it is an ORM entity.
Sometimes it could be a collection.

I believe the answer is specific to the context.

Title: Classes naming: singular or plural?

Body:
It is always difficult for me to choose between singular and plural forms for classes names:

```<code>CustomerRepository vs. CustomersRepository
CustomerService vs. CustomersService
CustomerController vs. CustomersController
</code>```

And for composite names it is even more difficult:

OrderCustomerRepository vs. OrderCustomersRepository vs.
  OrdersCustomersRepository

What approach do you prefer and why?


问:
What is negative code?
I was reading the Wikipedia article on Douglas McIlroy and found a quote that mentions

"The real hero of programming is the one who writes negative code."

What does that mean?

答:
It means reducing lines of code, by removing redundancies or using more concise constructs.

See for example this famous anecdote from the original Apple Lisa developer team:

When the Lisa team was pushing to finalize their software in 1982, project managers started requiring programmers to submit weekly forms reporting on the number of lines of code they had written. Bill Atkinson thought that was silly. For the week in which he had rewritten QuickDraw’s region calculation routines to be six times faster and 2000 lines shorter, he put "-2000" on the form. After a few more weeks the managers stopped asking him to fill out the form, and he gladly complied.

OwnerDisplayName: Anonymous

Title: What is negative code?

OwnerDisplayName: Thilo


答:
It's tongue-in-cheek. If it costs you $N per average coded line, then coding "negative lines" is surely a winner.

This means, as practical advice, that small code that accomplishes the job, is much better than big code that do the same thing, all other things being equal.

Title: What is negative code?

Body:
I was reading the Wikipedia article on Douglas McIlroy and found a quote that mentions

"The real hero of programming is the one who writes negative code."

What does that mean?

OwnerDisplayName: Ira Baxter


问:
Learning on the Fly
I would like to know what other developers do when a situation arises to implement a couple of features in language unknown to you.

You are familiar with Javascript, and you do not know jquery, how do you go by implementing some features in jquery assuming you have not much time.

答:
I know this is not great advice, but my take on the issue is:

Just do it.

Do it the best you can, and try to have a mindset in which you consider trying new things the rule instead of an unfortunate exception.

Don't worry too much about not knowing what is the best way of doing things, your goal at this stage is just getting things done. You can later (hopefully not much later) analyze how others would have done it and compare.

More specific techniques I find useful:

Try to look for lots, and lots of example code written by people more experienced in the technology.

Set up a rapid prototyping environment that makes it easy for you to try quick and dirty pieces of code to see what works and what doesn't. This could be a unit testing framework, a REPL interpreter, an existing sample application that you can modify.

Set up from the beginning a source control system to store every piece of code you write, specially all the experiments you are going to be writing so you can refer to them later.

Try to find the best book on the subject and buy it. Read it in the bus, during breakfast or lunch, at the movies.. everywhere.

Look for the forums, IRC channels, mailing list where the experts hang out and try to browse the archives reading random conversations just to familiarize with the kind of topics that are common with the technology.

OwnerDisplayName: funlearning

Title: Learning on the Fly


答:
There's a Bill Gates quote along the lines of measuring programmer productivity by lines of code is like measuring aircraft building progress by weight.

I'd like to add that the LOC metric has encouraged the use of overly long-winded languages and deliberate reinventing the wheel to meet quota.

Title: What is negative code?

OwnerDisplayName: Ugly American


答:
Writing the same program in less code is a goal for everyone.

If a program took 200 LOC to code, and I write it in 150, I wrote -50 LOC. So I wrote negative code.

Title: What is negative code?

OwnerDisplayName: LucaB


答:
When I was in high school -- and yes, we had computers back in the 70s, though we had to make them out of animal skins using stone knives -- one of the math teachers ran a programming contest. The rules were that the winning program would be the one that produced the correct output, and that had the smallest product of lines of code times run time. That is, if your program took, say 100 lines of code and ran for 5 seconds, your score was 500. If someone else wrote 90 lines of code and ran for 6 seconds, his score was 540. Low score wins, like golf.

It struck me as a brilliant scoring system, rewarding both conciseness and performance.

But the entry that technically met the winning criteria was disqualified. The problem was to print a list of all prime numbers less than 100. The disqualified entry went something like this (most of the students were using BASIC back then):

```<code>100 print "2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61,"
110 print "67, 71, 73, 79, 83, 87, 89, 91, 97"
</code>```

The student who wrote that entry pointed out that not only was it short and very efficient, but the algorithm should be obvious to anyone with even a minimal knowledge of programming, making the program highly maintainable.

Title: What is negative code?

Body:
When I was in high school -- and yes, we had computers back in the 70s, though we had to make them out of animal skins using stone knives -- one of the math teachers ran a programming contest. The rules were that the winning program would be the one that produced the correct output, and that had the smallest product of lines of code times run time. That is, if your program took, say 100 lines of code and ran for 5 seconds, your score was 500. If someone else wrote 90 lines of code and ran for 6 seconds, his score was 540. Low score wins, like golf.

It struck me as a brilliant scoring system, rewarding both conciseness and performance.

But the entry that technically met the winning criteria was disqualified. The problem was to print a list of all prime numbers less than 100. The disqualified entry went something like this (most of the students were using BASIC back then):

100 print "2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61,"
110 print "67, 71, 73, 79, 83, 87, 89, 91, 97"

The student who wrote that entry pointed out that not only was it short and very efficient, but the algorithm should be obvious to anyone with even a minimal knowledge of programming, making the program highly maintainable.

OwnerDisplayName: Jay


答:
It's because fundamentally, computer programming is mathematics. Functional languages were designed with this in mind and this is why much of the tutorials are focused on the mathematics.

It's only difficult to learn if you aren't used to thinking of computer programming as having a mathematical foundation.

Title: why are all the functional programming tutorials so mathy?

Body:
I've been trying to learn functional programming and most tutorials I have found use math as examples for the more complicated constructs (even the simple ones in some cases). Why is this? I would imagine something easier could be used. Its making it difficult to learn.

Background Info:
I have been writing software for 12 years. I understand some of the concepts such as closures, functions as first class citizens, and generics. I may be having problems with higher-order functions at some advanced level, but I would like to believe I have a basic grasp. Monads are biting me in the butt, and at this point I haven't gotten past that (I'm sure I will eventually, because I'm persistent).


答:
Google, Google like the wind.

There is so much code out there you are very likely to find something you can manipulate clumsily into what you need for a small project until you learn to do it right.

Title: Learning on the Fly

Body:
I would like to know what other developers do when a situation arises to implement a couple of features in language unknown to you.

You are familiar with Javascript, and you do not know jquery, how do you go by implementing some features in jquery assuming you have not much time.


答:
There are numerous reasons, and they are all kind of related:

Most functional programming languages were developed in an academic context, where CS is closely linked with Mathematics, so the people who designed them have a strong Math background (and tend to assume the same about their audience)

Functional programming is a paradigm especially suited to solve math-heavy problems

The theory behind FP, lambda calculus (basically, an abstract theory of functions), is a branch of Mathematics, and FP languages tend to use the concepts and terminology from lambda calculus

Also, FP isn't any more mathy really than other paradigms, but the key concepts (functions as real first-class citizens, higher-order functions, closures, and purity) require a certain mindset. At some point, your mind should go "click"; if you understand these 4 core ideas, the rest is likely to be just as easy as any other paradigm.


问:
What does GWT not provide that straight AJAX coding gives?
For an experience core Java programmer with no AJAX and very little Javascript experience, the GWT is attractive.  But, what will I be missing if I just use GWT?</p>

答:
GWT creates a powerful abstraction: the illusion that even though you are technically running javascript and ajax, you appear to be coding a local desktop application in plain old Java.

The abstraction frequently leaks, though - ajax calls are not in fact the same as local function calls, there is a network involved with finite bandwidth, latency, network errors, and security issues. GWT does a great job abstracting them away, but as with any abstraction, you need to know what happens underneath to use it efficiently.

You're also missing out on things that could be simple and easy with plain ajax (possibly aided by something like jquery), but are incredibly hard in GWT because they don't fit GWT's model. If you're writing something that's supposed to look and behave like a desktop application, GWT is a good choice, but many things on the web don't lend themselves to this approach.


问:
How do you learn a language's standard framework/API/functionality?
I understand how to code. I know how to get around the basics of the languages I use regularly. I know how to write slightly-above-basic regular expressions, I can talk to databases, I can accept input, print output, handle files, etc. I'm more or less assured of my basic ability to spit out the source code for moderately complex program.

My problem is that I never feel like it's enough. I feel like I only know a small portion of the standard library of my language, and that until I understand it all, at least in passing, I have no right to even try to get a job using it. I'm just out of (community/junior/whathaveyou) college, and my friends are getting jobs in the industry, but I still feel like a fake or a poser and that I'm just not good enough.

Is there a decent marker for "I know enough" that I could use to assure myself that I can code? Should I take the fact that I'm at least capable of coding up a FizzBuzz as an indicator that it's alright to apply for things? How can I learn more of these standard libraries, frameworks, and/or APIs relatively easily? I code on a regular basis, I read books, but my knowledge still feels so shallow.

HELP!

答:
Based from what you write in your question, you actually can code, and you are willing to improve your skills and knowledge.

Everybody, in each job, has to start out little, as a newbie, and then grow with experience.

How much fast your growth is depends on you, everybody grows at different speeds, the only important thing is that you don't ask too much out of yourself now.

If something you feel you don't quite understand yet, don't worry. Soon you will be able to get the picture.

You may want to start to work in the industry as soon as possible. Since you already can code, you already can start working. This is because theory is not good enough, you need practice, and real world problems to solve.

As for your library code knowledge concerns, it will come with time, as long as you keep to study it, read documentation and practice using it. Site like this are also very useful and you will learn faster if you actively ask and answer related questions.

A personal advice: if you really want to stand out from the many people who do spaghetti code, calling themselves programmers, learn best practices. It doesn't matter which language or library you are learning or coding with, learn best practices. This will save you a lot of time, bugs, glitches, headaches, and will help you feeling a better programmer.


答:
Thilo's answer is probably most accurate historically, but the "negative code" metaphor can also include performance and memory use - rewarding efforts to defer execution or allocation of something until it is actually needed.

This "procrastination pays" mentality produced such tongue-in-cheek axioms such as "Doing nothing is always faster than doing something", "The fastest code is the code that never executes", and "If you can put it off long enough, you might not ever have to do it" (referring to deferral of expensive operations until actually required)

One technique to realizing negative code is to challenge initial assumptions and definitions of the problem.  If you can redefine the problem / input domain such that "sticky issue #3" is categorically impossible, then you don't have to spend time or code dealing with sticky issue #3. You've eliminated code by optimizing the design.

Title: What is negative code?


问:
How do I handle refactoring that takes longer than one sprint?
I work with a code base that is over 500K lines of code. It is in serious need of refactoring. There have been refactoring efforts identified that will take longer than the normal two week sprint. These can't be broken up into smaller tasks as I have seen suggested in other answers on this site. The product needs to work at the end of the iteration, and partial refactoring will leave the system in an unusable state as the dependency between items is horrible. So what would be the best way to approach this hurdle? Again I mention, breaking it down into smaller pieces is is not an option, that has already been done.

Update:
People seem to need an explanation of why this can't be fit into a 2 week sprint. There is more involved in a sprint than just writing code. We have a policy of no code without tests. That policy did not always exist and a large portion of the codebase does not have them. Also some of our integration tests are still manual tests. The issue is not that the refactoring itself is so large. It is with the fact that small changes have an effect on many parts of the system, and we need to ensure that those parts still operate correctly.

We can't put off or extend a sprint because we have monthly hotfixes. So this change extending past a sprint cannot stop the other work being added to the hotfix.

Refactoring vs Redesign:
Just because our development process is not efficent enough to handle this refactoring in a two week cycle does not warrant renaming it to a redesign. I would like to believe that in the future we could accomplish the exact same task within a two week cycle as our process improves. The code in question here has not had to change in a very long time, and is quite stable. Now, as the direction of the company is becoming more adaptable to change, we want this portion of the code base to be as adaptable as the rest. Which requires refactoring it. Based on the answers here, it is becoming apparent that there is missing scaffolding necessary to make this refactoring work in the time frame of normal sprints.

Answer:

I am going to do the branch and merge approach that Corbin March suggested the first time so we can learn more about these problem areas and how to identify the missing tests. I think moving forward, we should take the approach that Buhb suggested of identifying the areas that are missing tests and implement those first, then do the refactoring. It will allow us to keep to our normal two week sprint cycle, just like many here have been saying should always be the case for refactoring.

答:
Having recently gone through the same issue with a part of our codebase (which also is a bit larger), I hope I can share a few insights with you. In my situation, the codebase had been developed by another team, so noone from the original developers was involved in this refactoring. My experience with the codebase was about 1 year, and another developer tasked with it 2 years.

Allow me two small notes regarding the other answers here:

Branching will help you establish a playground for yourself, but do never merge your changes to trunk in one big changeset. You will get into serious trouble with the rest of the team.

You need to do it incrementally, and it can be done. No excuses. Read Working Efficiently with Legacy Code cover to cover. Read it again.

Thinking you can do it one big step is a fallacy. Although it seems more work, doing it incrementally is much easier to manage.

Going seemingly "off-reservation" for two weeks or more won't go unnoticed. You need to ensure you're backed by project management, and even more importantly the team. If the team isn't committed to this refactoring (and this means, do it now, not in the distant future), you will get into trouble.

Don't do it alone, use pair programming. This doesn't strictly mean you need to sit in front of the same keyboard all the time, but can handle small and narrow tasks (e.g. write tests that capture the behavior of this class) individually.

Do a Scratch Refactoring and treat it as such. (A sort of "throw-away" prototype refactoring, the "throw-away" bit is important!) Honestly, it is unlikely you know all the implications your refactoring will have. A scratch refactoring will help you in certain regards:

You will discover pieces of the system you never knew they existed.

You will have a much better view on how modules interconnect

You will discover a new way of grouping your system into modules, likely much different from your current understanding. Discuss insights with your partner. Try to distill your new view. Write a short architecture whitepaper (or draw a diagram) that says where things are currently and where they should logically belong.

When you have done your scratch refactoring, I hope you will discover that you can't just go and change everything all over. You will feel bad, it's just a big fat mess and you can't just flip a switch and make it work. This is what happened to me, it might be different in your situation.

However, my partner and I did have a much better understanding of our system. Now we were able to identify individual, smaller (albeit still large) refactorings/redesigns. We captured our vision of the system in a diagram and shared it with the team, together with the backlog items we came up with to implement that vision. Empowered by common consensus, we decided which items we would implement over the course of the next iteration.

One last thing that helped us was using a big whiteboard. There's too many things to keep in your head. It is utterly important you keep notes. Write yourself a de-briefing note at the end of the day, capturing what you have done today and want to do tomorrow. It does help relaxing big times, and you need a relaxed time if you want to keep up with the task. Good luck!


答:
I believe you're asking the wrong question here, and if you'll permit me a little bit of unwarranted psychology, I think it's because you're plagued by a little bit of self-doubt and low self-confidence.

Stop broadly comparing yourself to others

First of all, you can't compare yourself on a broad level to other programmers. Even the rock stars that you may look up to right now likely have problems (sloppiness, Yet Another Way Of Doing Things, and attitude problems), so don't worry about whether you compare to them. Instead, your approach should be to acquire as many mentors as you can, glean all the knowledge possible, and become better by watching and mimicking experts.

Learn to learn

Also, the best approach to becoming a better programmer and learner in general is not in learning specific things, or understanding by memory. IMO, rote memorization is the lowest form of learning. It's like a program that's missing the crucial "processing" step of Input->Process->Output. Teach yourself concepts like the ones you mentioned in your question. Broad understanding of programming is where you provide the most value. Learning a new language within paradigms you're familiar with is cakewalk compared to learning how to problem solve.

And now, for some poor advice from someone only a little older than you

One of the biggest mistakes I made as a young man was that I made everyone else's decisions for them by assuming I wasn't good enough, and that my time and talent were not worth their time and money. I constantly undersold my abilities and my talent, sparse though it may have been at the time. This was a huge mistake.

What you need to understand is that even a moderately decent programmer seems like a wizard to average everyday joe. They may hate you, they may get sick of always having to ask a local nerd how to turn their computer on, but because they lack insight and understanding into what you do, no matter how trivial and simple it seems to you, it is impossible to them.

People WILL pay you for your time, your talent, and your energy. There are enough absolutely terrible programmers in our industry that are making a killing simply because they can sit in a seat and (arguably) write basic programs. Play your cards right by developing some self-confidence through achievement, practice your speaking and body language, continue mastering your craft by always looking for things you don't know, and run toward those things to seek more understanding, and finally: stop downplaying the skills you've developed.

Title: How do you learn a language's standard framework/API/functionality?

Body:
I understand how to code. I know how to get around the basics of the languages I use regularly. I know how to write slightly-above-basic regular expressions, I can talk to databases, I can accept input, print output, handle files, etc. I'm more or less assured of my basic ability to spit out the source code for moderately complex program.

My problem is that I never feel like it's enough. I feel like I only know a small portion of the standard library of my language, and that until I understand it all, at least in passing, I have no right to even try to get a job using it. I'm just out of (community/junior/whathaveyou) college, and my friends are getting jobs in the industry, but I still feel like a fake or a poser and that I'm just not good enough.

Is there a decent marker for "I know enough" that I could use to assure myself that I can code? Should I take the fact that I'm at least capable of coding up a FizzBuzz as an indicator that it's alright to apply for things? How can I learn more of these standard libraries, frameworks, and/or APIs relatively easily? I code on a regular basis, I read books, but my knowledge still feels so shallow.

HELP!


问:
Code Style for XAML
I started coding WPF applications a several months ago and now I am asking myself if there are some style guides for XAML. I do not need to get explained the benefits of Binding, Converters, Styles, Templates etc. My question is more basically.

Is there an official (or unofficial) „best practice“ about the order of attributes etc:

For instance:

```<code><ComboBox Grid.Column="0" Grid.Row="0"
          Name="CellType"
          ItemsSource="{Binding EditorTypes}"
          SelectedItem="{Binding EditorType}">
</code>```

Is there something like

always attached properties first [last]

always declare a column [row] in a Grid, even if there is only one

Are there some rules/guides I should read to make my code look more common?

答:
There is no "official" best practice rules. There is however a Google Group that wants to establish these best practices: https://groups.google.com/group/wpf-disciples/web/wpf-and-xaml-coding-guidelines?hl=en. There even are some propositions on how to organize these files for bigger projects (company scale)

Their propositions look reasonable.

Title: Code Style for XAML


答: In object oriented code, where the setters/getters of child classes can be different, you should always use them.</p>


问:
Creating an a project-site for an open source project
So I have an open source project that I would like to promote and I want to create a project-site for it where I will host the documentation, etc. (preferably something that integrates with github for handling downloads, issues, etc). The project-site should be just like a typical.

Is there anything out-of-the-box for this or do I have to code it from scratch?

Thank you.

答: Why not use GitHub, BitBucket or SourceForge ?</p>


答:
It seems ok as long as there is nothing outside the repository. Infact, I believe one should not invest time in deployment tools the first few months of the project. Cause there will be too many deployments, not enough customers to be bothered about a formal release process.

But once the project is about a year old its worth considering investing in deployment tool. Simple reasons are

Business grows so you plan to host it on more than one server

There might be bugs on a particular environment and you dont have any place to replicate the bug. There is no easy way to set it up without a tar-untar-forget_about_home_for_a_week process.

Some one is likely to break the build. Who broke the build

If you want to convince them, ask them to setup another server for internal testing or QA.

Title: Is it acceptable to deploy web app to production directly from SVN

Body:
Question

Is there a legitimate reason NOT to use SVN for production deploys, or is this merely a case of personal preference and there is no real case against SVN?

Background

My workplace has a culture of tagging release in SVN and then deploying those releases directly to the various web servers using svn co or svn switch including directly to production.

I personally have a problem with this as I believe that without using a build and deploy script or some form or automated deploy you lose integration environment settings as they're undocumented.  However more than that I have a gut feeling that there may be a hidden danger to doing that which has been overlooked, something which has yet to rear its ugly head.

I've brought up my concerns with the operations staff who are responsible for deploying code to our various environments (staging, pre-prod, production) etc.  Their arguments were pretty much that it's worked pretty well so far, no reason to change.

Edit:

What I mean about build and deploy:

For example, if a developer requires a web.config setting added for a particular environment. Web.config is generally not kept in svn and so these files are updated manually without any form of automated build script. So if they're lost or OPS forget to add a field to the web.config for a release then you have issues.

A build script that say uses XMLPoke to automatically generate a web.config appropriate for a particular environment is ideal in that you have a versionable script which documents all changes necessary for each of your environments.

Current Build and Deploy Method

For the project in question a developer builds a release manually, other projects have the build step automated either with NANT, or MSBuild which is OK.

Database migrations for most projects are via DB scripts, or migration scripts (Migrator.NET), or CMS Packages.

CI is usually done by Team City on a per checkin basis, we have a code review process that all tickets are done in branches and then peer reviewed for validation and correctness/quality prior to checking into trunk (works well).

However actual code deploy is pretty much always via SVN, either via a checkout of a tagged release or more generally an SVN Switch.  This is something that sticks odd with me that we're using our repository as part of the deploy process.

Configuration doesn't generally change very often, the only things that will be in config files are environment specific information.  Everything else is in the db.

Don't get me wrong this works, it works well.  However I want to try and push for an automated build and deploy.  I've used this with Rails and Capistrano, and for personal projects using Cygwin, Nant and SSH.

More importantly I would need very specific valid arguments to get my colleagues to change to using an Automated build and deploy.

Or are there NO real valid arguments against using SVN specifically to deploy to production?


答:
Google it.*

*Note: In order for this to work, you need to try to learn abstract concepts as a developer in order to know what to Google, as opposed to just learning how to do something in a particular way.  Learn how things work, not just that they work.

Title: Learning on the Fly


问:
Automatic programming: write code that writes code
After reading the book The Pragmatic Programmer, one of the arguments I found most interesting was "write code that writes code".

I tried searching over the net for some more explanations or articles about it, and while I found some good articles on the subject, I still haven't found any specific code implementation or good examples.

I feel it's still not a so common argument, something that lacks documentation or it's not embraced by so many people, and I would like to know more about it.

What do you think about the subject? Is it something that will really increase your productivity? What are some good resources on the subject, among books, blogs, slideshows, etc?

Some code examples would be greatly appreciated to allow me to better understand its implementation.

Here's the wiki page on the subject with various relevant programming techniques, like Meta Programming, Generative Programming and Code Generation.

答:
Even better, use code that someone else wrote that writes your code for you.

Code automation is generally good for ORMs and other database interaction code, and of course for repetitive but similar code building.

Of course, if you're building out lots of similar looking classes, perhaps you could've accomplished the same thing in a dynamic language much sooner, but I digress.

This is embraced by many people, although you'll often find the software labeled as code generators.

See companies and products like CodeSmith and MyGeneration, or take a browse at this Wikipedia article: http://en.wikipedia.org/wiki/Comparison_of_code_generation_tools


问:
Performance vs. Laziness: Why use setters from within a class?
I notice that web related code uses setter methods to set class fields instead of setting them directly since they are in scope.  I find this to be a bit odd.  Using setters is certainly safer, but if unit tests are implemented then bugs will be found.  And it's not worth the extra stack call, imo.

Does any production code do this or is this just what you see in sample code online?

Edit:  I have to make clear that I'm only talking about the case whereby the setter consists solely of a single assignment expression and nothing more.

答:
To the performance aspect, a modern Just In Time compiler will In-Line the setter call if it is truly just a trivial set.  There's no allocation of a new method stack or any of that cost to consider.  Avoiding using getters/setters isn't really a performance concern even as a micro-optimization. (yes there is a cost to perform the inline, but the question refers to webapps, where ostensibly that happens once and the server remains up indefinitely.)

So some things in favor of using the setters

1) The setter may not be just a simple set for all time.  I guess this is some personal opinion, but hoping automated tests will catch any and all bugs possibly introduced by skipping a setter that later gains side effects seems naive.

2) Set methods may be instrumented at run time by other frameworks.  Persistence systems and aspect oriented programming frameworks can both add additional functionality to set methods that isn't seen in the source of the class.  And again, just because one isn't in use now, doesn't mean it never will be.

3) A field that is accessed via a set method is clearly externally visible and changable state, as opposed to a truly private field with no accessors that is clearly internal state.  It can improve understanding if the fields that represent only internally managed state "stand out" in code for lacking set calls.

4) Fewer worries about bugs where people leave off the 'this.' and set a method scope variable instead of the instance scope variable that they hid sloppily.  (It's amazing how many people have conditioned themselves to completely ignore compiler warnings, even in IDEs that highlight them.)

In favor of not using the setter

1) All I can come up with is some people may find it easier to read.


答:
I prefer going a bit further, and, instead of writing code that writes code, writing code that generates objects, methods, functions. This can be achieved with Lisp macros or Ruby dynamic program modification capabilities for example.

The little difference is that you don't end with source files that were automatically generated. Usually these files are not human readable and cannot be modified, so why bother with them. I don't like the idea of increasing my code base with something I can't control.

One book I enjoyed reading on the subject was Metaprogramming Ruby (if you know Ruby language)

Edit after the following question in comment :

Why should it be useful it I still have to code the generating code? Should I write a code able to generate different things depending on user input, so that I can reuse it over and over?

First, metaprogramming is not a goal, but a tool. Don't use metaprogramming because "its cool" or "X said every developer should use it".

I think one good reason to use metaprogramming is to generalize some common pattern (pattern as something that repeats) that you have found in your code and that no other usual programming technics (inheritance, design patterns, etc.) can achieve.

As said by Jordan, one typical use case is database handling and ORM (Object Relation Mapping). Once again, in Ruby, you should look at ActiveRecord that is a great example of metaprogramming applied to ORM.

As final note :

Don't think "I want to apply metaprogramming, where could I apply it in my code ?".

Think "I see this pattern that's repeating all over my code, I can't find a way to refactor the code into something smaller and more reusable. Maybe metaprogramming can help me ?"

Title: Automatic programming: write code that writes code

Body:
After reading the book The Pragmatic Programmer, one of the arguments I found most interesting was "write code that writes code".

I tried searching over the net for some more explanations or articles about it, and while I found some good articles on the subject, I still haven't found any specific code implementation or good examples.

I feel it's still not a so common argument, something that lacks documentation or it's not embraced by so many people, and I would like to know more about it.

What do you think about the subject? Is it something that will really increase your productivity? What are some good resources on the subject, among books, blogs, slideshows, etc?

Some code examples would be greatly appreciated to allow me to better understand its implementation.

Here's the wiki page on the subject with various relevant programming techniques, like Meta Programming, Generative Programming and Code Generation.


问:
Career guidance books for programmers
I am currently reading the recently published Being Geek by Michael "Rands" Lopp and I can't get enough of it.

Is there any other career guidance books aimed directly or indirectly at programmers that are worth reading?

答: I've written a book which I published May this year just to answer this type of question. You can check it out at: http://siamacnikoo.com/life-as-a-software-developer.php</p>

Title: Career guidance books for programmers

OwnerDisplayName: Siamac Nikoo


问:
What is the most orthogonal programming language?
I find myself repeatedly annoyed by having to teach freshmen about special language rules (like array-to-pointer decay) that have absolutely nothing to do with programming in itself. So I wondered:

What is the programming language with the smallest number of special language rules, where everything is first class and can be composed without annoying technical restrictions? Wouldn't such a language be the perfect teaching language?

Moderator Note

We're looking for long answers that provide some explanation and context. Don't just list a language: please explain why you think the language answers the question. Answers that don't explain anything will be deleted. See Good Subjective, Bad Subjective for more information.

答:
What is the programming language with the smallest number of special language rules, where everything is first class and can be composed without annoying technical restrictions? Wouldn't such a language be the perfect teaching language?

To expand on my comment, in Jot everything is first class (because it's a lambda calculus) and can be composed. There is only one instruction. It's an absolutely awful teaching language.

In general, Turing tarpits have very few special rules and require you to understand the fundamentals of computation very well before you can do anything. The perfect teaching language allows students to experiment without pulling out all of their hair, so higher level abstractions are actually a good thing.


答:
I have set up a CI server at my work that automatically creates our installer assuming that the unit tests pass successfully. It took about a day of work and it has saved me much more than that since I set it up.

If there is any manual process in configuring your release/installer/production website then you will invariably save yourself and the company time. This is appropriate to you as from your question it looks like there are manual configuration steps in your setup process.

For a reference, see Joel himself talk about how a single click build process saves you in the short to medium term.


答:
what constitutes a valid value and the accessor's implementation changes more often than you should care to manage manually.

it's highly tedious and error prone to verify all direct accesses follow the requirements set by the setter when implementations change. at that point, you realize you are validating and copying code all over that place (well, there are a lot of programmers that just trust they will not introduce a bug), which only makes the problem worse by giving you more implementations to validate manually and  more chances for error. as the program evolves, it's easier and simpler to always use the setter and just move on with life.

in some cases, you will need direct access. this varies by language, but is common during initialization and destruction.

regarding performance: if the cost of function calls is a valid performance problem, you may be using the wrong tools, language, or approach. i do a lot of work in c++ -- the cost is trivial to nothing in optimized builds if well written. other languages are not as good in that regard.


答:
How you do this varies depending on your requirments. Assuming you're using static code generation you could write all the infrastructure yourself, or you could use an existing generator such as CodeSmith or MyGeneration. Using these you just need to write the required templates.

My last project involving this was some basic ASP.NET CRUD screens (code generation is good for this). The process went define entities as metadata in xml files. Write templates to cover the various artifacts required (entity classes, repositories, service classes, asp.net controls, asp.net pages etc.). Run the generation process and style the output.

There is some overhead in writing the templates but they can be reused for subsequent similar projects. Similarly changes to the underlying data are handled by changing the metadata and rerunning the generation making changes simpler and quicker to implement.

As for testing. Since this is a templated system you will need to spend some time initially validating the output of the process, if you template is wrong all output from that template will be similarly wrong. Once you're happy with this you can also use the code generators to create basic tests from the xml metadata which you can then extend to cover special cases. However remember you may still need to hand code tests to cater for specific things, code generation reduces your work, it doesn't eliminate it entirely.