答:
I do not believe that you should focus your optimizations looking for magic keywords, but here goes some tips:

"inline" might do wonders in numerical apps if you  have many short numerical functions

Be careful when copying values all around when you could use a reference. This sounds basic but if you have many classes that are copy/assignment compatible your code could be hiding some copies. Make sure your constructors are defined with the "explicit" keyword, that way your compiler will show you where implicit copies are done.

Give C++11 a try. There are some interesting optimizations. There are more things that are solved statically. Also one very interesting thing for your case is the rvalue reference optimization. It is a very important optimization on the return value of functions. You will notice that a lot if you overload operators, which you will do if you operate different units and try to structure your old code.

There are lots of things that can be done with STL and really interesting template metaprograming, but that is a whole different level to what most people is used to.

Do not rely too much on your compiler optimizations. C++ syntax is well known to make life easier for low-level programmers and a nightmare for compiler designers. That is one of the reasons for which good static analyzers took so long to appear. I know that Scott Mayers made that comment and how C++11 improvements will help to get better tools, but cannot quote where he did.

On the line with compilers... do not expect to get SIMD and overall paralel optimizations. Compilers are really bad at it and unless you get your hands dirty with some library for it, your code will target only one core, one thread of your machine.

It might sound silly but the keyword "const" is really important. If you make clear that some value does not change, the compiler will apply a whole extra set of optimizations. Detecting if a variable could be considered const takes some extra parsing that most compilers do not perform not even with optimizations maxed out. Related with this for example, if your loops do not seem to have a clear/constant end, the compiler will not unroll them (or maybe not as good as it could)

However I wonder why you are migrating from Fortran77 to C++. Fortran sure is an old language, but it is the king for mathematics no matter how ugly it looks, the best way to deal with old code is building a good layer and operate it from outside with the new infrastructure and language you want. It is easier said than done, because sure you will have still to fix some Fortran code in order to make it easier to operate from outside.

If you decide to go on with C++ at least you will get much nicer libraries for multithreading (and that is one of the biggest improvements of C++11) where Fortran lags behind. Try to avoid CUDA if not absolutely necessary, it is really good and mature but focused on NVIDIA. I would keep an eye on OpenCL

Be aware that there is one huge difference for Math. In C++ (like most languages), the values of a matrix are stored as a set of rows while Fotran stores them as a set of columns. This makes a huge difference on the best memory usage of your algorithms. Hence if your algorithms are optimized for Fortran, their loops will target columns instead of rows. (look here) That is how seriously Fortran optimized for Mathematics goes.

One final concern. You want to use C++ and not Fotran77. Because you can get a better abstraction and design? Well, that is a good reason, but please, be wary of the market obsession with object oriented programming. It is a good thing, but not a silver bullet. A GUI for example should always be object oriented, but if you do lots of math and move huge amounts of memory, some aspect oriented style would be nice. Even better for your domain problem, have a look at data oriented design as an alternative to object oriented design (and see one case where OOP fails)


问:
How to spend less time on debugging?
Following the Pareto rule, a programmer spends only 20% of his time for really useful things.

I spend 80% of my time debugging, fixing small things to get everything working.

Is there a way to spend less time debugging?

答:
Unit testing will help as hopefully if you introduce bugs they will break before your production code - well written unit tests will also tell you exactly what broke.

That'll get you most of the way, but for 99.999% of projects you will still need to debug things from time time. The best thing to do here I find is to do 4 things:

use immutable types wherever possible - if something has a wrong value you'll know exactly where to look immediately (where it's being constructed).

enforce invariants in the code - if you know a value is definitely not allowed then check for it and throw an exception in the entry points to methods and constructors. If you combine this with immutable types then you can also begin making certain assumptions about what is valid or not.

ensure you have adequate logging - get this in early and it'll give you a lot of important information about when things go wrong. AOP works really well here. Logging as an afterthought is usually a bit rubbish - get it in early as part of the project setup.

if your code base is big/complex enough avoid using primitives - e.g. have a type called 'Age' rather than just using an int. It'll seem a bit pointless at first, but being able to track down all uses of something in an instant is a huge debugging win.

ContentLicense: CC BY-SA 3.0

Title: How to spend less time on debugging?


问:
Learning Each Type of Programming Language
I have heard several times that every programmer should learn one of each type of language. Now, this is not necessarily true, but I believe it is a good idea.

I've learned a Procedural Language (Perl), but what are the other types?

What are the differences between them and what are some examples of each?

答:
Programming languages have a number of mostly orthogonal features; the most prominent one lies in the paradigm or paradigms they support. The wikipedia article covers paradigms exhaustively; the most important paradigms are probably these:

Procedural / Structured

Functional

Object-Oriented

Event-Driven and Aspect-Oriented

Generic

Logic

But languages differ in other ways as well:

Typing system (dynamic vs. static typing, and strong vs. weak types)

Build process and runtime environment (interpreted, bytecode-compiled, fully compiled)

Memory management (manual like C / C++, mandatory automatic garbage collection like Java, optional GC like D, ...)

Evaluation discipline (eager vs. lazy; most languages are eager by default, but many provide lazy constructs)

Scoping rules (compare how scope works in PHP, Javascript and C, three languages that are otherwise quite similar in terms of syntax)


问:
Can code be the documentation in open source developer tools? How frequently is it?
It's understandable that after a big development effort, some OSS authors deem reasonable that the project users should make an effort too in order to get started.

Can the source code effectively be the project's documentation? Does it need to be structured in a particular way in order to achieve this? And how often is this approach taken?

