答:
I have actually organized such TFS structures like the one you are mentioning and while it does present unique challenges to CI it has a number of different benefits.  One clear one is it supports and encourages proper componentization into seperate .NET projects and thus supports good TDD by encouraging 100% test coverage.  Right off the bat I notice a few problems that you can address.

sometimes a project in solution A just reference dlls directly from the output directory of a project hosted in solution B, sometimes the project has just been included directly even if it resides FAR away in the folder structure.

Binary references to the output of other directories isn't a good approach, and becomes a bad approach when intermingled with project references as well.  Try to do one or the other, preferablly changing your binary references to project refercences for consistency at the very least.  At this point each Solution can represent a single buildable application or application tier, (Eg. SuperApp.sln, OtherAppServices.sln, OtherAppPresentationTier.sln).

To build ALL projects I recommend creating a Master Solution as well.  The Master Solution will have project references to everything and essentially exists for the sole benefit of having a single build command that handles all projects in the application suite.  Developers should not use the Master Solution for active development or debugging.  This makes assembling the build artifacts a lot easier.

Deployment then can be done with a simple batch, powershell or Perl script.  This will essentially build the appropriate solution or the Master solution and then deploy everything to the appropriate environments.  This can be easily integrated into any CI server if done right.

•How to facilitate sharing of business logic between separate deployment artifacts

Create a project for common business logic or have better seperation of concerns for more global or universal business logic.  All deployable solutions that wish to reference this should do so by a project reference.

In organizing your code in TFS, it becomes easier to achieve this by keeping common or shared projects at a higher level in the directory tree.

Title: How to structure multiple overlapping solutions / projects in .Net?

Body:
I recently started out working for a new client with an old legacy codebase in which there are multiple .net solutions, each typically hosts some projects unique to that solution but then "borrows" / "links in" (add existing project) some other projects which technically belongs to other solutions (at least if you go by the folder structure in TFS)

I have never seen a setup this intertwined, there is no clear build order, sometimes a project in solution A just reference dlls directly from the output directory of a project hosted in solution B, sometimes the project has just been included directly even if it resides FAR away in the folder structure.

It looks like everything has been optimized for developer laziness.

When I confronted them with why they didn't have a CI server they responded that it is hard to set up with the code organized like it is. (I'm setting it up now and cursing this code-organization)

The solutions are organized around deployment artifacts (stuff that needs to be deployed together are in the same solution) which I think is a wise decision, but the contents of those solutions (the projects) are all over the place.

Is there a consensus of a best practice to use when reusing common class libraries across multiple solutions / deployment artifacts,

How to structure code in the VCS

How to facilitate sharing of business logic between separate deployment artifacts


问:
How is Delphi XE2 going to work across platforms?
So I've been reading a little about Delphi XE2 and I probably will go to the world tour thing in Chicago coming up later this month and ask this question if no one can answer it here.

What I wonder is how is my Delphi code going to be executed on a Mac? Is something else going to have to run (i.e. virtual machine) in order for the program to run?

答:
FreePascal has always been an excellent framework/language and tool. Actually the method of creating apps for iPhone by designing forms in Delphi and then compiling the same in Free Pascal (as Free Pascal was not having designer and Delphi was not having compiler earlier) for generating iPod/iPhone apps were there about more than a year ago.

But Delphi XE has made this capability in to an awesome feature, in its latest version - Delphi XE2. In Delphi XE2, we can use Firemonkey designer for creating UI for mobile apps iPhone/Androd and the same can be compiled for either iPhone or Android. It is true that Delphi XE2 is currently using FreePascal compiler but it will be having own compiler shortly (under completion). This is as per the info I got from Embarcadero Official World Tour, which I attended.

I have seen a Demo in which Delphi XE2 FireMonkey was used to design an iPhone/Android app and compile the same project for iPhone/Android!!!. It was awesome to see the demo running on iPhone etc.

BTW, I feel one of the other features of Delphi XE2, which I liked most (apart from the 64bit compile feature) is its "Live Binding" feature (this is awesome, and can be described as "linking any data to anything" - the possibilities are only limited by creativity and design of linking).

ContentLicense: CC BY-SA 3.0


问:
Difference between statechart and sequence diagram
I realise these two diagrams are very similar, with the obvious difference one models the sequence of a certain function, whilst the other models the state throughout a function being carried out.

The differences that I have identified are as follows - probably incorrect:

State chart is more of a logical view of any functionality, showing a wider array of deviating paths - however, saying that, sequence diagrams also have the ability to provide alternate (alt) paths, conditions, loops etc.

A sequence diagram is aimed at one specific function, e.g. withdrawing money from your bank account, whereas a state chart can model a whole system.

State chart example & Sequence diagram example

答:
Scott Ambler provides a very good overview of UML sequence diagrams and UML state chart/machine diagrams.

Your differences aren't actually that far from the truth, though.

A sequence diagram typically shows the execution of a particular use case for the application and the objects (as in instances of a class) that are involved in carrying out that use case. It could either show a single path, or all of the various paths, through the use case, starting with an actor (user, external system, event) initiating some kind of action.

State diagrams show the various states that are valid for an object (which could be anything from a method to a class to the system as a whole). That could be a particular class or the system as a whole. This type of diagram shows what actions are valid for a given object, depending on what state it is currently in.


问:
How do you tell if advice from a senior developer is bad?
Recently, I started my first job as a junior developer and I have a more senior developer in charge of mentoring me in this small company. However, there are several times when he would give me advice on things that I just couldn't agree with (it goes against what I learned in several good books on the topic written by the experts, questions I asked on some Q&A sites also agree with me) and given our busy schedule, we probably have no time for long debates.

