答:
Objective-C has a lot of real market value.  I strongly suggest you start working on one of those iPhone apps you've been itching to write.  Do it now.

There are huge resources available to anyone wanting to learn object oriented programming in general and Objective-C in particular, many of them free.

In my opinion Objective-C kind of sucks, C++ is a way better language, and both are way better than the suckage that is Java.

But really, who cares what I think?  I'm not going to write that cool iPhone app you are thinking about, you are.

The market sees the thousands of really cool and useful programs being written in Objective-C, and rewards the developers who write them.  And  if Objective-C was truely sucky its unlikely that so many excellent programs could  have been written using it in the first place.

Title: Objective-C As A First OOP Language?


问:
Abstract exception super type
If throwing System.Exception is considered so bad, why wasn't Exception made abstract in the first place?

That way, it would not be possible to call:

```<code>throw new Exception("Error occurred.");
</code>```

This would enforce using derived exceptions to provide more details about the error that occurred.

For example, when I want to provide a custom exception hierarchy for a library, I usually declare an abstract base class for my exceptions:

```<code>public abstract class CustomExceptionBase : Exception
{
    /* some stuff here */
}
</code>```

And then some derived exception with a more specific purpose:

```<code>public class DerivedCustomException : CustomExceptionBase
{
    /* some more specific stuff here */
}
</code>```

Then when calling any library method, one could have this generic try/catch block to directly catch any error coming from the library:

```<code>try
{
    /* library calls here */
}
catch (CustomExceptionBase ex)
{
    /* exception handling */
}
</code>```

Is this a good practice?

Would it be good if Exception was made abstract?

EDIT : My point here is that even if an exception class is marked abstract, you can still catch it in a catch-all block. Making it abstract is only a way to forbid programmers to throw a "super-wide" exception. Usually, when you voluntarily throw an exception, you should know what type it is and why it happened. Thus enforcing to throw a more specific exception type.

答:
Possibility A: It's logically correct.

You are correct that Microsoft, along with many others do not suggest throwing a new Exception() directly for a plethora of reasons.

That being said, we can consider the academic ideal that the purpose of a the Exception class hierarchy is to define a narrowing effect so that only the most specific exceptions can be caught.  (i.e. ArgumentNullException is narrower than ArgumentException).

The Exception class is no exception (pun not intended).  It is intended to be the broadest possible exception, a "super exception" that almost cannot be caught because its scope is infinitely wide.  'Exception' it is not abstract in the sense that Exception cannot exist as an entity on its own.  It can (though admittedly no good cases are defined yet - see Possibility B), and therefore should be publicly constructible.

The 'abstract' keyword (in a purely academic sense) is only applicable when the base class makes no sense on its own - i.e. FourLeggedAnimal.

All of this in mind, there would be no technical reason to make the class abstract, other than to be a source of aggravation to developers.

Possibility B: Design Lock-in / They didn't know

If MS made this class abstract, they may have been in trouble if they changed their mind down the road, as this class is very essential to the fundamentals of the language.  They already goofed with ApplicationException, so it's foreseeable that they anticipated a change in recommendation down the road, too. (see Link)

There may be other reasons (I am thinking maybe this has to do with Reflection, or some other technical reason), so I am making this post a CW.

ContentLicense: CC BY-SA 3.0

Title: Abstract exception super type

ContentLicense: CC BY-SA 4.0


问:
Better control on code updates
I will briefly explain my situation.

I have a website in PHP, this website is powered by a custom framework + some "plug-in" made ad hoc for it.

I am the only developer of this. Until now I just test locally any changes than I upload the php files via FTP.

I don't feel confortable anymore with this. The code base has grown quite a lot and I need some sort of system that helps to keep track of changes (line by line) and can restore to an old version easly if something goes wrong.

Are there any good solution for this?

Note: I never used something like version control or subversion because I think they are too much for this situation (I am the only developer and I just need basic feature)

Note2: Something with a nice web interface would be perfect, I can pay for a good service too

As now I found:

http://beanstalkapp.com/

http://github.com/

http://www.codespaces.com/

http://codesion.com/

https://bitbucket.org/

答:
Version control will give you what you want. It will show you code changes and file differences. It will let you revert files to earlier versions. Some version control systems will also let you automate deployment, so you can label/mark the files you want to go into the next build and deploy only the ones that you've selected. Some version control systems also integrate defect tracking and management, so you can look at the problem ticket and the code change to fix it all on the same screen.

You don't have to use all of the advanced features of a version control system but the basic ones will certainly do what you want. Any other tool that gives you these features is just a different form of a version control system.

If you wait until the project is SO big that you do need it, it will be more difficult to implement and integrate. Do it now (yes, I know there's a bit of a learning curve at first but it will be worth it in the long run) while it's still not too much trouble to add to your process. Another reason to learn version control is that many larger companies use it. Not having it on your resume, or saying "huh?" when someone asks in an interview about what version control system you use could hurt you if you're evenly matched against other applicants in all other areas.

Title: Better control on code updates


答:
I think you should stop worrying and start to love version control. That you are just one person working on the code is not really relevant, as you have noticed there are still a lot of occasions when being able to go back in time and review changes are very valuable.

These days distributed version control like mercurial and git are what most people seem to talk about. If you are just starting with doing version control I think howvere subversion is probably easier to get started with. The svn book can be a good starting point.

Title: Better control on code updates

Body:
I will briefly explain my situation.

I have a website in PHP, this website is powered by a custom framework + some "plug-in" made ad hoc for it.

I am the only developer of this. Until now I just test locally any changes than I upload the php files via FTP.

I don't feel confortable anymore with this. The code base has grown quite a lot and I need some sort of system that helps to keep track of changes (line by line) and can restore to an old version easly if something goes wrong.

Are there any good solution for this?

Note: I never used something like version control or subversion because I think they are too much for this situation (I am the only developer and I just need basic feature)

Note2: Something with a nice web interface would be perfect, I can pay for a good service too

As now I found:

http://beanstalkapp.com/

http://github.com/

http://www.codespaces.com/

http://codesion.com/

https://bitbucket.org/


问:
Beginner's guide to writing comments?
Is there a definitive guide to writing code comments, aimed at budding developers?

Ideally, it would cover when comments should (and should not) be used, and what comments should contain.

This answer:

Do not comment WHAT you are doing, but WHY you are doing it.

The WHAT is taken care of by clean, readable and simple code with proper choice of variable names to support it. Comments show a higher level structure to the code that can't be (or is hard to) show by the code itself.

comes close, but it's a little concise for inexperienced programmers (an expansion on that with several examples and corner cases would be excellent, I think).

Update: In addition to the answers here, I think this answer to another question is highly relevant.

答: My suggestion would be to write some code without any comments whatsoever, and then walk away from it. Come back to it in a year and read it. The part that you don't understand easily is the part you should've commented. </p>

OwnerDisplayName: Cameron

Title: Beginner's guide to writing comments?


问:
Is there an open source license for this?
I have written code at home, on my own time and using my own knowledge and equipment, while under no contract or NDA.  I want to make this code open source so that I can use it in software I write for an employer, without denying myself the right to use it at home or elsewhere later.

I'm not sure if saying it is in the "public domain" would fit this purpose, or if I need to find an open source license.  I want anyone to be able to use the code in closed source proprietary software with zero requirements for including a license with the source or binary.  And I want to minimize the risk of anyone being sued for using it.  (I'm aware that one can never be 100% safe from being sued.)

Is there an open source license that fits this purpose?  To what extent is what I want to do even possible?

I wouldn't mind putting the license in comments in the code files themselves, but that obviously doesn't go with the binary.

答:
The Boost License seems to fit your bill nicely. It is aproved by the OSI.

From the Rationale for this License:

It was requested that a single Boost license be developed that met the traditional requirements that Boost licenses, particularly:

Must be simple to read and understand.

Must grant permission without fee to copy, use and modify the software for any use (commercial and non-commercial).

Must require that the license appear with all copies [including redistributions] of the software source code.

Must not require that the license appear with executables or other binary uses of the library.

Must not require that the source code be available for execution or other binary uses of the library.


答:
I don't know the actual reasons why it was done this way, and to a certrain degree I agree that preventing infintely wide exceptions from being thrown would be a good thing.

BUT... when coding small demo apps or proof-of-concepts, I don't want to start designing 10 different exception sub-classes, or spending time trying to decide which is the "best" exception class for the situation. I'd rather just throw Exception and pass a string that explains the details. When it's throw-away code, I don't care about these things and if I was forced to care about such things, I'd either create my own GenericException class and throw that everywhere, or move to a different tool/language. For some projects, I agree that properly creating relevant Exception subclasses is important, but not all projects require that.

Title: Abstract exception super type

Body:
If throwing System.Exception is considered so bad, why wasn't Exception made abstract in the first place?

That way, it would not be possible to call:

```<code>throw new Exception("Error occurred.");
</code>```

This would enforce using derived exceptions to provide more details about the error that occurred.

For example, when I want to provide a custom exception hierarchy for a library, I usually declare an abstract base class for my exceptions:

```<code>public abstract class CustomExceptionBase : Exception
{
    /* some stuff here */
}
</code>```

And then some derived exception with a more specific purpose:

```<code>public class DerivedCustomException : CustomExceptionBase
{
    /* some more specific stuff here */
}
</code>```

