答:
You may want to take a look at this article.

A prototype-based language has the notion of a prototypical object, an
  object used as a template from which to get the initial properties for
  a new object. Any object can specify its own properties, either when
  you create it or at run time. In addition, any object can be
  associated as the prototype for another object, allowing the second
  object to share the first object's properties.

If you add a property to an object that is used as the prototype for a set of objects, the objects for which it is the prototype also get the new property.

That's one of the main advantages of a prototype-based language over class-based ones.

Also, it's easy to get a classical OO inheritance with JS if you need to, but it's often difficult to get a prototype-model for a language which doesn't implement it by default.


问:
Being stupid to get better productivity?
I've spent a lot of time reading different books about "good design", "design patterns", etc. I'm a big fan of the SOLID approach and every time I need to write a simple piece of code, I think about the future. So, if implementing a new feature or a bug fix requires just adding three lines of code like this:

if(xxx) {
    doSomething();
}
```

It doesn't mean I'll do it this way. If I feel like this piece of code is likely to become larger in the nearest future, I'll think of adding abstractions, moving this functionality somewhere else and so on. The goal I'm pursuing is keeping average complexity the same as it was before my changes.

I believe, that from the code standpoint, it's quite a good idea - my code is never long enough, and it's quite easy to understand the meanings for different entities, like classes, methods, and relations between classes and objects.

The problem is, it takes too much time, and I often feel like it would be better if I just implemented that feature "as is". It's just about "three lines of code" vs. "new interface + two classes to implement that interface".

From a product standpoint (when we're talking about the result), the things I do are quite senseless. I know that if we're going to work on the next version, having good code is really great. But on the other side, the time you've spent to make your code "good" may have been spent for implementing a couple of useful features.

I often feel very unsatisfied with my results - good code that only can do A is worse than bad code that can do A, B, C, and D.

Is this approach likely to result in a positive net gain for a software project, or is it a waste of time?

答: Many books on lean and/or agile development will help reinforce this approach: do what is necessary right now. If you know you're building a framework, then add in abstractions. Otherwise, don't add complexity until you need it. I recommend Lean Software Development, which will introduce many other concepts that can make a substantive difference in productivity.

ContentLicense: CC BY-SA 3.0


问:
Can you write a (dynamic) website using only XHTML and CSS?
I am more of a desktop developer that a web developer. Therefore I only know XHTML and CSS when it comes to the web (and C#, if that is in any way useful). I have a little experience with ASP.NET with C# but I am in no ways an expert in it.

Say I want to write a small website to give a preview to any new software I make. Is XHTML and CSS enough to make it? Will I need to learn some server-side language? (or web development framework?) If so any suggestions?

I don't want to create something as awesome as Facebook or Stack-overflow. Just a normal website, kind of like http://thenewboston.com.

答:
Therefore I only know XHTML and CSS when it comes to the web (and C#, if that is in any >way useful).

As a matter of fact, C# is useful, because it is used as the server side language in ASP.Net, so...

Will I need to learn some server-side language?

...no, you already know one. If you are familiar with Winforms or WPF, you should not have too much trouble getting a basic dynamic website going in ASP.Net. You will have a to learn a few new controls and some parts of .Net you may not be familiar with, but it will not be like learning a platorm from scratch. I would recommend going for ASP.Net MVC3, but Webforms is also an option.


答:
Yes.

You can absolutely create a site like The New Boston without a stitch of server side code. It's a basic blog site. You can easily maintain the site with No DB and just a set of flat files. Though I recommend you consider using a CMS, or one of the common blogging platforms.

Edit:
To reply to the comments below. Widgets and other free cut and paste java script services. Think back to how High school kids created web pages back in the Mid 90's.

I'd also like to point out the http://www.thenewboston.com does not allow for comments.

Title: Can you write a (dynamic) website using only XHTML and CSS?

Body:
I am more of a desktop developer that a web developer. Therefore I only know XHTML and CSS when it comes to the web (and C#, if that is in any way useful). I have a little experience with ASP.NET with C# but I am in no ways an expert in it.

Say I want to write a small website to give a preview to any new software I make. Is XHTML and CSS enough to make it? Will I need to learn some server-side language? (or web development framework?) If so any suggestions?

I don't want to create something as awesome as Facebook or Stack-overflow. Just a normal website, kind of like http://thenewboston.com.


问:
What is the best way to INSERT a large dataset into a MySQL database (or any database in general)
As part of a PHP project, I have to insert a row into a MySQL database. I'm obviously used to doing this, but this required inserting into 90 columns in one query. The resulting query looks horrible and monolithic (especially inserting my PHP variables as the values):

```<code>INSERT INTO mytable (column1, colum2, ..., column90)
VALUES
('value1', 'value2', ..., 'value90')
</code>```

and I'm concerned that I'm not going about this in the right way. It also took me a long (boring) time just to type everything in and testing writing the test code will be equally tedious I fear.

How do professionals go about quickly writing and testing these queries? Is there a way I can speed up the process?

答: If you can easily get the column names into an Excel spreadsheet, you could write Excel macros to produce code for various queries and DML statements, then just paste values into another column and your insert/update statement is created automatically for you. Manually typing is a very slow way to do it, so see if you can find tricks using your existing tools. Many developer-oriented text editors also have the ability to record and store macros to make repetitive jobs like this much faster and easier.</p>


问:
How do you approach a new project where the code has already been written?

Possible Duplicate:

  How do you dive into large code bases?

I'm about to take on maintenance and enhancements of a fairly large and complex Java EE project with a Javascript front end.

I'm trawling through the code trying to work out how it all hangs together but I wondered if any of you people have come up with a methodology for doing this that works best for you? do you start with the UI and work backwards to the database? Or take discrete 'slices' through the system for particular bits of functionality? Do you take notes?

How do you get up to speed with a new project?

答:
When faced with a big existing system I keep to the areas I need to go. It depends on the job though.

If you are to write a code review. You need to look at everything.

If you have to fix bugs. You have to have to get a idea where to look for certain problems.

If you have to extend the software. Just keep to your area.

This is talking about > 1 man year projects. I often enough thought I'd seen everything and then discovered that a really big bug was waiting round the corner I hadn't seen.

OwnerDisplayName: DrBacchus


答:
It's funny how people talk about right way / wrong way of doing things.
At the same time the task of programming is still painfully difficult, and gives no good solutions for writing big complex systems.

It may be that someday we, programmers, will finally figure out how to write complex software. Until then I suggest that you always start with "stupid" prototype implementation first, and then spend just enough time on refactoring so that your colleges can follow your code.

Title: Being stupid to get better productivity?

Body:
I've spent a lot of time reading different books about "good design", "design patterns", etc. I'm a big fan of the SOLID approach and every time I need to write a simple piece of code, I think about the future. So, if implementing a new feature or a bug fix requires just adding three lines of code like this:

if(xxx) {
    doSomething();
}
```

It doesn't mean I'll do it this way. If I feel like this piece of code is likely to become larger in the nearest future, I'll think of adding abstractions, moving this functionality somewhere else and so on. The goal I'm pursuing is keeping average complexity the same as it was before my changes.

I believe, that from the code standpoint, it's quite a good idea - my code is never long enough, and it's quite easy to understand the meanings for different entities, like classes, methods, and relations between classes and objects.

The problem is, it takes too much time, and I often feel like it would be better if I just implemented that feature "as is". It's just about "three lines of code" vs. "new interface + two classes to implement that interface".

