答:
The problem is, I'm not learning anything new about computer science in my programming class.

Even in Germany, you don't get the "CS" stuff (data structures, algorithms, turing model, automatons, proofs, complexity, etc.) until grade 11. In fact, only few select schools offer CS at grade 11(-13). If you are out of luck, university (basically "grade 14+" in our system) is the first institution you will get real CS from.

Before that, what schools do is just applied practice. Internet technologies like HTML and Javascript to make your own web page. Programming with QBASIC to drive some LEDs hooked up to the LPT port. Stuff you can get done without CS theory.

That's for where to take classes. But that is usually not the place where the most proficient programmers emerge from. The B.Sc.s have theory, but the programs they write usually suck because they lack familiarity with pretty much all languages. Even people that just moved from M.Sc. to PhD have the problem, less, but noticable.

Few, if any, delve into what is essential for programming: selected paradigms, or perhaps called patterns. I am not talking about procedural VS OOP, or imperative vs declarative. Did any course ever talk about the Builder pattern? The Factory pattern? No? (I recommend http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612 )

What programmers should at best have is experience, and a lot of that. That does not mean they should not also have an understanding about CS concepts (the more the better), but in contrast to university exams, it is not so strictly necessary to understand everything.

And as I see it, the programmers being able to churn code has more practical (industrial) weight than a scientist being able to churn theory. (Conversely, a clever business that has to deal with internals of algorithms employs one of each type of person and utilizes twin programming, a.k.a. pair programming.)

Title: As a programmer, what paths should I take concerning education?

Body:
After a burst of ranting about homework, the applicability of the classes I'm taking, and my computer science teacher, I have some questions concerning education for my career path as a developer.

I taught myself everything I know about programming. I've been thinking lately about the advantages of teaching myself vs. learning from a teacher. I feel I might miss some things I would normally learn. I might learn some concepts wrong, or something. After all, computer science eduction has been around longer than I have.

The problem is, I'm not learning anything new about computer science in my programming class. I put the computer programming 2 course on my schedule (it was labeled as Computer Science when I signed up for it). It turns out that it's just learning C++ and of course OOP. In fact, the CP2 students are in the same classroom at the same time as the CP2 students, except the CP1 course is a half-year class instead of full year. I thought we'd do something like data structures (other than arrays), or something I'm less experienced in. The teacher had me change my schedule to CP1, but he "lets me loose" to work on projects with the CP2 students while he teaches the CP1 students.

I usually end up helping the CP2 students with build errors and things like that after I'm done. I certainly don't mind helping them, but I'm not learning anything new, and I likely won't, seeing that AFAIK linked lists will be the most advanced concept taught (for the CP2 students; The class ends this semester for CP1, including me). Frankly, I'm not interested in copying source code from paper to screen, which is 90% of what the CP2 students do.

I want to be learning something computer science related. I'd hate to sit around waiting for my options to catch up. I want to take classes not offered by my high school, like discrete mathematics, algorithms and data structures, or something like that.

So my question is, where can I take classes which aren't offered by my high school? Can I take college classes? (keep in mind there isn't any concurrent, AP, or distance-ed classes concerning computer science offered by my high school besides the CP1/CP2 class I'm in). Do you know any online classes I could take?

Thanks,
Danny Shields

P.S: I talk about my programming experience on my StackExchange profile if it helps.


问:
As a programmer, what paths should I take concerning education?
After a burst of ranting about homework, the applicability of the classes I'm taking, and my computer science teacher, I have some questions concerning education for my career path as a developer.

I taught myself everything I know about programming. I've been thinking lately about the advantages of teaching myself vs. learning from a teacher. I feel I might miss some things I would normally learn. I might learn some concepts wrong, or something. After all, computer science eduction has been around longer than I have.

The problem is, I'm not learning anything new about computer science in my programming class. I put the computer programming 2 course on my schedule (it was labeled as Computer Science when I signed up for it). It turns out that it's just learning C++ and of course OOP. In fact, the CP2 students are in the same classroom at the same time as the CP2 students, except the CP1 course is a half-year class instead of full year. I thought we'd do something like data structures (other than arrays), or something I'm less experienced in. The teacher had me change my schedule to CP1, but he "lets me loose" to work on projects with the CP2 students while he teaches the CP1 students.

I usually end up helping the CP2 students with build errors and things like that after I'm done. I certainly don't mind helping them, but I'm not learning anything new, and I likely won't, seeing that AFAIK linked lists will be the most advanced concept taught (for the CP2 students; The class ends this semester for CP1, including me). Frankly, I'm not interested in copying source code from paper to screen, which is 90% of what the CP2 students do.

I want to be learning something computer science related. I'd hate to sit around waiting for my options to catch up. I want to take classes not offered by my high school, like discrete mathematics, algorithms and data structures, or something like that.

So my question is, where can I take classes which aren't offered by my high school? Can I take college classes? (keep in mind there isn't any concurrent, AP, or distance-ed classes concerning computer science offered by my high school besides the CP1/CP2 class I'm in). Do you know any online classes I could take?

Thanks,
Danny Shields

P.S: I talk about my programming experience on my StackExchange profile if it helps.

答:
Reading your question I thought you were a college student. So I'm impresed that your highschool offers as much as it does. My kids were able to take one or two courses from the local community college. The Opencourseware stuff is pretty decent -although a bit spotty. I tried
to learn garduate level Chemical Kinetics this way (for work), but was afraid I might be
missing some fundamentals, so I recommended my employer hire someone with an actual degree in the subject, rather than risking that I might program things wrongly, due do missing something fundamental. So not having a knowledgeable teacher/mentor has its problems. And I don't know how you can obtain official credit for learning. But I think it can at least get you a leg up learning wise.
   here is the URL for MITs CS course notes:
http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/

Personally, I think math would be a great background. The real CS stuff contains a lot of it. I was always great at the analytic stuff, but never got graph theory, which can be important for some branches of CS. Also if you can wrangle some sort of paid programming project that would be great. In college I volunteered for a paid programming job one of the professors offered, so
I both learned, and earned at the same time.

If I had college to do over again, I'd spend five years, and take as much applied math as I could stand. As it was, AP credits let we whizz through in three, but I was both underprepared and burned out for grad school.

ContentLicense: CC BY-SA 2.5


问:
Do you have any techniques to help you get started in the morning?
I'm not a morning person.  I got into the habit of working from 10 to 7/8, sometimes 9.

Nevertheless, many of the places I've worked for have asked for something more like 8 to 6 or 9 to 6.

Honestly, I have a real tough time getting my brain going in the morning and getting into the code.  Once I do, I can concentrate for a long time and be quite productive.

It's getting into the code and starting to get going with it that I have trouble with.  Sometimes I will waste time in the morning just because I can't focus on the problem (yes, I am writing this in the morning).

I've put all my busy work in the morning, but as a developer, I don't have a lot of busy work.

It kind of becomes a self reinforcing thing; because you don't get things done in the morning, you have to stay later.  Because you have to stay later, then its harder to get started the next morning, etc.

Do other people have trouble with this?  If so, any techniques you've learned?

Thanks!

答:
There are many possible solutions: You may depends on your family, co-workers, may try some time-managing tools like Workrave. But above all, you must know that what's your benefit in starting early in the morning; what you will get and what you will lose. If you think getting start early is better, then find out what you should do.

It requires some of self-controlling, but after you can do it for a week, things will be like eating cake.

P/s: Personally, I don't like smoking, coffee... it's not very good in the long run. I recommend exerscies/ sports instead.


答:
I think it's mostly about sleeping habits. These didn't really exist so much before electronics came along. Lighting and sound affect your circadian rhythm

Don't listen to music and stare into a bright screen all night like me, it makes going to sleep hard because these act as triggers to keep you awake.

I leave my bedroom window open, the light seems to wake me up less abruptly and I feel less tired. I usually wake up before my alarm having slept less but feeling more awake.

Make your environment (light and sound) a little more natural and you'll probably sleep more normally.

Title: Do you have any techniques to help you get started in the morning?

Body:
I'm not a morning person.  I got into the habit of working from 10 to 7/8, sometimes 9.

Nevertheless, many of the places I've worked for have asked for something more like 8 to 6 or 9 to 6.

Honestly, I have a real tough time getting my brain going in the morning and getting into the code.  Once I do, I can concentrate for a long time and be quite productive.

It's getting into the code and starting to get going with it that I have trouble with.  Sometimes I will waste time in the morning just because I can't focus on the problem (yes, I am writing this in the morning).

I've put all my busy work in the morning, but as a developer, I don't have a lot of busy work.

It kind of becomes a self reinforcing thing; because you don't get things done in the morning, you have to stay later.  Because you have to stay later, then its harder to get started the next morning, etc.

Do other people have trouble with this?  If so, any techniques you've learned?

Thanks!


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

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

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

Should I write a resignation letter

How much notice should I give

Should I give a reason for leaving

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

Overview of replies

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

答:
Give two weeks notice. Put it in writing. Get all documents you need from the employer before leaving if possible. Make sure you get your stuff and they get theirs.

I don't think you need to give more than two weeks notice. I also don't think you need to make yourself available for technical questions after you have left, I've made that mistake before. Keep it courteous, positive, but don't drag it out.

Title: How do programmers quit a job?

ContentLicense: CC BY-SA 3.0