Then when calling any library method, one could have this generic try/catch block to directly catch any error coming from the library:

```<code>try
{
    /* library calls here */
}
catch (CustomExceptionBase ex)
{
    /* exception handling */
}
</code>```

Is this a good practice?

Would it be good if Exception was made abstract?

EDIT : My point here is that even if an exception class is marked abstract, you can still catch it in a catch-all block. Making it abstract is only a way to forbid programmers to throw a "super-wide" exception. Usually, when you voluntarily throw an exception, you should know what type it is and why it happened. Thus enforcing to throw a more specific exception type.


问:
Is it wise to ask about design decisions made on a product during an interview?
I've been thinking about interview questions lately and I've been reflecting on bad interview experiences I've had in the past. One of particular note is where I had asked the interviewer why the team chose to use EJB 3 over Spring in their product. The interviewer pretty much tore my face off, yelling "Because Spring is not the be all and end all of Java software development, do you want this job or not?".  In response to this, I told him that this probably wasn't the job for me and I promptly walked out of the interview.

I was informed at the beginning of the interview that the company had high staff turnover, the product they were working was initially created in Modula-3 then ported to Perl and finally to Java. I was handed a 10 page booklet of technical questions covering Java, EJB, SQL and JDBC and I was asked questions about the technology stacks I've worked with. When prompted to ask questions, I felt it was reasonable to ask them about their technology stack and and get reasonable answers back, not to send the interviewer into flames.

Question:
Is it a good idea to probe on architectural choices taken in an interview? If not, why?

From my own point of view, an interview is a two-way process. If the interviewers are testing me on my technical skills, I've got every right to ask them the same questions to:

1) Figure out what their mindset and attitudes towards developing software are.
2) Determine if their approach is in line with how I would approach problems of that kind.

It's possible that the interviewer who got angry had poor interviewing skills and forgot that an interview is a two-way exchange. If I was asked this, I would have given a reasonable answer, but I certainly wouldn't have tried to put an interviewee in a state of meek capitulation where the head just bobs up and down with no conversation.

答:
answer: It is a good idea to ask about architectural decision making. But you need to be careful how you ask such questions.

Simply put: You should ask "How did you go about choosing technology X over technology Y?".

You want to phrase it in a way to communicate that you are generally interested in the process of decision making within the team. Nobody will want to go over every legacy decision the company has ever made with a candidate.

When you ask "Why did you choose technology X over technology Y?", it may come off that you disagree with their decision (which is ok...but can be taken as hostile) or that you want to boast about how much you know about the technologies in question (which would be annoying for anyone), despite your good intentions.


答:
A few years back I was in an interview and had been asked various technical questions about a programming language... which I hadn't done well on (60/40 correct/incorrect). The discussion moved onto the project they had in hand and I started asking questions about the design and then pointed out a couple of problems and limitations they would introduce.

I was offered the job the next day. Unfortunately I was unable to take it up for personal reasons.

Asking questions about design shouldn't be a problem if they are intelligent questions especially if you can then relate them to their business.

Title: Is it wise to ask about design decisions made on a product during an interview?

Body:
I've been thinking about interview questions lately and I've been reflecting on bad interview experiences I've had in the past. One of particular note is where I had asked the interviewer why the team chose to use EJB 3 over Spring in their product. The interviewer pretty much tore my face off, yelling "Because Spring is not the be all and end all of Java software development, do you want this job or not?".  In response to this, I told him that this probably wasn't the job for me and I promptly walked out of the interview.

I was informed at the beginning of the interview that the company had high staff turnover, the product they were working was initially created in Modula-3 then ported to Perl and finally to Java. I was handed a 10 page booklet of technical questions covering Java, EJB, SQL and JDBC and I was asked questions about the technology stacks I've worked with. When prompted to ask questions, I felt it was reasonable to ask them about their technology stack and and get reasonable answers back, not to send the interviewer into flames.

Question:
Is it a good idea to probe on architectural choices taken in an interview? If not, why?

From my own point of view, an interview is a two-way process. If the interviewers are testing me on my technical skills, I've got every right to ask them the same questions to:

1) Figure out what their mindset and attitudes towards developing software are.
2) Determine if their approach is in line with how I would approach problems of that kind.

It's possible that the interviewer who got angry had poor interviewing skills and forgot that an interview is a two-way exchange. If I was asked this, I would have given a reasonable answer, but I certainly wouldn't have tried to put an interviewee in a state of meek capitulation where the head just bobs up and down with no conversation.


问:
Suggestions for getting an open source electron beam tracking code going
I work in the field of accelerator physics and synchrotron radiation. High energy electrons circulating in large rings of magnets produce x-rays that are used for a variety of different kinds of science.

Running and improving these facilities requires controlling and modelling the electron beam as it circulates in the ring. A code to model this basically requires trackers to follow the electrons through the elements (something called a symplectic integrator), and then the computation of different parameters associated with this motion. The problem with these codes is that every facility has there own (maybe 4-5 different codes, some with multiple versions). In principle the code is not so complex. And as a modelling project, one might think it has some general interest.  Who doesn't want to be able to create a track in space out of magnets and watch the electrons circulate?

There is a Matlab based code to do this called Accelerator Toolbox, but the creator of the code is no longer in the field. I put the code in Sourceforge under the name atcollab. The basic resource is a set of symplectic integrators written in C. These are then compiled into mex code and interfaced via Matlab. It has been useful to put the code on Sourceforge in order to exchange code, but the community of users is quite small and most are too busy to put that much time into collaboration. So in terms of really improving the code, I don't think it has been so successful.

Any piece of this picture could be recreated without that much difficulty, but overall it is a bit complex, and because each lab has their own installation with lots of added-on code and locally developed tools, people find it hard to really work together and share code. Somehow I think we need to involve a wider community in our development, or just use some standard tools. But for that, I suppose it needs to be of some general interest. I think symplectic integrators may have some general interest. And the part about a plug-in architecture to build up the ring ought to fit other patterns. Or the other option is to just accept that this is not a problem of general interest, and work harder within our small community.

Suggestions or anecdotes of analogous experience would be appreciated.

答:
I think that the main thing you need to do is make contacts with more people in similar positions at other scynchrotrons. Share your code and ideas with with more people and you may be able to get them to share their code with you, or at the very least contribute to improving your code.

If there isn't enough overlap between what the communal project is doing and what each individual lab does then you will find it difficult to motivate your existing collaborators, let alone bring in new ones. You may want to discuss with your current collaborators what can be done to help more people use the software in the project. Maybe some people prefer to do something in a slightly different way to how you do it at the moment and that is a barrier to their inclusion.

To find new collaborators, you could hunt through scientific papers published by synchrotrons around the world, looking for people doing the same sort of work you are doing. Another option is to go to conferences and make more contacts that way.

Diamond Light Source, the UK Synchrotron facility, decided to release it's user facing Data Acquisition and Scientific data analysis software under GPL a few years ago. The OpenGda website has allowed us to make contact with a number of synchrotrons around the world who are starting to deploy GDA onto beamlines at their facilities.

You may want to look at the Computational Science stack exchange site, it is turning into quite a useful resource.

Also, talking about open science, for a great example of crowdsource science, take a look at foldit. Harnessing the tenacity, intuition and ingenuity of gamers allows science do do things like Decode AIDS Protein That Stumped Researchers For 15 Years In Just 3 Weeks.


问:
Does unit testing lead to premature generalization (specifically in the context of C++)?

Preliminary notes

I'll not go into the distinction of the different kinds of test there are, there are already a few questions on these sites regarding that.

I'll take what's there and that says: unit testing in the sense of "testing the smallest isolatable unit of an application" from which this question actually derives

The isolation problem

What is the smallest isolatable unit of a program. Well, as I see it, it (highly?) depends on what language you are coding in.

Micheal Feathers talks about the concept of a seam: [WEwLC, p31]

A seam is a place where you can alter behavior in your program without editing in that place.

And without going into the details, I understand a seam -- in the context of unit testing -- to be a place in a program where your "test" can interface with your "unit".

Examples

Unit test -- especially in C++ -- require from the code under test to add more seams that would be strictly called for for a given problem.

Example:

Adding a virtual interface where non-virtual implementation would have been sufficient

Splitting -- generalizing(?) -- a (smallish) class further "just" to facilitate adding a test.

Splitting a single-executable project into seemingly "independent" libs, "just" to facilitate compiling them independently for the tests.

The question

I'll try a few versions that hopefully ask about the same point:

Is the way that Unit Tests require one to structure an application's code "only" beneficial for the unit tests or is it actually beneficial to the applications structure.

Is the code generalization that is needed to make it unit-testable useful for anything but the unit tests?

Does adding unit tests force one to generalize unnecessarily?

Is the shape unit tests force on code "always" also a good shape for the code in general as seen from the problem domain?

I remember a rule of thumb that said don't generalize until you need to / until there's a second place that uses the code. With Unit Tests, there's always a second place that uses the code -- namely the unit test. So is this reason enough to generalize?

答:
I am going to throw The Way of Testivus at you, but to summarise:

If you are spending a great deal of time and energy making your code more complicated to test a single part of the system, it may be that your structure is wrong, or that your testing approach is wrong.

The simplest guide is this: What you are testing is the public interface of your code in the way it is intended to be used by other parts of the system.