From a product standpoint (when we're talking about the result), the things I do are quite senseless. I know that if we're going to work on the next version, having good code is really great. But on the other side, the time you've spent to make your code "good" may have been spent for implementing a couple of useful features.

I often feel very unsatisfied with my results - good code that only can do A is worse than bad code that can do A, B, C, and D.

Is this approach likely to result in a positive net gain for a software project, or is it a waste of time?


答:
Well, it appears that the example site you've used is actually content driven. I.e. there's a number of articles, which are grouped in categories etc.

You will need some sort of data store and server side logic to handle that data, i.e. generate HTML for index trees etc.

If it is a site like that you want to make, I suggest you use your favorite open-source blog/wiki engine.

If you do this for the sake of learning, then of course you should try to do this from scratch. Today, there is a class of web frameworks I'd like to call RoRish (although this might be historically unjustified in some cases or even their approach to providing a simple and expressive way to create web applications may vary). Those frameworks are very streamlined at quickly solving the common problems of web development. About any of them has a build a blogging engine in 15 minutes tutorial. They focus on the bare essentials of data driven web applications, definitely making them a good entry point for web applications.

Here's a bunch of frameworks you might want to look at:

Django (Python)

Grails (Groovy)

CakePHP, Symfony, CodeIgniter (PHP)

Merb, RoR, Sinatra (Ruby)

Lift (Scala)

There's many, many more. You might even find something suitable for C#, although after a short look, I found nothing I could recommend. I'll leave that to the respective experts.


问:
Can applications override the OS keyboard layout?
We have in-house .NET application, which can be used across multiple languages. Lately we received a strange bug that is when our application is being used, user was unable to enter accent characters (Spanish, Win 7) in other applications (ex: MS Word or Notepad). Strange, huh!

Did anyone come across similar bug? If yes how did you solve that?

答:
Yes, it's possible. Applications can listen for key-press events and do whatever they want.

It is also possible to remap the keyboard behavior in Windows, both for single applications and directly by the Windows registry. This may cause conflicts with other applications trying to type some special characters.

Finally, it's possible to change the currently used keyboard layout, and even if in theory every application should retain its own layout used, it's really common in windows to change it for some application and see it changed also for others.


问:
What is the best way to validate the following data?
Lets say I receive an xml request that is sent to my web service and this request contains some data in it such as Hotel Room/Rate pairs (Room = Double Queen, Rate = 10%).  The database has all of these Room/Rate pairs stored, so when the xml request comes in, I have to validate them to see if the request contains both the room and the rate in the database.  If I receive one room/rate pair and it is not in the database, I fail the message and send back an error response, but if I receive 3 room/rate pairs for example, and 2 are found in the database, but one is not, I would process the succussfull ones and send back warnings for the ones that were not found.  The other scenario is if I receive 3 room/rate pair and they all are not found in the database, then I want to send back an error message.  What is the best way to approach these scenarios?</p>

答:
My opinion is that you should be consistent and always follow the same path regardless of the number of data you have in the request. That way the client of your application knows what to expect. As such, being consistent leaves you only with two choices:

strict: you are very strict and nothing goes through if you have one error (like, this is a transaction). You stop at the first error and return the response explaining where you find the first error.

permissive: The valid rooms are successfully updated. For each room you don't have in your database, you generate a warning and continue. The response will contain a warning for each problematic data.

From what I understand it does not seem you require your request to be transactional (everything passes, or nothing) so my guess is that you may be "permissive". The client should check the warnings and do whatever it can to do better next time.

There is also a third choice, but I don't know if you can implement that into your business domain: why not "create" the missing rooms in the database if you don't have them ?


答:
I think the mindset that will help you is to always strive for concrete solutions to coding problems instead of abstract solutions. Abstractions should only be added when they actually help simplify the code base (when for instance they allow you to make the code base smaller).

Many programmers have found that abstractions emerge almost on their own, when they DRY their code up. Design Patterns and Best Practices help you to find opportunities for doing just that, but are not in themselves goals worth pursuing.


问:
What happens at [platform] user groups?
I'm a .NET developer, but I've never been to a .NET user group meeting or anything like that.

I might have the opportunity soon to start attending one, but I'm wondering. What happens at user groups? I'm not looking necessarily for info specifically about .NET ones, but they are preferred.

What do you get out of it excluding the opportunity for networking?

答:
one good part of users groups are the mailing-lists. here, you briefly get informed about trends, news, frameworks, etc.

drawback of user-groups is the "club" behavior in some cases. if you are new or outsider, the hierarchy in some user groups can be disturbing. also, the hidden recruiting strategies of companies may be disturbing for technical subject matter.

ContentLicense: CC BY-SA 2.5

Title: What happens at [platform] user groups?


答: What you probably want to do is to incorporate success/failure in for each request in your response. So, in your example, the user would receive a response saying that the first 2 are successful and the final one failed. Bonus points for including why it failed.

Title: What is the best way to validate the following data?

Body: Lets say I receive an xml request that is sent to my web service and this request contains some data in it such as Hotel Room/Rate pairs (Room = Double Queen, Rate = 10%).  The database has all of these Room/Rate pairs stored, so when the xml request comes in, I have to validate them to see if the request contains both the room and the rate in the database.  If I receive one room/rate pair and it is not in the database, I fail the message and send back an error response, but if I receive 3 room/rate pairs for example, and 2 are found in the database, but one is not, I would process the succussfull ones and send back warnings for the ones that were not found.  The other scenario is if I receive 3 room/rate pair and they all are not found in the database, then I want to send back an error message.  What is the best way to approach these scenarios?</p>


问:
What is a good start for small web-design projects?
What are the most common templates, languages, web-design tools that you recommend for me to be able to start web-design? I do software but I have not not had web-design experience, I have been a Win32 developer with VB 6.0, Delphi, C#,etc.., not web-based. The type of web-design I have in mind is some simple web-sites, even static web sites, that the owner of some small business like a restaurant wants to have a web-site to show its services ..I know there are some stuff people start with like WordPress, Joomla, PHP CMSes, CSS frameworks,... I am looking for stuff like this that helps speeds up building a nice website...what are the things people mostly use these days?

Thanks

答:
I would recommend you to write LISP. There are many Frameworks out there for LISP, see this StackOverflow question for reference.  As you can see here, with LISP you have many advantages.

P.S:
I would use PHP but you get too much downvotes for just mentioning it in a positive way.
BUT you get free Webspaces with PHP everywhere, Joomla, Wordpress etc. are written in PHP (even Facebook started with PHP).
There are some good Frameworks for rapid development like Cake-PHP, too.
Also PHP is a very simple language wich is easy to learn.


答:
In the second edition of Stroustrups 'The C++ programming language', (I don't have the page available) I read

Don't add code spontaneously in place.

and I went good following the advice. Of course there are tradeoffs, and you have to find a balance, but short fragments are better testable than a big spaghetti mess.

I often experienced, that while differentiating from one case to two cases, if you think about 2 as n-cases, you open up a door to many new possibilities, which you might not have thought about.

But then you have to ask the YAGNI question: Is it worth it? Will it really be useful? Being experienced means, that you will be rarely wrong, and as a beginner more often wrong.

You should be critical enough to recognize a pattern, and detect, whether your code is hard to maintain, because of too much abstraction, or hard to maintain, because everything is solved in place.

The solution is not this or that, but to think about it. :)


答:
Twitter Bootstrap

Twitter's open source boilerplate template that's actually presentable and good enough for even some production apps.  Check it out and use it to get a HUGE head start on your design, and is well-documented enough that you can quickly build on it.

I'm using this for my current startup and it's cut dev time literally in half (plus, I'm not a very good designer).

Title: What is a good start for small web-design projects?

Body:
What are the most common templates, languages, web-design tools that you recommend for me to be able to start web-design? I do software but I have not not had web-design experience, I have been a Win32 developer with VB 6.0, Delphi, C#,etc.., not web-based. The type of web-design I have in mind is some simple web-sites, even static web sites, that the owner of some small business like a restaurant wants to have a web-site to show its services ..I know there are some stuff people start with like WordPress, Joomla, PHP CMSes, CSS frameworks,... I am looking for stuff like this that helps speeds up building a nice website...what are the things people mostly use these days?

Thanks


问:
Work experience instead of education?
I wanted to name this topic as "Education vs. Experience", but this topic already exists. I've read that discussion and though what I'd like to ask is related with that topic, the question is quite different.

I've started learning programming about 12 years ago. For the last 4 years I'm working as developer in software outsourcing (located in Russia). I'm thinking about leaving Russia and moving somewhere else like Australia (doesn't matter basically). I have a number of examples illustrating the general ability and success stories, but still there's a difference between all these people and my case.

I have quite a good technical experience - primary areas are C++ and .NET. I have already participated in 7 projects based on different technologies/platforms (Windows, Linux, Android, Qt, .NET, etc). So, I believe, I'm capable of working as a software developer. Let's just take it - "from technical standpoint, this guy is absolutely OK".

The only problem is, I don't have any education. So, here's the question:

In most cases, may I read words like "BS in CS, equivalent, or better" as "N years of experience"?

Update:
Is there a sense in getting certificates like MCSD (for .NET)? I know there's a separate topic for this question, but still asking for the case when there's no education but there are certificates and experience.

答:
This is entirely dependent on the company.  IMO good companies don't care about a piece of paper, they care about results and experience and "Can you get the job done".  The bad companies put all their faith in degrees, certifications, and buzzwords and won't give you the time of day even if you have 8 years experience doing exactly the thing they are hiring for if you don't have X degree or Y Microsoft certification.  Technical recruiters are especially guilty of that as most of them are technically ignorant and glorified salespeople, so buzzwords are all they know.

In short: Work experience trumps education.  If it doesn't, chances are you don't want to work for the company anyways because they're putting more faith in education, which almost never teaches you anything beyond the basics, instead of in practical and verifiable results.

Title: Work experience instead of education?


问:
Standards to constraint HTML renderer in only US-EN
Does W3C or any other organisation has standard or protocol to constraint all developers to make sure they must use american english while they develop any sort of interpreter?

To avoid something like,

I was writing code and tried to align image in centre(spelled in
  british english)

align='centre'

above didn't work!!

There is no spelling mistake, above spelled word meaning is "middle"

when I wrote

align='center' it worked,

Does this mean HTML is written in "American
  English"?

What if a developer from British background writes a renderer for web browsers such as gecko?

EDIT

Sorry I am not ranting but, I was wondering if W3C has any standards written somewhere which states that any future code or html tag written for HTML language must be in US-EN.

Does anyone have idea whether W3C have some constraint on this?

答:
http://www.w3.org/Consortium/Translation/

The working language of the W3C is US English. The official version of
  a W3C document is the US English language version at the W3C site. The
  W3C tries to reach as many people and organizations around the world
  as possible. But translating specifications is a lot of work, and we
  need your help. We made it easy to help us with translations, and
  invite you to volunteer to translate some W3C specification and other
  documents, alone or together with somebody else.


问:
How to sell a high SO reputation at an interview
A question with absolutely no relevance to myself:

How would a programmer with a stellar SO reputation (like 30k+) market his or herself to poential employers/investors who have never heard of SO?
In other words, how can one describe SO in a few sentences that will make a high reputation sound impressive at an interview?

答: Dunno about 30K+. I only got 8.6K but I'm overall 2nd place for the language I got hired for, which actually was one of the things that got me my current job. I put it in my CV in the section "participation in relevant online communities".</p>


问:
My boss wants a narrated line-by-line English explanation of our code
I have been specifically asked to give line by line (or as appropriate - for example, image by image, etc.) explanation or commentary which my boss wants to be able to read and follow.

Since he is not a programmer, he can not follow the code so wants it all translated into English.

Has anyone been asked to do this before?

I have commented on all of the source code and used JSDoc to generate full documentation of all functions, variables, etc... and included an implementation example, and full working demos with comments throughout.

Is there anything else I can do to comment the code for non-programmers?

This isn't a reasonable request, is it?

UPDATE

In the end, I managed to explain why it was not a good use of time to do what he was asking. He is a reasonable guy, and just did not have an understanding of what my job involves. Once he saw this post, I think he quickly understood that it was not a normal request.

I did provide documentation that is suitable for another programmer to follow (JSDoc and inline comments - as well as some extra notes on technical issues), and a very broad flow chart diagram of the main logic of the program for my boss to follow.

In the end, all parties were satisfied and we have moved on.

答: Do you have design documents? Those are the English explanation of what the code does. A non-programming manager should not need more than that.</p>

OwnerDisplayName: BIlly Moon


答:
I don't think it's a reasonable request. SOURCE CODE is not meant to be read in English (or any other language for that matter).

Maybe he's afraid you are going to make your code do something he doesn't approve or is aware of. If that's  the case, I don't think there is something you can do about it. You will have to write the documentation or maybe convince him/her to hire someone to audit your code.

Title: My boss wants a narrated line-by-line English explanation of our code

Body:
I have been specifically asked to give line by line (or as appropriate - for example, image by image, etc.) explanation or commentary which my boss wants to be able to read and follow.

Since he is not a programmer, he can not follow the code so wants it all translated into English.

Has anyone been asked to do this before?

I have commented on all of the source code and used JSDoc to generate full documentation of all functions, variables, etc... and included an implementation example, and full working demos with comments throughout.

Is there anything else I can do to comment the code for non-programmers?

This isn't a reasonable request, is it?

UPDATE

In the end, I managed to explain why it was not a good use of time to do what he was asking. He is a reasonable guy, and just did not have an understanding of what my job involves. Once he saw this post, I think he quickly understood that it was not a normal request.

I did provide documentation that is suitable for another programmer to follow (JSDoc and inline comments - as well as some extra notes on technical issues), and a very broad flow chart diagram of the main logic of the program for my boss to follow.

In the end, all parties were satisfied and we have moved on.


答: IMHO...if he's responsible for getting the task done, he should know how it works... :)</p>


答:
In general, the fastest way to load a large dataset into a SQL database is to use the native bulk loading interface. As far as I know, every SQL dbms has at least one.

MySQL docs: Using the Bulk Loader

If I have to turn a tab- or comma-delimited file into SQL INSERT statements, I use awk to read the input file and write the output file. There's nothing really special about awk; it just happens to be the text-processing language I know best. You could get the same results by writing code in Perl, Python, Ruby, Rexx, Lisp, and so on.

Title: What is the best way to INSERT a large dataset into a MySQL database (or any database in general)

Body:
As part of a PHP project, I have to insert a row into a MySQL database. I'm obviously used to doing this, but this required inserting into 90 columns in one query. The resulting query looks horrible and monolithic (especially inserting my PHP variables as the values):

```<code>INSERT INTO mytable (column1, colum2, ..., column90)
VALUES
('value1', 'value2', ..., 'value90')
</code>```

and I'm concerned that I'm not going about this in the right way. It also took me a long (boring) time just to type everything in and testing writing the test code will be equally tedious I fear.

How do professionals go about quickly writing and testing these queries? Is there a way I can speed up the process?


答:
SOLID and KISS/YAGNI principles are near-polar opposites. One will tell you that if doSomething() can't be justified as an integral part of the job the class that calls it is doing, it should be in a different class that is loosely coupled and injected. The other will tell you that if this is the one place doSomething is used, even extracting it into a method may have been overkill.

This is what makes good programmers worth their weight in gold. "Proper" structure is a case-by-case basis, requiring knowledge of the current codebase, the future path of the program, and the needs of the business behind the program.

I like to follow this simple three-step methodology.

On the first pass, make it work.

On the second pass, make it clean.

On the third pass, make it SOLID.

Basically, this is how you blend KISS with SOLID. When you first write a line of code, for all you know it'll be a one-off; it simply has to work and nobody cares how, so don't get fancy. The second time you put your cursor in that line of code, you have disproved your original hypothesis; in revisiting this code, you are likely extending it or hooking into it from somewhere else. Now, you should clean it up a little; extract methods for commonly-used tidbits, reduce or eliminate copy/paste coding, add a few comments, etc etc. The third time you come back to this code, it's now a major intersection for your program's execution paths. Now you should treat it as a core part of your program, and apply the SOLID rules where feasible.

Example: You need to write a simple line of text to the console. The first time this happens, Console.WriteLine() is just fine. Then you come back to this code after new requirements also dictate writing the same line to an output log. In this simple example, there may not be a lot of repetitive "copy/paste" code (or maybe there is), but you can still do some basic cleanup, maybe extract a method or two to avoid inlining IO operations into deeper business logic. Then, you come back when the client wants the same text output to a named pipe for a monitoring server. Now, this outputting routine is kind of a big deal; you're broadcasting the same text three ways. This is the textbook example of an algorithm that would benefit from a Composite pattern; develop a simple IWriter interface with a Write() method, implement that interface to create ConsoleWriter, FileWriter and NamedPipeWriter classes, and one more time to create a "MultiWriter" composite class, then expose an IWriter dependency on your class, set up the MultiWriter composite with the three actual writers, and plug it in. Now, it's pretty SOLID; from this point forth, whenever the requirements dictate that output should go anywhere new, you just create a new IWriter and plug it in to the MultiWriter, no need to touch any existing working code.


答: A flow chart will probably be of more benefit to him. This is certainly an unusual request and doesn't say much about him as a manager.</p>


问:
JavaScript's prompt, confirm and alert considered "old-fashioned"
Lately I've been developing a web-based management system for a gym. Their previous app was developed in Visual Basic. For the new app, all the front-end scripting uses jQuery, the server is running PHP & MySQL... you know, the typical el-cheapo linux based stack.

Anyways, I was wondering why JavaScript's prompt, confirm and alert message dialogs are so underused nowadays. There a lot of jQuery plugins for modal windows and alert messages that try to mimic something that the language already offers and every browser is forced to support properly.

Using hand-made or plugin-based solutions is ok for complex forms and special needs, but if you just need to ask for a single value or confirm the deletion of a record, why would you add such overhead to your web app? Furthermore, iOS and Android offer nicely adapted message dialogs when you use prompt, confirm and alert.

答: Bottom line: The default prompt, confirm and alert dialog boxes match the style of your browser, not the style of your site. Most UI people want all dialog boxes to flow with the UI of their site. They use modal windows to present messages and collect data using the same fonts and colors as the site's UI, not the default grey and blue of MSIE or FF.</p>


答: It would be much faster for him to learn to read code than it would be to translate the entire code of any interesting application to English.  Besides, we tried that with COBOL and it didn't help at all.  If he's not willing to learn, but just wants to make his ignorance someone else's problem, you have a seriously pointy-headed boss.  </p>


答:
Line-by-line, is ridiculous. What I might suggest is offering to generate docs from comments and give him that. That was sufficient for a number of Canadian Government grants and audits that I've worked on in the past.

He won't get line-by-line but he'll get method-by-method which should still be more granularity than he needs.

Some existing solutions, depending on your platform:

C# : sandcastle

Java : javadoc

"C++, C, Java, Objective-C, Python, IDL (Corba and Microsoft flavors), Fortran, VHDL, PHP, C#, and to some extent D." : doxygen


问:
How to really master MySQL?
I have been using mysql for the same amount of time I have been using PHP. However I feel about 10x more confident in PHP; or any other programming language. But I just can't seem to really really grasp SQL. I mean, I can select, update, insert, delete, join, etc. but when it comes to more complex stuff I am lost. How to write a more complicated select statement, how to use indexes properly, which engine to use, etc.

For some reason I really find the mysql docs hard to follow, but the php ones easy to follow.

I am starting to think that maybe my brain is just wired in a way that makes programming make since but sql confusing. I don't know. Most people think Regex is so confusing but to me it makes more scientific sense than how to construct an sql statement. Please don't get me wrong, I am not hating on SQL, I really like it, I just want to understand it better.

Whats the best/fastest way to really master MySQL?

When I say "master" I don't mean the guru among gurus, I mean smart enough to figure out most of the questions I ask on SO myself without needing help.

答:
First and foremost, get a thorough understanding of joins. Not just inner and left joins either. Know what a cross join does and a full outer join. Know the circumstances that would cause you to choose a particular type of join. Understand that they are not interchangeable and that query that uses a left join may return different results than one that uses an inner join. (One would think that would be obvious but I've read too many questions where people in decribing their problem, somewhat randomly try different joins.)

Next really understand aggregates and how they work. Mysql will let you get away with not doing group bys in a standard way. But have the discipline to completely define the group by clause properly. It will help you understand what you are doing and will make your knowldge more easily transferable to other databases.

Learn what the case statement does.

When doing complex queries learn to work in chunks. Verify at each chunk that you have the results you expect.  So for instance suppose you need to write a reporting query on orders that have been returned in the last 3 months and the reason for the return as well as the contact information for the customer. First step is to get the orders returned in the last three months.  Once you know you have that solid, you can add the information on the reason for return. Once you have that solid, you can add the customer who returned it. Once you have that solid, add the contact information for the person. At each stage, check your results and see if they make sense. In this case, I probably want to end up with only one record per returned order. If at any intermediate stage, the number of results goes up or down, you know you have a problme with the query. Sometimes in building blocks, you will want to see additional fields just to verify if the information is correct. I put these on a separate line and comment them out as I work through the next step (removing them at the end once I know I'm right) so they are available to see again easily if adding another wrinkle made the query go funny. You cannot do complex querying correctly without a thorough understanding of what your results should be look like. Thinking it looks OK becasue it returned some results will almost guarantee that you have wrong results a good portion of the time.

Here is a list of some basic things you should be able to do in SQL without having to think about it:

First a straight up select with no joins (and no select *) but with
conditions on the select

You should know how to combine two or more tables and get records
that are in all the tables

You should know how to combine two or more tables and get records
that are in all the tables but return only one record from the table
with the many side of the one-to-many relationship

You should be able to get the records in one table but not in an
associated table

You should be able to Aggregate data for a report

You should be able to insert one record to a table

You should be able to update one record in a table

You should be able to delete one record in a table

You should be able to insert a group of records to a table without
a cursor

You should be able to update a group of records in a table
 without a cursor

You should be able to delete a group of records in a table without
 a cursor

You should be able to perform multiple actions in one
 transaction and handle error trapping

You should be able to create union of records and know when to
 use UNION vice UNION ALL

You should be able to vary the data for one field based on some
 criteria (using CASE)

Once you feel comfortable with your basic SQL knowledge, get to know your database structure. I can write complex queries against the very complicated dbs I support much faster than other people because I understand the structure and don't have to think about where things are stored.  If you understand the table structure and foreign key relationships and where lookup values are stored and what the columns mean (not just their name but what data is held in them) then you can be expert in querying that database. The first thing I do in any new job is thoroughly understand the db structure.

Title: How to really master MySQL?


答:
I would break your question into two categories:

1) Web Design: Are you a designer? I have found the design aspect of creating graphically interesting websites a challenge when doing full-stack development. There are a lot of pieces if you are creating a non-trivial web design (color, fonts, graphics, etc.)

Since it sounds like you are more of a coder, consider frameworks that have themes like WordPress or Drupal.  You can purchase well-designed custom themes from many place.  Since your goal is to design a specific type of static site you may save a lot of headache by going this route.

2) If you are looking for ways to get started in web development then again there are frameworks and a lot of great beginning books on using them.  I favor Ruby on Rails and The Rails Tutorial or Agile Web Development with Rails are two great titles that take you from start to finish.  There are also many books on Zend, CakePHP, etc. which do the same thing.  Give them a try if that's your interest.


答: Joe, your last comment explained a lot.  I think the real problem is the data design. New columns may be needed when the document format changes, and in my experience document formats tend to change frequently.   Instead of a 90-column table, with a single row per report, I would  store the report data in a table with four columns: report_id, format_id, field_name, field_value.  Each report would be represented by 90 rows, one for each field value in the report.  This should simplify your code considerably.</p>


答:
He should not bother to know any of that. Tell him, that in software development implementation is subject to change. Event design is subject to change. Tell him about information hiding, encapsulation and abstraction.

He, as part of your team, as client of your code, in a broader sense, should only work with a clear, high level abstraction of what your code does. The same way any layer of your code works with another layer of somebody else's code. Knowing any more than that, will only slow him down, and risks him making assumptions based on the inner workings of your code. Those assumptions will cease holding, when you have to change your code, which becomes a problem, if he built any kind of system or process based on them.

And also having to do this kind of work will reduce your efficiency. Not only will you have to make subsequent changes in two different places, but it will also negatively impact your work morale, which will reduce your output even further.


问:
How do you help your fellow programmers to grow?
As a team lead, how can you help your programmers to grow?

The reason I ask this is because there are a few programmers working with me, and I really want to "turn them on the loose", to realize their maximum potential, and to keep them happy.

But I don't quite know how to do this, do I have to

Interact with them frequently, or give them quiet time, leave them undisturbed?

Ask them to follow coding guidelines, such as enforcing unit tests, coding styles, or let them do whatever they see fit?

Be lenient with them. Such as don't really care whether they really come into office for 8 hours or 4 hours, or need to enforce some "disciplines" in the work place?

Guess what, each positions have their own points, and different people would argue for different things. Such confusions make managing people indefinitely harder.

What do you think?

答:
One way to help your people grow is to let them do what they do best.

If you are lucky, you will have one or two programmers whose personal "testing" standards are stricter than those of the department as a whole. In that case, you can put them on the "honor system" for those issues, or even adopt their methods.

With "flex time," you can afford more leeway to your more productive workers. As long as they are getting the job done, I'd worry less about their hours. Some people come in, put in 5-6 "nonstop" hours, and achieve more than others who put in 10 slow-paced hours.

But one of your jobs as a manager is to correct WEAKNESSES. That is, you will have to BEAR DOWn on sloppy programmers whose test standards are inadequate, or people who aren't productive enough--because they aren't putting down the time.


问:
What are good questions to ask a sales engineer candidate?
What are good interview questions to ask a candidate for a sales engineer position? We're an enterprise software company and the candidate we hire needs to be able to (and I think this holds for any company hiring to this position). I write "customer (programmer)" because the customer is almost always a programmer.

Give clear answers to customer (programmer) questions.

Focus on how we address the customer (programmer) needs, not list out features.

Sound enthusiastic when talking/demonstrating to the customer (programmer).

When demonstrating a feature, explain why it is of value to the customer (programmer).

Care a great deal about providing quality support to customers (programmers).

So, any suggested questions, things to watch for, etc? (Even though a sales engineer is a programmer, what we need is quite different because programming skills can be average but communication skills are very important.)

答:
You could ask the person for their passions and try to persuade you about them in terms of explaining why something is so good and important to them.  Look at how well do they paraphrase and clarify their answers and break things down over and over again.

The key isn't so much in the words themselves but in the how are those words presented.  What kinds of emotions are behind them?  Does the person seem to run out of patience quickly?  How many times can they take someone asking, "Why?" before breaking?  Do they answer the question or just seem to do a lot of hand waving?


答:
Instead of asking questions, I would test him in real conditions:

Pick a random product online, similar to yours (for programmers). It much be unknown to him.

Give the candidate 15 minutes to review the product website. He can take notes and he is left alone in the room.

Once prepared, ask him to convince you to buy his product in less than 10 minutes.

If you can, repeat the last step with 2 other colleagues.

This can be done by phone too.

I had to do such exercices in the past (for management not sales), and it's the only way I felt I demonstrate my capabilities.

Title: What are good questions to ask a sales engineer candidate?

Body:
What are good interview questions to ask a candidate for a sales engineer position? We're an enterprise software company and the candidate we hire needs to be able to (and I think this holds for any company hiring to this position). I write "customer (programmer)" because the customer is almost always a programmer.

Give clear answers to customer (programmer) questions.

Focus on how we address the customer (programmer) needs, not list out features.

Sound enthusiastic when talking/demonstrating to the customer (programmer).

When demonstrating a feature, explain why it is of value to the customer (programmer).

Care a great deal about providing quality support to customers (programmers).

So, any suggested questions, things to watch for, etc? (Even though a sales engineer is a programmer, what we need is quite different because programming skills can be average but communication skills are very important.)


答:
I would take a look at this list of 100 Interview Questions for Software Developers. They cover a lot of ground, and only rarely have I been asked questions from the breadth of this list, even though I feel that I can answer most of them in sufficient detail for an interview. I'm not exactly sure what the work of a sales engineer entails, but it sounds like it has a customer focus, so I would emphasize questions from that list on requirements, testing, configuration management, and project management - these seem to be the technical areas that would be most applicable.

Situational interview questions might also be appropriate. Ask the candidate to give a presentation, pitch a product, or provide support to a user.


答:
No, it is not a reasonable request!

TALK HIM OUT OF IT, or have someone else talk him out of it, by all means. That is an irrational idea, which although doable is so expensive to do it should never actually be done. An overview of functions and subroutines is reasonable, but to "explain" every code line is not. It would be more effective for him to learn to read the language in hand, than to do that.

The next thing he will be asking for is to translate mathematical formulas, or whatnot into English text. Although certainly possible that introduces much room for error and misinterpretation, and should never be done. Just like "translating" code to English.


答:
As a programmer, you really have "two" jobs.

The first is to create good programs. The second is to "sell" them to customers inside and outside the company.

Your boss' request "hurts" your first job. It takes more time to document your programs. On the other hand, he's actually making you work harder on your "second" job.

Your boss is asking you to document your program in English for HIS benefit, and presumably for the benefit of people he has to deal with, inside and outside the company. If you help him to do his job, it should work to your benefit in the long run, when you ask him for more hardware, personnel, or money for raises. After all, he asked you to do more work.


答:
I think BDD would suit well with this problem, although it seems that your project is near-completion, so kinda hard to implement it in now, so it's more like for future reference.

With BDD use-cases are described as humanly-readable documents that are then translated into automated functional tests.


答:
Sounds like a good chance to try literate programming.  Google it. :)