Of course this only would be feasible if the project is aimed to developers, and written in the same targeted language of the application (e.g. you can't understand the V8 engine only knowing JavaScript).

答:
Nearly all the popular Java OSS packages I've used have been well documented with javadocs.  To be technical this means that the source code contains, not is, the documentation.

Whatever the case, these are generally some of the best documented systems I've used.  I believe this is due to keeping the documents with the source code, allowing them to be updated in parallel--then splitting out the docs later.


答:
Adding to the comments for Unit Testing but it is only really good if your code has been separated to support it (e.g. MVC).  If you can't implement MVC (or similar) (legacy project), unit tests don't work at all for your UI.  I would then add automated UI testing (Microsoft Coded UI Tests, WaitN) as this will reduce errors in that portion of your code.

I would also highly recommend running static analysis tools (e.g FxCop/Microsoft Code Analysis, Resharper, JustCode for the MS world).  These can find all kinds of common coding problems which can reduce the silly debugging tasks and focus more on debugging business logic.

Title: How to spend less time on debugging?

Body:
Following the Pareto rule, a programmer spends only 20% of his time for really useful things.

I spend 80% of my time debugging, fixing small things to get everything working.

Is there a way to spend less time debugging?


问:
Fastest C++ XML parsing library
I have thousands of .xml files from size 1MB-45MB (no DTDs). I need to parse and further manipulate these XML files before generating separate .xml files with the results of my regex.

What the fastest open-source XML parsing library for C++? Aside from the parsing library, what other approaches can I use to speed up XML parsing?

答:
RapidXml is an attempt to create the fastest XML parser possible,
  while retaining useability, portability and reasonable W3C
  compatibility. It is an in-situ parser written in modern C++, with
  parsing speed approaching that of strlen function executed on the same
  data.

http://rapidxml.sourceforge.net/

Maybe you could start comparing Expat with this one? Expat is known to be really efficient on speed.
RapidXml is used as backend of some boost libraries, mostly Boost.PropertyTree.

Also, I think maybe a more xml-scheme-specific approach could (maybe) be more efficient because of knowledge of the structure of the code. Such claim is just a supposition but if you're interested, CodeSynthesis provide a C++ code generators that takes an xsd file as input. The resulting parsing code might be more helpful... if you take time to define your format in an xsd. There are other similar tools available but it's the one I'm using for my last project. Those tools are mostly based on xerces but you can generate code that is independent. No idea about the performance impact.

Title: Fastest C++ XML parsing library


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

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

答:
UML is painful if you also try Model Driven development. I mean that UML is a very useful graphical notation only and everything else is useless.
I don't spend on modeling but use UML every day in order to create the structure of my projects. What I do is to quickly draw a basic usecase diagram at requirement levels, then immediately switch to class diagrams. I add requirement traceability between usecase and class diagrams. My class diagram also create code because it is live synchronized. No tag in the code all model is saved in the UML model which is mapped to the Java project.

I create the skeleton of my application with few class diagrams, then switch to code. Once I finished the code I merge it with the model. It is a kind of iteration between code and model where the code runs the model. So my class diagrams give me a higher level of abstraction and my code while my code gives me my business logic implementation (e.g. methods).

UML modeling requires less than 10 minutes per day, which is done when I need time to think what I need to develop and how.

UML is great, fantastic and really useful but model driven development is useless !!

ContentLicense: CC BY-SA 2.5

Title: How often do you use Formal UML?


答: Give your code a careful read before you even compile it.  A very careful read for syntax and functionality.  It can be surprisingly informative, and is also a good indicator if a section of code is too complicated.</p>

Title: How to spend less time on debugging?


问:
Should a newcomer to Perl learn both Perl 5 and 6?
I have started playing around with Perl 5 lately, and it seems very interesting. I would like to spend some time learning it more in depth when I can.

My question, since Perl 6 is slowly taking place (I believe...) and is said to break backward compatibility, is this: am I better learning Perl 5 and then Perl 6, or is learning Perl 6 directly a better time investment according to you?

If the changes from Perl 5 to 6 are making it hard to understand Perl 5, I should certainly start with Perl 5 to be able to read "old" scripts, then check Perl 6. There is also the "Perl 6 is not yet completely released" problem. I know there's an early adopter implementation for Perl 6, but if Perl 6 isn't officially released before some more years, I'll stick to 5 for now.

I would certainly like some insight on this. Feel free to discuss related stuff. My interest in scripting languages is fairly new.

Thanks!

答: Best advice: no, no, no! Perl 5 is best right now since Perl 6 is not fully developed.</p>


问:
Best way to parse optional grammar rules?
I started to write a hand written parser just for fun. For simple rules it is working, but I have problem with the optional grammar rules. I marked the optional rules with a question mark.

Here is a simple rule:

```<code>rule1:  "AA"? "AB"? "AC"? "AD"
</code>```

So AA, AB and AC string is optional, but AD is required.

ex.:
"AAABAD" is matching,
"AAAD" is matching,
"AAAB" is not matching,
"AD" is matching,
...

I need an algorithm and not a regex tool or something like that. I can solve this with brute force method (so trying every possible combination of the rules) but I think there is a better way to do this.

答:
Normally your lexer would distinguish "AA", from "AB", etc.  If that's an issue I can elaborate.

If the lexer does, you have the partial grammar:

Rule1 → "AA" Rule1B

Rule1 → Rule1B

Rule1B → "AB" Rule1C

Rule1B → Rule1C

Rule1C → "AC" "AD"

Rule1C → "AD"

This might not be that efficient, but it's relatively clear.  I believe you will need recursive descent with backtracking for this though.


问:
What to do when allowing application to run in an invalid state?
We currently have a 'global catch all exceptions' section in our application.  When an uncaught exception is thrown, the stack trace is displayed and the application continues running.

More often than not, this leaves the state of the application invalid going forward.  Especially with NullReferenceExceptions, and threading exceptions being the cause.

I decided to have the application log the exception in the 'global' section and shutdown and restart.  This was met with criticism from management - who asserted that the user should choose to select whether or not to restart under these conditions, since it never shut down before.  (Though I tried my best to explain that the issue was allowing the app to continue running in the first place).

I am looking for things to watch out for now, and specific approaches I can take to handle code that is now allowed to continue to run while in an invalid state.

答:
Gee this sounds familiar.

I was once the manager for a group that had a large application which had a few unhandled exceptions that were eventually caught be a global catch-all-and-display-the-world-has-ended handler. By default this used to allow the application to keep running.

Your point about application state in this case is the same one I made: the application should not continue running because its internal state is unknown, and most likely suspect (after all that's how an exception came to be raised in the first place).

I wanted the application modified so that the user could save data and then the application would exit - no opportunity to continue. This was met by fierce resistance, mainly from developers who argued that it had continued for a long time and there had been minimal damage - just lots of complaints. In the end I had to back down - the user was allowed to continue but dialogs were changed to strongly suggest to users that they should exit and restart. I still think this was wrong.

In then end, every exception that is seen needs to be analysed to find the underlying cause, and appropriate fixes, code changes, or whatever need to be applied so that exceptions don't happen - or if they do they are caught as part of normal program flow and locally handled.

(Sometimes, sadly, exceptions are propagated out of things like libraries. One of the rules I was taught a long, long time ago was: "do not ever rely on exceptions for normal program flow". It seems this is not always regularly practiced any more.)

I feel your pain - but in the end, the principle is a simple one and you should be sticking to it: When the last chance exception handler is fired, things are really sick. The program should exit. Doing otherwise gives users the misleading impression that they can continue working, but internally the program has an unknown or broken state. Continuing to work only leads to things getting progressively worse. In the end this translates into loss of customer satisfaction. Customers are also pissed off by a program that raises an exception and exits - if there is unsaved program state you should try and save it, perhaps in a manner that makes it clear that what is saved may not be reliable. At least you reduce the chance of data loss. But continuing to operate... bad bad move. You have to choose the lesser of 2 evils.


答:
Its definitely best practice to shutdown the application which has thrown an unhandled exception. Under Winforms in .NET, there used to be a dialog which popped up and gave you a big warning with the option to continue running. But since I think .NET 3.5 that continue option is no longer there and you are forced to shutdown the app.

Whether you then restart the application automatically is up to you - I have seen this done by some other major software like browsers.

The dialog for our 'global' catch all exception handler displays the stack trace plus other information (machine name, time, error message, current user name, etc) in a textbox which can be copied to the clipboard. A button is available to email support with the information (button is named 'Send Error Report'). In my experience, the user probably won't bother informing you of it happening unless they are given an easy way like this to email you. And writing the exception details to a log file, while still necessary, won't be of much use to the developer until you get access to file or to the machine.

Title: What to do when allowing application to run in an invalid state?

Body:
We currently have a 'global catch all exceptions' section in our application.  When an uncaught exception is thrown, the stack trace is displayed and the application continues running.

More often than not, this leaves the state of the application invalid going forward.  Especially with NullReferenceExceptions, and threading exceptions being the cause.

I decided to have the application log the exception in the 'global' section and shutdown and restart.  This was met with criticism from management - who asserted that the user should choose to select whether or not to restart under these conditions, since it never shut down before.  (Though I tried my best to explain that the issue was allowing the app to continue running in the first place).

I am looking for things to watch out for now, and specific approaches I can take to handle code that is now allowed to continue to run while in an invalid state.


答: Make it work, then make it fast, then make it pretty. Most bugs come from early optimizations or re-factoring at lines of code that were totally fine. If you go with object orientation don't repeat yourself, keep it simple and always make sanity checks of value ranges especially if your methods will still work at constraints. It won't help you make less mistakes but it will likely help you to spot bugs faster and therefore debugging takes less time.</p>

Title: How to spend less time on debugging?


答: Depending on the situation there's an answer I used once:  If something goes haywire but it's not a certain fatality I reset the document name--if the work gets corrupted it wouldn't overwrite the original.  It was only intended to allow them time for a graceful exit.</p>


问:
What is the job title hierarchy amongst software engineers?

Possible Duplicate:

  What does the suffix after software engineer/developer job titles mean? (i.e. Software Developer III)

  work advancement titles

I've been struggling to understand job hierarchy in software engineering.

The system is further complicated because of the lack of consistent naming conventions when assigning roles: for example, some companies just have a "senior software developer" position while others have Software Engineer I, Software Engineer II, Software Engineer III, and so on.

Even in the top level positions, we have things like "Principal Software Engineer" vs. "Staff Software Engineer".

What is the standard hierarchy for software engineers? Is there a generally accepted pecking order?

答: There is no standard hierarchy of software job titles. Titles are peculiar to each company. If you have a question about a job title there's no point in asking anybody except that company.</p>


答:
Job titles only have meaning within a specific organization sometimes only within a small section of that organization. In general they are only useful in assessing the "Dilbert Co-efficient" of your current employer.

Also be careful with the title "Engineer" in some countries its illegal to use the title unless you are an accredited member of the local Civil/Electrical/Electronic professional body.  "Software Engineer" doesn't count for much with "real" engineers.

Title: What is the job title hierarchy amongst software engineers?

Body:
Possible Duplicate:

  What does the suffix after software engineer/developer job titles mean? (i.e. Software Developer III)

  work advancement titles

I've been struggling to understand job hierarchy in software engineering.

The system is further complicated because of the lack of consistent naming conventions when assigning roles: for example, some companies just have a "senior software developer" position while others have Software Engineer I, Software Engineer II, Software Engineer III, and so on.

Even in the top level positions, we have things like "Principal Software Engineer" vs. "Staff Software Engineer".

What is the standard hierarchy for software engineers? Is there a generally accepted pecking order?


答:
There is no global standard for designations or i assume no one has made one till now. Its good to have guidelines for design, naming convention but the code has nothing much to do with the designation of the person writing it.

The one you have mentioned would be company specific and you can think of them as levels in a game where in you play at one level, gain experience and points/life and then qualify for the next level. This part pretty much is same all over, so the more you play the better you get and higher the chances of going up the levels but then as its is for all games the rules are different and so in this case its the company.


答:
Wikipedia gives a good overview of corporate titles and under the hierarchy for Information Technology companies you have the following:

Chief Executive Officer

Vice President

Senior Project Manager / Senior Product Manager / Senior Software Architect

Project Manager / Product Manager / Software Architect

Project Lead / Senior Team Lead / Senior Technical Lead

Module Lead / Team Lead / Technical Lead

Senior Software Engineer / Senior QA Engineer

Software Engineer / QA Engineer

While each company will have it's own naming convention and resposibilities for a role, they do seem to fall within this basic hierarchy.

Hope this helps you out some.


答:
My two top thoughts are 1) Write better code which will fail when you do something unexpected 2) Become better at debugging

My code is littered with

```<code>if(value!=null) throw new NotImplementedException();
if(obj.v>0) throw new Exception(); //sometimes i dont write NotImplementedException
if(value=="thing") throw ...;
</code>```

Whenever i execute that piece of code the exception is thrown which causes the debugger to stop which lets me code in the new features or avoid the conditions rather then get confused about what is happening/have a bug