If your tests are becoming long and complicated, it's an indication that using the public interface is going to be difficult.

If you have to use inheritance to enable your class to be used by anything other than the single instance that it's currently going to be used for, then there's a good chance your class is too heavily tied into its usage environment. Can you give an example of a situation where this is true?

However, beware of unit-testing dogma. Write the test that allows you to detect the issue that will cause the client to shout at you.


答:
I've not done much interviewing, but, from your experience, I would conclude:

a) It's OK if you want to make an informed decision about whether you want the job;

b) It's not OK if you already decided you want the job.

People can easily get offended by benign quentions about their choices. That's an awfully bad trait, but a common one.


问:
Releasing an open source project without getting embarrassed
I've been working by myself on a fairly large open source project for quite a while and it's nearing the point where I'd like to release it. However, I'm self-taught and I don't really know anyone who could adequately review my project.

A few years ago, I had released a small bit of code which pretty much got ripped apart (in a critical sense) on the forum where I released it. Even though the code worked, the criticism was accurate but brutal. It prompted me to begin searching for best practices for everything and in the end I feel that it made me a much better developer. I've gone over everything in my project so many times trying to make it perfect that I've lost count.

I believe in my project and think it has the potential to help a lot of people and I feel like I've done some cool things in interesting ways with it. Still, because I'm self-taught, I can't help but wonder what gaps exist in my self-education. The way my code was ripped apart last time isn't something I'd like to repeat. I think my two biggest fears with releasing my project that I've poured countless hours into are being absolutely embarrassed because I missed some patently obvious things because of my self-education or, worse, releasing it to the sound of crickets.

Is there anyone who has been in a similar situation? I'm not afraid of constructive criticism, so long as it is constructive and not just a rant on how I screwed up. I know there is a code review site on StackExchange, but it's not really set up for large projects and I didn't feel like the community there is large enough yet to get good feedback if I were to post parts of my project piecemeal (I tried with one file). What can I do to give my project at least some measure of success without getting embarrassed or devestated in the process?

答:
Real code is always rotting and dirty, slapped together and maintained in an approximately ad hoc fashion. Cleanup is limited to documenting special cases and special constants. There is an impedance mismatch between clean code and the real world.

I also have noticed that any competent engineer can tear someone else's code apart.

If (1) it passes tests and gets the purpose done without failing AND (2) you can make minor changes with only minor rewrite, it's good code.


问:
How to improve your ability to debug existing code
A common task in the working world is dealing with existing, but buggy code. What are some tips to improve your skills as a debugger?</p>

答:
As others have said - do not assume anything. This is especially true if its code you've written. When debugging others code you are more likely to slow down because the code is new to you or you don't trust the coder. When debugging your own code its too easy to assume you wrote it correctly, slow down!

For the actual process of debugging:

Write unit tests if they don't already exists.

Add appropriate logging if doesn't already exist.

Then use the debugging.

Adding the unit tests and logging first more efficient that using the debugger first up. You also get the added advantage of having the unit tests to help not introducing future bugs and the logging will help debugging sessions in the future.

ContentLicense: CC BY-SA 2.5


问:
Is the term "web portal" obsolete?
My boss uses the term "portal" for the project I work on all the time.

To me, the word makes me think of Yahoo in the late 90s. Does the word "portal" have old-school connotations, or is it just me? Do you think it's ok to use it or will it drag our client's perception of the product down into the middle-ages?

答:
I don't think it's obsolete. In my experience, it's usually used to describe a particular type of website. Usually, a "portal" site is one that is not available to the public - you need to sign in to it, and it's also not always possible for the general public to even request access. I'm thinking banks, insurance companies, schools, etc... often refer to the websites that provide service exclusively to their customers/clients as "portals". This is how I am most familiar with the term because I have worked on a few projects that fit this definition and were definitely called portals by all involved. However, not all of the websites were called portals.

This definition is not always restricted to exclusive access, because I know some websites, like Yahoo!, like to call their landing page a "portal" to everything that is available via Yahoo!, and anyone can access the content of this portal. So a "portal" could be a site that is simply an entry point to other services provdided by the provider of the portal. The other services and portal could all be a part of the same, web application, or they could all be separate applications.

Maybe you're boss is using the term wrong and applying it to sites that don't fit any definition of "portal"?

Title: Is the term "web portal" obsolete?


答:
Portal can have old-school connotations though it is important to remember the context of the term.  For example, I remember in a couple of video games where there would be portals as a way to move a character around in a fictional world.  In my work environment, various departments will have "portal sites" that is how they communicate within the company that does make sense.

The key point is to make sure you understand all the nuances that may be meant within someone saying a portal as while there are search engine portals, there are also a whole lot of other ways to use the term that may or may not have been intended.  Ambiguous language can be annoying but this is why there are clarification questions to nail down to the context so that there isn't a misunderstanding.

Title: Is the term "web portal" obsolete?

Body:
My boss uses the term "portal" for the project I work on all the time.

To me, the word makes me think of Yahoo in the late 90s. Does the word "portal" have old-school connotations, or is it just me? Do you think it's ok to use it or will it drag our client's perception of the product down into the middle-ages?


答: "Portal" has two meanings in this case.  First, it can mean a sort of aggregation site (like your Yahoo example).  Second, it can mean a sort of site architecture, where the page is kind of a formatting container which takes data from "portlets" (or the equivalent).  It's often used to create dashboard-type sites where information from several different systems can be collected (a lot of Sharepoint sites are built like this).</p>

Title: Is the term "web portal" obsolete?


问:
Interpolation search vs Binary Search
When should I used interpolation search instead of binary search?

For example, I have a sorted dataset, in what situations would I use binary search to find an item in this dataset or in which situation should I used interpolation search?

What properties of the dataset would be the determining factor?

答:
I'd likely think the question is how easily can you come up with an interpolation function that actually does better than binary search.

From Wikipedia on Interpolation Search:

Using big-O notation, the performance of the interpolation algorithm
  on a data set of size N is O(N); however under the assumption of a
  uniform distribution of the data on the linear scale used for
  interpolation, the performance can be shown to be O(log log N).

Practical performance of interpolation search depends on whether the
  reduced number of probes is outweighed by the more complicated
  calculations needed for each probe. It can be useful for locating a
  record in a large sorted file on disk, where each probe involves a
  disk seek and is much slower than the interpolation arithmetic.

Index structures like B-trees also reduce the number of disk accesses,
  and are more often used to index on-disk data in part because they can
  index many types of data and can be updated online. Still,
  interpolation search may be useful when one is forced to search
  certain sorted but unindexed on-disk datasets.

Title: Interpolation search vs Binary Search


问:
To implement registration page with Vaadin or not?
This is a tactical implementation question about usage of Vaadin or in some part of my application.

Vaadin is a great framework to login users and implement sophisticated web applications with many pages. However, I think it is not very well suited to desgin pages to register new users for my application. Am I right? Am I am wrong?

It seems to me that a simple HTML/CSS/Javascript login + email registration + confirmation email with confirmation link cannot be implemented easily with Vaadin. It seems like Vaadin would be overkill. Do you agree? Or am I missing something?

I am looking for feedback from experienced Vaadin users.

答:
I had to make the same decision and went for a simple HTML login using plain servlets and templates. The rationale was:

1) We're using OpenID and I experienced some difficulty catching redirects from providers in a Vaadin app.

2) By managing security at the servlet level there is a reduced surface area for attack. You can just override getNewApplication in AbstractApplicationServlet to control access to the app.  This approach is recommended in this article: Creating Secure Vaadin Applications using JEE6


问:
Introducing Programming To a Mathematician
I currently am a programmer, I'm almost 16 years of age and have pretty much narrowed my careers down to something involving a Computer Science degree or Electrical Engineering degree (I know they are quite different but this question is about my friend) but my friend isn't so sure.

He is very interested in maths and is very good at it and I think he would enjoy programming but he isn't willing to try it (edit he is willing to try but has never done before). Can anyone give me an suggestions for a language or tool that he could dabble in programming (at a reasonably basic level I assume) to solve maths problems or involve some kind of maths.

As I say he enjoys maths a lot but I think he would enjoy programming, the problem is I don't want him to be put off by the stuff that isn't relevant at introductory levels such as memory allocation et al. I know that is very important but the point is that I want him to learn a bit of programming with maths then hopefully if he is interested enough he can start learning programming as programming.

Edit:
Its not that he's completely uninterested - more that he hasn't actively explored the area before, maybe because he isn't informed about it. I wouldn't want to force him to do something he doesn't want to, I see this as more of a little push so that he can learn about programming. If he doesn't like it - fair enough, I can't control that and don't want to but if he turns out to enjoy it - this push will have been the right thing.

答:
For mathematicians,  The greatest turn-on is Algorithms.
Your friend must start implementing them in Python ( its friendly ).

Numberical computing environments like MATLAB will be useful for matrix manipulations, plotting of functions and data, implementation of algorithms.


答:
If he majors in mathematics he then he will no doubt end up doing quite a bit of programming, if not in low level languages like C++, then in higher level, mathematics specific, languages like Maple or Mathematica depending on what he is doing.

Also, depending on his area of research he may end up doing applied mathematics or statical analysis, both of which will require a significant amount of programming. He better get used to programming now regardless on what he decides.