But... it's not necessarily an entirely unreasonable request.  Part of your job (the more important part, imo) is to communicate your algorithm(s) to other developers, and, if necessary, non-technical people.  Solitary genius programmers who can't communicate are always problematic, I think.

To that end, your code should be darn clear (meaning: either truly self-documenting or well documented, and by "self-documenting" I mean variables and functions have one meaning or responsibility and their names reflect that clearly).  Your boss may have good reasons for his request. Maybe (I'm just guessing here) you or your predecessor have a reputation for impenetrable, fragile code and this is your boss's remedy.  It's a bit extreme, but might be a useful exercise for you.  I assume he knows that it takes time to write better docs (and if he doesn't, he should be educated -- it's just like writing a term paper: takes longer to write than to read).


问:
How to release project under public domain?
I'm currently working on project, which is going to demonstrate how widgets can be done with Context Framework. I will also publish the source code.

In this case I want to give users as much freedom as possible, so that they can freely copy-paste, modify and also relicense whatever code they reuse.

So, how do I mention that in the project? Are the some ready-made licences etc. that are suitable for this?

答:
The Creative Commons CC0 license should suit your purposes.  It's public domain made as explicit and universal as possible.

The Problem

Dedicating works to the public domain is difficult if not impossible for those wanting to contribute their works for public use before applicable copyright or database protection terms expire. Few if any jurisdictions have a process for doing so easily and reliably. Laws vary from jurisdiction to jurisdiction as to what rights are automatically granted and how and when they expire or may be voluntarily relinquished. More challenging yet, many legal systems effectively prohibit any attempt by these owners to surrender rights automatically conferred by law, particularly moral rights, even when the author wishing to do so is well informed and resolute about doing so and contributing their work to the public domain.

A Solution

CC0 helps solve this problem by giving creators a way to waive all their copyright and related rights in their works to the fullest extent allowed by law. CC0 is a universal instrument that is not adapted to the laws of any particular legal jurisdiction, similar to many open source software licenses. And while no tool, not even CC0, can guarantee a complete relinquishment of all copyright and database rights in every jurisdiction, we believe it provides the best and most complete alternative for contributing a work to the public domain given the many complex and diverse copyright and database systems around the world...


答:
Is there a micro-manager of the year award?  It sounds like your boss deserves a nomination.  Someone who believes he needs line-by-line level understanding of the code, but doesn't want to learn how to read it directly, is about as perfect as micro-manager as can be imagined.

One advantage of being a developer is that the difficulty of understanding code prevents micromanagement beyond a certain degree, at least at the detailed implementation level, at least by non-technical management, because even the most hard-core micro-manager recognizes that they are over their head at that level.  But your boss's genius may found a way to shatter the silicon curtain.

And, as a bonus, it wastes tremendous amounts of developer time doing the translation, even before he uses the English translation to start suggesting various improvements (I'm assuming he knows how to code better than the programmers, even though he can't read the code, and will be able to share his wisdom just as soon as someone translates it, otherwise why would he need every line translated?).

So, no, it's not a reasonable request, and I've never heard of it before.  And I feel for you.  I think everyone may need to start quietly looking for another job, because once he starts using code translation as a management tool it's probably going to be a brutal place to work (er, a more brutal place to work).

On the plus side, maybe you can get a new anti-pattern named after your situation?  How about the "Dirty Hungarian Phrasebook" anti-pattern, after the Monty Python skit where a tobacconist is trying to communicate with someone who doesn't speak English by using a Hungarian phrase book that has comically false translations?


答: Even a line by line translation will not effectively convey the meaning of each line of code. A programmers understanding of a line of code is always in the context of many factors. Get into something like a piece of multi-threaded code and the english translation will not make any more sense than the raw code. Think about functionality that is spread between multiple functions/files. Some code makes absolutely no sense without explaining extensive amounts of other code. Try to explain the different parts involved in dependency injection "line by line" and you will see what I mean. Just about anything that goes beyond God-function procedural code will require an extensive amount of programming knowledge just to understand the English translation. Also, look at something as simple as an if/else decision statement. There is no line-by-line, since the next line is dependent on run time data. The next line could be one of several possibilities. By the time you have explained what your application does, you will have made your PM into a programmer and you will both be 5 years older.


问:
How do you tackle really bizarre errors that keep you puzzled for more than 10 hours?
You know them, those errors that make NO sense. Where it seems like a gremlin just jumped deep inside your chips and messed up something. Do you take a walk, write stuff, call an uncle?</p>

答:
A combination of all of these :

Get away from it for a while so it can sit on your back burner. Sleep, rest, eat, take a walk, whatever.

Examine the problem more, what else does it do wrong, what other symptoms can you find?

Research the problem, see what you can find. Remember to try different keywords

Try something different. A work around. A different debugging technique. A validator. A different computer.

Talk to someone. Even if they are not able to help, or not even a programmer, sometimes talking will trigger the idea lightbulb

Restart! If appropriate, try restarting your computer, the server, etc. If nothing else, you can use the time to think.

Ask StackOverflow! We are here to help


问:
How to make a GPL license with more severe penalties?
I am considering open sourcing some software, but when I read the answers on this questions, it seems like the penalty of ignoring a GPL license is rather small, compared to the costs of the suing party to document that the other party has included GPL code in their proprietary code and the costs of suing.

Therefore, I would like to know if there is a way to make a license or some kind of contract before source code is accessed, which is stricter than GPL. What I want to achieve is that a company including GPL code in their proprietary code have to GPL their whole code, and not just rewrite the GPL code. Is this possible?

答:
The GPL is not a contract; it's a license. That’s why it doesn’t mention penalties.

It’s your code, and your copyright. Let’s say, for example, that someone took some of your code and used it or published it without your permission. What have they done wrong? What could you sue them for? Copyright infringement, that’s what. And that’s all.

Free Software and Open Source licenses give people rights they otherwise would not have. You’re giving people the right to use your code under certain conditions. If they use your code in ways which do not meet those conditions, what have they done wrong? See the paragraph above. Copyright infringement is all they’ve done wrong, and you can sue for.

You could create some form of contract, instead of a license, but I don’t think you could do that in a way which would match the FSF’s definition of “Free Software” or the OSI’s definition of “Open Source Software”. Maybe you could, but I doubt it. Also, the FSF’s licenses are themselves copyrighted. You’re free to use them verbatim, but you can’t make an altered version of the GNU GPL. You’d have to rewrite it altogether. And for that, you’d need a lawyer.


答:
Sit down with him and talk him through 10 lines of the code.  Explain every detail until you both agree he understands it to the extent he wanted to.

Maybe this experience is all he's looking for: just an impression of what your work looks like to you, and what the software looks like from your point of view.  That's a good thing in my book.

If after this, he still wants you to continue, say: notice how many questions I had to ask; imagine if I would have had to explain all of this without being able to ask questions, how could I possibly have known what to include and what to leave out?  How much time would it have taken before the results would be useful to you?  Now how many lines do you want me to do in this way?


答:
Use your technical expertise to pursuade your boss.

Let him know that it will take just as long to do this as it did for you to code it in the first place (Feel free to make it longer.).

Ask him how up-to-date this document needs to be. Inform him all coding changes will now take at least twice as long.

If you or anyone else finds any bugs, ask him if you should fix them now or wait until you are done psuedo coding. Remind him about #1 & #2.

Like all bad solution suggestions, it's better to identify the problem. Maybe your boss is getting hit with technical questions by upper-management and he feels embarassed since he's unable to answer. There could be one particular section of code that he feels the most concerned about, so you could limit this massive undertaking to just that area.

By submitting a sample, he may come to the conclusion that if you don't understand how coding works (What is a loop and what is it doing to all these items?) it doesn't mattere what language it is in. He's better off understanding the application from a power user perspective. I think it is fair for you to let him know that you'd rather be writing real code/hint - I'm looking for another job.


答: The beauty of English is that is obfucates beautifully. If you use this to your advantage, you may never heve to deal with this sort of request again. I would take a small piece of the code as a sample but one which is very abstracted and not at all easy to understand. I would then write up the comments in technical english as if you were writing it up for a chapter in a programming book. The longer  and more complicated to follow, the better. Tell him how many hours it took you to document this one feature. Then explain that it is only 1/10th of 1 % (use actual figures based on lines of code if you can, they are probably worse than this) of the actual code base. When he realizes he has no clue what the English translation says and that it will take 20,000 man-hours to do this level of documentation he will back off fairly quickly. But be very earnestly trying to accomplish his task. Don;t try this if you can't pull that off and he suspects you are playing him.</p>


问:
Should development methods squash a developer's individualism?
I'm in my final semester of college and am taking a software engineering course.  In the class we learn about various software development methods. The one we focused on, and used to develop our project, was the waterfall method.

I feel like the instructor may have implemented it wrong. In our class diagrams, we had to list ALL properties and methods including private ones. I have read a few books, namely Clean Code, that say to keep functions as short and focused as possible. It seems tedious to list every little function in our diagrams if they don't help other developers out (they're private, no one else will use them). Plus, I may not think of every tiny function when designing the program, they may come along when refactoring.