To become better at debugging mess around with the call stack, breakpoints (with conditions), the immediate window (also known as prompt or repl window), 'watch' variables and whatever else.

Title: How to spend less time on debugging?

Body:
My two top thoughts are 1) Write better code which will fail when you do something unexpected 2) Become better at debugging

My code is littered with

if(value!=null) throw new NotImplementedException();
if(obj.v>0) throw new Exception(); //sometimes i dont write NotImplementedException
if(value=="thing") throw ...;

Whenever i execute that piece of code the exception is thrown which causes the debugger to stop which lets me code in the new features or avoid the conditions rather then get confused about what is happening/have a bug

To become better at debugging mess around with the call stack, breakpoints (with conditions), the immediate window (also known as prompt or repl window), 'watch' variables and whatever else.


问:
How long would it take for someone completely new to programming to get enough knowledge to make it to the job market as a junior programmer?(C#)
I just want to know how long would it take me to become proficient enough (in let's say C#) in order to be able to get into the job market as a junior/entry level programmer. I have read all those articles and discussions about "how long would it take" but the answers always seem to be like "...it will take you two weeks to know the syntax, but it will take you 10 years to become a good programmer..." or "...the same time that it would take you to learn German...". Nevertheless, there is a continuum between the two extremes. I know that I'm not going to produce great code in a few months, I just want to know how long would it take me to write code "good enough" to be considered "hirable". I know that the answer depends on many factors, so I will be as specific as possible describing my situation:

-I'm in my late 20's.

-Haven't made it in programming beyond creating objects in C#.

-Have some friends (5) who studied CS and are working as programmers. A couple of them are able to help me through my learning process though no full time.

-Very underdeveloped mathematics skills. Never made it beyond very basic algebra, not because I didn't understand it, but rather because I studied something unrelated to mathematics.

-Fast learner. I made it through a Basic Algebra book in less than two weeks and scored A in a test after more than 7 years without
even opening an arithmetic book. I don't know the multiplication table, but I get by because I know in principle what multiplication is.
If you ask me how much is 8*8 my brain goes like: it is 80-(2*8)... yeah, I'm at that level...

-My IQ is consistently over 135 in standard tests.(to maple_shaft: yes, standardized tests, like the ones to complete for MENSA; anyway I'm not that proud about it at all since EQ is where the real deal is. I just brought it up because I know that in the field of programming it is a good trait to have.)

-Very high capacity of abstraction and generalization.

-I won't be able to study full time. I could study for an average of 1.5hrs on work days and 6hrs on days off.

If you read this far maybe you would also be so kind to respond as concisely as possible to these two questions:

A. Is it realistic for someone with no college education to make it to high levels in the industry?

B. How would you describe the relation between the daily work of an application developer in an average project of an average company and mathematics (mainly: calculus, trigonometry, etc)?

Physics <---> Mathematics (Strong Correlation. All great physicists are great mathematicians... there is no way around it).

Architecture <---> Civil Engineering (Somehow Correlated, but you can earn your bread with only some general concepts of it).

General Mechanic <---> Engineering (I'm just going to use the tools that you created to fix what you created, but how I do it is another thing).

Thank you very much in advance for your replies.
Please, please, no offensive or repetitive answers; I would appreciate serious answers.

Thank you for your time.

答:
Generelly this is very hard to answer since we don't know you...

But I would roughly estimate 6-12 months to a "hirable" status...

You should invest into some good books (IF C# is the language you want to learn then for example "C# in Depth" - see http://csharpindepth.com/)... after 3-4 months you should start digging through the source code of good opensource software (for example http://codeplex.com or http://codeproject.com)... these are great resources to learn how it should and how it shouldn't be done... another point is aside from technical skills: you will need to get good at communication etc. (a nice compilation see http://www.kalzumeus.com/2011/10/28/dont-call-yourself-a-programmer/).

As to your question A: If the motivation/determination is right then definitely yes.

As to your question B: on average I would say "somehow correlated".


答:
As you said it really does depend on many factors

A fast learner in algebra has no co-relation to how fast you will grasp programming, have you gone through OO concepts and do you find the concepts of class , interfaces and framework methods graspable.

First and foremost thing is you have to invest time to practice and need to have some inclined interest in writing some code coz practice is the main key. you need not worry about the output since 8*8 in the code will give the proper output but you need to know how to write this in so that it performs the calculation. There are many areas to work in programming and only some of them are mathematical.

Short and long answer is Practice , practice, practice and iteratively you would get the concepts right and be on the path of a good programmer and you still hold the urge and enthusiasm to code.

Title: How long would it take for someone completely new to programming to get enough knowledge to make it to the job market as a junior programmer?(C#)

Body:
I just want to know how long would it take me to become proficient enough (in let's say C#) in order to be able to get into the job market as a junior/entry level programmer. I have read all those articles and discussions about "how long would it take" but the answers always seem to be like "...it will take you two weeks to know the syntax, but it will take you 10 years to become a good programmer..." or "...the same time that it would take you to learn German...". Nevertheless, there is a continuum between the two extremes. I know that I'm not going to produce great code in a few months, I just want to know how long would it take me to write code "good enough" to be considered "hirable". I know that the answer depends on many factors, so I will be as specific as possible describing my situation:

-I'm in my late 20's.

-Haven't made it in programming beyond creating objects in C#.

-Have some friends (5) who studied CS and are working as programmers. A couple of them are able to help me through my learning process though no full time.

-Very underdeveloped mathematics skills. Never made it beyond very basic algebra, not because I didn't understand it, but rather because I studied something unrelated to mathematics.

-Fast learner. I made it through a Basic Algebra book in less than two weeks and scored A in a test after more than 7 years without
even opening an arithmetic book. I don't know the multiplication table, but I get by because I know in principle what multiplication is.
If you ask me how much is 8*8 my brain goes like: it is 80-(2*8)... yeah, I'm at that level...

-My IQ is consistently over 135 in standard tests.(to maple_shaft: yes, standardized tests, like the ones to complete for MENSA; anyway I'm not that proud about it at all since EQ is where the real deal is. I just brought it up because I know that in the field of programming it is a good trait to have.)

-Very high capacity of abstraction and generalization.

-I won't be able to study full time. I could study for an average of 1.5hrs on work days and 6hrs on days off.

If you read this far maybe you would also be so kind to respond as concisely as possible to these two questions:

A. Is it realistic for someone with no college education to make it to high levels in the industry?

B. How would you describe the relation between the daily work of an application developer in an average project of an average company and mathematics (mainly: calculus, trigonometry, etc)?

Physics <---> Mathematics (Strong Correlation. All great physicists are great mathematicians... there is no way around it).

Architecture <---> Civil Engineering (Somehow Correlated, but you can earn your bread with only some general concepts of it).

General Mechanic <---> Engineering (I'm just going to use the tools that you created to fix what you created, but how I do it is another thing).

Thank you very much in advance for your replies.
Please, please, no offensive or repetitive answers; I would appreciate serious answers.

Thank you for your time.


答:
At Microsoft, the titles are:

Software Development Engineer (two internal levels, 59 and 60)

SDE II (61 and 62)

Senior SDE (63 and 64)

Principal SDE (65 and 66)

At Google, there are senior titles like Staff Software Engineer and Sr. Staff Software Engineer.

At Apple, there are titles like Software Engineer I to Software Engineer V.

See also: What is the difference between these senior software engineer titles?


答:
A. Is it realistic for someone with no college education to make it to high levels in the industry?

Yes. Especially if you're well motivated and reasonably smart. (And depending on what you mean by "high levels".)

Some formal education specifically in computing (obviously) helps, preferably higher than high-school level though not necessarily a university degree: some kind of diploma or even a semester at night-school in a couple of subjects would be much better than nothing. There are some general computer science concepts that you may or may not pick up on if you just learn one specific language.

Having said that, there are plenty of self-taught programmers, some great, some terrible, and I know some pretty terrible programmers who somehow managed to get a computing degree, so...

You also need good communication skills. Judging solely from your question you have better communication skills than some of my colleagues.

I won't be able to study full time. I could study for an average of 1.5hrs on work days and 6hrs on days off

If you have the aptitude and have the motivation to study that much every week I'd say 6-12 months is reasonable to get you ready for a junior programming job, but there will probably still be a lot that you won't know. And bear in mind that you'll be competing with people who've studied full-time for longer than that, so the state of the job market at the time will be a big factor. If you already have friends in the industry they may be able to help you get a foot in the door.

B. How would you describe the relation between the daily work of an application developer in an average project of an average company and mathematics (mainly: calculus, trigonometry, etc)?

I've worked in programming for nearly twenty years and never needed calculus (haven't touched it since high school). I've occassionally used some basic trig. If you work on something with a lot of graphics (a game being the obvious example) you will probably be doing a lot of maths including some trig, but the typical "business app" or website doesn't tend to need more than fairly easy algebra. A financial app obviously uses more maths, and naturally if you're developing a maths program you'll need higher maths skills.

In your case you said, "Never made it beyond very basic algebra." Have you done "sets"? If not you might want to learn about that on one of the many maths tutor websites, it will definitely help you in programming. If the reason you didn't progress further in maths is that you didn't understand the harder concepts then you may not have the right aptitude for programming. If you didn't have trouble but just never had an interest because you were headed for medicine then you could be fine. You don't need to be great at maths to be good at programming.

Very high capacity of abstraction and generalization

That will certainly help.

Good luck!


答:
A. There's no reason why you can't be successful without a CS degree. If you have enough determination, really enjoy programming, and can become reasonably good at it, then there shouldn't be any limit to what you can achieve. However, its a fact of life that I think the majority of jobs out there do ask for some sort of formal qualification. So you might be better to initially lower your sights and go for an IT related job in a company that also employs developers, and then attempt to cross skill on the job and apply for internal positions as they arise. I've seen this happen many times myself with coworkers.

B. I can honestly say that I don't think maths figures that much at all in the average developer's job. In 18+ years of developing I've only briefly touched on the linear algebra studied at university. Seriously, with google these days I'm sure you can get by with basic maths skills as a developer. I have worked on some graphical apps that did require some computational geometry skills, but I wouldn't call it advanced maths by any regard.

Good luck...


问:
How to make security usable in a web application?
I'm in the planning stages of developing a web application that I want to make as secure as possible. I'm pretty clear about how to do that from a technical point of view, but there is one massive potential security hole: I want the site to have users.

As anyone who has ever been a user knows, users forget usernames, forget passwords, sometimes forget that they even had an account with your site. Users respond to phishing emails and give away their credentials. If you do anything that they find too complicated they won't use your site, it has to be simple and all happen in as few clicks as possible, but we have to balance that out by making it as hard as possible for users to accidentally give away their credentials and to keep access to the service as secure as possible.

What I'm particularly interested in are strategies that go beyond the standard username and password combination and ways of recovering or resetting passwords that make things easy for users but hard for anyone trying to steal their account. I know a lot of sites provide an extra user-set security question, but because I don't trust users not to create a stupid question like "what is 1+1" I don't see how this can guarantee security.

Are there strategies that could be useable to the most clueless user but challenging to a determined and targetted attack aiming to break into their account? If not what are the closest things we could get? As a user what are the best/worst sites for this you have encountered and why?

答: You can also use OpenID and OAuth rather than having user create new account</p>


问:
Count a row VS Save the Row count after each update
I want to know whether saving row count in a table is better than counting it each time of the proccess.

Quick Example : A visitor goes to Group Clan, the page displays clan information and Members who have joined the group,Should the page look for all the users who joined the clan and count them, or just display the number of members already saved in table ?

I think the first one is not possible to get manipulated with but IT MIGHT cost performance

Your Ideas ?

答:
You may use a view to return the count. Depending on your DB, the view results may be cached till the participating tables change, resulting in efficiency. But make sure the results are cached and that indices are maintained on views too. Storing a count means updating it everytime you write to the table(s), too.
Check out this thread. </p>


答:
Saving the row count will be "faster" but it may cause other problems. You need to ensure the update is completely atomic and not part of a bigger unit of work, otherwise, you will be plagued by deadlocks and timeouts when your site gets even moderately busy.

By "completely atomic" I mean you need to "BEGIN;" immediately followed by the " UPDATE YOURTABLE SET CNT = CNT + 1;" immediately followed by "COMMIT;"

Title: Count a row VS Save the Row count after each update

Body:
I want to know whether saving row count in a table is better than counting it each time of the proccess.

Quick Example : A visitor goes to Group Clan, the page displays clan information and Members who have joined the group,Should the page look for all the users who joined the clan and count them, or just display the number of members already saved in table ?

I think the first one is not possible to get manipulated with but IT MIGHT cost performance

Your Ideas ?


问:
How would I access trac on mobile phone?
as a programmer I live with Trac, how do you go about accessing trac projects via a mobile phone, nokia/android/iphone/windows mobile, the mobile platform is not important, I can get a new phone but trac is there to stay.</p>

答:
You could always try to use the phone's browser app to surf to your Trac page.

If you have your Trac in your LAN and want to access it from Internet, you will need to configure your firewall to be able to do so.


问:
Lean/Kanban *Inside* Software (i.e. WIP-Limits, Reducing Queues and Pull as Programming Techniques)
Thinking about Kanban, I realized that the queuing-theory behind the SW-development-methodology obviously also applies to concurrent software. Now I'm looking for whether this kind of thinking is explicitly applied in some area.

A simple example: We usually want to limit the number of threads to avoid cache-thrashing (WIP-Limits).

In the paper about the disruptor pattern[1], one statement that I found interesting was that producer/consumers are rarely balanced so when using queues, either consumers wait (queues are empty), or producers produce more than is consumed, resulting in either a full capacity-constrained queue or an unconstrained one blowing up and eating away memory. Both, in lean-speak, is waste, and increases lead-time.

Does anybody have examples of WIP-Limits, reducing/eliminating queues, pull or single piece flow being applied in programming?

http://disruptor.googlecode.com/files/Disruptor-1.0.pdf

答:
Typical application of WIP limit in programming is any type of pool:

Thread pool

Connection pool

Object pool

etc.

You know that your resources are somehow constrained and you can constrain them be allowing only specific number of resources. Any other work item requesting a resource must wait till any resource in use is returned back in the pool.

It also solves problems with expensive construction of resources and it can be further improved to solve management of resources when only small number of work items is generated (the size of the pool can dynamically change between allowed thresholds).


答:
I would say you'd grasp enough in a year or less to get an absolute junior position.
(When I had my first job I was straight out of college and didn't have a clue!)

Unfortunately your age may not be on your side.
In my experience juniors are expected to be younger or straight out of college, an older person would be expected to have experience. It's a bit of a catch 22, most employers expect experience, but you can't have experience if you can't get the job in the first place.


问:
How can we plan projects realistically while accounting for support issues?
We're having a problem at work: we're trying to schedule work so that we can assess time scales and get deadline dates.

The problem is that it's difficult to plan for a project without knowing everything that's going to happen.

For instance, right now we've planned all our projects through the start of December, however in that time we will have various in house and external meetings, teleconferences and extra work. It's all well and good to say that a project will take three weeks, but if there is a week's worth of interruption in that time then the date of completion will be pushed back a week.

The problem is 3 fold:

When we schedule projects the time scales are taken literally. If we estimate three weeks, the deadline is set for three week's time, the client is told, and there is no room for extension.

Interim work and such means that we lose productive time working on the project.

Sometimes clients don't have the time that we need to take to do the work, so they'll sometimes come to us and say they need a project done by the end of the month even when we think that the work will take two months - not to mention we already have work to be doing.

We have a Gantt chart which we are trying to fill in with all the projects we have and we fill in timesheets, but they're not compared to the Gantt chart at all. This makes it difficult to say "Well, we scheduled 3 weeks for this project, but we've lost a week here so the deadline has to move back a week."

It's also not professional to keep missing deadlines we've communicated to the client.

How do other people deal with this type of situation? How do you manage the planning of projects? How much "extra" time do you schedule into a project to account for non-project work that occurs during a project? How do you deal with support issues and bugs and stuff? Things you can't account for during planning?

UPDATE

Lots of good answers thank you.

答:
You're absolutely correct - it is difficult to plan a project without knowing everything that's going to happen. But it is very important to keep a track of things that are a norm as well as the tasks that your forsee. Here's where schedule management plays a part. I've been using the Microsoft project management (standard version) for which also includes features that're part of a project management scheduling software.

You can visit http://www.microsoft.com/project/en/us/schedule-management.aspx for more information.


答:
How to spend less time debugging? Write less code.

Seriously, as long as you write code, you'll need to debug it. Unit tests etc help immensely, but don't think you'll ever remove the need for it altogether.

Title: How to spend less time on debugging?


问:
What is "syntactic delegation"
Steve Yegge mentions it in When Polymorphism Fails:

... I think this implies that type is best represented via properties rather than classes, because of the inherent inflexibility of classes. But in "traditional" languages like C++ and Java, this makes code sharing a bit harder, because of the lack of support for syntactic delegation. ...

(emphasis added)

A Google search turns up a State of the Onion address by Larry wall.

答:
Looks like Steve Yegge refers to explicit support of delegation by means of programming language syntax.

Given his references to C++ and Java I would say he has in mind something like support for delegation as it is provided in C#, see eg this MSDN tutorial - this tutorial refers to delegate keyword.

Title: What is "syntactic delegation"


答:
While I totally support the unit testing suggested above, TDD or BDD will be of great value as you need to first think about the problem and the solution.

But personally for me, taking a few minutes just to sit quietly and think about the problem and how to approach it and any pro's and cons with each approach, does wonders for my quality of code and helps clear my mind of clutter.

Sometimes a quick scribble on a piece of paper helps you see the larger connected pieces of the puzzle.

I write the worst code when I just dive in head first and pound the keyboard. A little bit of thought and contemplation makes a world of difference.

PS. I mean 5 maybe ten minutes, not hours writing a huge spec.

Title: How to spend less time on debugging?


答:
Assume the following:

```<code>class Foo {
    public function foo1() {...}
    public function foo2() {...}
}
class Bar {
    public function bar1() {...}
    public function bar2() {...}
}
</code>```

Classically, when composing a class of these two, that delegates calls to them, it would look like:

```<code>class FooBar {
    var foo:Foo;
    var bar:Bar;
    public function foo1() { foo.foo1(); }
    public function foo2() { foo.foo2(); }
    public function bar1() { bar.bar1(); }
    public function bar2() { bar.bar2(); }
}
</code>```

There is no syntactic construct to support what you are doing. For every call you want to delegate, you will have to write the same thing over and over again.

Languages that use message passing, such as Ruby, Smalltalk and Objective-C, work around the need for that, by invoking a specific method in response to unknown messages.

It looks something like this:

```<code>class FooBar {
    var foo:Foo;
    var bar:Bar;
    override public function handleUnknownMethod(name:String, args:Array) {
         if (foo.hasMethod(name)) foo.invoke(name, args);
         else if (bar.hasMethod(name)) bar.invoke(name, args);
         else super.handleUnknowMethod(name, args);
    }
}
</code>```

This is "better" in the sense that you don't have to do this for every single method. This makes composition less costly and code sharing easier.

Note that this is also not syntactic delegation. What this is, is deferring handling of calls to undefined methods to runtime, which means you can use the language itself to handle them.

Syntactic delegation would be something like:

```<code>class FooBar {
    @forwardAll var foo:Foo;
    @forwardAll var bar:Bar;
}
</code>```

That would be a syntactic sugar the compiler would resolve by generating a public method for every public method in Foo, that would merely delegate the call to foo and would do the same for bar/Bar.

Title: What is "syntactic delegation"

Body:
Steve Yegge mentions it in When Polymorphism Fails:

... I think this implies that type is best represented via properties rather than classes, because of the inherent inflexibility of classes. But in "traditional" languages like C++ and Java, this makes code sharing a bit harder, because of the lack of support for syntactic delegation. ...

(emphasis added)

A Google search turns up a State of the Onion address by Larry wall.

Body:
Assume the following:

class Foo {
    public function foo1() {...}
    public function foo2() {...}
}
class Bar {
    public function bar1() {...}
    public function bar2() {...}
}

Classically, when composing a class of these two, that delegates calls to them, it would look like:

class FooBar {
    var foo:Foo;
    var bar:Bar;
    public function foo1() { foo.foo1(); }
    public function foo2() { foo.foo2(); }
    public function bar1() { bar.bar1(); }
    public function bar2() { bar.bar2(); }
}

There is no syntactic construct to support what you are doing. For every call you want to delegate, you will have to write the same thing over and over again.

Languages that use message passing, such as Ruby, Smalltalk and Objective-C, work around the need for that, by invoking a specific method in response to unknown messages.

It looks something like this:

class FooBar {
    var foo:Foo;
    var bar:Bar;
    override public function handleUnknownMethod(name:String, args:Array) {
         if (foo.hasMethod(name)) foo.invoke(name, args);
         else if (bar.hasMethod(name)) bar.invoke(name, args);
         else super.handleUnknowMethod(name, args);
    }
}

This is "better" in the sense that you don't have to do this for every single method. This makes composition less costly and code sharing easier.

Note that this is also not syntactic delegation. What this is, is deferring handling of calls to undefined methods to runtime, which means you can use the language itself to handle them.

Syntactic delegation would be something like:

class FooBar {
    @forwardAll var foo:Foo;
    @forwardAll var bar:Bar;
}

That would be a syntactic sugar the compiler would resolve by generating a public method for every public method in Foo, that would merely delegate the call to foo and would do the same for bar/Bar.


问:
What keywords are important to speedup the code in C++?
I'm porting to C++ and adding a lot of functionality to a numerical application written in Fortran 77. While I hate F77, I have to admit that the thing goes very fast. Now, I'm implementing practically the same structure and algorithm, but nevertheless the difference in the execution time is noticeable. Not big, but it's there. And I'm wondering, could it be that I need to pass extra information to the compiler? The only related information that I've been able to find is a recommendation to use the restrict key word which is supported by g++, but that's all. Hence, my question: Are there anymore keywords important to speedup code in C++ in numerical applications? or maybe compiler directives?

Thanks!

答:
One thing to remember when porting from Fortran to C++ is the different array layout: Fortran, by default, uses column-major layout, C and C++ row-major. When your program relies heavily on linear algebra (like all Fortran programs seem to do), the different cache behaviour will make a major difference.

If that seems to be the problem (read: your profiler shows you are spending considerable time in linear algebra), try using a decent LA library like Eigen with matrices in column-major layout.


问:
How to spend less time on debugging?
Following the Pareto rule, a programmer spends only 20% of his time for really useful things.

I spend 80% of my time debugging, fixing small things to get everything working.

Is there a way to spend less time debugging?

答:
Code in Agda or Coq. Once your code compiles, it will work. If it's too hardcore, choose a language with a weaker type system, e.g., Haskell or F#.

But still, in most cases you'll be much more productive spending 20% of your time on coding and 80% on testing and debugging. 100% of a week is much more than 20% of an hour. If debugging is what you need to get things done, than debugging is not a waste of time and you should not be bothered with "improving" this proportion.

Title: How to spend less time on debugging?


答:
Most answers seem focused on how to reduce the number of problems you have to debug and that is valuable. However, debugging will always be necessary so it is useful to look at ways of getting faster at debugging.

Know how to use your version control software.

Using branches will help you separate out areas of development and you'll be able to see which area of development has the bug and which don't.

Learn how to use bisection in your VCS, Git has this built in. If you use a different VCS that doesn't have bisection built in look for a tool that works like git bisect but for your VCS (I know this exists for SVN and shouldn't be too hard to create for other VCSs). This will help you narrow down to the code change that introduced the bug, which will help with knowing where to point your debugger. This bisection process will be faster if you have tests for the bug and knowing which commit contains the offending change will be more useful if you practice atomic commits.

Improve your understanding of the programming language you use.

Read books, blogs and code about the programming language.

Every time you fix a bug make sure you thoroughly understand why the code didn't work and why your fix works. Over time you will learn many gotchas in your language which will help you avoid their problems and spot the symptoms of them should they re-occur.

Be logical

Don't change more than one thing at once otherwise if the behaviour changes you won't know which change caused the change in behaviour.

Verify your assumptions.

Title: How to spend less time on debugging?


问:
How much of original code is left in modern software products?
Many of you out there work for large companies that ship well-known software. I was wondering, how much of original code (basically, code that was "v1.0" release) is left in modern massive applications, such as, say, Firefox, Photoshop, Windows, Linux, etc? I'd really prefer first-hand experience and real-world war stories.

Thanks for satisfying my curiosity.

EDIT

Turns out there's a degree of misunderstanding. What I'm after is basically as follows: when you blame/annotate source code, are there any parts or even whole files untouched since the initial 1.0 release.

答: Even ostensibly 'cutting edge' systems used for games, like iD Tech and Unreal, would still have a fair bit of 1.0 code in them. </p>


问:
Is the market of small-scale development/production tools that difficult?
I was wondering, is there an economic rationale in developing and marketing a small tool (standalone or rather plugin)? Of course, let's assume that the tool does indeed solve a real problem from the production process. And by small, I mean an application that can be developed by 1-2 developers within 2 years. Do you know any contemporary success stories?

I have two observations that make me wonder:

Anyway I turn around people ask for free and preferably open-source tools. Even when the price is low, and the software is worth its price, I see this big reluctance to spend any money on commercial development software. An application author would probably have to assume that only a very small percentage of all people who might find his application useful, will actually purchase it.

I've seen a few good commercial software examples that after some time started offering free licenses. The most notable example for me was gDEBugger from Graphic Remedy. Last time I checked it didn't even had any worthy competitor (commercial or noncommercial) in the market of OpenGL debuggers. I have no idea what might have made them do that, other than poor sales.

答:
Some things to consider if you want to be successful in this market:

Quality is key.  Nobody will spend money on something that sucks.

No matter the cost, identify the searchable keywords and make sure that you are on the first page of Google search results, no matter the cost.

Keep an eye on open source up and comers.  They can threaten your company, especially if they are almost as good or better than your product.  Try to stay ahead of them in functionality and use.  If that simply won't work, identify the lead contributors to the project and offer to hire them and pay big money.  This can sometimes kill the project that threatens your company.

Put up a pretty site with good literature and good graphic design.  Contract out the web design, it is well worth the investment.  Nobody will want to buy your product if the site looks amateurish.

Offer a free trial, preferably one that has full functionality but expires after so many uses or after a set amount of time.  You want people to see how convenient and awesome it is, and then word of mouth will spread it throughout their friends and the company.  Companies tend to have budgets for developer tools, I convinced my company to buy a third-party proprietary merge and diff tool that is amazing, and everybody loves it.

If you do not offer a trial, give 95% of the functionality for free, but make integration, interoperability or other "enterprisey" related functionality require a full license.  Developers are notoriously stingy, corporations are a little easier to convince.

Keep your team and your company lean and mean.  This will keep costs down and make sure you keep the team focused.

Start thinking about other similar ideas for tools and try to get as many of them out there as possible, hopefully on completely different sites.  Chances are 7 will fail completely, 2 will be moderately successful, 1 may be a huge success and cash cow.


问:
how much do I really need to know to become Jr Developer?
I believe I have a very good understanding of programming logic fundamentals (passing around variables, nested conditional statements, etc). I am currently going through a book on ASP.NET and am pretty much lost on all the Page Rendering Model, Custom Rendered Controls, Composite Controls, etc. I understand how to use the standard controls no problem. Do I really need to understand all those other things to become a junior developer? Any advice is appreciated!</p>

答:
i see your post and i amazed me that you are asking for Jr developer.
You just prepare your old projects what you have done in your college and company. after completing you'll see that you prepare some more new things and it will really help you to clear the Jr developer interview.</p>

OwnerDisplayName: joey land


问:
Proxied calls not working as expected
I have been modifying an application to have a cleaner client/server split to allow for load splitting and resource sharing etc. Everything is written to an interface so it was easy to add a remoting layer to the interface using a proxy. Everything worked fine. The next phase was to add a caching layer to the interface and again this worked fine and speed was improved but not as much as I would have expected. On inspection it became very clear what was going on.

I feel sure that this behavior has been seen many times before and there is probably a design pattern to solve the problem but it eludes me and I'm not even sure how to describe it.

It is easiest explained with an example. Let's imagine the interface is

```<code>interface IMyCode {
    List<IThing> getLots( List<String> );
    IThing getOne( String id );
}
</code>```

The getLots() method calls getOne() and fills up the list before returning.

The interface is implemented at the client which is proxied to a remoting client which then calls the remoting server which in turn calls the implementation at the server. At the client and the server layers there is also a cache.

So we have :-

```<code>Client interface
      |
 Client cache
      |
 Remote client
      |
 Remote server
      |
  Server cache
      |
Server interface
</code>```

If we call getOne("A") at the client interface, the call is passed to the client cache which faults. This then calls the remote client which passes the call to the remote server. This then calls the server cache which also faults and so the call is eventually passed to the server interface which actually gets the IThing. In turn the server cache is filled and finally the client cache also.

If getOne("A") is again called at the client interface the client cache has the data and it gets returned immediately. If a second client called getOne("B") it would fill the server cache with "B" as well as it's own client cache. Then, when the first client calls getOne("B") the client cache faults but the server cache has the data.

This is all as one would expect and works well.

Now lets call getLots( [ "C", "D" ] ). This works as you would expect by calling getOne() twice but there is a subtlety here. The call to getLots() cannot directly make use of the cache. Therefore the sequence is to call the client interface which in turn calls the remote client, then the remote server and eventually the server interface. This then calls getOne() to fill the list before returning.

The problem is that the getOne() calls are being satisfied at the server when ideally they should be satisfied at the client. If you imagine that the client/server link is really slow then it becomes clear why the client call is more efficient than the server call once the client cache has the data.

This example is contrived to illustrate the point. The more general problem is that you cannot just keep adding proxied layers to an interface and expect it to work as you would imagine. As soon as the call goes 'through' the proxy any subsequent calls are on the proxied side rather than 'self' side.

Have I failed to learn or not learned something correctly?

All this is implemented in Java and I haven't used EJBs.

It seems that the example may be confusing. The problem is nothing to do with cache efficiencies. It is more to do with an illusion created by the use of proxies or AOP techniques in general.

When you have an object whose class implements an interface there is an assumption that a call on that object might make further calls on that same object. For example,

```<code>public String getInternalString() {
    return InetAddress.getLocalHost().toString();
}

public String getString() {
    return getInternalString();
}
</code>```

If you get an object and call getString() the result depends where the code is running. If you add a remoting proxy to the class then the result could be different for calls to getString() and getInternalString() on the same object. This is because the initial call gets 'deproxied' before the actual method is called.

I find this not only confusing but I wonder how I can control this behavior especially as the use of the proxy may be by a third party.

The concept is fine but the practice is certainly not what I expected.

Have I missed the point somewhere?

答:
I'm bashing this out in a hurry before a talk, so apologies if I'm a little unclear

I think the main issue is that your getLots() call basically goes into a loop of multiple getOne() calls. Without seeing your code and your infrastructure in detail - I'd be tempted to have the getLots() call do exactly that, get lots of objects in a single call, loading up your two caches along the way.

Yes there's a one-off upfront cost for this call, but afterwards your caches are fuller, making subsequent getOne() calls much more likely to be faster and getLots() calls also likely to get faster (depending on your search key range).  Of course you have to think about how you ensure that the getLots() calls efficiently search and return from your caches as well as going down the layers as required.

It sounds like you measure performance before and after you make changes, which is good.  You can use that to measure the most efficient size of the getLots() calls that you make to the server (when there's no cache or partial cache or full cache involved).

Title: Proxied calls not working as expected


答:
Often it takes a lot of effort and time to be allowed to spend even a small account of money.

You are then often expected to do an eval and decided on a corporate level what tool will be used for the job by everyone, hence having to a get agreement from a lot of people.

Then there is this cost of tracking licences on a companywide bases, including tracking what is installed on each developer’s machine, often there is a rule that no personally owned licences may be used on work machines.

Is this enough to explain a “big reluctance”?

Title: Is the market of small-scale development/production tools that difficult?

Body:
I was wondering, is there an economic rationale in developing and marketing a small tool (standalone or rather plugin)? Of course, let's assume that the tool does indeed solve a real problem from the production process. And by small, I mean an application that can be developed by 1-2 developers within 2 years. Do you know any contemporary success stories?

I have two observations that make me wonder:

Anyway I turn around people ask for free and preferably open-source tools. Even when the price is low, and the software is worth its price, I see this big reluctance to spend any money on commercial development software. An application author would probably have to assume that only a very small percentage of all people who might find his application useful, will actually purchase it.

I've seen a few good commercial software examples that after some time started offering free licenses. The most notable example for me was gDEBugger from Graphic Remedy. Last time I checked it didn't even had any worthy competitor (commercial or noncommercial) in the market of OpenGL debuggers. I have no idea what might have made them do that, other than poor sales.


答:
In addition to Maple_Shaft's answer, I've found that a lot of open source competitors to commercially developed software follow the Pareto principle fairly closely unless they have a large base of developers.

Put simply they solve the easy 80% of the problem, and leave the hard 20% alone.  It very well may be that the last 20% is too localized to be developed in a general sense and requires additional insight that the end user can provide.

You need to be certain that you've addressed the hard parts of the problem well to make an investment in your solution better than "getting by" with whatever's available on the market.  You need to emphasize customer service, access to developers to address specific problems and a track record of reliability.

Otherwise what value are you adding to what they can achieve for free and a little work?


答:
As you asked for examples: Tasktop would be my pick, the basic functionality was done in less than 2 years and it's definitely a success story.

Their choice of open-sourcing the basic tool right from the start and providing enterprise features commercially worked out perfectly. There are no competing tools because the basic functionality already is available as open-source which stops the hackers and there is no business case for developing competing enterprise extensions which stops the professionals.


问:
What is the actual problem with a prototype based design?
I feel like anything that can be developed using OO/functional languages can be generally made 'better' using a prototype based language, because they appaer to have the best of them all: high order functions, flexibility to simulate any OO structure, productivity (low verbosity) and scalability because of concurrency. But it seems like they are avoided for the creation of executable applications and of bigger projects in general. Why that?</p>

答:
But it seems like they are avoided for the creation of executable applications and of bigger projects in general. Why that?

I don't know, but the assumption is false.

Larger projects use prototypical languages:

JavaScript is the most popular language on github.

Cloud9 is a full-blown cloud based IDE written in JavaScript that connects to GitHub. 98% of this project is JavaScript, 2% is CoffeScript, go look at the source and tell me it's a trivial application.

Node, not like you haven't heard of it, just happens to be that event-loop webserver framework for building a web app in JavaScript.

three.js is a 3dEngine in JavaScript. Because, you know, that's not really a big project...

pdf.js

Broadway doesn't do much, just decodes h.264 natively in your browser without codex.

The JVM has been implemented in JavaScript, allowing JVM bytecode from Scala, Java, or Clojure to run inside JavaScript.

Bcrypt is implemented in JavaScript.

One of the best video games of all time was written in Lua.

Lua is used in a lot of places.

How much "bigger" do you want? Are you expecting someone write code that emulates a computer and can just take a linux ISO and run a whole operating system out of your browser and you can start writing code from a linux command-line in C++... or something ridiculous like that? Okay, we have that too.

Seriously, what's "bigger?"

Again, you have the most proliferated language on github that has lead to an IDE, a webserver, a 3d graphics engine, a pdf document rendering tool, video decoder, encryption library and x86 emulator.

I'm not even going to bother linking to the endless slew of webapps and stuff in the chrome store, frameworks of all shapes and sizes, static code analysis tools, or other 'trivial' projects that nobody uses because the language is just so painfully slow and we can't be sure of how to write code in it.

Oh wait, we can be sure how to write quality code in JavaScript. It's called reading the funny manual, writing unit tests, static code analysis, and other fun things you do in every other language if you're competent in that language also.

It's not "risky" because it's got a prototype, it just means you need to know what you're doing, the same way you need to know how to program in whatever paradigm you enjoy. It's not "slow" because it's a prototype, languages out there that I haven't mentioned run at near-C speeds. You can find more information on your local search engine.

Good day.


问:
Is "Computer Science != Software Engineering" an excuse to teach programming poorly?
We've all heard it; whenever there's a discussion about CS grads having poor development skills someone eventually says,

Computer science isn't software engineering.

The problem that I see is that programming and software development are taught in CS courses. They're just commonly taught poorly. If it's being taught, then why not teach it right the first time? *

So I would like to see what the opinions are on 2 questions:

Is the CS != SE argument a copout or excuse for not properly teaching programming skills.

Regardless of your answer to question 1; if you were in the almighty position of making such a decision: would you force an emphasis on proper teaching of programming in CS courses?

*. I have a suspicion, based on anecdotal evidence I obtained throughout my education, that most academics in the field haven't had to write code to be maintained and haven't maintained code, and as a result don't have the knowledge/skills to teach it effectively.

答:
Part of the problem here is the fact that 4 years is not enough time to become a polished software engineer. Given that we want the undergrad to have exposure to more things than just math and CS courses and the fact that there is plenty of pure mechanics to learn (algorithms, data structures, language syntax), we can not expect a green CS major to be a software engineer.

I would agree that CS != SE and I'm not sure you can just go to school and become a SE (even with a Masters)


答:
Some good answers already, just some more food for though in addtion to what others have said.

Learn from your mistakes. Don't keep making the same ones over and over again.

Make sure to cover edge cases when programming - those are places where there are frequently bugs.

Pay attention to the requirement. Even if it works but doesn't do what the requirement specified, that's a bug.

Exception logs can be a real help when something goes wrong six months from now. Be in the habit of recording exceptions.

Title: How to spend less time on debugging?


问:
What scripting language to use for large file transfers on windows xp client machines
I'm a java developer that is tasked with creating some scripts that will handle large xml document file transfers by hitting some web service api's from windows xp client machines.  There may be other document formats involved like .pdf, .doc, .xls or .txt, but I'm not sure on that at this point.

I've looked into powershell, groovy, perl, but I'm not sure which one would be the best to use as I've not done work with any of those and there may be a better alternative than these three I've listed.

So for security, ease of deployment, and maintenance for the script (not overly complicated to write or large), what would fit the best for these requirements?

答: It looks like PowerShell has some cmdlets to efficiently handle transferring files.  I think that's what I'd use in your case.  Not much to install, and you are building on a supplied service, so performance should be good.  I don't like PowerShell personally, but given your situation it looks like the most reasonable approach.  Hopefully you won't find it as klunky as I do...</p>

ContentLicense: CC BY-SA 4.0


答:
If can put an interpreter of your choice on the client computer then I would go with Groovy as it would be easiest for you as an experienced Java developer to use.

BUT I see in your responses that you may not have the option to load your interpreter on to the computer as groovy requires a JVM to run.  Perl is not on an XP system by default and if you can't load a JVM you more then likely can not install Strawberry or Active State Perl. So this may limit you to Microsoft technologies that do not include Powershell (As Powershell is an add on for XP - you are not guarantied that it is there - and assuming you can not make the client down load it) This leaves Window Script Host - and JScript or VBScript (and for your sanity do not consider VBScirpt at all) or a native application.

If Powershell is available and you can insure the security is set to run scripts I would go with Powershell as my second choice. Followed by Windows Script Host as Windows Script Host gives access to a number of COM objects that can download and process XML but will have a learning curve from where you are coming from.

I would recommend in order
Groovy
Powershell
then Windows Script Host

Title: What scripting language to use for large file transfers on windows xp client machines

Body:
I'm a java developer that is tasked with creating some scripts that will handle large xml document file transfers by hitting some web service api's from windows xp client machines.  There may be other document formats involved like .pdf, .doc, .xls or .txt, but I'm not sure on that at this point.

I've looked into powershell, groovy, perl, but I'm not sure which one would be the best to use as I've not done work with any of those and there may be a better alternative than these three I've listed.

So for security, ease of deployment, and maintenance for the script (not overly complicated to write or large), what would fit the best for these requirements?


答:
Your code will hardly become faster magically by sprinkling a few keywords here and there. And simply copying algorithms from one language to another (if that's indeed what you are doing) is never going to help. Speed correlates with

a good design, and

selectively applied optimizations based on careful profiling.

As for design: The one thing that made C++ equal FORTRAN's performance was the invention of expression templates by Todd Veldhuizen for his blitz++ library.

Title: What keywords are important to speedup the code in C++?

Body:
I'm porting to C++ and adding a lot of functionality to a numerical application written in Fortran 77. While I hate F77, I have to admit that the thing goes very fast. Now, I'm implementing practically the same structure and algorithm, but nevertheless the difference in the execution time is noticeable. Not big, but it's there. And I'm wondering, could it be that I need to pass extra information to the compiler? The only related information that I've been able to find is a recommendation to use the restrict key word which is supported by g++, but that's all. Hence, my question: Are there anymore keywords important to speedup code in C++ in numerical applications? or maybe compiler directives?

Thanks!


问:
Is there a way to combat Sales perpetually overcommitting?
I seem to be repeatedly stuck in a situation where release dates are set not based on anything technical, but because someone in Sales has committed to a customer by then.  Based on discussions with friends in development at other companies, the same thing seems to happen.

"Here is the committed feature set and here is the committed release date", and it's difficult to argue because at this point there is money riding on it, and that trumps everything.

In general, is there a way to push back on this?  If not for this release, what about in future?  The problem I have is that the only way I see one way of doing so, and that's by doing the best I can, but release the software 'as is', so to speak.

I don't want to release bug-ridden software since it's my name attached, but doing 80 hour weeks for months at a time just vindicates the arbitrarily set release date.

edit: for the record, I'm not doing 80 hour weeks now, just that comes to mind as what would be required to cover the expected feature set by the release date.

答:
The development team must be consulted on these decisions or you will never get out of that cycle. If you aren't managing the team, then one of your line managers needs to advocate for the development team. If they are part of the problem, then you may want to consider other employment options.

Generally speaking, Sales shouldn't be committing to anything without the Product Management's acceptance, who should obviously be consulting with the development team for timelines. There's really no good excuse for bypassing this in a big or small company because ultimately the Sales team will take some heat for under-delivering (whether in quality or scope).


答:
This is something you need to take to your manager (there is development managers, right?) and explain the problem.  It's a change that needs to happen on an organizational level - sales needs to get buy in from development before making commitments, and before that will happen, they need to get that direction from their bosses.

There's nothing you can do to actually make the change happen, but you should definitely be bringing it up to your manager.

In addition to trying to change the culture (good luck), any time they come to you with a deadline you can't meet, push back - with numbers.  Break down the project and show them your time estimate.  If it's a six week project, tell them.  If it's been promised to the client in four weeks, you can't do it, and you need to disseminate that information as quickly as possible.  Hopefully, your salespeople will be able to go back to the client and set better expectations, or work with you to come up with a smaller acceptable feature set to deliver within the promised timeline, with the additional features to be added later.

Edit to add: Do not let them talk your estimate down.  Be confident that it's correct, and stick to it.  They will try to bargain with you, but don't let them.

Title: Is there a way to combat Sales perpetually overcommitting?

Body:
I seem to be repeatedly stuck in a situation where release dates are set not based on anything technical, but because someone in Sales has committed to a customer by then.  Based on discussions with friends in development at other companies, the same thing seems to happen.

"Here is the committed feature set and here is the committed release date", and it's difficult to argue because at this point there is money riding on it, and that trumps everything.

In general, is there a way to push back on this?  If not for this release, what about in future?  The problem I have is that the only way I see one way of doing so, and that's by doing the best I can, but release the software 'as is', so to speak.

I don't want to release bug-ridden software since it's my name attached, but doing 80 hour weeks for months at a time just vindicates the arbitrarily set release date.

edit: for the record, I'm not doing 80 hour weeks now, just that comes to mind as what would be required to cover the expected feature set by the release date.


答:
Stop doing the 80 hour weeks. This is positive reinforcement. Because they are getting the product on time with expected costs, they are going to continue doing it, regardless of what it does to you.

If they cannot budget time properly, then that's management's fault. Not yours.

Let them miss a few deadlines.


答:
In general, is there a way to push back on this? If not for this release, what about in future?

Of course, there is: Let them fail badly with this approach. Nothing teaches as well as failing.

Make an estimation yourself before you start and show it to them. Then do your best, write good code, stop compensating for their stupidity with your free time, and when they complain afterwards, remind them of the time estimation you had shown them, based on engineering principles.

And you better start doing this with the current project.

If they keep blaming you for the problem, you'd better start hunting for a new job, since nothing will convince them that they are the problem.

As an afterthought, I think this question actually warrants a link to the famous EA story as featured in one of Joel's books: EA: The Human Story.


答:
At least in the United States, education as a whole has become about profit. Schools are dumbing down curriculum across the board to increase enrollment. There are more people in college that don't belong there than ever. Learning proper techniques is not something you can teach easily so they don't.

Personally I would put more emphasis on SE than there typically is but I believe CS as a program is less appropriate for people looking to get into industry. I think more institutions should offer a practical SE program.

Title: Is "Computer Science != Software Engineering" an excuse to teach programming poorly?

Body:
We've all heard it; whenever there's a discussion about CS grads having poor development skills someone eventually says,

Computer science isn't software engineering.

The problem that I see is that programming and software development are taught in CS courses. They're just commonly taught poorly. If it's being taught, then why not teach it right the first time? *

So I would like to see what the opinions are on 2 questions:

Is the CS != SE argument a copout or excuse for not properly teaching programming skills.

Regardless of your answer to question 1; if you were in the almighty position of making such a decision: would you force an emphasis on proper teaching of programming in CS courses?

*. I have a suspicion, based on anecdotal evidence I obtained throughout my education, that most academics in the field haven't had to write code to be maintained and haven't maintained code, and as a result don't have the knowledge/skills to teach it effectively.


答: With Agile development we see consultants selling points for ~1000-1500 each.  If you can change the sales process to where they have to sell based on the points scale then the sales team will be forced to work with the development team to come up with reasonable estimates.  </p>


答:
This is almost a universal thing in smaller companies as they have a greater need to close a deal.  Until I was brought into sales meetings at my company I was bitter about this but I can at least understand how and why it happens a little more.

Clients want it fast and many will play hard to get.  This encourages sales to bend on time commitments just to get something signed.  A signed contract is gold because you can acquire capital or credit using one.  Sometimes it is better to have a tight deadline than nothing to work on at all.

Other times if it is a hot market and there are a lot of competitors then the company has an impending need to get a product out the door FASTER than everybody else.  A bigger company or one with more capital can always hire more resources, a smaller one can't.

Where it is scummy is when the deadlines are truly artificial and it is pushed by sales and management to secure large bonuses for themselves.

Don't make a habit of working more than 45 hours a week, it is bad for your health and that comes first.


答:
It's hard to answer without knowing your company structure.

Some general tools to help are:

Have agree upon (but those in charge, not sales) quality controls

Have a product roadmap (internal and external)

By having agreed upon quality controls, you have a business-driven reason for not being able to release buggy software. You might need to convince your bosses why this is important (hopefully not), but there is plenty of literature out there to aid in this.

By having a product roadmap, Sales know what they can and cannot promise to customers. If they want to change the roadmap, they have to raise it with the Product Manager/Project Manager/ Development Manager or whoever else is in change of it.

If they promise something to a customer that hasn't already being agreed to, tough luck. Hopefully your roadmap is based upon market data on customer needs. "What exactly do you propose we drop from these 8 other high priority features that we have evidence our customer base needs?"

Last of all, as already expected, don't work 80 hour weeks. You aren't even helping the company by doing that because you are just aiding them in digging a deeper hole.


问:
C++ skills higher than C skills?
I feel that the often seen C/C++ doesn't really describe my skills in my CV. So I'm planning to separate it into advanced C++ knowledge and mediocre C skills.

Do you think this is confusing for the reader? She could think: "C is a subset of C++, so what is this guy trying to tel me?" Well, what I'm trying to tell is: I have done several real world C++ projects while pure C projects where just a hobby thing. Do you agree that a skilled C++ programmer not necessarily is a qualified C guy or do you think that this switch is done easily?

答:
For the people that really matter, no, it shouldn't confuse them.

Anyone who knows anything about real-world C and C++ programming knows that although despite their similarities and history, production programming in either is more often than not a completely different animal.

Title: C++ skills higher than C skills?


答:
Personally, I find it very annoying when people write "C/C++", because C and C++ are very different languages.  Conversely, if I see "C, C++" or "C++ and C" on a resume, it impresses me to no end.  Unfortunately, almost everyone writes "C/C++", and it typically means "I know C++, but I can do C if I have to."

Also, I would not be so specific on the CV.  Just list the programming languages you know, possibly in the order from most proficient to least proficient.  That should get you past the HR buzz-word filter, and then you can explain during a technical interview what your strengths and weaknesses are.

Title: C++ skills higher than C skills?

Body:
I feel that the often seen C/C++ doesn't really describe my skills in my CV. So I'm planning to separate it into advanced C++ knowledge and mediocre C skills.

Do you think this is confusing for the reader? She could think: "C is a subset of C++, so what is this guy trying to tel me?" Well, what I'm trying to tell is: I have done several real world C++ projects while pure C projects where just a hobby thing. Do you agree that a skilled C++ programmer not necessarily is a qualified C guy or do you think that this switch is done easily?


答: No, it should not be confusing because C and C++ though similar and sharing similar roots are different in paradigm and usage. Thus, it should be separated, also the expertise should be separated too. Plus, i think you can mention more specific expertise(like GUI/FLTK or other libraries that you're familiar with) with the two separated.</p>

Title: C++ skills higher than C skills?


答:
First let's remember that we all generally have jobs to support the deals the sales guys make rather than to construct technically perfect programming-art. If they don't make the deals you don't have a job. </p>

<p>That said the trick is to find ways to work with sales to make everyone look good. Processes where the tech team can at least voice an opinion about proposals before they go out the door is key. Finding creative ways to handle compensation also helps alot -- if sales has to "tip out" engineering when engineering incurs massive overtime making an unrealistic schedule work it seems to drastically cut down the frequency of death march projects. </p>

Body:
First let's remember that we all generally have jobs to support the deals the sales guys make rather than to construct technically perfect programming-art. If they don't make the deals you don't have a job.

That said the trick is to find ways to work with sales to make everyone look good. Processes where the tech team can at least voice an opinion about proposals before they go out the door is key. Finding creative ways to handle compensation also helps alot -- if sales has to "tip out" engineering when engineering incurs massive overtime making an unrealistic schedule work it seems to drastically cut down the frequency of death march projects.


答:
These are good answers, but it's quite possible both the Fortran and the C++ versions contain substantial room for speedup, so you wouldn't really expect them to be exactly the same speed now.

Assuming you want either one to be as fast as possible for a given machine and input load, there is a countable infinity of programs that do the job, and some program(s) that take less time than all the others.
What you want to do is remove unnecessary activities until the program approaches that optimal shortness of time, regardless of language.

Here's how I do it, and here's an example of seriously aggressive performance tuning.

If I can just give examples, in C++ (using MFC) here is a case where something you wouldn't normally worry about, array indexing, turns out to cost 40% of the time and can be done better. In an example I did using stl vectors, the cost was even higher.

Similarly in Fortran, I was tuning some code that used the LAPACK library, which one would think would be about as finely optimized as possible.
Chances are it is, for large matrices and a small number of calls.
However, for small matrices and a large number of calls, guess what it was spending a heavy fraction of its time doing.
It was calling a function to do string compares to see what the options were in calling the math functions.
For example, DGEMM is a general routine to do matrix multiplication & scaling.
It's first two arguments are CHARACTER*1 flags that tell it whether either input matrix is transposed.
For small matrices, calling a function to test those flags is a major percent of the time, and could clearly be eliminated by writing a more specialized routine.

The only generality you can draw from these examples is that you need an effective diagnostic (like random-pausing) to tell what the problem is at each stage of performance tuning. The problems you find will undoubtedly be different from these examples, but in every case the only way you know what to fix is to have the program itself tell you.

Once you get rid of the extra stuff being done in the program that exists to make some unspecified general coding easier,
then you can turn the compiler's optimizer loose to do its own level of cycle-squeezing (assuming speed is your major concern).


答:
Yes it is a copout 100%, they should be teaching long term skills which will be useful throughout our career. Whether or not your intention is to go into academia or the industry you will need to be able to program in a way that can be maintained, even if it's only by yourself.

Yes, although it would only be stressed in the proper courses. Personally, if I have to talk to you to better understand how you tried to implement an algorithm I would mark down your grade.

Even if you go pure CS research you will probably have to create code to demonstrate your ideas. Proper programming skills will be useful to you at some point so why not begin in college.


答:
This generally occurs because of a perverse incentive - the salespeople are being paid on commission, while the production staff is paid on salary. The salespeople have several levers to work with: features, cost, and delivery date. They have a strong disincentive to lower the cost, because this generally lowers their commission, so they tend to ratchet UP features and delivery date (in terms of being earlier). They will push those as high as they can in order to close the deal.

Try and see it from their point of view, just for a moment. They've got a family to feed, too - and if the difference between closing a sale I've been working on for months is just trimming off a few weeks of the schedule, then it's an incredible temptation, especially if I don't really understand what that means.

The temptation is to say "twas always thus, and always thus will be." But one place I worked did at least have a solution PROPOSED, if not implemented...one manager finally threw up his hands and said, "if the programmers' overtime is being used to close a sale, then they should receive a portion of the commission." It wasn't implemented, but it would have aligned everybody's incentives more closely...the programmers would have been thrilled to hear about a new feature that had to come out in no time, because they'd be anticipating  the commission, and the salespeople would be LESS apt to create those circumstances, because they would be less likely to work to their advantage.


问:
Is there a standard name for this search approach?
In order to create a (Lucene) query, an "incomplete" domain object is used. All properties with a value are used for the query, the rest is ignored.

In the absence of a better name, we call it "search by example", but as with many other "original" approaches there is probably a (standard/agreed upon) name for this approach, but I could not find one.

Thank you.

答:
It's called Query By Example (QBE).

...It is the first graphical query language, using visual tables where the user would enter commands, example elements and conditions. Many graphical front-ends for databases use the ideas from QBE today. Originally limited only for the purpose of retrieving data, QBE was later extended to allow other operations, such as inserts, deletes and updates, as well as creation of temporary tables.

The motivation behind QBE is that a parser can convert the user's actions into statements expressed in a database manipulation language, such as SQL. Behind the scenes, it is this statement that is actually executed. A suitably comprehensive front-end can minimize the burden on the user to remember the finer details of SQL, and it is easier and more productive for end-users (and even programmers) to select tables and columns by selecting them rather than typing in their names...