Title: Introducing Programming To a Mathematician

Body:
I currently am a programmer, I'm almost 16 years of age and have pretty much narrowed my careers down to something involving a Computer Science degree or Electrical Engineering degree (I know they are quite different but this question is about my friend) but my friend isn't so sure.

He is very interested in maths and is very good at it and I think he would enjoy programming but he isn't willing to try it (edit he is willing to try but has never done before). Can anyone give me an suggestions for a language or tool that he could dabble in programming (at a reasonably basic level I assume) to solve maths problems or involve some kind of maths.

As I say he enjoys maths a lot but I think he would enjoy programming, the problem is I don't want him to be put off by the stuff that isn't relevant at introductory levels such as memory allocation et al. I know that is very important but the point is that I want him to learn a bit of programming with maths then hopefully if he is interested enough he can start learning programming as programming.

Edit:
Its not that he's completely uninterested - more that he hasn't actively explored the area before, maybe because he isn't informed about it. I wouldn't want to force him to do something he doesn't want to, I see this as more of a little push so that he can learn about programming. If he doesn't like it - fair enough, I can't control that and don't want to but if he turns out to enjoy it - this push will have been the right thing.


问:
Production-safe SQL stored procedure debugging
We have an enormous number of nested SQL stored procedures, and a number of different ways of debugging them (varying from developer to developer).

So far, our methods include:

An optional @debug parameter, that
causes the procedure to
printmessages as it runs (passing
the variable down to called
procedures).

Checking @@servername against a
table of test server names, and
printing as above

Writing everything the procedure
does to a log table (in production
and test)

Which of these is preferable (and why), or is there a better method we've overlooked?

答: I prefer #1 personally. With an @debug flag you can specify if production code gets run or not, and I find print messages are one of the most helpful things to use when trying to figure out what is going on.


答:
There is a webmasters.SE, we're programmers and our sites are notoriously outdated, although not so much as the postdoc crew.

Do you mean, A) does the 'word' portal have any meaning today, or B) should you still design your sites around web portals?

The answer to A) is yeah, it's not an antiquated word, it's an antiquated technique.

The answer to B) is no, See A. (as in antiquated)

Title: Is the term "web portal" obsolete?


答:
Teach him Haskell. It's a language where you can think just as in mathematics:

A function is something that maps input to output

Stuff is evaluated as needed

Type inference and a crazy type system

Convenient syntax

Great community (for instance on StackOverflow)

Monads

I'd suggest you to show him http://learnyouahaskell.com, one of the best tutorials for Haskell.


答: Functional programming and languages in the ML family or Haskell tend to fit quite well the mathematicians' minds.</p>


答:
Binary search and interpolation search are both considered as linear search methods.

They both expect the list being searched to be sorted on the column refered to as the key. This is very important.

Binary search works for strings or numbers as long as they are stored in sorted order. The primary idea behind Binary search is that it is based on examining the middle element. Interpolation search is a variant. Instead of using the exact middle element it guesses where the next element to compare with passed value is. See the reference provided by JB King answer or the one below in this answer for details on how the interpolation search algorithm calculates the next key value.

"Interpolation search works only on numerical elements arranged in sorted arrays order with uniform distribution (that is, the interval between any to successive elements are roughly constant" (quote from reference below P 737, also a performance comparison between different linear search methods are included).

Google Books - Classic Data Structures 2Nd Ed.

Title: Interpolation search vs Binary Search

Body:
When should I used interpolation search instead of binary search?

For example, I have a sorted dataset, in what situations would I use binary search to find an item in this dataset or in which situation should I used interpolation search?

What properties of the dataset would be the determining factor?


答:
Obviously, to do an interpolation search, you need some type of key for which more than ordering is known -- you have to be able to do computations on the keys to estimate a likely distance, not just compare keys to determine which is greater or lesser.

As far as properties of the dataset go, it mostly comes to one property: a likelihood that the keys are reasonably evenly (or at least predictably) distributed throughout the range of possibilities. Without that, an interpolation search can actually be slower than a binary search.

For example, consider a data set with strings of lower-case letters as keys. Let's assume you have a key that starts with "x". An interpolation search will clearly indicate that you should start searching very close to the end of the set. If, however, most of your keys actually start with 'z', and almost none with anything from 'a' though 'y', the one you're searching for may actually be very close to the beginning of the set instead. It can/may take a considerable number of iterations before the search gets close to the beginning where the string starting with 'w' reside. Each iteration would remove only ~10% of the data set from consideration, so it would take several iterations before it got close to the beginning where the keys starting with 'w' actually reside.

By contrast, a binary search would start at the middle, get to the one-quarter mark at the second iteration, one-eighth mark on the third, and so on. Its performance would be nearly unaffected by the skew in the keys. Each iterations would remove half the data set from consideration, just as if the keys were evenly distributed.

I hasten to add, however, that it really does take quite a skewed distribution to make an interpolation search noticeably worse than a binary search. It can, for example, perform quite well even in the presence of a fair amount of localized clustering.

I should also mention that an interpolation search does not necessarily need to use linear interpolation. For example, if your keys are known to follow some non-linear distribution (e.g., a bell-curve), it becomes fairly easy to take that into account in the interpolation function to get results little different from having an even distribution.

Title: Interpolation search vs Binary Search


答:
If you want a "math-like" language, Haskell is your best friend (for your best friend). You can easily make new functions without hassle. It is the best language recommendation I can give you for you friend. Here are some links:

Try Haskell - An online Haskell compiler and tutorial.

Learn You A Haskell For Great Good! - This is how I learned Haskell.

How to write a Haskell program - The title is somewhat misleading, it is geared to get new programmers started.

Programming in Haskell (Book) - Never read it, but it looks pretty good!

Discrete Mathematics Using a Computer - THIS IS A GREAT BOOK FOR YOUR BUDDIES SITUATION

11 Reasons To Use Haskell - From a comment!

Mathematica

Wolfram's Mathematica is another interest he may have.

Mathematica is a computational software program used in scientific, engineering, and         mathematical fields and other areas of technical computing. It was conceived by Stephen   Wolfram and is developed by Wolfram Research of Champaign, Illinois.

Although it is expensive, it is worth it. Here are some links:

Mathematica "Home Page" - Probably where you should start.

Documentation - Learn and use Mathematica.

Hands-On Mathematica Tutorial - Great way to get started.

Algorithms

Algorithms are important for any program, but your buddy should start with these when he gets comfortable with a language. Here are some more links:

Algorithms by S. Dasgupta, C.H. Papadimitriou, and U.V. Vazirani - This is an online publication of a great book!

LaTeX/Algorithms and Pseudocode - Looks promising!

List of Algorithms (Wikipedia) - This is one of my favorite Wikipedia entries.

Hope this helps! If you have any questions or feedback feel free to comment! By the way, all of these links are to free resources. If you want a printed book, I have a few recommendations, just leave a comment!


答:
If your friend is unwilling to give programming a try, I don't see why you want to force the issue. I think a key to being a programmer is being willing to learn, and if he is unwilling to learn then programming is probably not for him

But that being said, your best bet might be to create a small program yourself and show it off to him. Perhaps leave some parts of it unfinished and see if you can get him interested in helping you finish it. I know for me, the algorithms and logic behind a program are far more interesting then writing out the syntax, so perhaps try and have him assist you with the logic of the program, and then you go and code the thing and let him see the results of it.

If he shows any interest at all in the source code, then show him how to write his own stuff. Personally I think the language itself doesn't matter as long as it's easy to learn and has plenty of documentation.


问:
Why did visual programming never take off and what future paradigms might change that?
As the number of "visual" OS's such as Android, iOS and the promised Windows 8 are becoming more popular, it does not seem to me that we programmers have new ways to code using these new technologies, due to a possible lack in new visual programming languages paradigms.

I've seen several discussions about incompatibilities between the current coding development environment, and the new OS approaches from Windows 8, Android and other tablets OS's. I mean, today if we have a new tablet, it's almost a requirement for coding, to have, for instance, an external keyboard (due it seems to me it's very difficult to program using the touch screen), exactly because the coding assistance is not conceived to "write" thousands of lines of code.

So, how advanced should be the "new" visual programming languages paradigms? Which characteristics these new paradigms would be required?

答:
"I'm afraid there've been no progress at all since LabView."

Good observation along with the other posting here, but the potential for visual (graphical) programming paradigms have only scratched the surface over the last several decades.  New computer science is overcoming many of the drawbacks while offering the potential to truly engage the powerful pattern matching capabilities of our minds in the development of software systems, especially in the emerging parallel programming domain space.  This new science is called Cubicon.  Here is a conceptual description of this technology:

Icon expressions form the Cubicon invention, whereas its meta-object representations form the Cubicon innovation, fusing form and function as one medium.  The development of Cubicon was self-contained.  It was based on the premise that traditional programming approaches are no longer producing sufficient advances. Cubicon takes each of the language constructs that comprises the vocabulary of syntax, semantics, and context - and substitutes a graphical representation for the traditional use of every one of them a new interpretation.  In short, Cubicon is a completely new graphical language, a new way of looking at the programming world, a clearly defined graphical algebra.  As a graphical innovation, Cubicon supports the construction of a program in terms of a framework, the fusion of objects with their surroundings, and the combination of several views of an object expressed as language elements in a cube.  This conceptual approach led naturally to a selection of simple geometric forms organized as interacting perspectives.  The value of this approach to programming lies not only in the presentation of the language elements, but also in the dynamism that emerges from their composition, one that is perfectly controlled.