Did the instructor tell us wrong by asking us to list every function? And, do these design methods squash the developer's individualism to write code how they can best understand it?

答:
I think your instructor is out of touch.  Commercial software is rarely designed or documented to that extent.  It's far too expensive, and the resulting documentation cannot be maintained without even more expense.  IMO such practices are a legacy from days when coding was often done in assembly language.  Your time would have been better spent trying more agile practices: test-driven development, pair programming, continuous refactoring.

Did the instructor "tell you wrong" ?

I think so.

Assigning boring work to intellectual property workers is wasteful.  In school, boring work has little or no pedagogical value, except perhaps to inure students to boring work.  Such exercises have negative consequences, both to the students, and to the industry.  The students are harmed because their time is wasted.  The industry is harmed, because some students may conclude that such tedium is necessary, and useful.  It is neither.  In thirty years in software, the only work I can think of that was both boring and useful was changing backup tapes.  There were robots that could do that, but they were prohibitively expensive.


答:
No, the instructor is right in telling you to list all the properties and methods upfront if you are using the waterfall method.  Wikipedia notes a criticism of waterfall:

Many argue the waterfall model is a bad idea in practice—believing it
  impossible for any non-trivial project to finish a phase of a software
  product's lifecycle perfectly before moving to the next phases and
  learning from them. For example, clients may not know exactly what
  requirements they need before reviewing a working prototype and
  commenting on it. They may change their requirements constantly.
  Designers and programmers may have little control over this. If
  clients change their requirements after the design is finalized, the
  design must be modified to accommodate the new requirements. This
  effectively means invalidating a good deal of working hours, which
  means increased cost, especially if a large amount of the project's
  resources has already been invested in Big Design Up Front.