问:
What are some interesting but not too difficult projects for a beginner kernel hacker?
Having taken a course in Operating Systems I'm interested in expanding my knowledge of the Linux kernel and practice working with a big system. What are some interesting but not overly difficult projects I can try my hand at?

EDIT: a bit of background on what I did do with the kernel.

Implemented a new scheduling policy

Implemented User Threads and a corresponding mutex library (not really kernel hacking but contained kernel related theory)

答:
I've not done much work on kernels before (they scare me), but I've heard that http://kernelnewbies.org/ is a fantastic resource if you want to get involved in kernel work. As already mentioned SourceForge is a great place to look if you want to get involved in an open-source kernel-related project.

Also, a similar question has been asked on Stack Overflow before, so you may want to look here.

What are some interesting, small Linux kernel projects to help learn the source?


答: A little bit of sexual activity can freshen you. Not the full flesh tired sex but a little of mingling-wingling in the bed. </p>


问:
Who should participate in time estimation?
In an IT project:

Who should participate in time estimation? Developer, team leader, scrum master and etc?

Whose vote should be counted most?

答:
Who or whose should participate in time estimation? Developer, team leader, scrum master and etc?

I prefer all to be there in time estimation and we do the same here

Who or whose vote should be counted most?

Developer but still its all about team work again


答:
I don't know if there's a one-size-fits-all answer to this question. Where I work, there are usually two engineers from the team that will be implementing the feature/fix that provide an estimate. So two engineers each provides a "min", "max" and "expected" estimate. We would usually expect both estimates to be reasonably consistent, so if they're wildly different, then further discussion may be required (perhaps one engineer had made assumptions that the other did not, etc).

In our situation, nobody's "vote" is counted as such. We typically just average the two estimates (remember, if they're not already in the same ballpark, then we reject both and start with the discussions over again, so taking the average is not a big leap). The estimates are only estimates, after all, so they don't need to be exact.

Body:
In an IT project:

Who should participate in time estimation? Developer, team leader, scrum master and etc?

Whose vote should be counted most?


问:
What is the one bit of computer science theory I should know?
Speaking as someone with an Electronic Engineering rather than Computer Science degree, what is the one bit of computer science I should know to make me a better real world programmer?

(By real world I mean something I'm going to use and benefit from in my day to day job as a programmer - for instance I'd suggest understanding database normalisation is of more practical use than understanding a quick sort for which there are lots of libraries).

答:
Yeah, This kicked me into thinking for hours.

In the process, I had to remove some of the common answers given here already.

NO LIST

Big O(n) notation.
Hard to put it here but No, we can intuitively work out inefficiencies and compare different set of procedures without having even remotely heard of asymptotic algorithmic analysis.

Functional languages
No, A single family of language is just one approach to thinking about problems. Why only this bit should matter?

Halting Problem
Some are just too specific and people have lived life without knowing they existed.

Listen
If you are not listening then you live in world of your own. Not necessarily detrimental!

Software Development Cycle
Nah! We can still bumble our way to some incredible software or solo heroic effort.

complexity theory
I guess this could be it but without all the formalisms

That one bit of idea from Comp Science

I would say - "Abstractions Abstractions Abstractions ...".  Learn about it. See examples around it and learn how to build using it. It is every where. The whole of computer science, engineering and applications looks like layers upon layers of abstraction.

Once you know this, you start learning to look around well.

When you see some one using list insertion in python and not append, you smile because you know that python lists are built using array abstraction where insertions are costly and append cheaper.

This is but one example.


问:
Do you have your own 'misc utils' library? What part are you most proud of?
I know that many of us maintain our own little personal library with tools and utilities that we use often.

I've had mine since I was 16 years old so it has grown to quite a considerable size. Some of the stuff I've written has since been added to the framework. I wrote my own little implementation of expression trees for use with genetic algorithms long before LINQ, which I quite like and was proud of at the time - of course its pretty useless now. But recently I have been going through it and upgrading to .NET 4.0 and re-kindled an interest.

So I'm curious as to what you use your library for. Maybe we could get some cool ideas going for useful little snippets and share them amongst ourselves.

So my questions are:

Do you have a miscellaneous utility library?

Which part are you most proud of and why?

Give an example of code if you like :-)

答:
C++ indirect sort, based on the STL sort and a functor template.

The need for indirect sorting (in which the desired output was the permutation indexes that would result from sorting the data, but not the sorted data itself) appeared many times in a number of projects. I always wondered why STL did not provide an implementation for it.

Another was a C++ cyclic vector, where positive and negative indexes are modulo with the vector size (so that any integer values are valid indexes for the vector).


问:
Not Invented Here - what does it take to not succumb to it?
I will start with one, which however did not work the way I wanted.

Vendor Evaluation:
In the beginning of the project, we spent some time to do a survey of existing open-source libraries that can be used as building blocks for a larger library. Despite our efforts, there were a number of libraries which we did not come across until several months into the project. Had we found out those missed libraries earlier, we might have made our design decisions differently.

Architecture Compatibility:
It was understood from the very beginning that no single library could have satisfied all requirements, so several existing libraries are needed, along with some custom implementation to fill the gaps. These libraries would have to be wrapped into a single architecture so that the users will not need to know the internal construction of the library. Efficiency (in multiple aspects; can be summarized as "no CPU time, RAM nor Disk space can be wasted") was the main driving force in the architectural design; so the wrappers need to be equally efficient. In the beginning we did not know which open-source library would be compatible with the design (in the sense that the wrapper does not introduce any inefficiency of its own), as that would have required some pioneering work to find out.

Code quality:

One of the open-source library was about 20 years old. Another library was about 10 years old. In the prevailing thinking of open-source library, the older library is supposed to be more stable and have fewer bugs. Eventually we discovered that the opposite was true, and we ended up having to fix a number of bugs in the older library.

My original hypothesis is that "Does it take a lot of intelligence to not succumb to it? Does it take a lot of experience?" but after reviewing the project, I came to the conclusion that software reuse is like matchmaking - any notion of "missed opportunity" occurs naturally due to chance, and no amount of intentional effort will reduce missed opportunities.

What does it take to not succumb to Not Invented Here syndrome, in order to achieve the highest degree of software reuse and at the same time satisfying the software requirements perfectly?

Added (2010/12/18)

One of the reason we missed a good candidate library was that it was ruled out very early in the process. When there are more than 10 libraries in the initial list, there is some pressure to find rules that can quickly eliminate some of the candidates, because otherwise we would have spent too much time analyzing (analysis paralysis). However, this fast-track elimination caused the undesirable effect of rejecting one good library. (just like hiring?)

答:
I will typically opt for established, well tested and documented libraries provided that:

Licensing terms are agreeable and compatible with everything else I'm using

The library is actively maintained

In your case, it looks like you stumbled across some bits that simply weren't maintained any longer. That doesn't mean the code was not useful, if it provided you with a good starting point to accomplish your goals .. it just means that more effort than what was anticipated had to go into using it. Does that effort exceed what would be required to just write the library from scratch? If so, you probably made a bad call. If not, it saved you time and money.

I am fortunate enough to work only with open source UNIX like operating systems, so for me it is simply a question of what gets me to the final goal with the least amount of resistance, while not compromising on the project's design principles.

Additionally, I think every programmer has a tool box with lots of shelves in it. The libraries that you just fixed, for instance, can probably be re-used .. thus increasing their value to you in the long term.

That being said, I'm currently in the process of re-inventing a few wheels .. but only because the effort it would take to work around what I don't like in what exists exceeds the effort it would take to implement something on my own. For instance, you might be coding to a very specific architecture .. and could do VERY well without a bunch of portability kruft.

I'm well known for going a little slow initially, while taking ample time to make sure I won't regret today's decision a few months from now. If I strongly suspect that I'll regret not just biting the bullet and implementing something from scratch, I'll happily do it.


问:
What's the most absurd myth about programming issues?
To put it another way... What is the most commonly held and frustrating misunderstanding about programming, you have encountered?

Which widespread and longstanding myths/misconceptions do you find hard for programmers to dispel/correct.

Please, explain why this is a myth.

答:
The worst myth: If you are programming for a long time then you can be a Project Manager easily.

And that you should become a project manager if you have been programming for a long time.

OwnerDisplayName: Namwar Rizvi


答:
Age of code is not as important as mainteinance of code.  If nobody cares about it now, when did they?

If you pick up an uncared-for project, you end up - as you've experienced - maintaining it yourself.  Search out those with a vibrant and large community.  I have had good experience with Apache Jakarta projects and somewhat with Eclipse projects, plus several individual projects.

Title: Not Invented Here - what does it take to not succumb to it?

Body:
I will start with one, which however did not work the way I wanted.

Vendor Evaluation:
In the beginning of the project, we spent some time to do a survey of existing open-source libraries that can be used as building blocks for a larger library. Despite our efforts, there were a number of libraries which we did not come across until several months into the project. Had we found out those missed libraries earlier, we might have made our design decisions differently.

Architecture Compatibility:
It was understood from the very beginning that no single library could have satisfied all requirements, so several existing libraries are needed, along with some custom implementation to fill the gaps. These libraries would have to be wrapped into a single architecture so that the users will not need to know the internal construction of the library. Efficiency (in multiple aspects; can be summarized as "no CPU time, RAM nor Disk space can be wasted") was the main driving force in the architectural design; so the wrappers need to be equally efficient. In the beginning we did not know which open-source library would be compatible with the design (in the sense that the wrapper does not introduce any inefficiency of its own), as that would have required some pioneering work to find out.