The ‘art’ of software development can evolve more quickly into a true ‘science’ through the wide adoption of Cubicon.  Its science could lead to the third “killer app” category beyond the management of ‘words’ and ‘equations’: empowering a wide segment of the population with the ability to personally develop and manage general systems.  This theory characterizes any system by the interactions of its components and the nonlinearity of those interactions.

Expressing abstractions such as a cat, mammal, and animal taxonomy in programming language words does not convey a sense of context in general systems.  A ‘picture can be worth a thousand words’ with intuitive graphical abstractions.  Cubicon leverages a basic human capacity to effectively deal with spatial information in the expression of general systems as a sharable mental Cube Model.  Cubicon is a multiple paradigm language, enabling a domain expert to express intricate program structure and behavior in a completely syntax-driven and semantically bound declarative environment that effectively abstracts away the underlying computational engine much like an electronic spreadsheet.

The Cube Model has seven principle perspectives expressed as multiple schemata:

Topic Map - Graph substrate for topics and their associations

Genealogy - Ontology schema of concepts and templates

Composition - Parts-of-a-whole schema between collections

Network - Links between objects that carry messages

Collaboration - Directory of all software components and their dependencies with other communities

Image - Graphical user interface

Behavior (cube center) - Process-flow, control-flow, and finite state machine (FSM)

The Cubicon IDE also includes additional perspectives that collectively are used to capture, map and execute human intent within an immersive environment.  General systems can be simulated in high definition where any selected language element can be instantly viewed from multiple perspectives, always remaining agile for recombination as system requirements change over time.

Declarative programming has been applied through many graphical dataflow-based languages over the years.  These languages present prepackaged 'what' behavior in higher-level abstraction icons that can be connected through ‘wires.’  The challenge of this approach is the need for a source organization to support an explosion of icon types to cover all possible use cases.  Placing the burden on their developer community to customize the icon 'how' behaviors requires a novice to crack open an icon into a scripting language.  Thus, this approach defeats the original purpose of the declarative approach to shield the domain expert from this far less constrained text expression.  Getting to an equivalent declarative approach like a spreadsheet requires a different approach for use in programming of general systems.

Instead of abstracting the ‘how’ away, the extended applied research work in Cubicon’s development tackled the task of fully automating imperative programming.  This is where a micromachine-based language was an effective solution.  It enables a domain expert to express intricate logic in a highly automated environment.  Cubicon pushes the declarative language style down through control-flow and into the finite state machine (FSM) level of abstraction.  Real-time execution is performed under a synchronous reactive model of computation (MoC) that guarantees deterministic interactions with the ambient environment.  Not rocket science, just an exhaustive meta-design performed by decomposing the abstractions that comprise general systems, essentially removing the mystery out of working with the low-level programming 'gears and springs.'

OwnerDisplayName: Rego


问:
What is (are) the most useful technique/visualization for overall project status?
For reasons "above my pay grade", we're developing an issue/project tracking system where I work (similar to Trac, FogBugz, etc). The managers want a useful tool to be able to track the overall health of the project (e.g. How much time left, how are we performing vs estimates) and one of the features that has been requested is some type of critical path support and visualization.

The logic explained to me is that they want to be sure that at least the most important pieces of the project are currently being worked on. The initial idea was that we would create task-based dependencies. My understanding of project management tells me that this kind of granular approach is unnecessary - having milestones with specific deadlines/dependencies is much more useful.

I would like to know what are the most useful techniques and "pretty pictures" you've seen/used for project development. Having objective data would be best, but somewhat subjective data is helpful too.

答: Personally I think the different kind of burn-down charts used in agile projects are incredibly powerful as they answer the basic question of "if the project continues to run as it has, when are we done?". In projects I usually use burn-downs for the current sprint and for the entire release. Estimates used to produce the release burn-down are of course less exact but all in all they tend to predict the delivery pretty well.</p>


答:
I'd say some of this relates to your corporate culture and the aspects of development that you need to measure most.  No one can measure everything, so you have to find and monitor the sweet spots that are most likely to benefit your business.

Here's a few I've found helpful at various times:

Burndown charts - for Agile project especially - requires that developers are constantly evaluating and reporting their status, how long tasks will take to complete and the entirety of tasks in a short cycle.  If you are doing a waterfall development process, burndown for a phase can still be helpful, but only if the status reporting is really accurate - often waterfall projects are so burdened with paperwork that getting a straight status-related answer is painful and even impossible, which greatly reduces the value of this type of chart.

Bugs found/fixed per unit of time - useful especially in situations where high quality is needed - usually a chart with # bugs on the horizontal access and time in units (like weeks) from left to right.  There are two lines - # of bugs found each week, # of bugs resolved each week.  In a typical waterfall process, this will show - a steady and then a sharp rise in bugs found per week, which eventually tapers off as testers start hitting diminishing returns (in other words, they have to get more and more creative to find those last few bugs).  Then the # of bugs fixed line will at first keep pace a bit behind the # bugs found.  Eventually it will lag as a backlog is accumulated and the fixers are slammed with work.  As the testers slow down, the fixers catch up, and the two start to asymptotically approach some final point.  Somewhere around that flattening is when the product can be released - different companies have different metrics for what level of this is alpha, beta, etc.  This works well in a waterfall, tradtionally driven process, where quality expectations are high and the requirements are considered sacred.  Gets harder in sprints where you are changing the requirements every time.

SLA type metrics - how fast is the team responding to issues?  I know less about this type of monitoring, but in a QA of a live system with actual users, this is king - no matter what your development process is, the nature of how you support customers will define the perception of your product's quality, so responding to, communicating with, and fixing problems for customers in a timely manner with a minimum of cost is a big deal.

As an anti-recommendation - if I had my druthers, I'd avoid anything having to do with "lines of code" (LOC) - such as SLOC (source LOC), ELOC (estimated LOC) and other horrible acronyms.  Some companies are stuck to this form of metric, because 20 years ago, it was the way it was done and they have a huge historical repository.  These days, the meaning of 1 LOC and the work required to develop and sustain it can change radically and constantly - not just as programming languages evolve, but also as APIs change, how auto-generated code is created and maintained and other aspects of programming work.  Every time I see a system of metrics with LOC at it's base, I shudder, because I never see it yield accurate results and I see an unbearable amount of time expended trying to justify this lack of accuracy.   Most LOC related systems focus on the turn around between the accuracy of predictions (how big?  How hard to make?) in comparison to the actual outcome.  I think there's better, less formal, ways to do this -- like story points -- that will yeild good results.  The key to any prediction-accuracy tracking system is that the people making the predictions need to have a palpable way of experiencing the accuracy of those predictions if they are to be better estimators in the future.  For me, estimation in man-weeks or story points has been just as useful...

Note - I don't disagree with metrics about prediction accuracy - I think those can be incredibly helpful - especially in a constracting environment where prediction and customer expectation setting are a big part of the project's success.

Title: What is (are) the most useful technique/visualization for overall project status?

Body:
For reasons "above my pay grade", we're developing an issue/project tracking system where I work (similar to Trac, FogBugz, etc). The managers want a useful tool to be able to track the overall health of the project (e.g. How much time left, how are we performing vs estimates) and one of the features that has been requested is some type of critical path support and visualization.

The logic explained to me is that they want to be sure that at least the most important pieces of the project are currently being worked on. The initial idea was that we would create task-based dependencies. My understanding of project management tells me that this kind of granular approach is unnecessary - having milestones with specific deadlines/dependencies is much more useful.

I would like to know what are the most useful techniques and "pretty pictures" you've seen/used for project development. Having objective data would be best, but somewhat subjective data is helpful too.


答:
I agree with the Haskell, but from a practical point of view, he should also learn a language on a widely used abstract machine.  I mean a JVM language or .NET language of course.

There are languages on these platforms that are a little more interesting than the flagship languages. On the JVM have a look at Clojure and Scala.  On the .NET platform have a look at F#.

There was also a .NET language from Microsoft Research called c-omega which was very interesting, but is was just a research project.


答:
To be successful in this task, I would proceed as follows:
(1) Specify KPIs to be presented for each type of management level (I guess in your case, you will have 1)