These design methods don't squash the implementer of the design's individualism as there are still parts to interpret and ways to put one's unique touches on the structure,e.g. picture given a skeleton and adding the muscle and other tissues to create an animal wondering how much freedom did you have to design that animal?

You have found a shortcoming of waterfall yes but everything has its strengths and weaknesses.

Title: Should development methods squash a developer's individualism?

Body:
I'm in my final semester of college and am taking a software engineering course.  In the class we learn about various software development methods. The one we focused on, and used to develop our project, was the waterfall method.

I feel like the instructor may have implemented it wrong. In our class diagrams, we had to list ALL properties and methods including private ones. I have read a few books, namely Clean Code, that say to keep functions as short and focused as possible. It seems tedious to list every little function in our diagrams if they don't help other developers out (they're private, no one else will use them). Plus, I may not think of every tiny function when designing the program, they may come along when refactoring.

Did the instructor tell us wrong by asking us to list every function? And, do these design methods squash the developer's individualism to write code how they can best understand it?


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

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

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

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

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

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

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

答:
It doesn't matter what your colleagues say.  It doesn't matter what we say.

If you don't find any value in asking what the candidate's greatest weakness is, then don't ask it.  Please don't feel like the Interview Police will come beating down your door if you don't ask at least three of the following five questions:

Why do you want to work here?

What's your greatest strength/weakness?

Where do you want to be in five years?

What kind of plant would you be?

Tell me about a project that didn't go well.

Ask the questions that let you assess the value of the candidate as it applies to you.


答:
It seems tedious to list every little function in our diagrams if they don't help other developers out (they're private, no one else will use them).

If you think this is tedious, wait till you get a real job programming.  Consider, for a moment, that software may not be a viable career for you.

Plus, I may not think of every tiny function when designing the program, they may come along when refactoring.

So?

did the instructor tell us wrong by asking us to list every function?

No.  It's a common requirement.

And, do these design methods squash the implementer of the design (the developer's) individualism to write code how they can best understand it?

Yes.  The soul-crushing of individuals is an important part of software development.  All individuality will be beaten out of all programmers at all times in all possible ways.  It says that somewhere in the "God's Rules of Programming" handed down from some mountain to some prophet.

No.  You're just balking at the tedium.  Get over it and get back to work.


答:
Did you ask the instructor why you had to list all the methods?

It is possible that, like with much of what is asked for in a classroom environment, the intention was not to make your class diagrams more helpful to developers but to help you and your classmates think about how you would design your classes.  When students are learning how to decompose larger problems into smaller problems, it's probably helpful for them to think about what private methods they would likely need.  And it's probably helpful for the instructor to get a better idea of what methods students are thinking of implementing in order to intervene earlier in the process if someone's design is poorly thought out.  Documentation in a classroom environment is often much more involved than documentation in a real world environment because the instructor's intention is that writing the documentation forces students to consider things that they might be too inexperienced to think about if they are just focused on their code.

Of course, it is also possible that the instructor believes that this level of documentation is helpful in a real project.  If that's the case, the instructor is probably either out of date or came from a particular niche background where this level of planning and documentation is appropriate.  If you're building the navigation system for the space shuttle or designing medical devices, for example, it's generally far more appropriate to invest heavily in design up front rather than refactoring code during development.  If you're developing a social networking site, on the other hand, a more agile approach is more appropriate.


答:
Programming is the art of working within constraints. The CPU provides a limited instruction set; IO is constrained by the design of the hardware; OS APIs are created to encourage certain behaviors and restrict others; high level languages are often designed to promote one set of idioms over others...

And methodologies too are crafted to restrict.

Your challenge, in all aspects of the development process, is to realize your vision within those constraints. Will you bash your head against each wall thrown up by hardware, language, API, and methodology? Or will you find a way to harmonize what you wish to achieve with what is allowed and encouraged?

Do you really think your instructor wishes to read through endless pages of minutia? Then test that theory: break a program up, and document each atom. When his desk is sagging under the weight, I rather suspect you will find that his true desire is somewhat different from what you expect.

Or prepare the documentation as you see fit. Make it clear, make it understandable, make it read like a Dashiell Hammett novel. And then sit down and talk to him, show him what you've done, convince him of its merit.


答:
A simple rule of thumb to gauge project analysis complexity is "Can the developper or the company he works for can be held responsible for something dramatic enough (generally including death or huge amount of money lost) happening with the software created?".

I had the same experience as you for some of my courses. People who had a background in the miltary industry would teach us analysis. And that would be complete and exhaustive analysis, planning all the course of the project, even in the smallest details. You cannot afford much iterations with this kind of project (also bomb exploding can be ok, budget exploding are not), so no place for creativity here, you have to go by the plan.

On the other hand, if you have read a bit, you certainly read about agile methodologies. There is generally less documentation, and more room for the developper to use his creativity while developping a solution to the problem he does encounter.

In conclusion, the more experience you get, the better, and what your instructor is showing you does apply in some part of the industry. Just be aware that there are certainly as many way to manage and design a project as there are to code them. And you will find defenders and critics for all of them. Test them while you are studying, and choose the one you're happy with.


问:
Best way to use source control for a project (1-3 people)
So my partner and I are working on a practice management system and at first we didn't use any version control, then I persuaded him to use git. At the moment our system is that we have three branches: develop, master and release. Our git repo is on an external server, which has Apache, MySQL, etc. We do our daily coding on the develop branch (commits) and then we we have done some testing to make sure it's (semi) bug-free we merge it into the master branch. If we want to do something radical we just make a branch of master, mess around and if it works, good, we merge it back in, if not, we delete the branch.

Finally when we go for our weekly release we merge to the release branch to make sure we have a copy of the project as it was when we released. Unfortunately we don't track all files in git as it slows down git too much (e.g. images, especially since this is on an old server with a single-core 1.4 GHz AMD Sempron), as a git status usually changes from around 3s to about 1 minute; or because we can't (mysql databases). For us the slowdown is not workable so we just leave them out, and this has never seemed to be a problem because we haven't deleted any images, but we may start to soon as we start to optimize. So when we checkout previous commits sometimes the files aren't there and so it is broken (a big problem is we can't use version control on the database (because we don't know how), so because the schema has changed it is also broken if we go back).

And that's pretty much our workflow.

So after my background, my question is: Do you think that there are any improvements we could make to the above?

And on a side note: Does any know a reliable and easy-medium difficulty (i.e. not too hard) way to track mysql databases in git?

答: I think your concerns regarding git have been well-covered. The best VC for databases that I've seen is DB Ghost, or at least its concept. We are trying to adapt that to how we VC our DB as well in a preferably free manner.</p>


答:
In the class we learn about various software development methods. The
  one we focused on, and used to develop our project, was the waterfall
  method.