So far, I have been trying to avoid the issue by listening to him, raising a counterpoint based on what I've learned as current good practices. He raises his original point again (most of the time he will say best practice, more maintainable but just didn't go further), I take a note (since he didn't raise a new point to counter my counterpoint), think about it and research at home, but don't make any changes (I'm still not convinced). But recently, he approached me yet again, saw my code and asked me why haven't I changed it to his suggestion. This is the 3rd time in 2--3 weeks.

As a junior developer, I know that I should respect him, but at the same time I just can't agree with some of his advice. Yet I'm being pressured to make changes that I think will make the project worse. Of course as an inexperienced developer, I could be wrong and his way might be better, it may be 1 of those exception cases.

My question is: what can I do to better judge if a senior developer's advice is good, bad or maybe it's good, but outdated in today context? And if it is bad/outdated, what tactics can I use to not implement it his way despite his 'pressures' while maintaining the fact that I respect him as a senior?

答: Wow that's a wonderful opportunity for you to shine and show off your skills. Early in my career, I had someone who was my supervisor who was unable to make a decision, any decision, so I used that opportunity to learn how to do the work of the next higher level up. It got me promoted. You should do the same. </p>


问:
How can I start shipping code?
I have just started learning how to program using LPTHW, and as my skill level develops I would like to start shipping code whether or not it's ready to be shipped, just to get into the habit of always shipping code, and not having the fear of shipping code.

Is there are a beginner friendly guide to shipping code?

答:
When you're actually ready to ship your code (and not just because you want to, but because the code is ready), here are some resources.

I would follow Scant Rogers advice before doing any of this.

http://pypi.python.org/pypi - Python Package Index, usually used for libraries and all of these can be installed with the easy_install software

http://docs.python.org/library/distutils.html - The distutils package, which makes this incredibly easy to do

http://www.debian.org/doc/manuals/maint-guide/ - Debian maintainers guide. distutils "setup" function will allow you to make rpm and msi files for distribution on Red Hat (and Fedora and anything else that uses rpm's) and Windows, but it notably lacks the ability to make a deb package. You'll have to do that yourself if you want to try and get it into Debian. They're very strict about what packages they let in, so if it doesn't work, don't expect anybody to sponsor you.

Title: How can I start shipping code?


问:
Why after each restart, my local .NET sites take time to load for the first time?
I'm developing sites based on .NET platform. I usually deploy these sites on my local IIS, so that I can test them and see their functionality before going live. However, each time I restart windows, it seems that sites take a long time to run for the first time.

I know about JIT and I'm also aware of this question, but it doesn't answer my question.

Does JIT happens every time you restart windows? Is it related to creation of w3wp.exe process? Why sites are so slow for the first request after each restart?

答:
The slow reaction on your first request is because IIS only starts/loads a site or application pool on it's first incoming request. And after a fixed amount of time no new incoming requests arrive at the server IIS stops the site again (app pool recycling).

ASP.NET 4.0 has a new feature called auto-start. With this feature you can set an application pool or individual site to start itself before any requests. This is triggered on boot time (when IIS starts) or when you update an ASP.NET site (which stops the site).

```<code><applicationPools>
    <add name="MyAppPool" managedRuntimeVersion="v4.0" startMode="AlwaysRunning" />
</applicationPools>

<sites>
    <site name="MySite" id="1">
        <application path="/" serviceAutoStartEnabled="true" />
    </site>
</sites>
</code>```

You need IIS 7.5 to use this.

There's also an option to perform certain extra tasks when the auto-start kicks in, ex. to preload data into cache.

Body:
The slow reaction on your first request is because IIS only starts/loads a site or application pool on it's first incoming request. And after a fixed amount of time no new incoming requests arrive at the server IIS stops the site again (app pool recycling).

ASP.NET 4.0 has a new feature called auto-start. With this feature you can set an application pool or individual site to start itself before any requests. This is triggered on boot time (when IIS starts) or when you update an ASP.NET site (which stops the site).

<applicationPools>
    <add name="MyAppPool" managedRuntimeVersion="v4.0" startMode="AlwaysRunning" />
</applicationPools>

<sites>
    <site name="MySite" id="1">
        <application path="/" serviceAutoStartEnabled="true" />
    </site>
</sites>

You need IIS 7.5 to use this.

There's also an option to perform certain extra tasks when the auto-start kicks in, ex. to preload data into cache.


问:
Why do we love using i?

Possible Duplicate:

  Why do most of us use 'i' as a loop counter variable?

Maybe this questions seems to be extreamly stupid but I wonder why we use i as variable in most cases in for loops (and not other letter). This might be a historical cause.

eg.

```<code>for(int i = 0; i < 10; i++)
</code>```

答:
I guess the i stands for index.

Long ago, when computers were not that fast and memory and storage space was expensive, it was important to keep your source code small, so that it would fit in memory and the compilation process would run faster. Those things are not true anymore with today's computers, but still the i as the first index variable name stuck.

OwnerDisplayName: Greg

Title: Why do we love using i?

OwnerDisplayName: Jesper


答:
Long ago there was a programming language called FORTRAN, indeed the first so called higher programming language. In FORTRAN variables names beginning with i,j,k,l,m,n were implicitly declared of type INTEGER. So i can stand for:

integer

index (of an array, like in a[i])

or other things. Short names are typed quickly, so i is a good choice for a loop counter.

The FORTRAN convention goes deeper. Mathematicians love to name integer variables i,j,k,l,m, or n. They often use a,b,c,d,e,f for constant values and x,y,z for variables.

Title: Why do we love using i?

Body:
Possible Duplicate:

  Why do most of us use 'i' as a loop counter variable?

Maybe this questions seems to be extreamly stupid but I wonder why we use i as variable in most cases in for loops (and not other letter). This might be a historical cause.

eg.

```<code>for(int i = 0; i < 10; i++)
</code>```


问:
How do you manage cross-class dependencies on destruction/design (more of a C++ question)
So if I understand correctly, from SOLID design principles, every class should keep a single responsibility.

So there should be one class that creates and manages a resources, a second class that does resource processing/update, the third class that connects the resource to some other resource and so on.

The question is, how do you cleanly express that in code?

Because, in C++, the class destruction order plays an important role.

So you basically come to a situation where you get

```<code>ResourceClassInstanceManager cf;//does the ResourceClass creation, accounting and destruction?
ResourceClass &rcInstance = cf.GetResourceClass();//creates the instance of resource
ResourceClassUpdater rcu(&rcInstance);//updater that works on the class instance
ResourceConnector rcc(&rcInstance, &instanceOfAnotherClass);
</code>```

The problem here is that if cf leaves the scope first, or rcInstance is deleted before rcu or rcc. The other classes will still reference the nonexisting instance of ResourceClass.

This seems somewhat messy, as the whole creation/destruction chain has to be followed very carefully, and becomes really troubling as soon as you have pointers to objects and deeper nesting levels.

Is there a clean solution for this design problem?

答:
One solution could be to use smart pointers (for example, in Qt you have the class QPointer) instead of references: as soon as an object is destroyed, a smart pointer that was pointing to it will be set to NULL. So you will never be trying to reference an object that has been already destroyed.

Of course, you also need a mechanism to avoid a NULL pointer exception, e.g. you should check the value of a smart pointer before dereferencing it.

Additional Information

In my opinion, an important principle is that it must be clear which parts of the code (e.g. which objects) manage a certain object, and which parts of the code only use (or observe) the object.

My usual strategy is the following.

All managers wrap the pointer to a given object in a boost::shared_pointer (see also DeadMG's suggestion). This is a smart pointer with reference counting: when the last smart pointer for an object is destroyed, the referenced (managed) object is also destroyed.

In addition, I have observers, which just store a pointer to the object but have no influence on its lifetime. I used QPointer for this: when the object gets destroyed, the QPointer is automatically set to NULL. In this way, the observer can detect that the object does not exist any longer.

An important point here, is that objects themselves may observe or manage other objects. Pointers between objects lead to object graphs, but normally you can decompose this graph into an object tree (aggregation) with cross references (ordinary associations) between siblings of the tree.

In this case, I use shared pointers to implement the father/child relationship (each node manages its children, and the children are automatically destroyed when the father is destroyed), and QPointer's for references between children or for the child/parent relationship.


答:
For what it's worth, I never use i. Perhaps this is a byproduct of using simpler text-editors, rather than IDEs, but I find it makes it very difficult to scan through a routine looking for places where the variable is used. To see what I mean, try searching for all the places i exists on this page, and seeing which ones refer to it as a variable, and which are incidental.

I always use more meaningful names, like

```<code>for(int Index = 0; Index < 10; Index++)
{
    // do something
}
</code>```

Title: Why do we love using i?

Body:
For what it's worth, I never use i. Perhaps this is a byproduct of using simpler text-editors, rather than IDEs, but I find it makes it very difficult to scan through a routine looking for places where the variable is used. To see what I mean, try searching for all the places i exists on this page, and seeing which ones refer to it as a variable, and which are incidental.

I always use more meaningful names, like

for(int Index = 0; Index < 10; Index++)
{
    // do something
}


问:
Is it out of line to give unsolicited constructive criticism to a programmer?
I recently started work at new office that uses a proprietary program written by a solo developer. He's occasionally around as part-time tech support, but the company has signed off on this software and he's no longer being paid to develop it.

As a user of his software there are many issues that leap out to me as a source of concern:

very simple to directly view the DB as a low-privilege user

passwords stored as plaintext

dictionary admin passwords

app uses the DB root account

DB doesn't meet 1NF (eg. appointment1, appointment2, etc.)

I feel like these are serious issues and that if I were him I'd want them pointed out to me, but I'm not a qualified programmer (I'm a social worker) and I don't know if it would be rude of me to just buttonhole him and start blabbering about salted hashes and normal forms, especially when this is no longer a paid task of his.

Is it out of line? If not, how would you broach it?

Edit - more info prompted by comments:

The application holds sensitive data.

It's for internal use, but it's running on lots of machines in several cities and many visitors come through our offices.

My concerns are for the developer's future projects as well as this specific one.

答:
If you are not in a position to change the code yourself then you should decide which issue is the most important one and approach him about it. Rather than couching it as "criticism" do it under the guise of "feedback".

When I say feedback I mean a VERY distinct process of stating the behavior and the effect of it, along the lines of "When you X, here's what happens..." and speak STRICTLY of things are directly observable. Do not attack him, his professionalism, etc. Stick to the facts.

For a great overview on providing peer feedback listen to this postcast: http://www.manager-tools.com/2006/10/the-peer-feedback-model

If you have success with the first item, move onto the next most important one.

Good luck!

ContentLicense: CC BY-SA 2.5


答:
You're in a not-so-good situation but, as HLGEM pointed out, you can turn these positions into blessings-in-disguise. Your question is multi-faceted, so I'll approach it in parts.

I suspect, he does not know. At the same time, he tries to show me
  arrogance may be so that i don't turn up to him much for questions.

This could very well be true. There are a rash of developers who have been in the industry for decades and not be capable software leads - from a development or a mentoring standpoint (there is a difference). Experience comes from tackling fresh challenges and trying new ideas and learning new skills, but the majority of programmers spend their lives in a wing of The Corporate Office, working on The Payroll Application with their faithful Visual Basic and Java tools, never seeing the world racing by their cold, grey office.

There's nothing wrong with this. For many developers this all they ever wanted and are perfectly content with the situation - it is not, however, an ideal situation for fostering a future generation of programmers, let alone lead developers.

Bravado and arrogance can be a defense mechanism, trying to cover for inadequacies. How do you handle it? Don't confront it head on - if your lead is incompetent, and the boss is unwilling to rectify the situation then you'll have to live with it. That doesn't mean roll over and die, but you can't force somebody to be a good lead.

However, he just only reviews my code, and most of his comments are
  related to coding guidelines

This is what makes me think you're right in that he may not be a good programmer. That's not to say that he isn't a better programmer than you at the moment (at the very least he'll have more experience and exposure from being in the industry for so long) but again, that doesn't translate into being an effective lead. Guidelines are all well and good, but they are second to the function, effectiveness, and efficiency of the code.

What should i do in such situation?

I have informed my manager of this situation, and i have requested him
  to change my lead, although he tells "yes" everytime, but he does not
  take any serious action.

Have you enumerated all of these specific points to the manager, and with specific examples to back it up? If you've simply gone to him and said, "I need a new lead", he won't take you seriously and perceive it as an "interpersonal problem" rather than a technical problem. The reaction of a lot of bosses in this situation is to ignore it in the hopes that it will "work itself out".

Here's some suggestions.

Don't chafe at your situation - trial by fire, while not fun, teaches you some critical researching skills for later in your career.

Start pushing your lead to be more involved. Do this carefully and respectfully. Continue to push and be persistent until he gives in (this actually works for a lot of situations in life).

If your lead won't get involved, see if there are others who could help you. Unless you're working in a sweat-shop that is only concerned with milking hours then your company won't mind another developer with more experience showing you some ropes and reviewing your code.

Start keeping an eye out for a new job. I wouldn't say that you're in a "must leave" situation but it wouldn't hurt your career to be in a place that takes your development as a programmer more seriously.

Title: How do you tell if advice from a senior developer is bad?

Body:
Recently, I started my first job as a junior developer and I have a more senior developer in charge of mentoring me in this small company. However, there are several times when he would give me advice on things that I just couldn't agree with (it goes against what I learned in several good books on the topic written by the experts, questions I asked on some Q&A sites also agree with me) and given our busy schedule, we probably have no time for long debates.

So far, I have been trying to avoid the issue by listening to him, raising a counterpoint based on what I've learned as current good practices. He raises his original point again (most of the time he will say best practice, more maintainable but just didn't go further), I take a note (since he didn't raise a new point to counter my counterpoint), think about it and research at home, but don't make any changes (I'm still not convinced). But recently, he approached me yet again, saw my code and asked me why haven't I changed it to his suggestion. This is the 3rd time in 2--3 weeks.

As a junior developer, I know that I should respect him, but at the same time I just can't agree with some of his advice. Yet I'm being pressured to make changes that I think will make the project worse. Of course as an inexperienced developer, I could be wrong and his way might be better, it may be 1 of those exception cases.

My question is: what can I do to better judge if a senior developer's advice is good, bad or maybe it's good, but outdated in today context? And if it is bad/outdated, what tactics can I use to not implement it his way despite his 'pressures' while maintaining the fact that I respect him as a senior?


答: In FORTRAN  IV, the variable names I-N were implicitly assumed to be integers.  I think it's part of FORTRAN's legacy as a scientific computing language.  Linear algebra uses integer indexes to derefence values in vectors and matricies.  The convention diffused into other languages.</p>

Title: Why do we love using i?


答:
Most of my problems I have sorted by posting to forums and getting replies from others, and
I have been surviving for around 1 year like this.

What should I do in such situation?

To be honest, this is what a lot of technical jobs are like. You need to be a self-starter who can solve difficult problems by yourself (with the help if the internet and it's denizens) if you have to.

From the point of view of getting code reviews and getting help with architectural designs, even when I've had good managers I've never had much of a code review beyond "static variables should be prefixed a s_".

Take the opportunity to learn and learn how to learn; those will be skill that you can use into the future.


答:
As I understand it, your dev lead is actually just there to keep a watch on you "because leaving a developer entirely on his own would be irresponsible". But he doesn't have a clue how to actually judge your work.

Have you talked to him about it ? Maybe he's tired having to do that as well.

If you need advice and help, wouldn't it be a better and more productive solution to have a teammate work with you on your part of the project instead ?


问:
Is there an encyclopedia of algorithms?
Is there an encyclopedia of algorithms similar in style to the Handbook of Mathematics? It seems useful to have large numbers of them available in one place. I know the Art of Computer Programming is considered a good source but it does not seem encyclopedic so much as instructive.

Moderator Note

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

答:
If you're looking for an "encyclopedia of algorithms," it'd be hard to go wrong with Encyclopedia of Algorithms. I can't say that I've read it (at $399, it's cheap for an encyclopedia), but the blurb looks promising:

The Encyclopedia of Algorithms provides a comprehensive set of
  solutions to important algorithmic problems for students and
  researchers, including high-impact solutions from the most recent
  decade.

Someone already cited Steven Skiena's The Algorithm Design Manual, but I don't think anyone has yet mentioned Skiena's associated web site, The Stony Brook Algorithm Repository. From the web site:

This WWW page is intended to serve as a comprehensive collection of
  algorithm implementations for over seventy of the most fundamental
  problems in combinatorial algorithms.

The book is more than just a catalog of known algorithms; it's also a sort of tutorial (in the best sense of the word) on how to decide which algorithm to use to best suit your problem and situation. The repository, on the other hand, is more encyclopedic in nature. It doesn't necessarily contain a lot of detail about how to implement each algorithm yourself, but it does explain what the algorithm does and how it works in general, readable terms often taken from the book, and it provides links to actual implementations for each algorithm.

Title: Is there an encyclopedia of algorithms?


答:
As HLGEM and Jarrod said before this is really a blessing in disguise. Both of their answers are great and I want to add some points.

As your lead is not in your domain you get to take some of the important decisions for your part of the application as your lead doesn't know much about middleware. You also have closure with your manager about how the application should go, what the product users want and how your manager would want to tackle a situation presented to him by the product team. Tell me how many people will get that kind of knowledge on an application.

When you are in a large team you will sure have help from your teammates and/or your lead but you will not have the knowledge of how your manager thinks or the product team thinks because that kind of thing generally goes through your lead and may be some senior devs in a team.
I agree one person projects are kinda tough to carry but if the other side of the coin is so great why miss a chance. Learn what you can learn, enjoy while you can and if it gets too hard convince your manager as Jarrod said or find a new job/project depending upon the situation.


答:
As he's no longer being paid to work on it, probably not.  There are two possibilities:

He knows it's crap and hasn't fixed it.

He thinks it's good so he hasn't fixed it.

In either case, telling him it has serious flaws isn't going to improve it, since it's no longer being developed.

Title: Is it out of line to give unsolicited constructive criticism to a programmer?

Body:
I recently started work at new office that uses a proprietary program written by a solo developer. He's occasionally around as part-time tech support, but the company has signed off on this software and he's no longer being paid to develop it.

As a user of his software there are many issues that leap out to me as a source of concern:

very simple to directly view the DB as a low-privilege user

passwords stored as plaintext

dictionary admin passwords

app uses the DB root account

DB doesn't meet 1NF (eg. appointment1, appointment2, etc.)

I feel like these are serious issues and that if I were him I'd want them pointed out to me, but I'm not a qualified programmer (I'm a social worker) and I don't know if it would be rude of me to just buttonhole him and start blabbering about salted hashes and normal forms, especially when this is no longer a paid task of his.

Is it out of line? If not, how would you broach it?

Edit - more info prompted by comments:

The application holds sensitive data.

It's for internal use, but it's running on lots of machines in several cities and many visitors come through our offices.

My concerns are for the developer's future projects as well as this specific one.


答:
No. Destruction happens in reverse order of construction. rcc will be destroyed first. The fundamental problem here is that you're throwing around bad references- that is, you're throwing out a reference to a ResourceClass with no control over it. It should be wrapped in an appropriate smart pointer.

Also, I find your class design very highly questionable. What actually is the job of any of those classes except the ResourceClass itself? I don't need a helper class to call new, or call an update or connect function on a ResourceClass.

Title: How do you manage cross-class dependencies on destruction/design (more of a C++ question)

Body:
So if I understand correctly, from SOLID design principles, every class should keep a single responsibility.

So there should be one class that creates and manages a resources, a second class that does resource processing/update, the third class that connects the resource to some other resource and so on.

The question is, how do you cleanly express that in code?

Because, in C++, the class destruction order plays an important role.

So you basically come to a situation where you get

```<code>ResourceClassInstanceManager cf;//does the ResourceClass creation, accounting and destruction?
ResourceClass &rcInstance = cf.GetResourceClass();//creates the instance of resource
ResourceClassUpdater rcu(&rcInstance);//updater that works on the class instance
ResourceConnector rcc(&rcInstance, &instanceOfAnotherClass);
</code>```

The problem here is that if cf leaves the scope first, or rcInstance is deleted before rcu or rcc. The other classes will still reference the nonexisting instance of ResourceClass.

This seems somewhat messy, as the whole creation/destruction chain has to be followed very carefully, and becomes really troubling as soon as you have pointers to objects and deeper nesting levels.

Is there a clean solution for this design problem?


问:
Is thinking out loud during an interview really the best strategy?
In another question I asked recently about best practices for whiteboarding, there was general consensus that thinking out loud while coming up with the answer was the best strategy.

Indeed, long moments of silence are awkward.

However after recent interviews I have noticed that if my thinking out loud leads to wrong solutions or down the wrong path, that with further consideration I would have seen, interviewers tend to quickly jump in and point out problems with my approach, especially if I stop to pause for a minute. This was not an isolated case, and happened during more than one interview with more than one interviewer.

The other thing is that after the interview, on a problem I absolutely bombed, when I sat down and sketched out the problem on a piece of paper in silence I was able to sketch out the solution pretty quickly. Thinking out loud ends up with me spending brain cycles on reflecting on how what I say must be registering with the interviewer and in addition there's a fear of recognizing that I've gone down the wrong path and starting over after having written something on the board wastes a lot of time. Once you've started down one path and realize you've written a lot of junk, you can't undo it, whereas if you've thought quietly about it the interviewer wouldn't have seen the mess and it would have been quicker since whiteboarding a bad idea takes up more time than simply considering a bad idea.

I don't want moments of silence but at the same time speaking takes more time, leads to self-consciousness and can lead to interviewer intervention on something I might have figured out myself with just a little more time.

答:
The best strategy is to do what works for you. You've mentioned that thinking in silence helped you arrive at a solution, so perhaps that's what you should do from now on when you're being interviewed. I can understand being nervous and that this can affect your arrival at a solution, but you should use the approach you are most comfortable with.

I would not worry about there being any "awkward silence" during an interview. Consider it "thinking time".


答:
There's middle ground I believe. You don't need to articulate every single detail of your thought process, and I don't think this is expected. You can comment on the problem itself, you can describe how you're approaching the problem in broader terms.

"OK, I think I'd treat it like... I think the difficulty here could be... My first thought is... (leaving yourself an open option of adding: "...but it wouldn't quite work", if you figure out it is so)"

A trick is that your can correct the mistakes you just spotted as if you were lecturing.

Title: Is thinking out loud during an interview really the best strategy?

Body:
In another question I asked recently about best practices for whiteboarding, there was general consensus that thinking out loud while coming up with the answer was the best strategy.

Indeed, long moments of silence are awkward.

However after recent interviews I have noticed that if my thinking out loud leads to wrong solutions or down the wrong path, that with further consideration I would have seen, interviewers tend to quickly jump in and point out problems with my approach, especially if I stop to pause for a minute. This was not an isolated case, and happened during more than one interview with more than one interviewer.

The other thing is that after the interview, on a problem I absolutely bombed, when I sat down and sketched out the problem on a piece of paper in silence I was able to sketch out the solution pretty quickly. Thinking out loud ends up with me spending brain cycles on reflecting on how what I say must be registering with the interviewer and in addition there's a fear of recognizing that I've gone down the wrong path and starting over after having written something on the board wastes a lot of time. Once you've started down one path and realize you've written a lot of junk, you can't undo it, whereas if you've thought quietly about it the interviewer wouldn't have seen the mess and it would have been quicker since whiteboarding a bad idea takes up more time than simply considering a bad idea.

I don't want moments of silence but at the same time speaking takes more time, leads to self-consciousness and can lead to interviewer intervention on something I might have figured out myself with just a little more time.


答: I'm not sure it matters if you work through a problem in words or on paper/whiteboard, as long as you make your thought process clear to the interviewer. The whole point behind talking through a problem is to let the interviewer get into your mind and see how you solve problems. Maybe you're a type of person who can't verbalize and think at the same time, so the approach I would take would be to let the interviewer know that you prefer to work on paper rather than verbally. You need some verbal cues to the interviewer so they know what you are doing and thinking, but you don't need to detail everything in painful detail.</p>


答:
It may not the best strategy for you, but it surely is nice for the interviewers, as long as you don't go "Full Metal Jacket"-crazy on them.

Most interviewers appreciate that (at least for programming positions), as it allows them to:

evaluate your thought-process,

and guide you if you're on the wrong track.

But feel free to say "hang on, let me have a think about this" and think things through before rambling on too much. Take your time; but don't let them hanging for ages. They are anxious to see if you're stuck or not.

Also, being on the wrong path at first is not a bad thing: it is your throught process. It's incremental and you need encounter issues along the way. Fairly normal. It's only bad if you don't see that you're on the wrong track, or refuse to see it when told so, and then don't manage to find the right way.

It helps to get the conversation flowing and going forward.


答:
As always, "It depends"

If your thinking is along the lines of "here are my assumptions, things I'm considering as I'm preparing my answer," it's probably worth sharing. As an interviewer, I'd like to see the thought process and if you're willing to share - and change as needed - assumptions or presuppositions.

If you're letting me know that trying to remember the order of parameters for the a standard library function, that's probably not so good.


答: Why can't you undo it? Those sorts of questions are usually more about finding out whether you're able to say: "Hold the phone -- this, this, that, and this other part are all crap. I just realized that I assumed X, but that doesn't hold for this problem, so please bear with me while I back up a couple steps." Everyone makes mistakes, but not everyone is willing to admit to mistakes in a high pressure environment. If you see that you're wrong, just say so; don't try to cover it up and hope that they won't notice, because that's often exactly what they're really looking for.</p>


答:
As an interviewer, I'm quite happy to wait in silence for a few minutes while you think the problem over but, the longer I wait, the better answer I expect.

If you dive straight in and make mistakes but quickly spot them, that's fine. If you take time to think and get it right, that's better. But there's nothing worse than a developer who kills a lot of time thinking through a problem and then messes it up badly. That said, there's not a lot worse than a developer who is so keen to fill the gap that they do nothing but stumble.


问:
File shredder algorithm
As a part of learning system programming, I am looking to implement a file shredder. The simplest way (and probably seen as naive) would be to replace the data bytes with zeroes (I know OS splits the files and I'll replace bytes in all those chunks). But when I google on this topic, I am surprised to find multiple pass algorithms, some going as high as 35!

Could someone elucidate the benefit of multiple pass please? I couldn't find any explanation.

Thanks

答:
The overwriting of data with 0s in multiple passes only makes sense for magnetic storage devices, because of what @pufferfish said. For SSD and other flash storage mechanisms this fails, see http://www.usenix.org/events/fast11/tech/full_papers/Wei.pdf

Moral of the story: Dealing with hardware problem in software may change when hardware technology changes, although the API will not change.

Title: File shredder algorithm


答:
The Rosetta Code Wiki is a great collection of implementations of common algorithms in several languages. It's not entirely academic, but quite informative and fun to flip through.

In their own words:

Rosetta Code is a programming chrestomathy site. The idea is to
  present solutions to the same task in as many different languages
  as possible, to demonstrate how languages are similar and different,
  and to aid a person with a grounding in one approach to a problem in
  learning another.

Its main advantage over other resources (like the NIST Dictionary of Algorithms and Data Structures) is that it allows you to look at several implementations for different languages. Which can be helpful for various purposes (comparing expressiveness, verifying feasibility in a language or another, etc...).

For instance, the QuickSort page provides (as of 2013-10-07) at least 89 implementations.

Title: Is there an encyclopedia of algorithms?

Body:
Is there an encyclopedia of algorithms similar in style to the Handbook of Mathematics? It seems useful to have large numbers of them available in one place. I know the Art of Computer Programming is considered a good source but it does not seem encyclopedic so much as instructive.

Moderator Note

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


答:
Thinking it out loud looks like a safer bet to me.

<thinking out loud>

so, what are my options here?

think it out loud and get to right solution. Nice at all counts. Score: 2

think it out loud and get to wrong solution or get it right with help from interviewer. Bad, but at least gives me a chance that interviewer will appreciate thought process I exposed while getting there. Score: 0.5

silently get to the right solution. Pretty good, though there's a risk that interviewer will doubt my teamwork abilities. Score: 1.5

silently get to the wrong solution. Total disaster: not only I failed but also gave a big fat chance for interviewer to think I'm dumb. Score: -1

Count: thinking out loud wins over silence 2.5 : 0.5.

</thinking out loud>


答:
Talking aloud is a great way for interviewers to gauge your thought process -- and that's what interviewers are looking for.  They don't want some one who can just code, they want some one that knows how to solve problems.

Of course, for the person being interviewed, talking aloud is quite bothersome (I know it was for me). This is especially the case when a difficult question is asked.  If you need time to thing about the question, tell the interviewer to "hold on and let me thing about this for a second."  Then, when you think you have a solution, say what you thought about and how you reached your conclusion.

I find interviewers are happy to wait a few seconds while you think about the problem.

Another technique to give you time to think is ask the interviewer to clarify an aspect of the problem.  This will give you more time to think and it might help you see an obvious solution you hadn't thought of beforehand.


问:
Are software developers who ignore quality/standards better for the company?
Do software developers who choose not to put code optimization, standards and best practices as a top priority, create more useful code than those developers who want to worry about optimization, implementation of coding standards and practices above completing tasks on time?

How do these differing methodologies compare when it comes to individual performance reviews?

How do these styles compare in peer reviews?

What is the best way to influence your team to implement more best practices during the SDLC?

答:
No, they'll only get respect from the project's owner of the moment.

They'll get trashed for years by:

future maintainers,

future testers,

future project owners,

future managers,

and pretty much anyone involved with the codebase in the future.

They might even get the same treatment from:

the current testers,

the current technical documentation writers.


答:
Do I agree with developers who don't care about code optimization and practices?  No.

Do they do the job they need to do? Yes.

A business is about making money, and the only way to make money is to release products.  This usually means that projects have strict schedules, which means what may be the best way to do something may not be the quickest way to do something.

While I don't agree with this style of developing, it may be seen as respectable by the company if products are being released.

Title: Are software developers who ignore quality/standards better for the company?

Body:
Do software developers who choose not to put code optimization, standards and best practices as a top priority, create more useful code than those developers who want to worry about optimization, implementation of coding standards and practices above completing tasks on time?

How do these differing methodologies compare when it comes to individual performance reviews?

How do these styles compare in peer reviews?

What is the best way to influence your team to implement more best practices during the SDLC?


答:
I don't think there's a lot of point discussing this with the programmer.  For a start, he might not take kindly to being told how to do his job by an "amateur".

However, you might point out any serious security issues to your management.  Let them decide what to do about it.  In some cases, it sounds like the fixes would be simple changes to database account permissions that can be implemented in a few minutes.

But you (and management) also need to consider whether the security of this application really matters.  Does it contain valuable or sensitive information?  Are you likely to have problems with disgruntled employees?  Is the network properly secured?


答:
No. Best practices are best because, by definition, they help get projects done more correctly, in less time, with quicker modifcation down the road, so disregarding them is guaranteed to decrease profits. Of course, your managers might prescribe practices that they think are best, but actually are not, or they might misjudge what customers will pay for and what not - then all bets are off.

Coding standards are more tricky; it is possible to prescribe too much detail to your coders, which leads to decreased efficiency. But with experience it becomes quite easy to tell useful guidelines from anal-retentive micro-managing, so the same applies: actual best practices are always worthwhile, pseudo-best practices usually not.

Code optimization is usually not worth doing unless you have measured what your bottlenecks are, confirmed that doing an optimization is necessary and measured that your clever trick actually meets the preformance rquirement. Otherwise (which is mostly) it is not worth doing, and hence not optimal.


问:
Java SE and Java EE?
I was now talking with some people and they told me that if i was intrested in a job in the future for Java programming i should not spend too much time only learning Java SE i should spend time learning Java EE instead.. Now that brought me to some questions..

Java Enterprise Edition why use this ? What can i make with this that i can't make in Java SE?, And what kind of applications is this good for?

Is there any good books out there that i can read to learn the Java EE?

If i know Java SE well is it easier to learn Java EE ?

Thanks! I will keep browsing the web for some anwears for theese questions.. And if i find anything i wil update this question.

答: I think java EE is much more than just javax.* packages. Many framworks depend on them and this is a huge field to be in. There are a lot of concepts that are different from Java SE. I suggest you look into it for some time using a book like head first servlets and then decide where you wanna head to.</p>

OwnerDisplayName: TheCompBoy

Title: Java SE and Java EE?


答:
How much money they make for the company is debatable. If there is a level of revisiting the code in question, the maintenance costs will be rising and someone isn't going to be happy. High long term maintenance costs are more expensive than doing it properly up front. </p>

<p>How much respect they get is probably case specific. At some point, however, someone will notice. </p>

Body:
How much money they make for the company is debatable. If there is a level of revisiting the code in question, the maintenance costs will be rising and someone isn't going to be happy. High long term maintenance costs are more expensive than doing it properly up front.

How much respect they get is probably case specific. At some point, however, someone will notice.


答:
No, never.  IMO code optimization, best practices, actual craftsmanship are the MOST important thing to have in a codebase; without it the whole thing turns to sludge and is held together with duct tape.  It's an unsustainable design.  It's like ignoring a tumor because it's small and you're healthy now; sure you're healthy now but a few years down the road it becomes terminal because you ignored it for so long.

I not only do not agree with developers who don't care about these things, but I have zero respect for them to boot.  A surefire way to get me to consider leaving an organization, no matter how short a time I've been there, is to be surrounded by a team wherein I am the only person (if not the only person in the entire company) who cares about proper software engineering concepts.


答:
Not caring about these things may make the company more money in the short term, but could cost the company more money in the long term on more bug fixes and maintenance coding.

Sometimes a quick-and-dirty job may be necessary if there's a rush with competing companies to get similar products to market at the same time, but the future costs of such actions should be considered carefully.


答:
A good read: http://www.joelonsoftware.com/items/2009/09/23.html

But IMHO, one mans best practices is another mans nightmare. And every non-trivial code-base will be nightmare for an outsider.

Whatever you think, don't be a jerk about it.

EDIT: I'm not defending any of the positions, depending on the task I might lean to either side.


答:
Depends on the developer and the project/situation.

Extraordinary times requires extraordinary measures.

So if I need something delivered now, and a someone is over-engineering enterprise grade java application that leverages no less than 14 of the latest buzzword frameworks while a simple python script will do the job is as worse as the developer that cuts corners and thinks buggy code will do in normal times.

Part of being a developer is being flexible. You shouldn't be slave to your tools and blindly follow practices - there will always be a case where they will fail you. Knowing when to break and bend the rules is one of the things that come with a lot of experience and are valuable.

In your case - if he delivers more value than you because speed is critical, even after factoring the increased cost of maintenance down the road then he deserves the better compensation. On the other side - if you are stuck with cleaning his mess - you have a communication problem with the management.

It is case by case basis. Except coding style - there is no excuse there.


答:
Yes and no, which is a bit wishy washy but it's a best practise and not a perfect practise. Ideally you should follow them constantly, but there's always going to be a situation where the business wants to put it's needs before your products needs.

You'll be hated by the maintainers but loved by your boss.


答:
False dichotomy: qualities are orthogonal.</p>

```
                High Quality     Low Quality

Profitable         AWESOME       Sketchy

Unprofitable        Iffy         FIRE FIRST
```

Body:
False dichotomy: qualities are orthogonal.

                High Quality     Low Quality

Profitable         AWESOME       Sketchy

Unprofitable        Iffy         FIRE FIRST


问:
How can my multinational transition from one development platform to another?
I am working in IT department of a big, international company. We are developing different Intranet applications for the business (Complaints, Rebates, Service Desk etc). Now we decided to migrate from PHP platform to .NET (integration with MS CRM Dynamics, Exchange and MS Office be among many reasons). As there are about 20 different applications the business is using on current, PHP platform, we will have to come up with the best way to move them all to the new platform. I don't want to go into details how to convert the code etc, as while we do migrate we want to improve all of these applications.

So we came up with 2 main ways of moving these apps:

Support just one platform. What would it mean? Create homepage and literally migrate all apps as they are to .NET (without improving them while we do that). After New intranet is running we would start rebuilding migrated applications and improving them. That would save us developing intranet in .NET while having to support PHP platform.

Support both platforms for some time. That would mean building just a homepage and 1 or 2 new applications (which do not exist on our PHP platform). Making these available to the users but not taking off the PHP platform (we would incorporate menus and links to make it easier for users to move between apps on PHP page and the new one). Then we would start rewriting the PHP applications while improving them.

Now I am not sure what would be better, on one hand (option 1) we will potentially make everything easier for users by not forcing them to use two different platforms at the same time. Although they won't see any improvement of having the new platform, apart from everything looking nicer, the functionality of applications on the new platform will be the same for some time. Also I think we would add ourselves (IT dep) more work as esentially we would write every app twice.

On the other hand in option two (2) users would have worse experience as two platforms look different, but they would realise the benefits of the new platform as new applications are beeing moved.

Has any of you came across something like that? What would you choose? Or maybe there is even different, better way to those I have presented? I would like to know what do you think and how would you approach that.

答: For financial reason, most companies I have worked went with the second approach, rightfully I might add. It takes a lot of money, time, and risks for them to achieve #1. User mostly would understand #2 as long as they see your progress and interaction with them. In this lean & mean economy, I doubt anybody would take #1 approach. </p>

OwnerDisplayName: Daniel Gruszczyk

OwnerDisplayName: Taesung Shin


答:
If you think for a second that management doesn't understand how capable you REALLY are to get the job done, then you are probably wrong.  Management probably also understands that your lead right now would be completely useless if he replaced you and took over your work.

The REAL reasons they haven't relocated you are because despite all of your challenges that you present to them, you are still the best person for the job.  They obviously value your work too much to risk handing it off to anybody else.

Don't underestimate management's intelligence...

They are a lot smarter than most developers give them credit for.  I didn't understand this until I started managing.  They probably also are aware of how useless your lead really is but they are probably powerless to address that problem.

Let me paint a picture for you, Lead A with 5 yrs experience at the company is incompetent.  Manager knows this, recommends to his upper manager to lay off Lead A.  Upper manager asks why he wasn't dealt with years ago if he is that incompetent.  Manager looks bad now especially since Lead A has a bloated salary that was being paid for no benefit...

Here is another potential scenario, Lead A is close friends with somebody important.  He is too hot politically to take on,

Either way, with a long running mistake like that it is easier for large organizations to sweep imcompetent people under the rug, give them busy work and fake power that is appropriate to their years of "experience" where they can't do TOO MUCH damage.  Unfortunately many organizations would rather do this then actually deal with the problems.

Of course the reason for this is that the manager in this kind of organization is always better off short-term to deal with bad talent this way than to address the long term problems that these kinds of people can bring to the organization.

So while it is short-sighted and potentially unethical, you have to admit it is a little smarter than many developers actually give credit for.


问:
When should development stop and QA begin?
We write a complete functional specification for our development team of two. We do not have professional testers however we have drafted in the help of our available helpdesk personnel to perform 'QA testing'.

We have had problems in the past where complete chunks of functionality do not work, or the code is delivered is simply not according to the spec.

My questions are: at what stage should developers stop coding at hand over to the QA team? Is it too much to ask the developers to review their code against the spec before handing over to the QA team?

答:
It shouldn't!

It is very hard to do all the work, stop, and then fix all the issues. When you go to fix an issue you find during the QA process, you may learn that it would be better to do something differently.

Instead of thinking of everything as a lock-step process, try to make it more cyclical. Code some functionality and test it. Code some more and test it (and the old things still work). This more fluid process alleviates the hard ship of trying to front load everything. You can still have the concept of a code freeze (just fix bugs) when you get close to the deadline, but the point is to test early and often.


答: Well, if entire sections of code are being handed over to QA in a non-working state, perhaps you should look into adding some sort of unit/integration testing to your process.  Don't abuse your QA people by making them find out that you failed to unit or integration test your code.</p>

Title: When should development stop and QA begin?

Body:
We write a complete functional specification for our development team of two. We do not have professional testers however we have drafted in the help of our available helpdesk personnel to perform 'QA testing'.

We have had problems in the past where complete chunks of functionality do not work, or the code is delivered is simply not according to the spec.

My questions are: at what stage should developers stop coding at hand over to the QA team? Is it too much to ask the developers to review their code against the spec before handing over to the QA team?


问:
How to retain student/intern programmers?
We have a small team in our department and typically employ 1-3 students/interns.  The problem we have is retention.  We like to hire a student that will stick around as part of the team for more than just a summer quarter.  The problem is though the last 4 students we hired, up front we discussed this with them and they all ended up leaving earlier than we would have liked.

The relationships all ended in a good fashion, the students either obtained teaching assistant or research positions within the university, or went on to bigger and better things.  This is all understandable and we do not hold it against them for doing what is best for them.

But my perspective is different as I worked within our department for 2 years during undergraduate at which point I was brought on full time upon graduation.

How can we retain students?  We give them hardware they need/want, we provide them with problems to solve in anyway they see fit (within reason).  All in all to me this type of job for a student programmer is so flexible and awesome I cannot see how anyone would want to leave.

Thoughts ?

答: Hire people that want to do the kind of work you do. </p>


答:
It's a fine line, because if the code is delivered according to spec then to me that means there are not bugs (and no need for QA!). The fact that code is routinely not delivered to spec is the reason why we do QA in the first place.

But I don't actually think that's what you're talking about. What you mean is that the dev team seems a bit too lazy with their coding, and there are big obvious things that don't seem to work. Laying out before hand that unit tests need to be present for each of features A, B, and C (in the spec) and then having code and tests reviewed independently (by a team lean or manager) should help to alleviate this sort of problem.


答:
While there are excellent and timeless instructive books on the subject, I hardly think, you will find such an encyclopedia.

An encyclopedia on mathematics covers millennia of research. Algorithms on the other hand are barely studied for a century (speaking on a larger scale). The whole field of computer science is barely understood by anyone and most things are still moving quickly. If there were an encyclopedia on this right now, I guess you could throw 90% out the window in 10-20 years. And of the 10% worth keeping more than half was already printed half a century ago. The vast parts of the handbook of mathematics will be up to date in a hundred years from now.

Mathematics is pure and self-contained. This hardly applies to "the field of algorithms". It actually can hardly be thought of as a field, because a field usually operates on a well defined problem space, while algorithms actually only operate within a more less well defined solution space.

So if one were to compile an encyclopedia on algorithms, it is not really clear what to include, if your really want it to be comprehensive. Graph theory? Linear algebra? Numerical analysis?

IMHO, right now the best resource that fulfills the role of an encyclopedia, is "the internet" (behold). The point of an encyclopedia is to have an indexed, comprehensive, searchable repository of knowledge (on some topic). Personally, I find both this list and this list quite overwhelming. Also in other answers, numerous excellent algorithm databases have been linked.

So while you can't expect the same level of quality as you would expect from an encyclopedia that fills your bookshelf, you do get the level of timeliness required to compensate for the youth of the field you want to know about.

Title: Is there an encyclopedia of algorithms?


问:
What are the dangerous corners of Qt?
There's nothing perfect under the sun. Qt is no exception, and it does have limitations: we can't use pixmaps in a thread other than GUI, we can't use QImage with 16-bit-per-channel image format, etc..

Which situations have forced you to spoil the design because of Qt's limitations?

What are the most hated quirks?

Which design decisions should one avoid while using Qt in his projects?

答: Recently I found out that a QChar, despite its name, does not actually correspond to one character but to a UTF-16 code unit. Thus, when you want to scan an arbitrary Unicode text character by character, you have to add algorithms for dealing with high and low surrogates, combining characters and the like.</p>

Title: What are the dangerous corners of Qt?


答:
I would argue that at the very least, the developers should have tested the "happy path." That if they enter expected data then it does what the spec says it should do. Developers who don't do that much should be questioned.

I am also disappointed if a developer hasn't tested the obvious edge cases: a string too long for the database, obviously invalid text, if you enter letters where a number should be, etc. If that happens often, again questions should be asked.

However, assuming it isn't specifically mentioned in the spec, if a developer limits a name to just upper- and lower-case letters, but forgets that some names have apostrophes, or allows a date of 29th Feb 2011 - that's slightly more understandable. Unless they're making the same mistake time after time.

The QA team should be picking up the extreme edge cases. I prefer QA to be monkey-testers: just entering random garbage, seeing if they can break the app that way.

In web development, QA should try different browsers and try to find plugins that might affect the code. They should switch Javascript and CSS off and see what they can get away with then. That kind of thing. If you expect the developers to do that, you're spending too much money on it.


问:
Getting management to hire a new developer?
I've been working here for about 3 months now, and this company has been around since 2003. I've the only full time developer, and I don't know what happened to the part time guy who was doing work before I got hired, I haven't seen him since a month after I started, aside from a couple emails.

Essentially, that makes me the only developer, trying to balance adding new features to our main product (subscription website service), developing an Android-based version of the product, handling client issues, working on migrating clients from old version to new version (and the headaches that will result from this), fixing issues with a signup service for out ISP side of things, and helping with tech support for the ISP side. Not to mention the massive overhaul I'm fairly certain the database needs, that will mean at least a few months' work.

My bosses hired an intern to help me with the Android version, but the one boss randomly went to England until December, taking the intern with him.

Any tips I can use on convincing management to hire somebody else? Even if just a second full time support guy to help with the phone calls?

答:
You need to build a case for it.

Start by estimating the effort for every task on your plate.  In hours, days, whatever.  Make sure management sees this- mention this list to them the next time they ask you to do something.  Be sure this is written down.

For each new bit of work, estimate its relative effort and importance, and be sure management knows where it's going in your todo list.

When they start getting agitated that things aren't getting done as quickly as they'd like, point out the need for another developer.  1 person can get 1 hour of work done an hour.  2 people can get 2 hours of work done an hour (more or less).  If they want prompt support and improvements, they need to hire someone to help.


答:
If functionality is being delivered that doesn't work, then the problem is not between development and QA, but between development and the product owners.

Product owners and developers should be part of the same team, and should work together to define what needs to work to consider a feature "done", and to make sure that the code meets that need.

When code is delivered, testing should be a mere formality, because the product owners should have been working with the developers along the way to make sure that all the use cases are covered.

(If you have professional testers, they should be part of the team, and should be involved at every stage.)


问:
Is it possible to get a job in a high-demand company without having hobby projects?
I was curious if the recruitment team at high-demand companies such as Google takes a lack of hobby projects into consideration when evaluating candidates.

I'm a straight 40 hour/week programmer, who is lucky to spend an hour or two a month outside of work on anything programming related. I love hanging out on SO/SE during my breaks at work, and love answering questions, but after work I leave the programming world and go back to my life.

I already understand that you don't need hobby projects to be a good programmer, but does this lack of hobby projects affect my chances getting a job at a company that always has a long list of candidates trying to get in?

答:
Yes. I know a number of people who have done so, including myself. I've also done interviewing on behalf of high-profile companies. In my experience, they are more interested in your professional experience and what skills you can demonstrate in the course of an interview.

The most important use of hobby projects would probably be to demonstrate aptitude if your professional/educational experience is otherwise lacking.


答:
Sure it's possible.  I didn't see anything related to hobby programming in thier hiring process.  Sounds like if you have the skills and can demostrate those skills effectively, you have a shot of being hired.

https://www.google.com.au/about/jobs/lifeatgoogle/hiringprocess/

Title: Is it possible to get a job in a high-demand company without having hobby projects?

Body:
I was curious if the recruitment team at high-demand companies such as Google takes a lack of hobby projects into consideration when evaluating candidates.

I'm a straight 40 hour/week programmer, who is lucky to spend an hour or two a month outside of work on anything programming related. I love hanging out on SO/SE during my breaks at work, and love answering questions, but after work I leave the programming world and go back to my life.

I already understand that you don't need hobby projects to be a good programmer, but does this lack of hobby projects affect my chances getting a job at a company that always has a long list of candidates trying to get in?


答:
Definitely.  Hobby projects certainly look nice and demonstrate passion, but if your work is demanding and you're learning a lot and contributing amazing things during work...why would they care what you do in your free time?

These companies want to see passion, motivation, and skill.  Having hobby projects can be one way to show this, but there are a myriad of other ways.


答:
Depends on how crazy you are. When I think out loud, there are only two possible outcomes:

1) I finish my train of thought, and look up to find that the interviewers have scooted their chairs as far away from me as possible. Sometimes security arrives shortly thereafter, or nice young men in their clean white coats ha ha ha.

2) The technical interviewer startles the HR interviewer by joining in my geektacular glossolalia and we gabble geekspeek at each other for 15 minutes. Then we comb our hair, climb down off of our chairs, and pretend like nothing ever happened.

Lets be honest. A lot of us are pretty weird. If people often look at you strangely, you probably shouldn't think out loud.

An easy compromise (one that I use myself), is to illustrate your chain of thought with well chosen questions.


问:
Should we quit trying to do agile if QA takes 12 weeks?
Someone in my company recently proposed changes to our core product that our managers feel should trigger what I guess my company considers a full QA cycle (i.e. testing the entire product suite from the ground up). Apparently our QA takes 12 weeks to do a full QA cycle for our product. My problem with this is that we are trying to do Agile (although mostly half-assed in my opinion) development. We will do a whole set of sprints and then do a release, which QA will take forever to go through I guess. The question is really, if our QA is going to take 12 weeks to do their job, shouldn't we just give up trying to do Agile? What the hell is the point of trying to do Agile in a situation like this?</p>

答:
It sounds like you have a "Definition of Done" problem.

Given that your QA group is external, and only involved on customer releases, you can't rely on them for timely feedback on issues. That means if you want rapid feedback, you're going to have to bring some degree of testing "in-house" for the team.

Treat the QA Group as if they don't exist. Act is if your release at the end of the sprint will be deployed to your most critical environment the next day. The software isn't done until it's ready to go to the customers.

QA should find nothing.

This will be harder to get to. You'll probably have some things that sneak through the first few times. Automated acceptance tests and "regression" tests are your best friends here. TDD will help you build up large parts of such suites. You should be able to know -- quickly -- if you've broken anything.


问:
EF vs. NHibernate
In the past 2 years since I started writing business applications (before I did either high level front end or very low level systems programming), learned datasets, linq to sql, and now entity framework.  The logical thing to look at next seems to be NHibernate.

Reasons I eventually ended up at EF are: (1) it has the best designer support and (2) it is the most supported by Microsoft.

Reasons (these have elements of assumption) I am interested in NHibernate are: (1) it might not get superceded by a totally different thing as quickly as MS churns data access technologies (2) It seems like its either the front running or second to front running tool for what it does and (3) It appears to be stable and tracable back through time quite a bit.

Has anyone published a comparioson of the two?  Is one better than the other for certain types of architectures? Or is it just a matter of style and preference?

答:
We're doing a project where the architect chose NHibernate over EF. I wish the choice had gone the other way as a publisher-subscriber requirement was present from the beginning.

If you plan on using sync framework, go with EF, as NHibernate can't cope with the updates (to the columns that specify where the data came from, who changed it and is my copy the latest) that go on behind the scenes.

If you need to replicate data from one database to another (and keep primary keys the same), the session.Replicate function is poorly documented and seems to take longer than a straight copy.

Title: EF vs. NHibernate


问:
How do you track your progress in a project?
Here's the type of situation that I've been struggling with, and I'm certainly not the first:

Project has a budget based on the estimated time to develop the solution

Deadline to turn project over to the PM for QA is one some date

I am working on multiple projects at once, and each has a budgeted number of hours and deadline

Tracking my progress against a budget and deadline would be pretty straightforward if I knew exactly how I was going to implement it, and only had one or two projects to focus on at a time. However, I'm building websites with Drupal, and every project includes some functionality that might be available as module - or the available module won't work at all, and it will require significant effort to build that functionality.

What strategy have you found most helpful to keep track of where you are in a project so that you can accurately report to the PM how far along you are, and identify early on if the project is in danger of running late or going over budget, especially in cases where the time required for some parts is unknown?

答:
I ended up using a simple Excel file that I keep readily available and I update that with time spent on various projects throughout the day.  I categorize the entries and then just use the Sort and SubTotal features to do reporting per project.  Each week, I add a new worksheet to the file and track time for the week in that sheet.

It is hardly elegant but it is very simple and very flexible.  I've tried other more complicated solutions but I keep ending up back at this because of the simplicity.

The trick to making this work (well, any solution actually) is to develop the discipline to update it as you are working on things rather than waiting until the end of the day and then trying to remember what you did all day.  The more projects you juggle, the harder that gets.

If you mean to track your progress as in "Percent Complete" then good luck with that.  As any project manager will tell you, all tasks are at 90% complete all the time.  Its just that last 10% that takes all the time :)  Seriously, Percent Complete is one of the most worthless numbers associated with project management because most of the time it is literally just pulled out of thin air.


答:
You'll have to factor in the following parameters and resources:

Skill set of your team members

Dedication of your team members

Cohesiveness of your team members

Availability of your team members

Your familiarity with the team members and how they work/act/behave (alone, with each other and with customers and PMs)

Your familiarity with the project tasks and requirements and ability to translate those requirements to your team

The familiarity your team members have with those tasks

No software or spreadsheet or database is going to supplant the human interface and human understanding aspects when it comes to managing a software development project.  You can "guesstimate" all you want, but it's going to be a guesstimate, unless you know the team, the tasks and the resources at your disposal.  I'm sure I didn't answer your question, but I've been managing software development projects for twenty-odd years and have been told dozens of times of a "new and incredible" software product that will nail down estimation and project management but none of them work unless you nail down the items mentioned above.

Start by itemizing tasks at the lowest or most modular level (conceptually).  Assign difficulty values and estimated time durations (man hours, etc.).  Assign candidate resources.  Then work your way back to determine availability/overlap and you can use Project or a Gantt chart to lay out the scheduling from there.  I'm leaving out a ton of steps getting from assessment to the task/work breakdown effort, but you get the point.

Title: How do you track your progress in a project?

Body:
Here's the type of situation that I've been struggling with, and I'm certainly not the first:

Project has a budget based on the estimated time to develop the solution

Deadline to turn project over to the PM for QA is one some date

I am working on multiple projects at once, and each has a budgeted number of hours and deadline

Tracking my progress against a budget and deadline would be pretty straightforward if I knew exactly how I was going to implement it, and only had one or two projects to focus on at a time. However, I'm building websites with Drupal, and every project includes some functionality that might be available as module - or the available module won't work at all, and it will require significant effort to build that functionality.

What strategy have you found most helpful to keep track of where you are in a project so that you can accurately report to the PM how far along you are, and identify early on if the project is in danger of running late or going over budget, especially in cases where the time required for some parts is unknown?


答:
At this point I think the main (only?) advantages NH has over EF are some very fine-grained fetching strategies.  Instead of lazy-loading OR eager-loading everything, NH gives you some very nice intermediate options.

Having said that, I've never needed that level of control over my data access, and so the simplicity of EF has made the choice an easy one.

Just be aware that the EF designer file that's otherwise so nice to work with can become a nightmare in source control; it doesn't merge well, or at all.  Make sure you check it out with an explicit lock anytime you need to change stuff.

Title: EF vs. NHibernate

Body:
In the past 2 years since I started writing business applications (before I did either high level front end or very low level systems programming), learned datasets, linq to sql, and now entity framework.  The logical thing to look at next seems to be NHibernate.

Reasons I eventually ended up at EF are: (1) it has the best designer support and (2) it is the most supported by Microsoft.

Reasons (these have elements of assumption) I am interested in NHibernate are: (1) it might not get superceded by a totally different thing as quickly as MS churns data access technologies (2) It seems like its either the front running or second to front running tool for what it does and (3) It appears to be stable and tracable back through time quite a bit.

Has anyone published a comparioson of the two?  Is one better than the other for certain types of architectures? Or is it just a matter of style and preference?


问:
Are there pre-made commercial software licenses to choose from?
I currently have an open source project that is licensed under GPLv3.  I'd like to dual license it, so I can offer it for commercial use.  Are there any resources for choosing or creating a commercial software license?</p>

答: Creative Commons.  GNU.  And you can find hundreds of examples at Law school web sites and even use existing EULA content and edit it to suit your needs.  ALWAYS have your efforts reviewed by a competent attorney.</p>


答:
Absolutely.

But participating in open source projects (if it is a high profile project, it is definitely better) shows passion about your craft. It will help them to review your coding skills and how you approach problems.

I had been interviewed by the big G in the past even at that time I wasn't participating in any open source projects.

So submit your Resume and let them reject you, don't reject yourself :)


答: It's completely random.. I interviewed with them as a SDE. You will go through a series of interviews, and one person might think hobby projects are 100% crucial to having talent, and another might not care, or think they're distracting and an overall negative....</p>


答:
You should think carefully about whether you really want to work for Google if you only want to work 40 hours a week.  There is nothing wrong with being a 9-5'er; it's a totally valid life choice.  But it's not compatible with working at a startup, and it's not compatible with working for a number of tech giants, among which is Google.  There's a reason why they provide free dinners - it's that they want you there.

I was invited to interview with Google twice on the basis of my hobby projects, so I can confirm that hobby projects make you more visible.  I can't confirm that they will select against  you because you don't have hobby projects.  However, what I can tell you is that if you're not completely obsessed with computers and software, and willing to work a ton of extra hours, you won't be happy at a company like Google even if you do get hired on.  If you want a balanced life, look for a  place that has a slower pace like a financial institution or insurance company.

Again, there is absolutely nothing wrong with the choice you have made - but it has consequences, and you need to reconcile yourself to that.


问:
Should jQuery DOM manipulation be avoided in favor of JavaScript template engines?
From what I can tell, most developers will use heavy jQuery DOM manipulation tactics to deliver their updated AJAX views. Once things get out of hand, they may consider refactoring using template engines such as Mustache.js. Is this a valid assessment of a natural progression to use a template engine?

When I begin a new AJAX heavy project, is the best practice to use a template engine or is jQuery DOM manipulation good enough?

I have yet to find any negatives with using a template engine. The maintainability, efficiency and simplicity seem to be the redeeming qualities.

Please advise me on whether JavaScript template engines should be used or not by default.

答:
Some of the drawbacks of templating to update the DOM are mitigated by using some sort of MVC pattern on the javascript side - JSON updates a javascript model object, which is observed by a controller object which can either update the DOM via template or directly.

This is much more refactorable and DRY than repeating HTML fragments in multiple places.  It is also better for handling complex JSON, since the code to use the JSON object to update the model can be written once and not depend on the details of the DOM.


答:
We have a screening process for projects where we ask the developers to give a walkthrough/demo of their code before it comes into QA.  We include not only the QA testers, but the business owner(s) of the code, customer service, and marketing/design.   This tends to focus on the developers on at least the easy use cases, and sometimes the resulting discussion between the various teams results in changes to specs and a delay in entry into QA.
When we can, we involve QA much earlier in the process, which helps get bugs fixed while the code is still warm -- but we still do the walkthrough before "official" QA starts.

I sometimes have said that code should not be submitted to QA if you'd be upset if it mistakenly went to production instead of QA.    Code with major dysfunctionality does not belong in QA (except in specific circumstances)


答:
Best Practices is somewhat like common sense, everyone agrees that everyone should know it until any two people start discussing it in detail.  No two people completely agree on the definition and there is no logical source of truth that applies to all situations.

Are you writing the guidance system for a space satellite (you probably aren't)? Then Hell No poor quality / performing code is never acceptable in this sort of work.

Are you writing a throwaway website for a one time marketing push (you probably aren't doing this either or you wouldn't have asked the question, but it is more likely than the satellite)?  Then Hell Yes, get that piece of fluff out the door through any means necessary to meet deadline, the next marketing director is probably going to do something else with a different company anyway.  WHAT YOU DO IS NOT ART OR SCIENCE - GET PAID.

Everything else in between: negotiable, especially as long as the dev is on the hook for initial support.

Until the second coming of whatever holy being you prefer occurs and he/she/they/it defines development practices in a miraculous manner there is going to be significant room for debate on any project not directly responsible for life and death decisions that isn't so insignificant to be disposable.

Everything outside of life-critical labeled best practices is usually more like company policy, client spec, or personal opinion.  Many of them are personal opinion that many people currently agree on, but that does not make it an immutable guide for all situations.


问:
Effectiveness of "what is your greatest strength/weakness" interview questions
As someone who is now finding himself on the other end of the interview table, I'm wondering how useful these questions are from an employer's perspective. Some of my coworkers think they're good because you can see "how they respond," but I'm not convinced it tells you anything useful, for several reasons:

It's not a very comfortable question and can lead people to twist their answers, even if not on purpose

People may not fully know their greatest strengths or weaknesses (i.e. judge them by their peers)

Explaining what a strength is isn't as good as showing it

I still don't know any more about the candidate afterwards

The rationale of my coworkers is that it can help weed out people that give ridiculous responses, like one guy that said his greatest strength was "his intellect" or people that try to turn the weakness question into a strength like "I work too hard." But I think there's more effective ways to determine such things. If you want to see if someone's smart, ask them technical questions. If you want to see if someone is productive, look at their work history. If you want to see how someone reacts under stress or change, ask them how they've dealt with it and ask for concrete examples.

What are people's thoughts on these questions, from the perspective of an interviewer? What do they really tell you about a candidate, and what are better alternatives? How do I convince my colleagues of this?

答:
In and amongst other questions I don't think it's bad, in and of itself. If you are looking for the "one question to rule them all" candidate, this one is not it. Ideally a candidate has some awareness of what happens during interviews and will have a good answer where they admit to an honest weakness that they have (NOTE: we ALL have weaknesses - somebody who claims NONE is a giant red flag) but also tells you what they're doing to address it.

Example: "I sometimes tend to obsess over getting every last bit of information up front before doing any development. In the past that has led to some slow project starts. Now I try to get some basic functionality sketched out first and then iteratively fill it in as I get feedback from the users."

You admitted a weakness (instead of "ready, aim, fire" you're more of a "ready, aim, aim, aim, just a little for data, aim, aim...") but recognize it and are taking steps to deal with it.

Remember - you are going to have to work with this person day-in and day-out for a long time. You will see them more than your own family. Whatever you can do to figure things out about them you should do.


问:
Is there an encyclopedia of algorithms?
Is there an encyclopedia of algorithms similar in style to the Handbook of Mathematics? It seems useful to have large numbers of them available in one place. I know the Art of Computer Programming is considered a good source but it does not seem encyclopedic so much as instructive.

Moderator Note

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

答:
As far as extant sources, I think Wikipedia is the closest thing to what you're looking for. To wit, it might be useful to create a more defined "algorithm template" on Wikipedia for this purpose, but that's something to be discussed with Wikipedia editors and not here.

A quick note on The Art of Computer Programming: when it is completed it is to include a "summary" volume and although that won't help you now, it might be approximately what you're looking for. TAOCP is encyclopedic for what it does cover, but it isn't complete yet and Knuth's personality is such that he isn't going to include things unless he's exhaustively researched them.

Title: Is there an encyclopedia of algorithms?


问:
Is distributing patches in compliance with the GPL?
I'm designing a distro and some of the software packages included are maintained in such a way that my source repository doesn't actually include the source code, but they are included as an svn:externals property or a list of read-only repository URLs and are checked into the source tree before building.

Sometimes, the software requires a patch or two in order to build or work properly. These patches are included in the source tree and are automatically applied but not included in the end result. The repository is public and anyone can get the patches, which are maintained regularly.

My question is, is any of this setup violating the GPL? I really want to distribute under the GPL or compatible license, but I'm not really well-versed in legalese. Would I have to host repository snapshots once I publish in order to be in full compliance, or could I just host the patches?

答:
The GPL requires you to provide that the users you distribute your code to can also contribute and distribute their own changes.

Some GPL commentators go so far as claiming that you should distribute the build system, and so can only use FOSS tools and even a FOSS OS!

The GPL faq does say that you need to distribute the source even if you simply take the LINUX system and repackage your own distribution. Distributing diffs isn't enough

Personally I would have said, that if you distributing patches to a well known and widely available packages then that is making it easier for people to enhance and further distribute your contributions than if they were forced to use your source tree of a well known package en-bloc and were forced to integrate any changes to the main package  themselves.

I would ask myself, am I doing this to further the aims of the GPL, or to work around it - ie. Don't be evil (tm)


答: If you're distributing executables, you must make the corresponding full source available. Since the Internet is a medium customarily used for software interchange, providing a working URL where the software can be obtained should be sufficient to meet your GPL obligations. Otherwise, everyone who distributed every Linux distribution would have to personally host every corresponding source distribution, which nobody does and nobody even claims is needed.</p>

Title: Is distributing patches in compliance with the GPL?

Body:
I'm designing a distro and some of the software packages included are maintained in such a way that my source repository doesn't actually include the source code, but they are included as an svn:externals property or a list of read-only repository URLs and are checked into the source tree before building.

Sometimes, the software requires a patch or two in order to build or work properly. These patches are included in the source tree and are automatically applied but not included in the end result. The repository is public and anyone can get the patches, which are maintained regularly.

My question is, is any of this setup violating the GPL? I really want to distribute under the GPL or compatible license, but I'm not really well-versed in legalese. Would I have to host repository snapshots once I publish in order to be in full compliance, or could I just host the patches?


答:
I think most people just copy the EUA from some big software package from a big scary company.

Remember to replace Microsoft/Orace/whoever with your own name! There was the case of a database+programming language tools company big in the 90s that famously forgot!

Title: Are there pre-made commercial software licenses to choose from?

Body: I currently have an open source project that is licensed under GPLv3.  I'd like to dual license it, so I can offer it for commercial use.  Are there any resources for choosing or creating a commercial software license?</p>


答:
It all depends on the customer.

A customer that likes quick and dirty (and usually cheaper) doesn't care that it will present problems in the future.

Think cabinet construction.

Some will pay, and appreciate, good quality custom built cabinets. They don't mind the extra expense of hardwood drawers and top notch hardware. They don't mind it will take an extra week or even month to build and install the things.

Many won't. Many will opt for the cheap particle board mass produced stuff you get from a big box store. They want them installed in 2 days. A small gap here and there is perfectly acceptable. They don't care that they will fall apart in 10 years.

So if your managers are praising the developer that gets it done quick and dirty then either your customers don't want high quality or the managers are lying to the customers.

Only time will tell. Do what the managers want or find another job.


问:
backup visual studio folder and sql database
I like to backup things every night or say every week. I'm sure there's a more efficient way than emailing the solution folder and database files to myself! I don't have team foundation or any commercial products like that. I'm looking for a freeware. </p>

答:
Based on the question, I'm guessing you don't use a version control system. There are a number to choose from and some are better suited for different things, but either SVN or Git are two strong options. The advantage to version control is that it allows you to track how your code changes, see the differences and easily step back if you need to.

As for actual back ups, there are a number of programs that will do regular back ups of directories so you are not in trouble if your hard drive dies. Here is a list of software that range from a manual process you can execute when you want and just puts a copy in another location to a full fledged automated system that will do everything and provide restore points. This all works on the more general backups of any file. The revision control I talked about earlier is geared more directly to source files and will be a bigger benefit.