(2) Distill KPIs (e.g. LOC is to be avoided as indicated by bethlakshmi's post). Also, you need to ensure that the data reported is something you can produce or calculate accurately using the tools you have.

(3) Determine how you plan to collect, calculate and accumulate the data up-to-date and make sure this process is counted for in your project plan (sounds like a data-mart work)

(4) Specify the best representation to use to present the information (this is what your question is about) and do a prototype the looks to be approved by managers.

I would recommend a dashboard style presentation (see sample image below - I know it is not fancy!)

A better one can be found at Telerik-TeamPlus Tool

Now as per (4), you have already identified some KPIs. Next thing is to categorized the KPIs in groups (e.g. Overall Status, Financial Status, Staffing Status, Task Status)
Each group could be represented by a screen/page/Excel tab, etc.

In addition to Burndown charts mentioned by other responders, you may want to Use 1 or more Gantt Charts to show:
1 - Overall very high level project dependency
2 - Milestones for the on-going reporting period and its neighborhood (say current month and 1 month before and after)

Software to use and visualization capabilities greatly depends on what you have, what you can afford, where your current data is, how do you plan to publish the information, etc.

The list to choose from is long (Telerik-TeamPlus Product, MS-Project, Zoho Reports, Zoho Projects, Project Dashboard, among others of course)


答:
The best way to encourage your friend to try it might be to have him start programming without thinking too much about the fact that he's programming.

Once he's ready to deal more with "programming", you could both start with the same book and learn programming from a more mathematical foundation.  Two of my current favorite books are:

"Structure and Interpretation of Computer Programs" SICP (Abelson/Sussman)

"Land of Lisp: Learn to Program in Lisp, One Game at a Time!" (Barski), teaches programming through game programming exercises.

SICP is freely viewable at the MIT Press web site.

If your friend is mathematically inclined, Lisp will present no difficulty, and it frees you from having to learn any special syntax.  I think Lisp is easier to learn than Haskell.


答:
It depends on the area of mathematics he is interested in.

If he is more into Abstract Algebra or Combinatorics, he would probably like Haskell as the complex type system allows for direct programming of a variety of mathematics. ATS might also be an option.

I'd recommend Learn You a Haskell for a Great Good for an intro tutorial and Purely Functional Data Structures for Algorithms.

If he is more into Matrix Analysis, Differential Equations or Dynamical Systems, I'd recommend Matlab, NumPy, or Octave. APL is via Dyalog might also be of interest; though I'd not start him on that. Numerical Recipes, while in C++ can be adapted to serve as a good guide to algorithms.

If he wants to do Statistics then R is the natural choice.


问:
Is there a proven concept to website reverse certificate authentication?
We're looking at exposing some of our internal application data externally via a website. The actual details of the website aren't that interesting, it'll be built using ASP.NET/IIS etc, that might be relevant. With this, I'm essentially I'm looking for a mechanism to authenticate users viewing my website.

This sounds trivial, a username/password is typically fine, but I want more. Now I've read plenty about SSL/x.509 to realise that the CA determines that we're alright, and that the user can trust us. But I want to trust the user, I want the user to be rejected if they don't have the correct credentials.

I've seen a system for online banking whereby the bank issues a certificate which gets installed on the users' computer (it was actually smartcard based). If the website can't discover/utilise the key-pair then you are immediately rejected!

This is brutal, but necessary. Is there a mechanism where I can do the following:

Generate a certificate for a user

Issue the certificate for them to install, it can be installed on > 1 machine

If their certificate is not accessible, they are denied all access

A standard username/password scheme is then used after that

SSL employed using their certificate once they're "in"

This really must already exist, please point me in the right direction! Thanks for your help :)

答:
There absolutely is a mechanism that exists for doing this: HTTPS.

(I know what you're thinking--read to the end of the post before you decide it is not what you want!)

First, HTTPS is merely HTTP built on top of SSL, so having an in depth understanding of SSL will be beneficial.

Normally, SSL connections used on the web are only concerned with authenticating the server. However, there is a way that the server can authenticate the client as well by being its own CA and issuing a certificate to the client. This feature was built into the SSL protocol as an optional step in the event that you want 2 way authentication (much like what you are requesting).

Here's a BROAD picture of how it works:

The client initiates a connection with the server, requesting its certificate.

The server responds by sending its certificate back to the client. An optional part of this step is that the server can also challenge the client by requesting a certificate. Most websites do not do this. This is what you want to enable on your site.

The client authenticates the server's certificate is valid by using the CA's public key to decrypt the certificate (if the data matches, then it is known that the certificate had to come from the CA, as only the CA has the private key to generate certificates).

The client sends a symmetric key to the server (encrypted using a public key within the server's certificate). If the server requested a certificate, the client also sends its certificate to the server.

The server authenticates the client. Usually this occurs by the server itself assuming the role of the CA and determining that the certificate did in fact come from this server. This step only occurs if the server challenged the client.

Using the encrypted symmetric key that the client sent, the server determines what the symmetric key wil be and sends a confirmation back to the client.

At this point the handshake is done. All further correspondence occurs using a simple symmetric key encryption algorithm.

Now comes the question: How does the client get the certificate in the first place? First of all, you need a secure way to issue a certificate. You mentioned smart cards (which can be good. A simple jump drive is good too as long as you are certain it will not fall into the wrong hands). If we are talking CIA-level security, then there is no easy (or cheap) answer to how to distribute the certificate--you will have you use your own judgement and do your homework on this one.

Once the user has the certificate, every major operating system has mechanisms for installing the certificate so that your computer will be smart enough to respond automatically with the correct certificate. Finding information on how to do this shouldn't be tough (I did it before and don't remember too many problems finding information on the subject).

Unfortunately, I have only ever dealt with being a client when working with this, but these links (and anything else that shows up under a google search for "SSL Client Authentication") should help you out:

http://msdn.microsoft.com/en-us/library/aa922016.aspx

http://www.freebsddiary.org/openssl-client-authentication.php

http://code.activestate.com/recipes/117004-ssl-client-authentication-over-https/

I assume that you already know that this will bring headaches to your clients, so only do this if you are 100% certain that a simple web login with the more basic HTTPS encryption is not what you want.

Best of luck, and hope this helps.


问:
What is the difference between these senior software engineer titles?
I'm currently a senior research software engineer at a large company and am being offered a "senior staff engineer" position somewhere else. I am not sure if the new position's title conveys a sideways move or an advancement.

So, all other things being roughly equal (salary, domain of expertise, etc.), what is the external difference between these software engineer titles (in general and regardless of any particular company, if possible):

senior engineer

senior research engineer

senior staff engineer

member of technical staff

principal engineer

Edit:
Let me elaborate on "member of technical staff" since it's kind of uncommon. I think it's a high title, commonly associated with research. I know that Oracle, VMWare, and the old Bell Labs have these titles. See: Member of Technical Staff . I know what it means, but I don't know how it stacks up against the other titles, which is why I asked.

答: AT&T uses member of technical staff titles. They are assigned to solutions architects that are doing research work, architecture solutions etc. senior research engineer and senior engineer will differ based on company, but obviously research will be primary focus for senior research engineer. senior staff engineer and principal engineer are meaningless titles that will very widely based on industry, company and type of work you will be engaged in. As far as how these titles stack up you will figure that from pay you are offered vs size of the company and what is excepted of you. If I was in your shoes and there is no diff in pay and you are happy where you are why change? risk is there and there is no extra gain? All of these will be paid from $80K to $130K depending on company and city you are in. </p>


答: There is a whole free mathematical library and community built up around Python.  I'd start with "Sage", he should really enjoy using it and will learn Programming in Python incidentally. </p>


答: This is almost the goal of Facebook, so I wouldn't say the concept is obsolete.  The term, perhaps.  Just like in the late 90's many products were the "__ 2000".  It's a marketing term, and comes and goes in the cycles of that trade (next to go/going... Web 2.0 and a bit after that the practice of labeling everything under the sun "social").

Title: Is the term "web portal" obsolete?


答:
The longer I've been in this game, the more I've come to realize that the only measure of code quality is the client experience.  If you're writing a function, it's the caller of that function.  A library?  The devs who write for that library.  A framework?  The adopters of it.  A standalone?  The person or daemon who launches the program.

Nice code has its virtue, don't get me wrong- but when it's said and done the only measure is "Does it work?"  I've seen plenty of clean code that is a buggy mess, and plenty of satanically deranged code which is completely reliable (plus good clean and bad ugly too :) )

So, if the critics say your code is ugly, who cares.  If they say it doesn't work- that's the useful criticism (testing data!) which you seek to improve your program.  Hang in there, avoid the internet's population of trolls, and have fun on your project!

Title: Releasing an open source project without getting embarrassed

Body:
I've been working by myself on a fairly large open source project for quite a while and it's nearing the point where I'd like to release it. However, I'm self-taught and I don't really know anyone who could adequately review my project.

A few years ago, I had released a small bit of code which pretty much got ripped apart (in a critical sense) on the forum where I released it. Even though the code worked, the criticism was accurate but brutal. It prompted me to begin searching for best practices for everything and in the end I feel that it made me a much better developer. I've gone over everything in my project so many times trying to make it perfect that I've lost count.

I believe in my project and think it has the potential to help a lot of people and I feel like I've done some cool things in interesting ways with it. Still, because I'm self-taught, I can't help but wonder what gaps exist in my self-education. The way my code was ripped apart last time isn't something I'd like to repeat. I think my two biggest fears with releasing my project that I've poured countless hours into are being absolutely embarrassed because I missed some patently obvious things because of my self-education or, worse, releasing it to the sound of crickets.

Is there anyone who has been in a similar situation? I'm not afraid of constructive criticism, so long as it is constructive and not just a rant on how I screwed up. I know there is a code review site on StackExchange, but it's not really set up for large projects and I didn't feel like the community there is large enough yet to get good feedback if I were to post parts of my project piecemeal (I tried with one file). What can I do to give my project at least some measure of success without getting embarrassed or devestated in the process?


答:
You've reached a good realization about tradeoffs in language design.  Some of the core design decisions in C++ (the virtual function mechanism mixed with the static function call mechanism) make TDD tough.  The language doesn't really support what you need to make it easy.  It is easy to write C++ that is nigh impossible to unit test.

We've had better luck doing our TDD C++ code from a quasi-functional mindset- write functions not procedures (a function that takes no arguments and returns void), and use composition wherever possible.  Since its tough to substitute these member classes, we focus on testing those classes to build a trusted base, and then know that basic unit functions when we add it to something else.

The key is the quasi-functional approach.  Think about it, if all your C++ code was free functions that accessed no globals, that would be a snap to unit test :)