You probably learned the classical Waterfall model, which the person attributed with introducing it to the software development world stated from the start was inappropriate for developing large-scale software systems. You would probably be interested in reading Winston Royce's paper titled Managing the Developemt of Large Software Systems to learn more about the problems with what many people consider to be the Waterfall model.

However, the Waterfall model is good for teaching the software development lifecycle as you go through and can spend time learning about and performing requirements engineering, architectural design, detailed design, implementation, testing, and maintance in very clear, distinct phases.

In our class diagrams, we had to list ALL properties and methods
  including private ones. I have read a few books, namely Clean Code,
  that say to keep functions as short and focused as possible. It seems
  tedious to list every little function in our diagrams if they don't
  help other developers out (they're private, no one else will use
  them). Plus, I may not think of every tiny function when designing the
  program, they may come along when refactoring.

These are all very valid points.

Listing all properties and methods during the design phase, even when using Waterfall, is probably overkill. You should definitely list everything that's public, along with the essential properties. In reality, everything else is an implementation detail that you can obtain by reverse engineering your implementation into diagrams.

Clean Code's advice (I've never read it - I'm just going by what you posted) seems to be fair, and applicable even when using the Waterfall methodology. You can design your classes and methods with respect to the Single Responsibility Principle, separation of concerns, and other principles of SOLID. Waterfall doesn't tell you how to design, just when you need to do it. That said, it is harder up-front as you learn and think of better ways to do it during implementation.

I think this points out the fact that there needs to be iteration between design and implementaion very clearly - a problem that traditional Waterfall doesn't account for.


答: All of these suggestions are great.  However, I use a technique quite often that I didn't see mentioned.  Make lists to organize your thoughts about the problem.  If I have a particularly sticky problem I usually write out multiple lists such as: Facts, Assumptions, Questions, Symptoms, etc.  I find that oftentimes in the process of organizing things in this way I discover assumptions I didn't realize I had (that often turn out to be wrong), questions I didn't realize need to be asked, other permutations I can check, etc.</p>

Title: How do you tackle really bizarre errors that keep you puzzled for more than 10 hours?

Body: You know them, those errors that make NO sense. Where it seems like a gremlin just jumped deep inside your chips and messed up something. Do you take a walk, write stuff, call an uncle?</p>


问:
How do you approach a new project where the code has already been written?

Possible Duplicate:

  How do you dive into large code bases?

I'm about to take on maintenance and enhancements of a fairly large and complex Java EE project with a Javascript front end.

I'm trawling through the code trying to work out how it all hangs together but I wondered if any of you people have come up with a methodology for doing this that works best for you? do you start with the UI and work backwards to the database? Or take discrete 'slices' through the system for particular bits of functionality? Do you take notes?

How do you get up to speed with a new project?

答:
The words large and complex send shivers down my spine... you have 3 options.

1) Cry

2) Stare at code until your eyes go numb.

3) Set up a test environment and start throwing things at it. Go through what's happening line by line and you'll get a general impression quite quickly. A more detailed knowledge can only come with time and bug fixing.


答:
What if a developer from British background writes a renderer for web browsers such as gecko?

They will still have to adhere to the W3C standards, and those use US-English exclusively. If said British developer were to implement align="centre", then their product would not be a correct implementation.

Technically speaking, the standards define strings exactly as written, without any leeway for spelling; there is even one famous example of a misspelled word slipping into the HTTP standard (the "Referer" header). Using the correct spelling is actually an error in this context.

W3C does not formulate the use of American spelling and grammar as a constraint, but since US-English is their working language, and also the most commonly used language on the internet and in the programming world, the chance of a future specification containing British English is practically zero.

Title: Standards to constraint HTML renderer in only US-EN

Body:
Does W3C or any other organisation has standard or protocol to constraint all developers to make sure they must use american english while they develop any sort of interpreter?

To avoid something like,

I was writing code and tried to align image in centre(spelled in
  british english)

align='centre'

above didn't work!!

There is no spelling mistake, above spelled word meaning is "middle"

when I wrote

align='center' it worked,

Does this mean HTML is written in "American
  English"?

What if a developer from British background writes a renderer for web browsers such as gecko?

EDIT

Sorry I am not ranting but, I was wondering if W3C has any standards written somewhere which states that any future code or html tag written for HTML language must be in US-EN.

Does anyone have idea whether W3C have some constraint on this?


问:
Is there a reason for initial overconfidence of scientists and engineers working on artificial intelligence in the 1960s?
I just started an AI & Data Mining class, and the book. AI Application Programming, starts off with an overview of the history of AI. The first chapter deals with the history of AI from the 1940s to present. One particular statement stuck out at me:

[In the 60s] AI engineers overpromised and underdelivered...

What was the reason for the overconfidence? Was it because of mathematical prediction models showing that a breakthrough was around the corner, or due to the ever-increasing hardware capability to take advantage of?

答:
One reason was the success that we were having ELSEWHERE in the 1960s. We had just launched into space, and would soon land a man on the moon. We had just discovered cures for polio, and other major diseases.

But "artificial intelligence" was a different animal from the "engineering" problems we faced then. It was a "reasoning," rather than "mechanical" problem.

In short, AI (in the 1960s) was an idea "whose time had not yet come." It took more development, in subsequent decades, before it became as accessible as the other problems.


答:
The fact that your boss is willing to spent some time understanding the code that you written, you could use for your benefit.
Try introduce him to Cucumber:
http://cukes.info/

and make your boss write BDD test for you in the future.


答:
Build a test Harness to target that exact Defect and Isolate it

Just keep eliminating good code.. while replicating the defect. Until you target the exact piece of code casing the error. Then trace the code.

Recommended reading : The Pragmatic Programmer Specifically Chapter 10 : Tracer bullets


问:
How much effort goes into maintaining a build system?
In StackExchange Podcast #09 it is remarked:

Another study recently looked at how much effort goes into maintaining the build system: 5 to 30% of all development effort is spent on maintaining the build system.  With the variations being huge even when working on similar projects.

What is the name of the study referenced, and where can it be found? The audio of the podcast contains no further details.

Additionally, does anyone have any links to other studies covering the same topic.

答:
I don't have a link for you, but speaking from personal experience, that percentage varies according to 2 main points: 1) system design and complexity 2) and personal organization

A well designed system will require minimun effort to maintain even if it's quite complex. But if your staff is not properly trained and organized in handling the code, you'll probably spend a long time fixing bad builds or wrong commits and the likes...

However, when you have a development environment, Q&A, RC, and Production... It all takes its toll on the process of going from development to actual production.

I would say the percentages are correct, leaning over closer to the 30% mark than 5%. If all you are investing is 5%, you are doing a good job. (This is including errors found during Q&A or RC or even Production due to missmanagement of the Build System, which can cause huge delays).


问:
What are the proper uses of the various "Sign-in" terminologies?
What are the preferred use cases for the following sets of terms:

Log in / Log out

Log on / Log off

Sign in / Sign out

Sign on / Sign off

From what I can guess, "Logging in" should be used for a long-lived session (like a website), whereas "Sign in" should be for something that you will be attending to (like IM or a financial transaction).

I'm a little fuzzy here...

答:
These are all a matter of style (I prefer those with in/out over on/off).

Just choose one pair and make sure you use them consistently, and definitely don't mix your terms like Log on / Sign out.


答:
Which one sounds most natural?

```<code>What's your login detail?
What's your logon detail?
What's your sign in detail?
What's your sign on detail?
</code>```

That's sufficient for me to chose one.

Title: What are the proper uses of the various "Sign-in" terminologies?

Body:
What are the preferred use cases for the following sets of terms:

Log in / Log out

Log on / Log off

Sign in / Sign out

Sign on / Sign off

From what I can guess, "Logging in" should be used for a long-lived session (like a website), whereas "Sign in" should be for something that you will be attending to (like IM or a financial transaction).

I'm a little fuzzy here...

Body:
Which one sounds most natural?

What's your login detail?
What's your logon detail?
What's your sign in detail?
What's your sign on detail?

That's sufficient for me to chose one.


答:
I forget where I read it, I think it was the Rails company Thoughtbot but the basic idea was to use "Sign" for everything so that there are three actions always:

Sign In

Sign Out

Sign Up

This nomenclature makes sense because the basis for authentication is a logbook, so you "sign in" when you enter and "sign out" when you leave.


答:
It really is very simple:

You have been hired because of your skills as a programmer

Your manager does not have these skills

Ergo, your manager should not reasonably expect to be able to fully understand what you do

I've had a similar experience to this in a previous job. My manager was an accountant (and thus highly low-level detail oriented), and did not understand or truly trust programming. She could not comprehend that she, as a non-technical person, should not expect to be able to grasp the minutia of what I wrote. After many requests for excessive documentation and requests to train non-technical users in how to manage and alter the code (yes, really), I stopped trying to fob her off, and outright refused. The analogy I used to explain was simple:

I am not an accountant

I should not expect to understand every single transaction or posting in our accounts

This does not mean that the accounts are wrong, or untrustworthy, simply because I don't understand them

This is made possible by trusting the person who compiled them