Code quality:

One of the open-source library was about 20 years old. Another library was about 10 years old. In the prevailing thinking of open-source library, the older library is supposed to be more stable and have fewer bugs. Eventually we discovered that the opposite was true, and we ended up having to fix a number of bugs in the older library.

My original hypothesis is that "Does it take a lot of intelligence to not succumb to it? Does it take a lot of experience?" but after reviewing the project, I came to the conclusion that software reuse is like matchmaking - any notion of "missed opportunity" occurs naturally due to chance, and no amount of intentional effort will reduce missed opportunities.

What does it take to not succumb to Not Invented Here syndrome, in order to achieve the highest degree of software reuse and at the same time satisfying the software requirements perfectly?

Added (2010/12/18)

One of the reason we missed a good candidate library was that it was ruled out very early in the process. When there are more than 10 libraries in the initial list, there is some pressure to find rules that can quickly eliminate some of the candidates, because otherwise we would have spent too much time analyzing (analysis paralysis). However, this fast-track elimination caused the undesirable effect of rejecting one good library. (just like hiring?)


答:
Two things work for me to get the code flowing in the morning.

Set a few (2 or 3) clear objectives.

Set (short) deadlines for those objectives.

I write down this objectives. For example:

Fix reload crash

Setup ssl on apache

Tasks that work are those for which you have a clear idea on how to proceed and you can express them clearly. The point is not to give your brain slack to wonder how to proceed. Not all task work are suitable. But any project has lots of suitable pending tasks.

Lately I have been setting those two objectives as the last thing the day before. You will be surprised how effective a short self-imposed deadline is!


问:
Responding or Maintaining Emails - best practice
I would like to hear how you manage your emails when you get lot of emails on a day basis. Here some of the things that I follow,

Read emails and respond for 2 hours once. I will not disturb my work for intermediate emails unless until I got the email with high priority status.

Even I responded the emails, I maintain the incomplete tasks in a separate folder with follow-up tag and set reminder. I could do the proper follow up.

Usually archiving emails every month and take a backup of them in DVD. Email size quota issue can be avoided. As well as it wont take much time to configure if you have less number of emails in your server if you have to move to the another machine/laptop.

Created a rule to categorize the emails based on the To address and give more attention to the emails if it is directly addressed to me only.

Some of them above are not relevant or not needed for everyone. however, i feel that this is an important thing in management to have a smooth communication with higher/subordinate in any organization.

答:
I'm actually using Google's priority inbox.  I find I can glance over at my open gmail client and then actually look at anything which is flagged as a priority.  Like you I prefer to work in blocks without having to read email every 10 seconds.

I then use Gmail's labeling system to indicate which client/project/whatever the email is for, and the time I need to respond by (usually I respond immeidately).  I also use the 'star' to indicate that I'm expecting a response.


问:
Is this book a reliable source for beginning Java EE?
Core Servlets and Javaserver Pages: Core Technologies, Vol. 1 (2nd Edition)

Can I rely on this book to learn Servlets and JSP,or is there a better book out there I should be reading instead?

答: You might want to try the Head First series by Bert Bates and Kathy Sierra.  They're particularly geared towards being brain friendly (e.g. Easy to digest).</p>


问:
What do you use string reversal for?
In PHP it's strrev(), in Rails it's .reverse, but most languages don't have any string reverse function. Some have array reverse functions that can be used on characters. I was thinking this must be a major oversight but then it occurred to me, what would you actually use string reverse for???

The only time I can think I've seen it is in demos and lessons to turn "Hello World!" into "!dlroW olleH".

My question is; Is there a use for reversing a string or is it completely pointless?

.

Addendum

There have been way more answers that I had anticipated and not all of them were entirely academic. I would have put money that no one could come up with a legitimate example. I also didn't think I would learn anything new but Mark Canlas' regex suggestion is just brilliant and I look forward to the opportunity for it to prove itself. Thanks to all.

答:
The only real worls app I saw using the strrev was to store user passwords 'unreadable' in the database...

But I can remember there is a pattern in C to use the strrev, maybe I come up with it later.

Title: What do you use string reversal for?

OwnerDisplayName: Rene


答:
It's not so much about the people involved as the skills that need to be present:

An good understanding of the problem domain - this is particularly important when the requirements are ambiguous or high level.  As a programmer who has never worked in travel to estimate work concerning ticket classes on a plane and they'll assume that there are 3 or 4 (economy, business, first etc.) but if you've worked in travel you'll know that there are dozens.  This may mean that a Business Analyst or expert user is involved, though over time developers themselves will build up this sort of knowledge.

An understanding of the technology and the work that will be involved - usually a developer though a manager with recent experience who has the confidence of the team can often do the job.  Ideally though you get the person who will actually be doing the work as that way they're bought into the estimate.

An understanding of the estimating process - this is key.  There needs to be an understanding of how to do a decent estimate, how to ensure it's right, check for appropriate levels of contingency, check for double counting or too much padding.  Usually a PM, development manager or senior developer will bring this, though in some processes a solid estimating template can provide the necessary guidance.

Those skills can be in one person, though sometimes they'll need three or more, but the key thing is to make sure that those skills are present, not that particular people are present.

That said, generally though I'd look for more than two people as you want the additional assurance that two or more people checking each others work brings.

In terms of whose vote is counted most, it doesn't work like that.  It's a discussion and a negotiation.  If a manager thinks the developers estimate is too high he needs to explain why and challenge (not pressure) the developer to justify it and they need to reach a consensus.  In the event you can't reach that agreement I would say two things from experience:

(a) Don't go with the number you "want", it's just asking for trouble and what you want has no material impact on how quickly the work can be done.

(b) In pretty much every case I've seen where a developer has been over ruled on an estimate, the final number has come out closer to what the developer thought than whoever was over ruling them - largely because they ignored point (a) above.