Title: Does unit testing lead to premature generalization (specifically in the context of C++)?

Body:
Preliminary notes

I'll not go into the distinction of the different kinds of test there are, there are already a few questions on these sites regarding that.

I'll take what's there and that says: unit testing in the sense of "testing the smallest isolatable unit of an application" from which this question actually derives

The isolation problem

What is the smallest isolatable unit of a program. Well, as I see it, it (highly?) depends on what language you are coding in.

Micheal Feathers talks about the concept of a seam: [WEwLC, p31]

A seam is a place where you can alter behavior in your program without editing in that place.

And without going into the details, I understand a seam -- in the context of unit testing -- to be a place in a program where your "test" can interface with your "unit".

Examples

Unit test -- especially in C++ -- require from the code under test to add more seams that would be strictly called for for a given problem.

Example:

Adding a virtual interface where non-virtual implementation would have been sufficient

Splitting -- generalizing(?) -- a (smallish) class further "just" to facilitate adding a test.

Splitting a single-executable project into seemingly "independent" libs, "just" to facilitate compiling them independently for the tests.

The question

I'll try a few versions that hopefully ask about the same point:

Is the way that Unit Tests require one to structure an application's code "only" beneficial for the unit tests or is it actually beneficial to the applications structure.

Is the code generalization that is needed to make it unit-testable useful for anything but the unit tests?

Does adding unit tests force one to generalize unnecessarily?

Is the shape unit tests force on code "always" also a good shape for the code in general as seen from the problem domain?

I remember a rule of thumb that said don't generalize until you need to / until there's a second place that uses the code. With Unit Tests, there's always a second place that uses the code -- namely the unit test. So is this reason enough to generalize?


问:
Real-time chat in Ruby on Rails without owning a server
I'd want to implement a Real-time chat for my Rails app but I can't really host the server which handles the sockets. I've tried Faye but it needs a server. I've also heard of pusher but it's limited to 20 users at a time on the chat and I can't really be sure they won't be more.

I've thought of IRC but I think I can't really embed it into a rails app, maybe it needs sockets...

How can I implement a real-time chat without owning a server?

答:
Why are you not able to host it yourself? Is it the cost of hosting?

You could try Socket.IO running on Node.JS, hosted on a free Heroku account. The HTML would remain in your rails app, but the "web socket server" (technically a long-polling server in the case of Heroku) would be running on a free Heroku account.

Other than that, I'm not sure what you are asking. In order to host a website, you need a web host. In order to host a chat server, you need a server to host it on.


问:
Does anyone else have a refactoring problem?
It seems like after I've written a significant amount of code I get this anxious feeling like I haven't done it in the best possible way, and I end up continuously refactoring and spending way too much time on the project, or never getting it done sometimes. Does this ever happen to anyone else, and how do you deal with this?</p>

答:
There is no doubt I fall into this trap but some refactoring is important for the future support/debugging.

When writing a major piece of code it becomes very easy to keep through lines of code into the method that's currently being written. When I've completed a major piece of code I place a todo: code review comment. Then a few days later I'll do the code review and refactor accordingly. If I have trouble reading it a few days later what's going to happen in a few months or even years.


问:
How large is ok for a Class?
I’m a long time developer (I’m 49) but rather new to object oriented development. I’ve been reading about OO since Bertrand Meyer’s Eiffel, but have done really little OO programming.

The point is every book on OO design starts with an example of a boat, car or whatever common object we use very often, and they start adding attributes and methods, and explaining how they model the state of the object and what can be done with it.

So they usually go something like "the better the model the better it represents the object in the application and the better it all comes out".