At the end of it all, this is what this sounds like to me: a manager who has difficulty trusting their employees; or fears that they will leave, and thinks that this is an effective way to mitigate against it.

The only solution to this is to sit down and explain why this doesn't make sense. It is your job to understand the code and make it possible for someone with a similar skill set to yours to understand it, not your manager's. Showing them this thread may be a good idea (or a really, really terrible one, depending on their personality).


答:
From reading your question, it looks to me like one of the key requirements that's underlying your questions is the ability to understand and empathise with your customer and their needs. Unfortunately, an interview is a phenomenally poor forum to try and test understanding or empathy.

I think the way you're going to get the most out of this is to attempt to use some sort of case study. Give them some information about a customer (real or imaginary, but real is going to give you better results (anonymised, of course)). The candidate has to try and pitch to the customer, but you're not really interested in the pitch. What you're interested in are the questions that the candidate asks you in order to prepare for the pitch - it is here that the candidate will demonstrate their ability to analyse and understand a customer.

I should point out at this point that I'd probably hate to do this kind of interview, because it involves being put entirely on the spot. For maximum effectiveness and minimum candidate stress, send them the case study a few days before the interview, so they have some time to look it over.


答: I think the instructor is brilliant for making you do this project, and thus teaching you the pros and (mostly) cons of Waterfall development.</p>


答:
This looks like a candidate for a special holiday-issue pointy-haired-boss Dilbert strip!  His request certainly does not sound reasonable at first glance.

Humor aside, try to find out what he really needs, and why, then advise him of what it will cost in dollars or hours to give him that, and let him decide if he wants to spend that much money on it.

As for yourself, count up the hours it will take you to meet his seemingly bizarre request and then determine if you wouldn't be better off investing a fraction of that amount of time in finding a new job working for an employer willing to treat you as a professional!


问:
What are the major differences when moving from console-based to GUI-based programming?
I started, like many others, with console-based (as in terminal, not Playstation) programming. But sooner or later, one needs to touch upon GUI-based programming, whether you want to or not. This transition holds many changes in how you need to think about the frontend (and possibly also the backend).

So, what are the major differences when moving from console-based programming to GUI-based programming?

答: Usually I think of console-based program as the Model, whereas GUI-based program is the View/Controller that embeds the Model.</p>


问:
Can applications override the OS keyboard layout?
We have in-house .NET application, which can be used across multiple languages. Lately we received a strange bug that is when our application is being used, user was unable to enter accent characters (Spanish, Win 7) in other applications (ex: MS Word or Notepad). Strange, huh!

Did anyone come across similar bug? If yes how did you solve that?

答: One particular keystroke that might be helpful to check is the apostrophe (') keystroke through your event listeners. I'm pretty sure this what tells windows to toggle the accent for foreign languages.</p>


问:
My boss wants a narrated line-by-line English explanation of our code
I have been specifically asked to give line by line (or as appropriate - for example, image by image, etc.) explanation or commentary which my boss wants to be able to read and follow.

Since he is not a programmer, he can not follow the code so wants it all translated into English.

Has anyone been asked to do this before?

I have commented on all of the source code and used JSDoc to generate full documentation of all functions, variables, etc... and included an implementation example, and full working demos with comments throughout.

Is there anything else I can do to comment the code for non-programmers?

This isn't a reasonable request, is it?

UPDATE

In the end, I managed to explain why it was not a good use of time to do what he was asking. He is a reasonable guy, and just did not have an understanding of what my job involves. Once he saw this post, I think he quickly understood that it was not a normal request.

I did provide documentation that is suitable for another programmer to follow (JSDoc and inline comments - as well as some extra notes on technical issues), and a very broad flow chart diagram of the main logic of the program for my boss to follow.

In the end, all parties were satisfied and we have moved on.

答:
Why?

A line-by-line commentary not reasonable, but here's what I'd ask: why do you want this?

Is it because...

you want a complete understanding of what the software does (not necessarily how)?

you want to be sure another programmer can pick up the project if I leave?

you want to see that I'm doing real work?

There may be a reasonable desire behind this request, and you may be able to make your boss happy by figuring that out and meeting that need.

Update

Based on Mikey's comment, perhaps I stated this a little too bluntly. I don't mean that you should literally say "why do you want this?", just that you should find that out. Wording and tone of voice make a big difference. Specifically, you could say something like:

"I've been thinking about your request to have an explanation of every
  single line of code. It's a little bit unusual to do things that way.
  I was wondering if maybe there's something I'm not communicating well
  to you about my work. What is it that you really want to understand
  about our code, or about what I'm doing? What are you trying to
  accomplish here?"

Of course, it's possible that your boss is totally unreasonable. But it's more likely that he doesn't know how outlandish this request is and has some rational goal in mind.

If not, start polishing your resume. :)


问:
What are the worst false economies in software development?
What are the worst false economies (that is ways of saving money that ultimately cost more than they save) prevalent in the software industry and how do you combat them?</p>

答:
Having too many non-billable delivery managers.

Couple of years ago, in our company we had several big budget projects going on and recruitment was at peak. At that time our company hired too many delivery managers (Many of them were non IT!) and very few coders/testers. Manager to Programmer ratio was literally 1:2. Later, after completion of those projects, we had a situation where we had many of these managers (some of them were real slackers) sitting on bench doing nothing. We had one appraisal cycle where everyone got little/no raise (Even us hardworking programmers, sigh) so that company don't have to lay anyone off! Fortunately, company realized this situation and did the RIGHTSIZING in the first quarter this year!


答:
I really didn't like the most up-voted answer, because even though that sometime works, some times you just need to figure it out that same day, so what I'd recommend, in this order, is:

Confirm that it's not only happening to you. This can save you a lot of time. Maybe you uninstalled a required component, or made a change in your environment, and an exception is being swallowed somewhere in your code. If it's happening only to you, I would use an environment comparison tool. I recently read about a software called Envy, which allows you to do just that, although it's not freeware, it costs 10 USD.

Happening to everybody? Fine, now do a View History on the code and verify for recent changes that might have caused the error, either directly or indirectly.

There aren't any recent changes? If it's a very specific error (an exception), 'stackoverflow it'. Now that doesn't sound better than 'google it' but I feel good to say I first search stackoverflow for programming research than google. If it's a really known issue, it's very likely that you'll find a solution here. If not, then post a question on the related stackexchange site. You might get a very quick answer, or even if you don't, your question will be out there while you do more research. That's a benefit.

If you didn't find an answer online or it isn't a general error, then walk through the code step by step, checking if the obtained results of each step make sense for the result you expect. Go start to finish on each method, and bottom to top on a tiered solution. (i.e. if you're troubleshooting performance, start with the code that retrieves the records. doesn't make sense to start in the UI if you can determine quickly if the first step is the problem).

If after going through the code a couple of times you still haven't found what's wrong, call-in someone to talk about it. As someone already mentioned, talking about it out loud can light the bulb. Plus pair-programming is really useful.

At this point, if it's feasible, walk away either for some time or for the day. I read a very true tweet yesterday that said "I went to bed thinking 'how the fck' and woke up thinking 'but of course'". So true.

If you still don't have an answer, I'd dare say you could try refactoring into smaller tasks/methods/functions. Henry Ford said something like 'There isn't a task so complex that cannot be accomplished by breaking it into smaller tasks'. At this point, if the solution is too complex and you haven't figured out either by yourself or with the help of someone else, refactor the code into smaller tasks. Even if you don't end up commiting it, it can help you find the reason.

Add instrumentation to your code.

Tweet about it??


问:
What is the best way to scale a CQRS system?
In the previous months I have been asking a lot of questions concerning the architecture of an application I'm working on. Thanks to the answers the architectural design has changed - in fact, it has really been simplified as shown in the following graph:

Internally I have a two services (NOT WCF!) that follow CQS principles. It means that the query service simply returns database views; while the command service has a full domain model that contains all business logic, and repositories to access the database (no event mechanism or other complex pattern here). Both services use the same database. These services are class libraries, NO WCF services, because they are used only internally so I don't need the overhead of WCF (don't distribute your objects, Martin Fowler's first law).

These internal operations are used by the ASP.NET MVC site and the PartnerService. This PartnerService is a WCF service, which exposes the functionality I would like to be exposed to partners.

If I ever need to scale because of high traffic, I could add web servers and/or migrate parts to a full CQRS system (my contracts are already designed for it).

Does anyone see any problems with this?

One thing I see is that if the query or command service changes, this impacts both the web site and partner service directly, so I have to deploy the changes to both. But I don't know if this is an issue...?

Any feedback is appreciated! Thanks!

答:
One thing you could do to allow a little more flexibility on the query side of things things, is define your contracts with extension points. Fowler discusses this here:

http://martinfowler.com/articles/consumerDrivenContracts.html#ExtensionPoints

It essentially allows you to add properties that are exposed through the service without breaking existing consumers, so if the website needs another property exposed, you can supply it through the service without breaking the partner service.

"This allows the ProductSearch service to return results that include
  product descriptions, and consumers using the new schema to validate
  the entire document. Consumers using the old schema will not break,
  though they will not process the description."

That whole article is a good read wrt services evolving over time.

OwnerDisplayName: Lud

OwnerDisplayName: Paul