(That said in agile I believe, and certainly in XP, the rule is that the developers control the estimates and that's final.  If the users want to lower the estimates they have to change the requirement for something simpler.)

Title: Who should participate in time estimation?


问:
What should be in a coding standard?
What should be in a good (read:useful) coding standard?

Things the code should have.

Things the code shouldn't have.

Should the coding standard include definitions of things the language, compiler, or code formatter enforces?

What about metrics like cyclomatic complexity, lines per file, etc?

答: No one seems to have mentioned security - in a coding standard you must have reference to secure code requirements (eg the use of input validation modules, disallowing known weak functions such as strcpy, error handling requirements etc)</p>

Title: What should be in a coding standard?


答:
This is how I warmup my brain every morning:

(!) breakfast

not coffee (dangerous for the heart), but green tea or milk

take a shower

(!) ride to the office by bike (I have about 8 km of the way I can pass in 30 mins). Even if the weather is rainy or snowy - I have full set of bike-clothes that prevents me from moisture. So it accelerates blood and the brain really warms up perfectly. Also I don't feel "tired" in the morning, when other guys in the office do.

Signed with (!) are required

I proved to myself that this does not work:

go to bed early


答:
Examples. Neatly arranged, non-trivial, close-to-real-world examples that make use of every rule. Comments (not necessarily part of the code) which part of the example follows which rule.

Templates. Not the C++ kind, but something to copy-paste and fill with live. It's much easier to get that 24-lines boilerplate comment right when you have a reference to copy from.

Title: What should be in a coding standard?

Body:
What should be in a good (read:useful) coding standard?

Things the code should have.

Things the code shouldn't have.

Should the coding standard include definitions of things the language, compiler, or code formatter enforces?

What about metrics like cyclomatic complexity, lines per file, etc?


答:
Coding standards, when written on paper, is only so much effective.  I like it how Go is publishing its coding standard.  It has the tool gofmt to format the program text to a format.  Any debate on the coding format then will simply result as a patch to the sources of gofmt.

As for what the format should have,

how to name variables, macros, constants, literals, functions, etc

how to places {,},(,),[,] when it comes to if, function body, statement blocks for any other purposes,

how wide should indentations be,

how many characters a line of text is allowed

how many levels of indentations are allowed before the code is rejected/sent for refactoring

how many lines of code is allowed per function before it is sent back for refactoring

maximum number of arguments a function can take before it is sent back for refactoring

A few lines of comments before a function begins explaining briefly what it does, if the body is to exceed one page of on screen code; leaving how the object is achieved to the code in the function's body

When I am reading others' (C language mostly) code, if variable/function names are not intuitive in the context of the project or if it exceeds five levels of indentation or functions take more than six or seven arguments or a function runs for over two or three pages on screen, it becomes very hard to read and understand the code.  When asked to do enhancements/maintenance work on it, it only adds to the difficulty.  It makes me wish gofmt like program be written for every project (or even language) and every source code file be run through that program before it gets committed into the project.

Title: What should be in a coding standard?


问:
How can I judge whether a project is particularly complex or if I'm just slow in picking it up?
I'm making little progress on a major project.  The source is massive, many layers of objects, macaroni code, double-diamond graphs of multiple inheritance, half-baked features frozen when the original writer left, and no one knows why many pieces of it were designed the way they were.

I suppose any competent programmer would have some trouble figuring it all out well enough to fix bugs, finish the half-baked stuff and add new features.  However, I suspect I'm going slower than a typical programmer.

How do I judge whether the source is unusually bad and I'm just doing as well as anyone could, versus the source is typical for a project like this and I'm just slow-witted or underskilled?

答:
Ever seen the learning curve.

Theory says that initially it does take time to step up. The trick is to pass the step up point fast. If you are getting stuck regularly  then ask for the help from your manager or at least keep him/her informed about the problems you faced. As long as you are ok for schedule no issues.


问:
What are good approaches to cleaning up old projects?
I've got some software that I wrote around 2 years ago and needs some features added to it.  I've realised that it's in an awful mess, and I have the urge to move everything around, tidy up, etc. I've read the Joel on Software article about not starting again, so whats the best way forward?</p>

答: Well, at least refactor enough so the new feature can be added safely. I.e. don't make it even worse. The rest depends on motivation, budget and time constraints - but be aware to fully cleaning up a mess can take longer than originaly creating it.</p>


答:
You have three basic options:

If the app is very small and a real mess, starting again might actuall be your best bet.

Refactor.

Live with the mess and hack in the additional features.

Typically, option (2) is your best bet.

How much refactoring you actually do will depend on the resource you put in vs the value you get out. Questions to ask will include:

What time / budget is available?

How much modification do you anticipate in the future?

Who else will see the code? (ie. will messy code damage your reputation?)

Is anyone else expected to maintain the code?

What refactoring tools are available to help you?

What is your experience of refactoring?

What experience will you gain from refactoring?

What kinds of refactoring will give you the most benefits?

What automated tests already exist? Need to be written?

How much manual testing will be required?

How will you feel if you leave the code as it is?

In my experience, it is very easy to get into proper muddle during a refactoring session. The most important lessons that I've learned are to:

Do one thing at a time.

Take small steps.

Make good use of your source control (check in frequently + include comments).

Make use of automated refactoring tools.

Know the IDE.

Title: What are good approaches to cleaning up old projects?

Body: I've got some software that I wrote around 2 years ago and needs some features added to it.  I've realised that it's in an awful mess, and I have the urge to move everything around, tidy up, etc. I've read the Joel on Software article about not starting again, so whats the best way forward?</p>


答: This time while fixing the things make sure to document it. Next time you will see the code it will be much easier to recall the things. </p>


答:
A project has business requirements and deadlines coming from the top down. Those are "given estimations" for the first iteration.

These requirements must be partitioned to the biggest tasks having 100% known cost (like "enable logging" = 2 hours = "download log4j/SLF4J and plug in").

The estimation should be done at the highest possible level which already has enough technical expertise to do so.

The corrected estimations must travel back up in the form of "business visible feature" = "this amount of time" until they reach the business owner at an appropriate level, able to drop/change requirements or relax deadlines. Then back down. Until final convergence. In practice, people tend to ignore this phase or simplify it, which in turn may create risks associated with missed deadlines and opportunities.


答:
Dissect it, once piece at a time

Your situation is very common, "getting to grips" takes time as others have already mentioned.

What I find is that if you tackle it "one piece at a time", regardless of how complex a project is you will figure it out. You just have to be logical about it.

Start of with say a button, dig through the source code, put breakpoints, see step by step what's going on. There is two things you need to fulfil:

The high level overview.

The nitty gritty details that implement the above desired functionality.

once you understand parts of it, re-factor it.

Title: How can I judge whether a project is particularly complex or if I'm just slow in picking it up?

Body:
I'm making little progress on a major project.  The source is massive, many layers of objects, macaroni code, double-diamond graphs of multiple inheritance, half-baked features frozen when the original writer left, and no one knows why many pieces of it were designed the way they were.

I suppose any competent programmer would have some trouble figuring it all out well enough to fix bugs, finish the half-baked stuff and add new features.  However, I suspect I'm going slower than a typical programmer.

How do I judge whether the source is unusually bad and I'm just doing as well as anyone could, versus the source is typical for a project like this and I'm just slow-witted or underskilled?


问:
What's a good Programming Metaphor?
I am referring to explaining to the non-programmer what programming is. I made sure to search for similar questions before creating this one, but the few ones I did find seemed to dodge the question, and I specifically would like to see some metaphors or analogies. I personally find it easier to explain something technical to someone through the use of metaphors or analogies.

The reason I'm interested in this is because many people encounter the work of a programmer on a daily basis, but if you ask the average person what a programmer is or does, they don't really know. This leads to certain situations of misunderstanding (ex. "[...] but I thought you were good with computers!")

I really would like to find the best one out there. I would like to be able to easily explain to someone what my career choice is about. Of course, at least the general idea.

I personally don't have a solid one, but I have long thought about it and I have usually gravitated towards the 'language' metaphor, where we happen to know a language that computers understand, and therefore we are able to tell computers what to do, or "teach" them, to solve our problems.

For example:

Imagine that in an alternate reality, humanoid robots with artificial intelligence exist, and some people are able to communicate with them through a common language, which is a variation of English. These people who can communicate with the robots are able to teach them how to solve certain problems or do certain tasks, like doing our chores.

Well, although robots like that don't exist yet, programmers of our time are like those people, but instead of communicating with the robots, they communicate with computers. Programmers "teach" the computers how to perform certain tasks or solve certain problems by means of software which they create by using this "common language".

Programmers and this "common language" are what give us things like email, websites, video games, word processors, smart phones (to put it simply), and many other things which we use on a daily basis.

I don't mean to put programming on the throne or anything, it's just the best metaphor I could come up with.

I'm sure someone will find some issue with this one, it's probably a bit contrived, but then again that's why I'm asking this question.

答:
Sometimes I refer to programming as to controlling mindless zombies.  Summing up my blog post about it:

Like zombies, computers we operate with are very dumb.  It's hard to instruct them to doing anything unless the instructions are detailed

The zombie is aggressive and if we miss tiny detail in instructions, leave the creature unhandled, it can crush everything around himself.  The same with computers: a lack of a detail in instructions can make your program crash and destroy your data.

You have to know magic if you want to control a zombie.  The same with programming.

The more people with brains gather in one place, the more computers they're likely to have.  It seems that brains attract computers--the same way they attract zombies.

Title: What's a good Programming Metaphor?


问:
When should I care about performance?
For the longest time in places like Java's IRC channel, SO, and other places I've been told something along the lines of "Worry about how the code looks and its readability/understandability now, and performance later if absolutely necessary". So for the longest time, I haven't really been OCD about performance for my small desktop or web apps, just removing the obviously inefficient.

Most responses are "What about scalability?". Thats a legitimate point, but if my app was only built to parse, say, files 10,000 lines long, should I make my code a mess for the small percentage of people that are going to shove in a 1,000,000 line file?

My main question is when should I trade the easy but somewhat inefficient ways of doing tasks for big giant complicated beasts that do things extremely quickly but destroy any possible ways of upgrading and make the code excessively difficult and prone to rewriting anyway by the next developer?

答:
I normally write code to be readable first and foremost. If, and only if, I find that the program runs too slow to do its job, do I profile and optimise. That said, there is nothing wrong with getting into the habit of performing common optimisations that don't affect the readability of your code. That is, if a piece of code can be written in two equally (or nearly equally) readable ways, choose the one that's usually faster.

For example, in Python, list comprehensions (or generator expressions) tend to be faster than the equivalent for loop, so I use list comprehensions where I can, if they don't affect readability (for instance, I don't nest list comprehensions if I can avoid it, and use a for loop instead because nested list comprehensions can be hard to mentally parse).

Similarly, immutable data types tend to be faster than mutable ones, so I use immutable data types where I can.

Title: When should I care about performance?


答:
Joel wrote a nice article on this:

http://www.joelonsoftware.com/articles/fog0000000007.html

As a quick summary, if it's part of your core business, write it yourself, if not buy it.


答: It depends, is it going to cost more time maintaining it because it's a mess, or to rewrite it so it's not a mess and easily maintained.  I'm personally going through this right now, I'm converting an intranet site to ASP.Net MVC3 because the old code was a pile of crap (that I wrote) because it was supposed to be disposable (yes, I should know better).  The old pile of crap is still here, and it's a headache adding features and fixing bugs.  MVC is beautiful and makes working on it actually pleasurable, so it's getting a rewrite.


问:
Is SourceSafe really safe?
Having spent all morning trying to check something in - I now realise I've lost a couple of days worth of work.

Its happened before - and is apparently common occurrence with SourceSafe.  Can SourceSafe be used successfully, without problems, and if so, how?

答: It's an abomination.  But still better than nothing.</p>

Title: Is SourceSafe really safe?


答:
We took it out of operation about a year ago.

It happened several times that what I'd checked-in on the previous evening just wasn't there the next morning. I didn't find that amusing because it looked suspiciously like I just hadn't finished my work. Since I was new to the company then it might have been dangerous to me.

We them moved on to the TFS and it's been operating smoothly ever since.

Title: Is SourceSafe really safe?

Body:
Having spent all morning trying to check something in - I now realise I've lost a couple of days worth of work.

Its happened before - and is apparently common occurrence with SourceSafe.  Can SourceSafe be used successfully, without problems, and if so, how?


答:
I used it for a long time (nearly 10 years) without ever personally experiencing any issues (including within the teams I was working in though our code tended to be fairly well divided up to avoid conflicts and the like).