So far so good, but, on the other hand, I’ve found several authors that give recipes such as “a class should fit in just a single page” (I would add “on what monitor size?" now that we try not to print code!).

Take for example a PurchaseOrder class, that has a finite state machine controlling its behavior and a collection of PurchaseOrderItem, one of the arguments here at work is that we should use a PurchaseOrder simple class, with some methods (little more than a data class), and have a PurchaseOrderFSM “expert class” that handles the finite state machine for the PurchaseOrder.

I would say that falls in the “Feature Envy” or “Inappropriate Intimacy” classification of Jeff Atwood's Code Smells post on Coding Horror. I’d just call it common sense. If I can issue, approve or cancel my real purchase order, then the PurchaseOrder class should have issuePO, approvePO and cancelPO methods.

Doesn’t that goes with the “maximize cohesion” and “minimize coupling” age old principles that I understand as cornerstones of OO?

Besides, doesn’t that helps toward the maintainability of the class?

答:
Issuing a purchase order is often a complicated process that involves more than just the purchase order.  In this case, keeping the business logic in a separate class and making the purchase order simpler is probably the right thing to do.  In general, though, you're right -- you don't want "data structure" classes.  For example, your "POManager" business class' issue() method should probably call the PO's issue() method.  The PO can then set its status to "Issued" and note the issue date, while the POManager can then send a notification to accounts payable to let them know to expect an invoice, and another notification to inventory so they know there's something coming in and the expected date.

Anybody who pushes "rules" for method/class size obviously hasn't spent enough time in the real world.  As others have mentioned, it's often a refactoring indicator, but sometimes (especially in "data processing"-type work) you really do need to write a class with a single method that spans 500+ lines.  Don't get hung up on it.

Title: How large is ok for a Class?


问:
Where we should put validation for domain model
I still looking best practice for domain model validation. Is that good to put the validation in constructor of domain model ?  my domain model validation example as follows:

```<code>public class Order
 {
    private readonly List<OrderLine> _lineItems;

    public virtual Customer Customer { get; private set; }
    public virtual DateTime OrderDate { get; private set; }
    public virtual decimal OrderTotal { get; private set; }

    public Order (Customer customer)
    {
        if (customer == null)
            throw new  ArgumentException("Customer name must be defined");

        Customer = customer;
        OrderDate = DateTime.Now;
        _lineItems = new List<LineItem>();
    }

    public void AddOderLine //....
    public IEnumerable<OrderLine> AddOderLine { get {return _lineItems;} }
}

public class OrderLine
{
    public virtual Order Order { get; set; }
    public virtual Product Product { get; set; }
    public virtual int Quantity { get; set; }
    public virtual decimal UnitPrice { get; set; }

    public OrderLine(Order order, int quantity, Product product)
    {
        if (order == null)
            throw new  ArgumentException("Order name must be defined");
        if (quantity <= 0)
            throw new  ArgumentException("Quantity must be greater than zero");
        if (product == null)
            throw new  ArgumentException("Product name must be defined");

        Order = order;
        Quantity = quantity;
        Product = product;
    }
}
</code>```

Thanks for all of your suggestion.

答:
As I'm sure you already know...

In object-oriented programming, a constructor (sometimes shortened to
  ctor) in a class is a special type of subroutine called at the
  creation of an object. It prepares the new object for use, often
  accepting parameters which the constructor uses to set any member
  variables required when the object is first created. It is called a
  constructor because it constructs the values of data members of the
  class.

Checking validity of the data passed in as c'tor parameters is definitely valid in the constructor - otherwise you're possibly allowing the construction of an invalid object.

However (and this is just my opinion, can't find any good docs on it at this point) - if data validation requires complex operations (such as async operations - perhaps server-based validation if developing a desktop app), then it's better put in an initialization  or explicit validation function of some sort and the members set to default values (such as null) in the c'tor.

Also, just as a side note as you included it in your code sample...

Unless you're doing further validation (or other functionality) in AddOrderLine, I'd most likely expose the List<LineItem> as a property rather than have Order act as a facade.


问:
How to obtain an affordable electronic paper programmable kit or similar?
I'm really interested in playing around with the electronic paper technology, but I don't really want to program any commercial device (kindle or whatever).

I have some ideas and I want to start. How do I get a screen of electronic paper, a chip and how to start programming for it (language, interface)

答:
The older versions of the nook can be fairly easily rooted allowing you basically full access for less than $100. They don't have much in the way of horsepower they run android as a base operating system and I've heard they can run other flavors of Linux once rooted via micro SD card. You could easily take the device apart and mount it however you like, it's not difficult.

E-Ink does sell developer kits to make your own but they drift into the $1500 range.


问:
What does 'stage' mean in git?
I find git hard to understand as I could not find the meaning of the words used for the actions. I have checked the dictionary for the meaning of 'stage' and none of the meanings were related to source control concepts.

What does 'stage' mean in the context of git?

答:
To stage a file is to prepare it for a commit. Because git exposes this action to the users control it allows you to create partial commits, or to modify a file, stage it, modify it again, and only commit or revert to the original modification.

Staging allows you finer control over exactly how you want to approach version control.

Title: What does 'stage' mean in git?


问:
Is it good idea to require to commit only working code?
Sometimes I hear people saying something like "All committed code must be working". In some articles people even write descriptions how to create svn or git hooks that compile and test code before commit.

In my company we usually create one branch for a feature, and one programmer usually works in this branch. I often (1 per 100, I think and as I think with good reason) do non-compilable commits. It seems to me that requirement of "always compilable/stable" commits conflicts with the idea of frequent commits. A programmer would rather make one commit in a week than test the whole project's stability/compilability ten times a day. For only compilable code I use tags and some selected branches (trunk etc).

I see these reasons to commit not fully working or not compilable code:

If I develop a new feature, it is hard to make it work writing a few lines of code.

If I am editing a feature, it is again sometimes hard to keep code working every time.

If I am changing some function's prototype or interface, I would also make hundreds of changes, not mechanical changes, but intellectual. Sometimes one of them could cause me to carry out hundreds of commits (but if I want all commits to be stable I should commit 1 time instead of 100).

In all these cases to make stable commits I would make commits containing many-many-many changes and it will be very-very-very hard to find out "What happened in this commit?".

Another aspect of this problem is that compiling code gives no guarantee of proper working.

So is it good idea to require every commit to be stable/compilable?

Does it depends on branching model or CVS?

In your company, is it forbidden to make non compilable commits? Is it (and why) a bad idea to use only selected branches (including trunk) and tags for stable versions?

答: Ask yourself what would happen if you committed halfway through a large refactoring effort, then got hit by a bus. What would the other people on your team do? You might be interested in Git; with Git, you can make commits locally, then push those commits in bulk to the server. Even if your server doesn't use Git, you can use it to stage commits locally before pushing to something like CVS or SVN.</p>

OwnerDisplayName: Astronavigator

OwnerDisplayName: Jeff Kelley


答: I would say it depends on the branch where the commit is made.  A feature branch may well contain broken commits, but anything committed or merged to a master or a maintenance branch should compile and pass the testsuite (if there is one).</p>

Title: Is it good idea to require to commit only working code?

Body:
Sometimes I hear people saying something like "All committed code must be working". In some articles people even write descriptions how to create svn or git hooks that compile and test code before commit.

In my company we usually create one branch for a feature, and one programmer usually works in this branch. I often (1 per 100, I think and as I think with good reason) do non-compilable commits. It seems to me that requirement of "always compilable/stable" commits conflicts with the idea of frequent commits. A programmer would rather make one commit in a week than test the whole project's stability/compilability ten times a day. For only compilable code I use tags and some selected branches (trunk etc).

I see these reasons to commit not fully working or not compilable code:

If I develop a new feature, it is hard to make it work writing a few lines of code.

If I am editing a feature, it is again sometimes hard to keep code working every time.

If I am changing some function's prototype or interface, I would also make hundreds of changes, not mechanical changes, but intellectual. Sometimes one of them could cause me to carry out hundreds of commits (but if I want all commits to be stable I should commit 1 time instead of 100).

In all these cases to make stable commits I would make commits containing many-many-many changes and it will be very-very-very hard to find out "What happened in this commit?".

Another aspect of this problem is that compiling code gives no guarantee of proper working.

So is it good idea to require every commit to be stable/compilable?

Does it depends on branching model or CVS?

In your company, is it forbidden to make non compilable commits? Is it (and why) a bad idea to use only selected branches (including trunk) and tags for stable versions?

OwnerDisplayName: ibid


答: In order to determine whether the code works or not you need automated tests. If you don't have them, having the code compiling is a minimum to submit to the main branch. In your private branch I guess you can have code that doesn't compile, but probably it is not a good idea; the reason to submit often is to do merges and to avoid losing data in case of disk failure. If you are really so afraid of losing all the work that still not compiles, it means that you are going to have heck of a job to get it back to a working state, not really a nice idea. If you want to do a merge, then probably you should tweak your branching model, or try working with less dependencies.</p>

OwnerDisplayName: Luis


答:
Let's look at it this way.

You take a week off work and when you come back you get the latest code from the version control repository.

You make a few changes that take about an hour and then set about testing it. The code initially doesn't compile so you spend a day working on removing errors in code that you haven't even touched, so that it will compile.

You then find that it doesn't pass any of the test routines set up for your project and so you spend another day correcting that and ensuring that all tests pass.

You commit the code and find that there are many conflicts in the code that you have written against what is on the repository. You spend another day resolving the conflicts only to find that it doesn't pass any of the test routines that it did a day ago.

That strikes me a a massive waste of time. In my experience, non-compilable code is worthless, and so shouldn't be committed.

In fact I would say that on projects that have automated test routines, code that doesn't pass the tests shouldn't be committed either.

edit

I see that you've edited your question in light of all of these answers.

You never stated that you were working on a separate branch (which in itself can lead to trouble if merges are too few and far between), but I would still stand by the fact that non-compilable code shouldn't be committed.

Even if your code doesn't work, at least if it compiles people can merge it, build it, test it and prove that it doesn't work.

What's more I don't honestly believe that you make many hundreds of changes to your code and never compile it.

Obviously there are many strategies of software development and some work better than others. From my experience automated testing (and even test driven development) is a necessity, even more so as projects become larger. The beauty is that everyone knows that the code works before it is committed, whether to a branch or to the main trunk. There are many tools available that allow for automated builds and testing e.g. cruise control.

But your original question wasn't asking about SDLC's or strategies or even whether committed code should work but only whether non-compileable code should be committed.

OwnerDisplayName: ChrisBD


答:
You appear to be talking about two distinct things:

Code must be compilable.

Code must work.

For the first, I would say that all code committed should indeed be compilable before you commit. This is also fairly straightforward to do as I would imagine you would be compiling your code as you make changes. Some IDEs (eg. Eclipse) will even compile as you save. If you are doing active development, compiling your code should be part of your workflow so this requirement should be trivial.

The benefit of this is that anyone can jump in at any point in time and check out the head of your branch and get started on further work without having to first sort out compilation failures. That person may indeed be you, after a break.

The second is a more complex matter and has more flexibility as "working" is a very subjective thing. If you are creating a new feature, then often it won't actually "work" for quite a while. I would suggest looking at it in a slightly different way: namely ensuring you don't commit code that breaks anything else. Breakages are easier to measure.

As above, this is helpful for anyone (including yourself) being able to jump straight into the branch and having non-broken code. Having said that, I often tell junior colleagues that they can go ahead and treat their personal dev branches as their own domain and commit broken (but still compilable) code if they find it useful.

Regarding your comment about committing many files and being unable to work out what has changed, the way I work is that I will commit code in a single "logical unit". Whether that be one change in a single file, or a refactoring across many files. Working in this way I know exactly what has changed per commit.

A common theme above is how your commits affect other people and their ability to work. Software development is a collaborative effort and it's important to think about and understand how the state of your code affects your colleagues.

OwnerDisplayName: Burhan Ali


答:
You should also consider SQL Server Profiler.  In SQL Server Management Studio, select Tools -> SQL Server Profiler.  When the profiler window opens, select File -> New Trace...  (I don't know specifics about other RDBMSs, but they've got to have tools with similar functionality.)

As the long-term solution, you should of course move the business logic out of stored procedures.

Title: Production-safe SQL stored procedure debugging

Body:
We have an enormous number of nested SQL stored procedures, and a number of different ways of debugging them (varying from developer to developer).

So far, our methods include:

An optional @debug parameter, that
causes the procedure to
printmessages as it runs (passing
the variable down to called
procedures).

Checking @@servername against a
table of test server names, and
printing as above

Writing everything the procedure
does to a log table (in production
and test)

Which of these is preferable (and why), or is there a better method we've overlooked?


答: To stage a file is simply to prepare it finely for a commit. Git, with its index allows you to commit only certain parts of the changes you've done since the last commit. Say you're working on two features - one is finished, and one still needs some work done. You'd like to make a commit and go home (5 o'clock, finally!) but wouldn't like to commit the parts of the second feature, which is not done yet. You stage the parts you know belong to the first feature, and commit. Now your commit is your project with the first feature done, while the second is still in work-in-progress in your working directory.

Title: What does 'stage' mean in git?

Body:
I find git hard to understand as I could not find the meaning of the words used for the actions. I have checked the dictionary for the meaning of 'stage' and none of the meanings were related to source control concepts.

What does 'stage' mean in the context of git?


答:
Commit broken code? Yes. Push broken code? No. You should commit early and often in your own private branch -- That's what the tool is for, to track changes. When the code is working and tested, then you can push to others.

Of course, this advice only works with an SCM tool that provides both a commit and push/pull workflow. If you use a centralized system you absolutely should not commit code to the centralized server unless it at the very least compiles and passes a simple regression.

If your tool doesn't make it trivial to create your own private branches, pick a better tool if possible. Just don't go pushing/committing code that others can use unless you are reasonably certain it causes no regressions.


答: You can buy a small E-paper display and breakout board from Sparkfun for about $25 and $15 respectively. Hook them up to an Arduino or other microcontroller board and you're ready to start writing code. The language and tools you'll use will obviously depend on what controller you choose; for Arduino, you can find a lot of information at http://arduino.cc.</p>

Title: How to obtain an affordable electronic paper programmable kit or similar?

Body:
I'm really interested in playing around with the electronic paper technology, but I don't really want to program any commercial device (kindle or whatever).

I have some ideas and I want to start. How do I get a screen of electronic paper, a chip and how to start programming for it (language, interface)