But there are far too many stories of data loss to keep using it when there are decent, reliable open source alternatives out there.

Edit: From the comments the message seems to be avoid anything complex (branching, merging, conflicts) and you're probably fine.  Anything more and you're heading into risky territory.

Title: Is SourceSafe really safe?


答: My view is simple, migrate to something else ASAP. It won't take long (1-2 weeks WAG) and no matter how long the migration takes, it's easy to cost justify that to management. A little time to migrate equates to solid source control and very little chance of lost source code. Do a quick google search for "source safe horror stories" or similar if your boss is skeptic.</p>

Title: Is SourceSafe really safe?


答:
Worst. SCM. Ever.

All that is wrong in SCM is embodied in VSS. Even StarTeam is better than Source Safe. Source Safe is the Internet Explorer 1 of the version control world: entirely superceded by any other implementation.

How did I use it?

My typical workflow for getting things done was

Check out the project

Lock all the files (to avoid merging with anyone 'cos that opened the unholy gates of Hell)

Did my work

Each day checked my changes in

Checked it all back out again and fixed all the problems with integration

Checked it back in

In comparison to Subversion, the above is laughable (apart from checking you've not broken the build).

Restrictions to my team's programming practices

These are the rules the team had to work under to make it work for us. Your mileage may vary.

One person only may edit a file (Heaven help you if they go on holiday)

Do not branch it's too hard to manage

Never attempt to go back to a previous revision

What can be done?

Polarion has a good set of tools for migrating from the likes of Source Safe into Subversion (SVN) which is the current de facto standard within most enterprises for open source version control. Subversion does suffer from requiring a server to be available to allow checkins (unlike GIT or Mercurial which are designed for distributed offline teams).

Title: Is SourceSafe really safe?


问:
How to deal with Interviews where HR is missing?
The situation:

Person X, who already has a full-time job, applies to Company A. Money is good at A, but the real reason X had applied is 'cause the work at A really excites X.

Next someone from the technical dept. from A calls up X, gives some assignment and holds a round of technical interview over phone. X does very well in all of it so far.

Finally, X asks the tech guy from A "What's next?" The guy says we'd get back to you in 3-4 days time and then doesn't call up in the next 3-4 days. X is confused. He's got the mail-id of the tech guy but not sure if he should inquire -- this is no HR after all. In fact HR was never anywhere in this process. What should he do?

My Take: Don't mail. You already have a full-time job and this shows desperation.

The Problem: This isn't me and people tell me that some companies wait for candidate to get back just to double check their interest level.

Update

Mailing the engineering team proved very useful, they apologized for being busy and now I am told the next round is early January.

答:
If the guy at Company A said he'd get back in touch and doesn't then a short e-mail (if that's the only contact you've got) asking for news is OK.

Just keep it short and to the point. It doesn't show desperation, but a desire to move the process on - one way or the other.


答:
Yes, you should mail.  Politely and professionally with no pressure just asking if there is an update and if they need any more information from you.  If you hear nothing back from that I'd give it another week and phone him (just in case the mail address is wrong).  If after that you hear nothing I'd assume it's dead.

No HR involvement isn't necessarily a big deal.  Some companies don't involve HR except in the paperwork bit, and sometimes not even then.

A very small aside - companies waiting for you to chase them to show interest are idiots.  You showed interest by applying and going for an interview.  Judging a candidate on whether they chase would be a very odd measure as it could show anything from enthusiasm to desperation.  I honestly don't believe anyone is really doing this, and certainly no-one you want to work for.

Title: How to deal with Interviews where HR is missing?

Body:
The situation:

Person X, who already has a full-time job, applies to Company A. Money is good at A, but the real reason X had applied is 'cause the work at A really excites X.

Next someone from the technical dept. from A calls up X, gives some assignment and holds a round of technical interview over phone. X does very well in all of it so far.

Finally, X asks the tech guy from A "What's next?" The guy says we'd get back to you in 3-4 days time and then doesn't call up in the next 3-4 days. X is confused. He's got the mail-id of the tech guy but not sure if he should inquire -- this is no HR after all. In fact HR was never anywhere in this process. What should he do?

My Take: Don't mail. You already have a full-time job and this shows desperation.

The Problem: This isn't me and people tell me that some companies wait for candidate to get back just to double check their interest level.

Update

Mailing the engineering team proved very useful, they apologized for being busy and now I am told the next round is early January.


答:
HR is not required in a hiring process. Since most are unqualified, they're often only an obstacle.

Besides, if the manager and the technical guys didn't like you, the presence of HR would not get you any further.

My take is to wait for their reaction. I'd expect not a play "who wants whom" but a professional attitude.

The only situation I would contact them if I was under time pressure to accept an offer from a different company. Then before deciding to go with the company B I would have naturally wanted to know where the company A stands.


问:
Php: Whats my next step?
So in college I started learning Php, mostly starting with the Larry Ullman books. I got a job at a company after, where I was able to learn some stuff from the higher up guys. Since then, I've done freelance stuff and sort of learned things as I needed to.

I'm trying to figure out where to go next. I definitely want to stick with the web programming arena, and I'm enjoying concentrating on Php.

I know MySQL as well, but VERY little Javascript / Ajax.

I've also been reading a lot of OOP theory, and have a descent grasp of how it works, but it doesn't feel natural yet.

Where should I go from here? Is it worth learning Java fort a while to really get the OOP stuff down? I took introductory Java in college, but it was only 1 semester. Or should I concentrate on some of the open source stuff (Wordpress, Drupal, JQuery, etc). How about E-commerce solutions? I have no experience with that.

In terms of my goals, I don't have much plans for big, enterprise types of projects.  I would mostly be interested in working freelance on websites of small, to medium size.  But, I would like my coding to be as sound, and well structured as can be

thanks for the help!

答: If you call yourself a web programmer you can hardly get around JavaScript, jQuery is easier than raw JavaScript, but if you want to get good I suggest you start out on raw JavaScript.</p>

OwnerDisplayName: David

Title: Php: Whats my next step?


答:
You should consider looking into a PHP framework. CodeIgniter is easy to learn and use. It will help you write cleaner code. It also will save you the time of writing "plumbing" for every single project.

Regarding OOP, PHP is probably not the best place to learn it. I would recommend downloading one of the express editions of Visual Studio (either VB.NET or C#) and building some small projects on that.

Title: Php: Whats my next step?

Body:
So in college I started learning Php, mostly starting with the Larry Ullman books. I got a job at a company after, where I was able to learn some stuff from the higher up guys. Since then, I've done freelance stuff and sort of learned things as I needed to.

I'm trying to figure out where to go next. I definitely want to stick with the web programming arena, and I'm enjoying concentrating on Php.

I know MySQL as well, but VERY little Javascript / Ajax.

I've also been reading a lot of OOP theory, and have a descent grasp of how it works, but it doesn't feel natural yet.

Where should I go from here? Is it worth learning Java fort a while to really get the OOP stuff down? I took introductory Java in college, but it was only 1 semester. Or should I concentrate on some of the open source stuff (Wordpress, Drupal, JQuery, etc). How about E-commerce solutions? I have no experience with that.

In terms of my goals, I don't have much plans for big, enterprise types of projects.  I would mostly be interested in working freelance on websites of small, to medium size.  But, I would like my coding to be as sound, and well structured as can be

thanks for the help!


答:
My Take: Don't mail. You already have a full-time job and this shows desperation.

I've said it before, and I'll say it again: This is not dating. You apply for a job, you do interviews, you have invested time, so you have all right in the world to know the result. They haven't answered within the promised timeframe, so call them or mail them. Of course, don't stalk, don't call them every 30 minutes or send 200 mails per day.

This is not at all the same situation like dating someone of the opposite sex where you have to obey a ridiculous number of unwritten complex and contradictory rules that might, or might not, lead to procreation. "[Contacting] shows desperation" is a term straight out of the dating dictionary, but it has no place here.


答: You say that you read up a lot on OOP, so your next step is writing the actual code. Picking Java is as good as picking C# for this purpose - lots of resources available online. That's really all there is to it. And make sure you persevere.</p>

Title: Php: Whats my next step?


答:
I've been in the position of the hiring manager that you describe. I also had to put out fires, write code, deal with people who can't seem to get along, settle disputes on what library to use and manage a budget.

Oddly, I was also able to spend time with my family during most of those days.

Don't be shy to give a 'bump', something like this would be appropriate. Let's assume the manager's name is Gonzo:

Hi Gonzo,

We had an interview two weeks ago and
  I thought that we connected quite
  well. I'm really, really eager to
  tackle [problem here] and I've given
  it considerable thought. I realize
  that you might have someone else in
  mind, I'd like to share my newest ideas with
  you before you make a decision. Would
  it be possible to schedule a short
  phone call or meeting?

I really feel that I can be an asset
  to YoYoDyne systems, and that YoYoDyne
  is my best choice for personal and
  professional growth.

Regards,
  -- Joe Q. Hacker

You'll get one of three responses:

The position has been filled, but thank you for your enthusiasm

DOH! Sorry, I meant to call you, thanks for reminding me

We're still interviewing, but I'm interested in hearing what you have to say

If you don't ask, you'll never know. Many start up companies launch with a skeleton crew, where everyone wears several hats. Hiring managers are human, things fall through cracks .. the worst that they can say is 'no' if you follow up.

So, follow up.


答: Was this an advertised position, or was it simply that the company does exciting work so person X sent them a resume?  If there wasn't a position open, the manager could be fighting to get a headcount allocation, so was reluctant to reply until everything had shaken out.  Regardless, I'd follow up with a short note.</p>


答:
My view?

There's better ones that are easier to use, safer to use, and are completely free. Why bother using it at all?

This is one area of development where we have plenty of choice; most, or all, better than VSS.

Subversion

Mercurial

Git

More

Title: Is SourceSafe really safe?


答: Change your Source Control to SVN/Mercurial/Git and never look back!

Title: Is SourceSafe really safe?


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

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

答:
When I read about UML I tried this on all problems that I was to solve in my C++ course. Fortunatly one of the first examples I tried was to describe a linked list.

Didn't work.

That said, coupled with a good modelling process UML is useful. Just because it is for better or worse a standard.

I would love to see a description language of template meta programming. I think that would help a lot in understanding what is going on in <<<> > >-land

Title: How often do you use Formal UML?


问:
Concurrency: How do you approach the design and debug the implementation?
I've been developing concurrent systems for several years now, and I have a pretty good grasp on the subject despite my lack of formal training (i.e. no degree).  There's a few new languages that have become popular to at least talk about lately that are designed to make concurrency easier such as Erlang and Go.  It appears that their approach to concurrency echoes my own experience as to how to make systems scalable and take advantage of multiple cores/processors/machines.

However, I find that there are very few tools to help visualize what you intend to do, and verify that you are at least close to your original vision.  Debugging concurrent code can be a nightmare with languages that are not designed for concurrency (like C/C++, C#, Java, etc.).  In particular, it can be near impossible to recreate conditions that happen readily on one system in your development environment.

So, what are your approaches to designing a system to deal with concurrency and parallel processing?  Examples:

How do you figure out what can be made concurrent vs. what has to be sequential?

How do you reproduce error conditions and view what is happening as the application executes?

How do you visualize the interactions between the different concurrent parts of the application?

I have my own answers for some of these, but I'd also like to learn a bit more.

Edit

So far we have a lot of good input.  Many of the articles linked to are very good, and I've already read some of them.

My personal experience with concurrent programming leads me to believe you need a different mindset than you do with sequential programming.  The mental divide is probably as wide as the difference between object oriented programming and procedural programming.  I'd like this set of questions to focus more on the thought processes necessary (i.e. theory) to systematically approach the answers.  When providing more concrete answers, it helps to provide an example--something you went through personally.

Goal for the Bounty

Don't tell me what I should do.  I already have that under control.  Tell me what you do.  Tell me how you solve these problems.

答:
Well, for the verification process, when designing a large concurrent system - I tend to test the model using LTSA - Labelled Transition System Analyser.  It was developed by my old tutor, who is something of a veteran in the concurrency field and is Head of Computing at Imperial now.

As far as working out what can and cannot be concurrent, there are static analysers that could show that up I believe, though I tend to just draw scheduling diagrams for critical sections, the same as you would for project management.  Then identify sections that perform the same operation repetitively.  A quick-route is just to find loops, as they tend to be the areas that benefit from parallel processing.


答:
Number one feature: An absolute maximum of two pages.

This is something you want every developer to read and remember. You should not have to look up in the standard every time you need to write a new function (or worse a new line). So, keep it short and keep only the rules that really provides increased value to the final product.

Title: What should be in a coding standard?


答:
As others have mentioned, code test coverage is important.  I also like to see:

Project structure.  Are the tests part of the code, or are they in a separate project/package/directory?  Does the UI code live with the back-end stuff?  If not, how is it compartmentalized?

Development process.  Write tests before code?  Does fixing broken builds take priority over development? When are code reviews done, and what should they cover?

Source code management.  What gets checked in when?  Are design docs and test plans revision-controlled?  When do you branch and when do you tag?  Do you keep previous builds, and if so how many/for how long?

Deployment standards.  How is a build packaged?  What needs to go into release notes?  How are upgrade scripts created/controlled/run?

Forget all that crap about naming conventions, formatting and how many lines can be in a function/method/module.  One rule: use whatever the existing style is in whatever it is you're editing.  If you don't like somebody's style, pick it apart in a code review.  The only exception might be the tabs-vs-spaces thing, if only because many editors/IDEs will blindly convert one to the other, and then you wind up destroying your change history because every line was changed.

Title: What should be in a coding standard?


答:
-- My answers are MS/Visual Studio specific --

How do you figure out what can be made concurrent vs. what has to be sequential?

That's going to take domain knowledge, there's not going to be any blanket statement here to cover it.

How do you reproduce error conditions and view what is happening as the application executes?

Lots of logging, being able to turn logging on/off/up in production applications in order to catch it in production.  VS2010 Intellitrace is supposed to be able to help with this, but I haven't used it yet.

How do you visualize the interactions between the different concurrent parts of the application?

I don't have a good answer to this, would love to see one.

Title: Concurrency: How do you approach the design and debug the implementation?

Body:
I've been developing concurrent systems for several years now, and I have a pretty good grasp on the subject despite my lack of formal training (i.e. no degree).  There's a few new languages that have become popular to at least talk about lately that are designed to make concurrency easier such as Erlang and Go.  It appears that their approach to concurrency echoes my own experience as to how to make systems scalable and take advantage of multiple cores/processors/machines.

However, I find that there are very few tools to help visualize what you intend to do, and verify that you are at least close to your original vision.  Debugging concurrent code can be a nightmare with languages that are not designed for concurrency (like C/C++, C#, Java, etc.).  In particular, it can be near impossible to recreate conditions that happen readily on one system in your development environment.

So, what are your approaches to designing a system to deal with concurrency and parallel processing?  Examples:

How do you figure out what can be made concurrent vs. what has to be sequential?

How do you reproduce error conditions and view what is happening as the application executes?

How do you visualize the interactions between the different concurrent parts of the application?

I have my own answers for some of these, but I'd also like to learn a bit more.

Edit

So far we have a lot of good input.  Many of the articles linked to are very good, and I've already read some of them.

My personal experience with concurrent programming leads me to believe you need a different mindset than you do with sequential programming.  The mental divide is probably as wide as the difference between object oriented programming and procedural programming.  I'd like this set of questions to focus more on the thought processes necessary (i.e. theory) to systematically approach the answers.  When providing more concrete answers, it helps to provide an example--something you went through personally.

Goal for the Bounty

Don't tell me what I should do.  I already have that under control.  Tell me what you do.  Tell me how you solve these problems.


问:
Given known inputs and outputs, can we generate candidate functions that will map the inputs to outputs?
I've run into a problem where I have a set of inputs, as well as a couple known input-output pairs. I am interested in the output, but in order to get that, I need to figure out how the input is used to generate the output.

So for example, I might have the following input strings along with a few known output strings

```<code>char001 --> dasjudash2 // known input/output
char002 --> ef2y789e2y // known
char003 --> jnjxf9823d // known
char004 --> ?          // unknown output
char005 --> ?          // unknown output
</code>```

I believe that there may exist some algorithm that takes an input and produces the given output, but this algorithm is unknown. It is very possible that the pairs are randomly generated as well (eg: look at the sky, randomly pick a string of characters). I could stare at it long and hard and try to think of how they are related, but computers can probably help me out.

Basically, given known inputs and outputs, is it possible to come up with potential functions that will take known inputs and generate known outputs, and then use that to take the rest of the inputs and generate the corresponding outputs?

Given that the solution may be one of an infinite possibilities (including the possibility that no solution exists, in the case that someone did just look at the sky and pick random characters out of a hat), I would quickly dismiss it as a computationally infeasible task, but perhaps my intuition is wrong and there is research evidence to show that this problem is solvable?

答:
You should definitely get more experience in theoretical computer science. This function is trivial to define. Say you have pairs p_i = (I_i, O_i) of input/output pairs, then you can define f(I) by a simple chained if-else, in which you test whether I == I_i and then return O_i for each i. Given that your I_i are unique (i.e. your pairs show determinism of the output calculation), this function clearly reproduces all your input/output pairs correctly.

Therefore, there may never be no solution. However, it will also never be an interesting solution, as it doesn't do much of anything, let alone correctly handle other inputs. Furthermore, you can never guess a function that returns the correct result for the new input char004, simply, because the definition of correct is lacking.

Mathematically speaking, you are always free to define functions partially, i.e. f(x) = x for all x except your I_i inputs and f(I_1) = O_1, f(I_2) = O_2, .... Due to that, if you only provide a certain number of points, you can never be able  to tell anything about a general function that produces it. In mathematics we therefore often limit the function we are looking for in certain ways. For example, if you want to find a non-partially defined polynomial function, then a pair of input/outputs can get you much closer. But for that to work, we have to rely on things like continuity.

Unless you add some similar restriction for your desired functions, there will always be infinitely many uninteresting solutions.


答:
This is a classic machine learning problem. It's an example of regression. You'd want to split your set of "knowns" into two groups, one to train with, and one to test against. Set up the appropriate machine learning algorithm* and train with part of your knowns. Then input the other set of inputs to check the reliability of the answer against the known outputs. Repeat.

That's the short version -- there's lots of work and learning that goes in the middle.

One note, however, is that odds are, when you find some mapping from the inputs to the outputs, you won't be able to decipher what it means. It might be in the form of a series of rectangular arrays of floating point numbers. The actual solution that does the mapping will probably end up being a bunch of parameters to some underlying calculation that just works, without being clear why.

* insert tons of hard work here

Title: Given known inputs and outputs, can we generate candidate functions that will map the inputs to outputs?

Body:
I've run into a problem where I have a set of inputs, as well as a couple known input-output pairs. I am interested in the output, but in order to get that, I need to figure out how the input is used to generate the output.

So for example, I might have the following input strings along with a few known output strings

```<code>char001 --> dasjudash2 // known input/output
char002 --> ef2y789e2y // known
char003 --> jnjxf9823d // known
char004 --> ?          // unknown output
char005 --> ?          // unknown output
</code>```

I believe that there may exist some algorithm that takes an input and produces the given output, but this algorithm is unknown. It is very possible that the pairs are randomly generated as well (eg: look at the sky, randomly pick a string of characters). I could stare at it long and hard and try to think of how they are related, but computers can probably help me out.

Basically, given known inputs and outputs, is it possible to come up with potential functions that will take known inputs and generate known outputs, and then use that to take the rest of the inputs and generate the corresponding outputs?

Given that the solution may be one of an infinite possibilities (including the possibility that no solution exists, in the case that someone did just look at the sky and pick random characters out of a hat), I would quickly dismiss it as a computationally infeasible task, but perhaps my intuition is wrong and there is research evidence to show that this problem is solvable?


问:
What does neo4j's licensing guide mean?
There are three versions of Neo4j apparently, called Community, Advanced, and Enterprise.  Neo4j's Licensing Guide says that Community is GPL3 (which I confirmed from the LICENSE file in the tarball) and the Advanced/Enterprise seems to be dual licensed under AGPL3 and a proprietary license.  What exactly does statement of the guide mean?:

If you’re using Neo4j to build closed-source online applications that are central to your business, then you’ll want to talk to us about commercial licensing of Neo4j Advanced or Enterprise editions.

What exactly is meant by a closed source application in the context of server software?  Does writing software that merely talks to neo4j over RPC trigger the AGPL under Neo's interpretations? If so, that's vastly differently from how the 10gen treats MongoDB (AGPL).

The above wouldn't be as confusing if it weren't for the following statement:

... you’re free to use the Community edition of Neo4j Server under a GPL license – which means you can use it anywhere you would use something like MySQL. Used in this way, only changes you make to the Neo4j software itself should be open-sourced and shared with the community.

That last sentence is not required of GPL3 software modified for an organization but never distributed and only ever made available as a web application. In fact that's the exact reason AGPL3 was invented, to plug that gap.

Further, the following statement makes no sense since a public domain project is a project without copyright:

We love open source development: so you are free to use all Neo4j components for your open-source, public domain project under either the GPL (for Community edition) or the AGPL (for Advanced and Enterprise).

答:
Closed source means the same thing for server-side software as for all other kinds of software: The source code is not available to the users of the software (or only under very restrictive conditions).

If you write software that communicates over a network with other software, then your choice of license for your software is not affected by the copyright license that is used for the remote software you communicate with. (Just think about it, if the AGPL affected the software used to access an AGPL site, users of IE would be in violation of copyright. That can't be right.)

This means that it is no problem to access a service that uses AGPL with a closed-source application.

The (A)GPL license of Neo4j would start to kick in if you make modifications to Neo4j or if your application builds upon Neo4j in the sense that Neo4j is included in your application as a library.

Title: What does neo4j's licensing guide mean?


问:
Identify algorithm for my resource allocation needs
I'm trying to automate a task and I lack the right vocabulary to look up the correct algorithm. It really feels like a common problem that has likely been solved many times before.

All I'm looking for is for someone to point me in the right direction or help me with the right search terms to look up a solution / algorithm. If you happen to know of an actuall library (javascript), then even better.

Made-up scenario

Say I have 3 'buckets', Bucket A, Bucket B and Bucket C. Each of these can hold a certain number of 'Balls'.

Bucket A: Capacity 10 balls.

Bucket B: Capacity 15 balls.

Bucket C: Capacity 5 balls.

Now, I also have an inventory of balls and each one can only
be put into certain 'buckets'.
One ball can only go in Bucket 2, The next ball can go into
Bucket 1 OR Bucket 3, and so on.

Now.. I need to determine the best way to place the balls
in order to try to fill up each 'bucket' to it's capacity (or as close as possible).

Real scenario

My real reason for this is to schedule people (balls) to visit locations (buckets) for a requested number of hours (capacity of the bucket). However,
due to the following reasons all the libraries/algorithms I've found while searching for "scheduling" so far
do not work in my scenario.

I do not care about start/end times at all, only person -> location

My people (balls) all have a strict list of locations they can visit. Each one is unique.

Each person is available for an arbitrary number of whole (integer) hours that they can spend at exactly one location. Using someone that's available for 8 hours for only 7 of those hours is OK.

Each location (bucket) requests a certain number of hours that I try to fulfill to the best of my ability with any combination of people.

I have ~50 locations and ~100 people. It's not a requirement that I get a perfect solution, but 'pretty close'.

I found schedule.js which looks fantastic, but I've been unable to abuse it to fit my needs.

答:
If the number of hours each person is available is constant (e.g. it's always 1 hour), then your problem can be modeled as a Network Flow, easily solvable in polynomial time with Ford-Fulkerson's algorithm.

To build your flow network, create two layers of nodes; the first layer represents your balls, the second layer represents your buckets.  Add an edge from the source to each ball with capacity 1.  Add an edge from each ball to each compatible bucket with capacity 1.  Add an edge from each bucket to the sink with capacity corresponding to the bucket capacity.  Maximum flow represents optimal assignment.

Otherwise, if the number of hours each person can contribute varies, then the above algorithm does not work due to your constraint that each person can only visit one location.  (Network flow would solve the problem, but it might split one person's hours across multiple locations.)  In this case you have something that's related to a Knapsack or Bin Packing problem.

If the number of hours each person can contribute is an integer, you can solve it via pseudo-polynomial dynamic programming.  Otherwise, you have to either:

Implement a brute-force backtracking algorithm.  This will give you an exact solution but will not work if the number of people or locations exceeds 50 or so.

Implement a combinatorial heuristic method, as Doc Brown suggested.  Hill Climbing or Simulated Annealing will perform very well for this problem and give you optimal or nearly optimal results very quickly.


问:
What is the simplest archive file format to aim for when writing collections of files?
I've created a PHP-based document management system and hosted it on my Raspberry Pi. I created a "backup" function that zips together all the documents, but it takes too long due to the hardware constraints of the Pi, as well as the fact that compression cannot be disabled when creating zip files in PHP.

This has led me to think that perhaps I should just devise some sort of binary file format that allows multiple files to be stored in it, and dump all my uncompressed documents into it when the user asks for backups. Oddly, I'm not necessarily concerned about the lack of possible "unarchivers".

Which file format is the easiest to implement, whether a standard format, or a proposed new format?

Is there any other alternative for solving my problem that does not require implementing a custom archiver?

Note that I wish to avoid the following:

Shell commands (not portable).

Installing third party dependencies (may not work on a third party hosted system).

Rewriting my system in a different language.

答:
The only solution I would consider for this problem is TAR. If you cannot find a PHP Tar implementation then implementing TAR in PHP saves you the time of designing your own format.

Although you are not interested in unarchivers, the fact that every OS of any real consequence has TAR tools means verifying your implementation becomes significantly easier.

I am not  PHP programmer, but a quick Google search of PHP + TAR has enough hits to tells me a TAR solution is readily available in PHP, giving more reasons to us it.


问:
Is this a good practice or not?
I have a colleague who has come up with a way of 'genericizing' information from a database so that all his web application's drop-down lists can share the same object in his MVC.NET C# code and Views, which can contain different data depending on what tables it is being used against.

We work for a government agency, and we have facilities divided up into areas called "Regions", which contain further subdivided areas called VISNs, which each contain "Sites" or "Facilities". My colleague has developed a very complex security scheme whereby people can be granted access to data based on their permission level which can be assigned by Region, VISN, Site, or any mixture of the three. It's a nice scheme and very clever. However, he has stored procedures that return lists of Regions, VISNs, and Sites based on a person's User Id, and he is returning "generic" values like TextFieldID, TextField, and TextParentID. My first problem with this, is that looking at this data coming out of the database, I would not know what the data is. I feel that fields coming from a query or stored procedure should be descriptive of the data they are delivering. What does everyone else think? The deeper issue for me however is that he is taking some of the data, concatenating it in his stored procedure like this

SELECT DISTINCT
    t.VisnID,
    NULL,
    t.StationID,
    'V' + CAST(t.VisnID as varchar) + ': ' + t.Station3N + ': ' + t.StationName,
    t.Inactive
FROM Stations t
```

<p>and sending it back in a "TextField" property, instead of sending back the discrete data separately (<code>Station3N</code>, <code>StationName</code>) and concatenating it in the View, which would allow for different concatenation depending on what device what accessing the application (perhaps mobile and desktop). His justification is that he can send all his various drop down data and capture them all, regardless of content, in the same C# object named "LookupValue." </p>

```public partial class LookupValue : IEquatable<LookupValue>
{
    public LookupValue(string textFieldId, string textField, bool inactive)
    {
        TextFieldID = textFieldId;
        TextField = textField;
        Inactive = inactive;
    }

    public LookupValue(string textParentId, string textFieldId, string textField, bool inactive)
    {
        TextParentID = textParentId;
        TextFieldID = textFieldId;
        TextField = textField;
        Inactive = inactive;
    }

    public LookupValue(string textParentId, string textSelfParentId, string textFieldId, string textField, bool inactive)
    {
        TextParentID = textParentId;
        TextSelfParentID = textSelfParentId;
        TextFieldID = textFieldId;
        TextField = textField;
        Inactive = inactive;
    }

    ///
    /// Returns a custom string identifier if the Inactive property is true.
    ///
    public string GetInactiveString()
    {
        string value = "";
        if (Inactive)
        {
            value = "[I]";
        }

        return value;
    }

    ///
    /// Returns a custom text label that concatenates the TextField property with the custom string identifier of the Inactive property.
    ///
    public string GetDisplayNameWithInactiveString
    {
        get { return TextField + " " + GetInactiveString(); }
    }

    public bool Equals(LookupValue other)
    {
        //Check whether the compared object is null.
        if (Object.ReferenceEquals(other, null)) return false;

        //Check whether the compared object references the same data.
        if (Object.ReferenceEquals(this, other)) return true;

        //Check whether the products' properties are equal.
        return TextFieldID.Equals(other.TextFieldID) && TextField.Equals(other.TextField);
    }

    // If Equals() returns true for a pair of objects
    // then GetHashCode() must return the same value for these objects.
    public override int GetHashCode()
    {
        //Get hash code for the TextFieldID field if it is not null.
        int hashTextFieldId = TextFieldID == null ? 0 : TextFieldID.GetHashCode();

        //Get hash code for the Code field.
        int hashTextField = TextField.GetHashCode();

        //Calculate the hash code for the product.
        return hashTextFieldId ^ hashTextField;
    }
}
```

He believes the re-usability of this object is worth the violation of Separation of Concerns and possible future difficulties in handling more than one display variation for a drop-down. I should point out that this object is contained in his Data project namespace (our projects are separated into Data, Web, Services, etc.) instead of the Web project namespace and he also returns this object to the Web layer via his Repository queries which call the stored procedures that I described earlier,  which is gross violation of Separation of Concerns in my opinion.

I am just looking for some confirmation from other programmers that this is in fact a bad practice, and also looking for ideas I can present him on better ways to do what he is attempting. I have my own ideas, but again I'm just looking for other's ideas so I have more options to present to him.

--Edit -- I forgot to mention that we are using Entity Framework as an ORM, and his Repository classes in his DAL are dumping the data from the stored procs into this LookupValue object.

答:
I've seen lots of patterns like this, and generally they're good - superficially they seem complex and awkward but they do provide a good way to avoid repeating very similar data access blocks.

I do agree that concatenating the data returned in the DB is a bad idea and the 3 fields should be returned and concatenated in the client (assuming it still needs to). One question you need to consider first though, is - is this concatenation format a standard for your forms? If so, then it does appear to make sense to do it in the DB (ie the data should already be in that format and is just modelled as 3 fields in the DB, but you should be thinking of the data as a single field, ie if the API to the DB should return that particular format of data, how it stores it internally is irrelevant)

Title: Is this a good practice or not?


问:
how to approach pharmacy software project
I would like to complete a pharmacy software proof concept. But I have a few questions I do not know.

Physician information

In order to refill or dispense a new RX the software needs to have access to a database of current doctors, is there a downloadable database or a service I can interact with to get a list of current practicing doctors ?

Medication information

needs to access a database of medications, which I believe companies like Medispan offer for a price. How much does interacting with these kinds of companies cost.

Billing

How can I interface be it with an insurance company, medicare, medicaid, etc for billing ? I have seen these programs are able to submit orders and get a response automatically for how much was billed and how much was paid etc.

What I have done

I started to just work on  basic windows form application which would be the client and then I imagine I would have to connect it to my server in order to perform authentication etc before I billed for them from the server.

Are the client applications connecting with the APIs directly or just an intermediary web service which in turn does all the work ?

I also found one open source project http://www.anshealth.com/ but it seems like its pretty complicated to setup and there isn't much documentation. There hasn't been a post in their forums since last year.

Edit

I edited my question in order to make it more specific, I have asked specifically three questions.

答:
The only way to get access to all those systems is to earn the TRUST of their creators/owners.

And I can tell you right now that you're not going to get that trust as a one person hobbyist or startup with no background in the field.

That's highly sensitive private and financial information you're talking about, data that needs to be seriously protected. Your company will need to go through all kinds of security screening before insurance companies and others will even consider dealing with you.

Yes, the bar is high, very high. And that's for reasons, very good reasons.

If your system makes a mistake, people can die. If it gets hacked, private information about thousands of people can end up on the street, to the great embarasment of your users, and probably severe financial consequences (and in many places criminal charges) for them, and likely for you as well.

If the system gets hacked, it's also an open conduit for massive fraud if you're interfacing with financial systems.

Can a small company earn that level of trust? Sure. But it takes time, lots of time.


问:
Why is software OS specific?
I'm trying to determine the technical details of why software produced using programming languages for certain operating systems only work with them.

It is my understanding that binaries are specific to certain processors due to the processor specific machine language they understand and the differing instruction sets between different processors. But where does the operating system specificity come from?
I used to assume it was APIs provided by the OS but then I saw this diagram in a book:

Operating Systems - Internals and Design Principles 7th ed - W. Stallings (Pearson, 2012)

As you can see, APIs are not indicated as a part of the operating system.

If for example I build a simple program in C using the following code:

```<code>#include<stdio.h>

main()
{
    printf("Hello World");

}
</code>```

Is the compiler doing anything OS specific when compiling this?

答:
An important distinction at this point is separating the compiler from the linker. The compiler most likely produces more or less the same output (the differences mostly being due to various #if WINDOWSs). The linker, on the other hand, has to handle all the platform specific stuff - linking the libraries, building the executable file etc.

In other words, the compiler cares mostly about the CPU architecture, because it's producing the actual runnable code, and has to use the instructions and resources of the CPU (note that .NET's IL or JVM's bytecode would be considered instruction sets of a virtual CPU in this view). This is why you must compile code separately for x86 and ARM, for example.

The linker, on the other hand, has to take all this raw data and instructions, and put it in a format that the loader (these days, this would almost always be the OS) can understand, as well as linking any statically linked libraries (which also includes the code required for dynamic linking, memory allocation etc.).

In other words, you could be able to compile the code only once and have it run on both Linux and Windows - but you have to link it twice, producing two different executables. Now, in practice, you often have to make allowances in code too (that's where the (pre-)compiler directives come in), so even compile once-link twice isn't used much. Not to mention that people are treating compilation and linking as a single step during the build (just like you no longer care about the parts of the compiler itself).

DOS-era software was often more binary-portable, but you have to understand that it was also compiled not against DOS or Unix, but rather against a certain contract that was common to most IBM-style PCs - offloading what today are API calls to software interrupts. This didn't need static linking, since you only had to set the necessary registers, call e.g. int 13h for graphics functions, and the CPU just jumped to a memory pointer declared in the interrupt table. Of course, again, practice was  alot trickier, because to get pedal-to-the-metal performance, you had to write all of those methods yourself, but that basically amounted to getting around the OS altogether. And of course, there's something that invariably needs interaction with the OS API - program termination. But still, if you used the simplest formats available (e.g. COM on DOS, which has no header, just instructions) and didn't want to exit, well - lucky you! And of course, you could handle proper termination in the runtime as well, so you could have code for both Unix termination and DOS termination in the same executable, and detect at runtime which one to use :)

Title: Why is software OS specific?


答:
It is trivial to generate functions that map the known inputs to known outputs and the other inputs to some outputs. It is, however, impossible to generate functions that map the other inputs to the "right" outputs, simply because you don't know what the "right" outputs are.

Or, put another way: since you don't know what the outputs should be, I can give you just about any function and you have no reason to believe that it is not the correct one.

```<code>def algorithm_guesser(name, known_inputs)
  define_method(name) do |input| known_inputs[input] or raise ArgumentError end
end

algorithm_guesser(:mystery_function,
  'char001' => 'dasjudash2',
  'char002' => 'ef2y789e2y',
  'char003' => 'jnjxf9823d')

mystery_function('char001')
# => 'dasjudash2'

mystery_function('char004')
# ArgumentError
</code>```

Of course, this is not terribly useful, but it is as correct as any other function you can come up with.

Body:
It is trivial to generate functions that map the known inputs to known outputs and the other inputs to some outputs. It is, however, impossible to generate functions that map the other inputs to the "right" outputs, simply because you don't know what the "right" outputs are.

Or, put another way: since you don't know what the outputs should be, I can give you just about any function and you have no reason to believe that it is not the correct one.

def algorithm_guesser(name, known_inputs)
  define_method(name) do |input| known_inputs[input] or raise ArgumentError end
end

algorithm_guesser(:mystery_function,
  'char001' => 'dasjudash2',
  'char002' => 'ef2y789e2y',
  'char003' => 'jnjxf9823d')

mystery_function('char001')
# => 'dasjudash2'

mystery_function('char004')
# ArgumentError

Of course, this is not terribly useful, but it is as correct as any other function you can come up with.