答:
We use a DAL layer that not only does the SQL stuff but handles the abstraction.  The DAL layer's responsibility is to take in a generic object called a data transfer object.  The data transfer object contains a list of DAL POCOs.  The DAL looks at each POCO (we decorate the class with attributes) and dynamically generates a mapper class based on the object type.  From there, it is just mapping POCO properties to stored procedure parameters.  The DAL is very simple, just Save, Delete, and Query on the interface along with a custom command when you want to do something else (call a stored procedure other than the basic Insert, Update, Delete, Query ones) for some extendability.

The DAL doesn't really care about the Domain, its tied to the schema.  So, the POCOs that the DAL uses may be mapped to different domain POCOs in the domain layer.  So there could be an intermediate layer in some cases, but you could use the POCOs that the DAL is using as they are just state objects and contain no methods or logic in them, but somethimes the domain and DAL don't really match up so thats when the domain would be responsible for converting the domain object to a DAL object/POCO.

From a DAL standpoint, currently we are supporting 50 out of planned ~200 tables with this pattern, I guess this is an home grown ORM lite.  With some code generators we implemented, most and the mapping code (tedious glue code) is handled automatically, so we can concentrate on the business and presentation logic.

But that's how we did it with 100% Sprocs.

Title: How to define the seams between the domain layer and a database full of stored procedures?

Body:
We have a legacy database full of stored procedures.

These stored procedures are somewhat CRUD-categorized but upon inspection of some procedures, they are not "simple" as they might update, delete, whatever other records in other tables.

So to my mind (correct me if I'm wrong) it would seem that using an ORM would be pretty difficult since

I can't access the tables directly: I must use a stored procedure

The stored procedures would not map to CRUD

I'm leaning toward defining repositories to isolate the domain layer from the database but I fear that I would need to define a lot of infrastructure (caching, unit of work and the like) that I get for "free" in a ORM.

Any insights?


问:
Ethics of collecting non-identifiable information on install
I wrapping up an application I'm writing that I'm hoping will get a decent user base. It will be free and open source, but I'm interested in collecting some analytic data on the install base.  Essentially a small version of Google Analytics, but for a desktop application instead of a website.

Details I would like to collect are:

Previous App Version (if any)

Current App Version

OS Version

Regional Geographic Location (Country/City level only, probably IP based).

Unique System Hash (To determine # of unique installs)

I have a feeling that the first three could probably be done with no real worries as they are data points gathered by pretty much EVERY website in existence without ever asking permission.

Geographic location I'm still fairly comfortable is OK. Again, collected by every website out there... and heck, they even get your actual IP.  I wouldn't get this, but actually resolve the geo location client side and send ONLY that.  All this data would probably be submitted to a google docs form, so I wouldn't have IP access even at the collection level.

I'm a little more worried about the unique system hash as people might see this as identifiable.  However, my current thought is to gather the systems motherboard and CPU serial, concatenate them together and then create a hash (probably MD5) out of that string.  Same thing that's done with passwords, no way to reverse it so really NO way to discern who the data actually belongs to.  You'd have to have that specific hash from every computer along with their owner info to match them up.

So, I'm probably fine, but I just want to cover my ass here.

Any thoughts from the community as to if the data I want to collect is reasonable or if there are some data points I should not collect (or none at all).  As previously mentioned, the application will be totally open source, so they would be more than able to look at the code and verify that no questionable data is sent.  The only thing I might be tempted to "hide" is the actual address of the collection form, purely so someone doesn't decide to spam it with bogus data (maybe I'm being to paranoid).  As it is, the app uses some web APIs for which I have personal keys that cannot be given away in the checked in source, so I have a file that is omitted from source control that contains things like those API keys.  The application still works without them, just in a more limited fashion and anyone could get a key of their own and compile to make it full featured.  I figure I could put the form URL in this section.

Thoughts?

答:
Just explain it in the setup and make it opt-in.  I could probably think of a few exceptions if you tortured me, but basically opt-out is always unethical (making the user go out of his way to prevent something).  Opt-in with full-disclosure means you and we don't have to decide if it is ethical, your users can decide for themselves.

The first two are app-specific, so I don't see a problem with them.  The third is probably necessary to do the install at all, so it's not really a question of if they'll tell you or not. The fourth is something I don't care about myself, but some people will. The last is something I'd be a little suspicious of from a user point of view.  This may not be personally identifiable directly, but it sounds like it can potentially be compared to similar data from websites and used for tracking and some level of data mining, even if all they know is that mystery user X installed your app and also frequented midgetporn.com.  Not that you would do that, but a user might not know that you're a StackExchange member and thus honest, trustworthy and upright.

Yeah, I know that horse has already left the barn.  But since you're asking about ethics, "everybody does it" is no reason to jump on the bandwagon yourself. In any case, there's probably no harm in asking first.  If you don't ask first, and even if the information is completely benign, you could look underhanded.

ContentLicense: CC BY-SA 3.0


问:
What books or resources would you recommend to learn practical OO design and development concepts?
I'm a self taught programmer; I understand the foundations of programming and what classes are, but my code tends to be messy with class methods interacting with a half a dozen other classes, and my structure is terrible.  If someone else were to look at my code, I don't think they would be able to understand what was going on.</p>

答: Head First Design Patterns is pretty good. The Gang of Four patterns book is the canonical reference, but for a beginner, it's a bit short on the details of the whys and wherefores.  Head First walks a less experienced programmer through examples and explains the thinking behind the design and the patterns.  It's not comprehensive, but it's more explanatory, and even aside from learning the specific patterns, it's useful for looking at the thinking behind OOP design in general. </p>


答:
Look into design patterns. These are tried-and-true methods to structure your code to solve commonly encountered problems. The more you become familiar with these, the more you'll train your eyes to seek out patterns and solve them elegantly. It'll also make describing your code easier in that you can use the name of the pattern to explain it.

The most classic authority on this is Design Patterns: Elements of Reusable Object-Oriented Software, often referred to as The Gang of Four, or simply Gamma. This book is pretty readable and a good reference to have in your bookcase.

A friendlier read, which may appeal to you even more if you're new to the concept of design patterns is Head First Design Patterns, which is a whimsical approach to learning these and it covers the most often encountered patterns. Another advantage to this source is that it also explains some concepts associated with good object oriented design.

Title: What books or resources would you recommend to learn practical OO design and development concepts?

Body: I'm a self taught programmer; I understand the foundations of programming and what classes are, but my code tends to be messy with class methods interacting with a half a dozen other classes, and my structure is terrible.  If someone else were to look at my code, I don't think they would be able to understand what was going on.</p>


问:
What's your favourite quote about programming?
What's your favourite quote about programming?

One quote per answer, and please check for duplicates before posting!

答:
2 + 2 = 5, for sufficiently large values of 2.

— Anon

LastEditorDisplayName: Roger Pate

ContentLicense: CC BY-SA 2.5


问:
Who invented pointers?
Pretty simple question, but something I haven't been able to find out. Who was the first person to describe the idea of a pointer? The abstract concept itself?</p>

答:
Pointers are more broadly References. The first language to have anything like that was ALGOL 60 which could call by name. This answer on SO goes into some detail. PL/I had pointers as did BCPL which means that CPL probably did too though I've not found any evidence for it. CPL is very hard to concrete information on.

To more directly answer your question as to the "who" either D. W. Barron, Christopher Strachey  or Martin Richards probably coined the term "pointer".

Title: Who invented pointers?


问:
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 think as a Jr Developer (I am one) you should be where you are at; solid knowledge of fundamentals, eagerness to learn and an open mind. You will consolidate your skills as you are introduced to new problems to solve. I think technology-specific skills are developed and learned on the job, at least that's what I've found. Good luck!</p>

OwnerDisplayName: joey land


答:
A Junior Developer needs to have the basics down.  In your field, that would include a pretty firm grasp on OOP, the layout of ASP.NET applications, master pages, code behind (whether it be C# or VB.NET), etc.  Basically the stuff you can pick up with personal projects.  Everything else is just gravy.

The specifics, like composite controls and page rendering will be picked up and mastered while actually utilizing the certain technology.  Nobody is going to expect you to walk in the front door and be a master with ASP.NET.  You are young and your experience dictates that.  Even the best developers aren't born knowing this stuff.  They know it because they've used it....for many, many years.

BUT MOST IMPORTANTLY:
Just be willing to learn and listen to the mid-level and senior developers.

Title: how much do I really need to know to become Jr Developer?

Body: 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>


答:
It's hard to guess exactly who came up with them, but the index registers in the IBM 704 were probably the first implementation. From a programming language viewpoint, therefore, it would undoubtedly have been the 704's assembly language.

It apparently took a few years after that before higher level programming languages were designed to take advantage of this innovation, but by then most of the inventing was done, and it mostly came down to picking names, notations, etc. to describe what the hardware supported.

Title: Who invented pointers?

Body: Pretty simple question, but something I haven't been able to find out. Who was the first person to describe the idea of a pointer? The abstract concept itself?</p>


问:
Type-clarifying comments and type checking in dynamic languages
I often feel that there's something wrong when I code blocks such as:

```<code>function foo (arg){ // arg: a SomeClass object
    ...
}
</code>```

or

```<code>function foo (arg){
    if (Object.prototype.toString.apply(arg) !== '[object Array]')
        throw new Error("Parameter must be an array");
    ...
}
</code>```

. With a statically typed language I wouldn't have to either clarify the expected argument type or check compliance to this expectation. In addition, the possibility of specifying a return type makes the code even more descriptive.

OTOH some cases lend themselves to self-documenting code:

```<code>function parse (json){
    ...
}
</code>```

. In the example above, it's reasonable enough to suppose that your API consumers will know both what the function is supposed to do, and what argument values will be acceptable.

However other times clarifying the code intent by choosing "clarifying" names would yield long, awkward names that mix the expected type of a variable and its role.

Am I using dynamic languages with the wrong mindset?

What conventions, techniques, patterns can save one from having to write ugly type-checking code and/or excessively depending on comments?

答:
I think your mindset is fundamentally sound, as long as you don’t overlook the advantages that a dynamic language gives you amongst which are  the reduction in boilerplate, the ability to handle impedance mismatches such as database access and localised expressiveness.

One small tip is to encapsulate the run-time type checking in the form of an assertion.  This makes the role of the checking code obvious and is effective when used in conjunction with unit tests.

However, static type declarations do not just provide the means for a compiler to perform a basic set of mandatory unit tests they provide a lot of information to the coder about objects they are using and methods they are calling.  Also, providing the assertions and tests to make up for the absence of a compiler’s type checking takes effort, repeated over and over again.  I would rather have a single keyword to indicate a type than many lines of assertions and tests.

Although dynamic languages can be very expressive at local level, say within a function, they are far less effective at showing the relationships between components in a large code base.  I would rather examine the details of and relationships between objects as revealed by the code in a set of class declarations than examine a bunch of procedural production code and unit tests which may or may not be complete.

I was recently maintaining some unfamiliar javascript code which involved manipulating a tree which was based on some JSON loaded from a server.  I had no idea what was guaranteed or even expected about any given node in the tree.  A class declaration would have at least given the original developer somewhere to hang information about the expectations about various nodes.

Whereas I might prefer to write in a dynamic language, I certainly prefer to read and maintain code in a statically typed one.


答:
Pointers are really storage addressed by the contents of a register. As such all assembler languages implement this in some way, and, before that all hard coded machine code implemented this.

There will be some argument as to the first computer that implemented this. As far as I know the  Manchestern University Small Scale System was the first to include storage addressed by program controlled registers. It may have been preceded by the ENIAC system but it had so little storage as to make addressable storage a moot point.

Title: Who invented pointers?


问:
How should I go about learning a very large and complex application?
Being a young and fairly inexperienced developer recently employed by a "real" software company I'd like some opinions and pointers on how to do the following:

Approaches on how to get familiar with a companies products , especially when you've no idea how it all works. The company I'm at now has one HUGE product , continually evolving and having been here for 2 weeks I've still no idea how it all sticks together apart from a special kind of glue made from the tears and frustration of young developers, it's incredibly fragmented and only 4 people in the office know the inner workings, all of them constantly busy

Give useful input on the product : Now, I know I'm just a kid in the company and I can't be expected to deliver anything ground-breaking in my first months, but  you have to give as much as you're paid. I'm getting around twice as much as at my previous job but objectively speaking I've not done anything to deserve it yet. Just sat around staring at my laptop screen trying to decipher code. Now you might say that this is what I'm here for , to start off with at least, but at my previous job I was something of a go-to-guy, making decisions and contributing to almost every aspect of the company's daily running. While that was a lot of work I enjoyed the feeling of being 'connected' in the inner workings of the company I have a stake in (a symbiotic relationship if you will).please edit this point down, I'll leave it up to you guys to decide what's important

I'll post more things as I think of them, have to get back to reading and writing something only vaguely resembling C#

答:
I assume you have already installed the development environment and have all the necessary tools working - if not, start with these. Setting up your dev environment usually takes a lot of time, with long idle periods waiting for software to download/install, while you can still do other things.

About your lack of information, I suggest you talk to your fellow developers and manager. If the senior devs are busy, talk to the others - they may be able to explain some things to you, or point you to documentation sources, and/or they are also frustrated by not having the full picture. In the latter case, you can approach your manager together, to work out some solution to your problem.

Even if the seniors are fully engaged, they probably understand that spending some time on teaching/mentoring the juniors now may reduce their workload in the long run. But it is management who ultimately decides about task assignment, so the decision is theirs to make.


答:
Applying UML and Patterns by Craig Larman

An excellent tutorial on object-oriented analysis and design, highly recommended. POS system case study alone makes it worth reading the book.

Another thing I like in this book is nicely described and explained walkthrough of a reasonably productive iterative development process.

Title reference to "UML and Patterns" is rather misleading, I think most of those who have read the book would agree on that. To study UML and design patterns one would better go elsewhere.

Book subtitle is much better fit for contents: "An Introduction to Object-Oriented Analysis and Design and Iterative Development"


答:
If I were you wouldn't worry so much about understanding "how it all works". If you are hired as a junior/inexperienced then focus on your tasks and ask questions when time given. For example when you are given a new task try to use that connection with your seniors to ask more general questions but don't ask too many questions at once. Also try to devote a little of your time each day in browsing through other parts the software, documents or whatever you have access to. Before you know it you'll see how it fits together end you'll end up being the senior.

Remember that if you consider it to be fragmented it may not actually be so, maybe you just don't know enough about the product yet.

Title: How should I go about learning a very large and complex application?

Body:
Being a young and fairly inexperienced developer recently employed by a "real" software company I'd like some opinions and pointers on how to do the following:

Approaches on how to get familiar with a companies products , especially when you've no idea how it all works. The company I'm at now has one HUGE product , continually evolving and having been here for 2 weeks I've still no idea how it all sticks together apart from a special kind of glue made from the tears and frustration of young developers, it's incredibly fragmented and only 4 people in the office know the inner workings, all of them constantly busy

Give useful input on the product : Now, I know I'm just a kid in the company and I can't be expected to deliver anything ground-breaking in my first months, but  you have to give as much as you're paid. I'm getting around twice as much as at my previous job but objectively speaking I've not done anything to deserve it yet. Just sat around staring at my laptop screen trying to decipher code. Now you might say that this is what I'm here for , to start off with at least, but at my previous job I was something of a go-to-guy, making decisions and contributing to almost every aspect of the company's daily running. While that was a lot of work I enjoyed the feeling of being 'connected' in the inner workings of the company I have a stake in (a symbiotic relationship if you will).please edit this point down, I'll leave it up to you guys to decide what's important

I'll post more things as I think of them, have to get back to reading and writing something only vaguely resembling C#


答:
2 weeks ? In my second job it was quite common for new hires to only get the 'oh! i get it now!' moment 9 months in....

If it is genuinely a huge product then they will expect a long time to 'get' it, just keep working hard and ask plenty of questions.


问:
Tools for managing a complicated project setup with many frameworks and no documentation
We have to extend a huge java project that makes use of frameworks like maven, spring, struts, freemarker and closure templates.

We do have access to source code but barely any documentation, and we have to extend this system. Our only solution is to find the place in the existing code, where something similar is already done. To find this place, we try to start from the action that is called and then with the help of the debugger try to find out which classes and Spring beans are involved.

The stack traces from the debugger are quite hard to understand, since a lot of reflection is being used.

Does anybody had a similiar setup and could provide a few tipps how to manage such a complicated setup?

答:
We did have the same problem in our company. A huge code and no documentation. We have never been able to extend it and the project was redone.

What was funny in the story is that few year later we found out that the team had almost done no code except business rules. They have create a small model and have generated a huge code from it. This is why the code was messy and impossible to understand by new developers. They did not let the original model as well so a really bad experience and exactly what should not be done !!

I sometimes hate Model Driven Development  :-) but like UML therefore a reverse engineering of the java code into a class diagram could help but not if the code has been already generated from a model. I mean that a reverse engineering is useful if a hand written code.


答:
One tip, ask lots of questions but not as you think of them.  Keep a list of questions and when you do get time with a senior developer bring out the list.  It's a far more efficient use of their time to answer 10 well thought through questions in on burst than five questions over the course of a day that interrupts their focus.

Consider using e-mail if they'd prefer that.

When you have the answer to a question, document it.  If there's a wiki use it.  If there isn't create one.  Even tiddlywiki would be better than nothing.


答:
Everyones different but I found the best way I came to grips quickly was to do the "hard" yards and get down and learning.  Basically this involved reading and more reading, investigating and more investigating and not being afraid to ask questions (although in the right situation and time).

If there are log files, look into these.  I found to a certain degree being involved in looking into bugs was a great way to start coming to grips with the project.  Although boring and not the most enjoyable it gave me a chance to really delve deep into a solution.  As long as you are prepared to investigate an issue as thoroughly as you can.  Even if you can't resolve it yourself and need to escalate it to a senior member, if you have shown your ability to really look into the issue and can help point out the areas you investigated and even offer your own opinions on what might be going wrong.

I found that senior members were more willing to sit down and then go through it with you at your desk if they know you have already taken the time to do alot of the donkey work.

An important note which may help you is when you ask questions try to write down the answer so that you do not make the same mistake of asking again.  Although most senior developers have a great deal of patience for juniors it can quickly wear thin when the junior does not seem to be paying attention to what you are saying.

Good luck in your new role.


问:
Why do languages such as C and C++ not have garbage collection, while Java does?
Well, I know that there are things like malloc/free for C, and new/using-a-destructor for memory management in C++, but I was wondering why there aren't "new updates" to these languages that allow the user to have the option to manually manage memory, or for the system to do it automatically (garbage collection)?

Somewhat of a newb-ish question, but only been in CS for about a year.

答:
Can you imagine writing a device handler in a language with garbage collection? How many bits could come down the line while the GC was running?

Or an operating system? How could you start the garbage collection running before you even start the kernel?

C is designed for low level close to the hardware tasks. The problem? is it is such a nice language that its a good choice for many higher level tasks as well. The language czars are aware of these uses but they need to support the requirements of device drivers, embedded code and operating systems as a priority.


问:
How can I automate production deployments without experiencing extreme anxiety?
At our shop we use SVN for source control and CruiseControl for CI on handling automatic builds and deployments to our development, test, and integration environments.

This all works smoothly however due to hardware and resource constraints our integration environment is not a 2 server load balanced environment like our production environment.  While everything else is equal that would be the only difference between our integration and production environments (although a big one!)

Theoretically the difference is a slightly different configuration of our app servers and the deploy script merely would have to drop the build artifacts into two servers instead of just the one, but why am I so nervous to automate our production deployments?!

I am generally not a control freak but I always feel the insatiable need to deploy production to production manually.  I have heard from colleagues that this is generally a Really BAD Thing™ but they failed to make a case against it.

I know that when I do it manually I can SEE that I am physically copying the correct files, I am physically shutting down the app servers and ensuring they closed successfully, I am physically starting the servers back up and then physically inspecting the logs to make sure it started up okay and the deployment was successful.  It gives me a peace of mind.

What are arguments against this OR arguments for automatic scripted production deployment?

答:
Computers don't make mistakes, people do.

Write your script once and thoroughly check it, go through it line by line. From then on you can be sure that each time you deploy, it will work.

Do it by hand and you're bound to make mistakes. Maybe you wrote, everything you have to do, down but it's oh so easy to make a mistake. You have to copy all files except the web.config file? You can bet that someday you will overwrite it. A script will never make this mistake.


问:
What are possible/useful implementations when extending exceptions?
I have seen a lot of exceptions - custom or integrated in the language (PHP) itself that have no differences but their class name.

When extending default exceptions to use within your own code, are there any other things you could implement that are useful besides the more specific exception name that do not violate things like single responsibility?

答:
More information about the error. A typical example is an SQL exception where you want to include things like the query that failed, ANSI-SQL error code, vendor-specific error code, the error message from the SQL driver, etc. Other examples: argument name for InvalidArgumentExceptions, HTTP status codes and messages for HttpExceptions, control ID and value for ValidationExceptions, ...

In fact, most exceptions can (and should) carry a bit more information beyond 'something went wrong'.

Even though you should normally avoid presenting this information to the user, it is still enormously helpful when examining logfiles or the like. Imagine you have a log entry that says "SqlException: Column 'usernaem' does not exist. (Query: SELECT * FROM user WHERE username = :usernaem)" instead of just "SqlException"...


问:
Which Resource Would Be Best for Learning C# / .Net?
I'm a PHP / Java / Objective-C programmer, looking to finally learn some MS technologies, to increase my marketability, etc.

I am looking at these two books, can anyone experienced in the field suggest one over the other, or another book that'd be good for learning C# / .Net, etc? What impressed me about "Pro C# 2010 and the .NET 4 Platform" thumbing through it at the bookstore, was that they explained a whole lot of the inner workings and paradigms of MS, not just the language. I haven't had a chance to look through the other one, and probably won't get a chance.

Here are the two I'm considering:

http://www.amazon.com/2010-NET-Platform-Andrew-Troelsen/dp/1430225491/

http://www.amazon.com/Professional-4-0-NET-Wrox-Programmer/dp/0470502258/

I know this is a very specific question, but I feel it can greatly benefit others like me, trying to get into some MS tech.

答:
In my opinion neither of those books you suggested are very good. The book by Troelsen seems to be recommended by many, however I didn't really care for it. I found it raced through so many topics, that the coverage of each topic felt too superficial.

I recommend you get a book just on C# to start with. And then pick a type of application such as Asp.net MVC and then get a good book that develops a decent sample application using that technology.

Another poster recommend C# via CLR. I agree that is a good book, and having read an earlier edition, I'm currently reading the latest edition. However I worry it might contain too much detail, and it might be better to choose a shorter book to start with. On the other hand if you are interested in the inner workings of .net it could be a good starting point.

Skeet's book is also good, and you can probably read it without too much trouble. But, from memory, it tends to assume that you are already somewhat familiar with C#, and explores language features introduced in C# 2.0, 3.0 etc in more detail.

You could try something like Essential C# 4.0, but again I have somewhat mixed feelings about the book, as although it is relatively complete and assumes no prior knowledge of C#, as an experienced programmer you might find it long winded.

Good Luck


问:
Why are exception specifications bad?
Back in school some 10+ years ago, they were teaching you to use exception specifiers. Since my background is as one of them Torvaldish C programmers who stubbornly avoids C++ unless forced to, I only end up in C++ sporadically, and when I do I still use exception specifiers since that's what I was taught.

However, the majority of C++ programmers seem to frown upon exception specifiers. I have read the debate and the arguments from various C++ gurus, like these. As far as I understand it, it boils down to three things:

Exception specifiers use a type system that is inconsistent with the rest of the language ("shadow type system").

If your function with an exception specifier throws anything else except what you have specified, the program will get terminated in bad, unexpected ways.

Exception specifiers will be removed in the upcoming C++ standard.

Am I missing something here or are these all the reasons?

My own opinions:

Regarding 1): So what. C++ is probably the most inconsistent programming language ever made, syntax-wise. We have the macros, the goto/labels, the horde (hoard?) of undefined-/unspecified-/implementation-defined behavior, the poorly-defined integer types, all the implicit type promotion rules, special-case keywords like friend, auto, register, explicit... And so on. Someone could probably write several thick books of all the weirdness in C/C++.
So why are people reacting against this particular inconsistency, which is a minor flaw in comparison to many other far more dangerous features of the language?

Regarding 2): Isn't that my own responsibility? There are so many other ways I can write a fatal bug in C++, why is this particular case any worse? Instead of writing throw(int) and then throwing Crash_t, I may as well claim that my function returns a pointer to int, then make a wild, explicit typecast and return a pointer to a Crash_t. The spirit of C/C++ has always been to leave most of the responsibility to the programmer.

What about advantages then? The most obvious is that if your function tries to explicitly throw any type other than what you specified, the compiler will give you an error. I believe that the standard is clear regarding this(?). Bugs will only happen when your function calls other functions that in turn throw the wrong type.

Coming from a world of deterministic, embedded C programs, I would most certainly prefer to know exactly what a function will throw at me. If there is something in the language supporting that, why not use it? The alternatives seem to be:

```<code>void func() throw(Egg_t);
</code>```

and

```<code>void func(); // This function throws an Egg_t
</code>```

I think there is a big chance that the caller ignores/forgets to implement the try-catch in the second case, less so in the first case.

As I understand it, if either one of these two forms decides to suddenly throw another kind of exception, the program will crash. In the first case because it isn't allowed to throw another exception, in the second case because nobody expected it to throw a SpanishInquisition_t and therefore that expression isn't caught where it should have been.

In case of the latter, to have some last resort catch(...) at the highest level of the program doesn't really seem any better than a program crash: "Hey, somewhere in your program something throwed a strange, unhandled exception.". You can't recover the program once you are that far from where the exception was thrown, the only thing you can do is to exit the program.

And from the user's point-of-view they couldn't care less if they get an evil message box from the OS saying "Program terminated. Blablabla at address 0x12345" or an evil message box from your program saying "Unhandled exception: myclass.func.something". The bug is still there.

With the upcoming C++ standard I'll have no other option but to abandon exception specifiers. But I would rather hear some solid argument why they are bad, rather than "His Holiness has stated it and thus it is so". Perhaps there are more arguments against them than the ones I listed, or perhaps there is more to them than I realize?

答:
Exception specs are bad because they're weakly enforced, and therefore don't actually accomplish much, and they're also bad because they force the run-time to check for unexpected exceptions so that they can terminate(), instead of invoking UB, this can waste a significant amount of performance.

So in summary, exception specs aren't enforced strongly enough in the language to actually make code any safer, and implementing them as specified was a big performance drain.

Title: Why are exception specifications bad?


答:
My general experience is that 90% of time the role name implies the type. E.g. you may have User class appear as "creator", "owner", "editor" and simply "currentUser" over and over in given application. If you use those identifiers for the roles consistently and take a little bit of care to avoid naming roles of different types similarly (e.g. don't use "owner" for parent objects if you used it for user owning document), anyone using the interface will learn what type of objects should go where quite fast.

Much of the rest will be obvious from context, especially if you also call actions consistently. Using long names or just accepting the name is not descriptive and adding enough documentation should do for the few cases that remain.

Title: Type-clarifying comments and type checking in dynamic languages

Body:
I often feel that there's something wrong when I code blocks such as:

```<code>function foo (arg){ // arg: a SomeClass object
    ...
}
</code>```

or

```<code>function foo (arg){
    if (Object.prototype.toString.apply(arg) !== '[object Array]')
        throw new Error("Parameter must be an array");
    ...
}
</code>```

. With a statically typed language I wouldn't have to either clarify the expected argument type or check compliance to this expectation. In addition, the possibility of specifying a return type makes the code even more descriptive.

OTOH some cases lend themselves to self-documenting code:

```<code>function parse (json){
    ...
}
</code>```

. In the example above, it's reasonable enough to suppose that your API consumers will know both what the function is supposed to do, and what argument values will be acceptable.

However other times clarifying the code intent by choosing "clarifying" names would yield long, awkward names that mix the expected type of a variable and its role.

Am I using dynamic languages with the wrong mindset?

What conventions, techniques, patterns can save one from having to write ugly type-checking code and/or excessively depending on comments?


答:
The truth is: it depends on company and on the meaning of junior position. Sometimes junior is equal to graduate and sometimes junior is above graduate.

Some companies expects that you know what ASP.NET is. Some companies expects that you know what .NET and C# is and some companies expects that you know what HTTP and web development is.

If junior = graduate you can find companies where simple diploma from information technology  related is enough (= theoretical knowledge) and company will teach you what they need. It doesn't mean you don't have to learn yourselves - self learning is the most important part of your career development.

The question is if ASP.NET WebForms are what you should learn? Definitely check ASP.NET MVC as well. Also being ASP.NET developer is not only about .NET - you should learn JavaScript and some JavaScript framework (like jQuery). Knowledge of HTML (especially HTML 5) and CSS can be also very useful.


问:
Which problems domains are more suited  to functional programming solutions
Which problems domains are more suited to functional programming solutions and why? Can anyone provide any examples?

EDIT Just to clarify, I'm not asking for a list of problems. I want to know what type of problems are best suited to functional solutions. For example I have heard financial problems are solved well with functional programming.

答:
Functional programming uses immutable datastructures and doesn't rely on mutable state, this means that the programs are easier to reason about and easier to prove for correctness.

Functional programming is easiest to use for stateless problems, e.g. programs that takes an input and generates an output without a need for side effects. Typical problem domains are compilers and stateless servers. Or libraries for calculations.


答:
Even as a not-so-new developer, I often find myself thrust into situations where I have no idea how the software works or is designed (if it was designed).  Often if there is someone around to ask, they don't know much more than I do, or are wrapped up in something else.

First step - Get prepared.  Install a dev environment, get a notebook, clear off a whiteboard.  If there are any design docs, find them and have them available for reference.  @mcottle's answer is a great one.  If you want to understand a system, you need to approach it like you're going to [take a test]/[teach someone else].  Write down lots of questions, draw relationships between components, and keep track of things that surprised you.  If a new developer were to put together a rough sketch of the system in a format (wiki, document, whatever) that I could pass around to other new developers as a starting point - 1 million brownie points in my book.

Second step - Approach it as a user.  What is this software for?  What problem is it designed to solve?  Read the manual.  This will hopefully give you some context as you move on.

Third step - Determine the edges of the system.  Where does input come from?  What's the final result?

Fourth step - Trace an input through the code base.  Don't get too hung up in the details on the first pass, just write down questions as you go.  As you make additional passes you can try and answer those questions and generate new ones.

Fifth step - Find the seams in the system.  The idea here is to find the major architectural layers (an I/O or network boundary is usually a good thing to document).

Sixth step - Now move on to breaking things into components.  Is the system modular enough that you can think about X without wondering what's happening to Y and Z?  If not, document that relationship.  From here you can divide and conquer your way through the system, breaking each component down until you reach a "good enough" understanding.

Note that this is a fairly thorough method.  In a very large project you'll likely be able to go a very long time without needing to know exactly how the Foo module interacts with Bar.  I would strive to learn enough about the system that I know which parts I feel comfortable changing and which are shrouded in mystery.  This is normal in any project; there are always libraries where you use 5% of the functionality and remain blissfully ignorant of the rest.


问:
Should I use a relational datamodel or Cassandra with ColumnFamily based indexes?
Currently we are working on some storage problems for log data from various servers and communication message logs (HTTP(S), XMPP). There will be many write operations and for read operations we will use search queries with filters.

Should we stick with the classic relation database schema solution or concentrate on Cassandra with ColumnFamily based indexes?

答: Hadoop, hbase, hive/pig is generally used for these kind of log analysis or to handle huge data produces logs & messages. This llnk can give give u more details http://www.cloudera.com/blog/2009/06/analyzing-apache-logs-with-pig/. But this has huge learning curve.</p>


答:
If the project is really huge, they won't expect you to know it in two weeks, or even two months.  If they do, then you are at the wrong place.

My latest position is one where a high degree of relevancy isn't expected on the actual product shipped for a year. To get up to speed I spent a lot of time reading documentation, just playing around with the product/hacking it, and asking a lot of questions.  The first few tasks you get (bug fixes, minor changes) should start to get you up to speed with the project.  Each one after that should bring more understanding.

I'm sure there is a process that you can have laid out and follow but, I've found it best to just keep plugging away at it.  The more you do, the more you will learn.


答:
Pointers as a basic concept are used in "indirect addressing" a function on most CPUs going back at least as the 6502.

Commodore used the "kernal" on its VIC 20, C64, and C128 computers. a fixed set of address software could call that would then be redirected to the current code. They could then modify the OS without breaking existing software.

I think the 8080 and Z80 had indirect address too, but I am not certain and I don't remember it in the 8008.

Title: Who invented pointers?


问:
How do you avoid working on the wrong branch?
Being careful is usually enough to prevent problems, but sometimes I need to double check the branch I'm working on (e.g. "hmm... I'm in the dev branch, right?") by checking the source control path of a random file.

In looking for an easier way, I thought of naming the solution files accordingly  (e.g. MySolution_Dev.sln) but with different file names in each branch, I can't merge the solution files.

It's not that big of a deal but are there any methods or "small tricks" you use to quickly ensure you're in the correct branch?  I'm using Visual Studio 2010 with TFS 2008.

答:
Name the working directories differently. That is, if your project is titled "MY_PROJECT," create a different working directory for each branch. If there is one branch named "dev," then you'd need a directory for trunk and a directory for dev, like this:</p>

```<code>~/henginy/projects/MY_PROJECT-trunk
~/henginy/projects/MY_PROJECT-dev
</code>```

Body:
Name the working directories differently. That is, if your project is titled "MY_PROJECT," create a different working directory for each branch. If there is one branch named "dev," then you'd need a directory for trunk and a directory for dev, like this:

~/henginy/projects/MY_PROJECT-trunk
~/henginy/projects/MY_PROJECT-dev


问:
Algorithm for formating SQL code
I need a tool (for in house usage) that will format SQL code (SQL Server/MySQL).

There are various 3rd party tools and online web sites that do it but no exactly how I need it.

So I want to write my own tool that will fit my needs.

First question is there any standard or a convention for how the SQL code should be formatted? (the tools that I tried format it differently)

The second question, how should I approach this task?
Should at first convert the sql query into some data structure like a Tree?

答:
...is there any standard or a convention for how the SQL code should be formatted?

Standard, no.  You can put an entire SQL statement on one line as far as an SQL parser is concerned.

Convention, sure there are lots.  It depends whether you're trying to maximize changeability or minimize space.  I've written SQL formatters for both cases.

I just used particular character combinations to tell me where to break the SQL statement.

Here's one example from a Java DB2 SQL formatter that I wrote.  Another Java program generated the Java code.  The SQL came directly from the SYSIBM tables.

```<code>protected void prepareIndex00Select(String codeFacl)
        throws SQLException {
    StringBuffer sb = new StringBuffer();
    sb.append("SELECT CODE_FACL, SEQ_FACL, FILLER_TOF ");
    sb.append("    , CODE_TOF, NAME_FACL, NAME_LENGTH ");
    sb.append("    , CODE_FMB, ID_NCIC_ORI, NBR_PRINTER_PREFIX ");
    sb.append("    , ID_PERSONNEL_OFC, COMPLEX_CODE ");
    sb.append("    , PHS_CODE, DESIG_FACL_GRP, IND_DESIG_AUTH ");
    sb.append("    , CODE_FACL_I_T, INTKEY_FACL, IND_CDM_SENTENCING ");
    sb.append("    , MAL_FEM_IND, DEL_AFTER, IND_INMATES ");
    sb.append("    , VALUE_SO_CPU_STD, VALUE_SO_CPU_DAY ");
    sb.append("    , CODE_CAT, VALUE_DCN, XIDBKEY ");
    sb.append("    , FACL_FK_REGN ");
    sb.append("  FROM ");
    sb.append(creator);
    sb.append(".FACL ");
    sb.append("  WHERE CODE_FACL = ? ");
    if (additionalSQL != null) sb.append(additionalSQL);

    psIndex00 = connection.prepareStatement(sb.toString());
    psIndex00.setString(1, codeFacl);

}   // End prepareIndex00Select method
</code>```

Title: Algorithm for formating SQL code

Body:
...is there any standard or a convention for how the SQL code should be formatted?

Standard, no.  You can put an entire SQL statement on one line as far as an SQL parser is concerned.

Convention, sure there are lots.  It depends whether you're trying to maximize changeability or minimize space.  I've written SQL formatters for both cases.

I just used particular character combinations to tell me where to break the SQL statement.

Here's one example from a Java DB2 SQL formatter that I wrote.  Another Java program generated the Java code.  The SQL came directly from the SYSIBM tables.

protected void prepareIndex00Select(String codeFacl)
        throws SQLException {
    StringBuffer sb = new StringBuffer();
    sb.append("SELECT CODE_FACL, SEQ_FACL, FILLER_TOF ");
    sb.append("    , CODE_TOF, NAME_FACL, NAME_LENGTH ");
    sb.append("    , CODE_FMB, ID_NCIC_ORI, NBR_PRINTER_PREFIX ");
    sb.append("    , ID_PERSONNEL_OFC, COMPLEX_CODE ");
    sb.append("    , PHS_CODE, DESIG_FACL_GRP, IND_DESIG_AUTH ");
    sb.append("    , CODE_FACL_I_T, INTKEY_FACL, IND_CDM_SENTENCING ");
    sb.append("    , MAL_FEM_IND, DEL_AFTER, IND_INMATES ");
    sb.append("    , VALUE_SO_CPU_STD, VALUE_SO_CPU_DAY ");
    sb.append("    , CODE_CAT, VALUE_DCN, XIDBKEY ");
    sb.append("    , FACL_FK_REGN ");
    sb.append("  FROM ");
    sb.append(creator);
    sb.append(".FACL ");
    sb.append("  WHERE CODE_FACL = ? ");
    if (additionalSQL != null) sb.append(additionalSQL);

    psIndex00 = connection.prepareStatement(sb.toString());
    psIndex00.setString(1, codeFacl);

}   // End prepareIndex00Select method


答:
This interview with Anders Hejlsberg is quite famous. In it, he explains why the C# design team discarded checked exceptions in the first place. In a nutshell, there are two major reasons: versionability and scalability.

I know the OP is focusing on C++ whereas Hejlsberg is discussing C#, but the points that Hejlsberg makes are perfectly applicable to C++ too.

Title: Why are exception specifications bad?

Body:
Back in school some 10+ years ago, they were teaching you to use exception specifiers. Since my background is as one of them Torvaldish C programmers who stubbornly avoids C++ unless forced to, I only end up in C++ sporadically, and when I do I still use exception specifiers since that's what I was taught.

However, the majority of C++ programmers seem to frown upon exception specifiers. I have read the debate and the arguments from various C++ gurus, like these. As far as I understand it, it boils down to three things:

Exception specifiers use a type system that is inconsistent with the rest of the language ("shadow type system").

If your function with an exception specifier throws anything else except what you have specified, the program will get terminated in bad, unexpected ways.

Exception specifiers will be removed in the upcoming C++ standard.

Am I missing something here or are these all the reasons?

My own opinions:

Regarding 1): So what. C++ is probably the most inconsistent programming language ever made, syntax-wise. We have the macros, the goto/labels, the horde (hoard?) of undefined-/unspecified-/implementation-defined behavior, the poorly-defined integer types, all the implicit type promotion rules, special-case keywords like friend, auto, register, explicit... And so on. Someone could probably write several thick books of all the weirdness in C/C++.
So why are people reacting against this particular inconsistency, which is a minor flaw in comparison to many other far more dangerous features of the language?

Regarding 2): Isn't that my own responsibility? There are so many other ways I can write a fatal bug in C++, why is this particular case any worse? Instead of writing throw(int) and then throwing Crash_t, I may as well claim that my function returns a pointer to int, then make a wild, explicit typecast and return a pointer to a Crash_t. The spirit of C/C++ has always been to leave most of the responsibility to the programmer.

What about advantages then? The most obvious is that if your function tries to explicitly throw any type other than what you specified, the compiler will give you an error. I believe that the standard is clear regarding this(?). Bugs will only happen when your function calls other functions that in turn throw the wrong type.

Coming from a world of deterministic, embedded C programs, I would most certainly prefer to know exactly what a function will throw at me. If there is something in the language supporting that, why not use it? The alternatives seem to be:

```<code>void func() throw(Egg_t);
</code>```

and

```<code>void func(); // This function throws an Egg_t
</code>```

I think there is a big chance that the caller ignores/forgets to implement the try-catch in the second case, less so in the first case.

As I understand it, if either one of these two forms decides to suddenly throw another kind of exception, the program will crash. In the first case because it isn't allowed to throw another exception, in the second case because nobody expected it to throw a SpanishInquisition_t and therefore that expression isn't caught where it should have been.

In case of the latter, to have some last resort catch(...) at the highest level of the program doesn't really seem any better than a program crash: "Hey, somewhere in your program something throwed a strange, unhandled exception.". You can't recover the program once you are that far from where the exception was thrown, the only thing you can do is to exit the program.

And from the user's point-of-view they couldn't care less if they get an evil message box from the OS saying "Program terminated. Blablabla at address 0x12345" or an evil message box from your program saying "Unhandled exception: myclass.func.something". The bug is still there.

With the upcoming C++ standard I'll have no other option but to abandon exception specifiers. But I would rather hear some solid argument why they are bad, rather than "His Holiness has stated it and thus it is so". Perhaps there are more arguments against them than the ones I listed, or perhaps there is more to them than I realize?


答:
One reason no-one uses them is because your primary assumption is wrong:

"The most obvious [advantage] is that if your function tries to explicitly throw
  any type other than what you specified, the compiler will give you an
  error."

```<code>struct foo {};
struct bar {};

struct test
{
    void baz() throw(foo)
    {
        throw bar();
    }
};

int main()
{
    test x;
    try { x.baz(); } catch(bar &b) {}
}
</code>```

This program compiles with no errors or warnings.

Furthermore, even though the exception would have been caught, the program still terminates.

Edit: to answer a point in your question, catch(...) (or better, catch(std::exeption&) or other base class, and then catch(...)) is still useful even if you don't know exactly what went wrong.

Consider that your user has hit a menu button for "save".  The handler for the menu button invites the application to save.  This could fail for myriad reasons: the file was on a network resource that vanished, there was a read-only file and it couldn't be saved over, etc.  But the handler doesn't really care why something failed; it only cares that it either succeeded or failed.  If it succeeded, all is good.  If it failed, it can tell the user.  The exact nature of the exception is irrelevant.  Furthermore, if you write proper, exception-safe code, it means that any such error can propagate through your system without bringing it down -- even for code that doesn't care about the error.  This makes it easier to extend the system.  For example, you now save via a database connection.  Are you going to propagate throw(SQLException) in the function stack all the way up, or just class it as "error" and handle it properly already along with all the other things that could go wrong?

Title: Why are exception specifications bad?

Body:
One reason no-one uses them is because your primary assumption is wrong:

"The most obvious [advantage] is that if your function tries to explicitly throw
  any type other than what you specified, the compiler will give you an
  error."

struct foo {};
struct bar {};

struct test
{
    void baz() throw(foo)
    {
        throw bar();
    }
};

int main()
{
    test x;
    try { x.baz(); } catch(bar &b) {}
}

This program compiles with no errors or warnings.

Furthermore, even though the exception would have been caught, the program still terminates.

Edit: to answer a point in your question, catch(...) (or better, catch(std::exeption&) or other base class, and then catch(...)) is still useful even if you don't know exactly what went wrong.

Consider that your user has hit a menu button for "save".  The handler for the menu button invites the application to save.  This could fail for myriad reasons: the file was on a network resource that vanished, there was a read-only file and it couldn't be saved over, etc.  But the handler doesn't really care why something failed; it only cares that it either succeeded or failed.  If it succeeded, all is good.  If it failed, it can tell the user.  The exact nature of the exception is irrelevant.  Furthermore, if you write proper, exception-safe code, it means that any such error can propagate through your system without bringing it down -- even for code that doesn't care about the error.  This makes it easier to extend the system.  For example, you now save via a database connection.  Are you going to propagate throw(SQLException) in the function stack all the way up, or just class it as "error" and handle it properly already along with all the other things that could go wrong?


问:
Storing page-specific javascript on an AJAX driven site?
I have a general question about the placement of javascript code in a AJAX-driven web application. At a previous job, we tended to throw everything in one monolithic file. When maintaining that file became too difficult, we split it up into multiple smaller files and "glued" them back together with a php "loader" (pretty much just a bunch of include statements)

Since all of my pages are dynamically loaded through AJAX, I cannot simply have different files called separately per page.

The obvious disadvantage to this method is that all of your javascript is loaded by the end user, even if it is not required on first page load. (Which compounds the problem, the more pages you have)

To get around this, I started putting page-specific javascript on the template page itself, in a

答:
There are two main JavaScript loading techniques.

The big file

Some people say HTTP cache works so send all of that javascript in one packaged minified gzipped file and forget about the rest. The first one is expensive, the rest are cheap

The parallel small HTTP requests

Other people say but you can send multiple HTTP requests in parallel so you should send many small asynchronous HTTP requests using some kind of loader library like require.js

Which you use is upto you, personally I use one monolithic file and I use a sensible packager (browserify)


问:
Which is most important to learn OOP first or to learn the OOP language you want to learn?
I face a problem nowadays, I have a really good book that explain OOP but it uses a language which I do not want to learn which is Java because my goal is to learn C#. And I don't know if I should understand OOP with Java at first and then learn C# or should I find any C# book even if the Java book is excellent in teaching OOP?</p>

答: Java and C# are so similar, if you learn OOP fundamentals in Java, you can reuse your knowledge in C# almost directly. There are some differences but the OO concepts are implemented pretty much the same way. C# has several features which Java lacks (delegates, lambdas, LINQ etc.) but these you can learn once you are comfortable with OOP (since these are actually coming from the functional world anyway).</p>


答:
This question is to personal to have a simple answer.

In my opinion, OO is language independent but it use it's syntax is different for the different languages. Try to find a good one about C#.

Title: Which is most important to learn OOP first or to learn the OOP language you want to learn?

Body: I face a problem nowadays, I have a really good book that explain OOP but it uses a language which I do not want to learn which is Java because my goal is to learn C#. And I don't know if I should understand OOP with Java at first and then learn C# or should I find any C# book even if the Java book is excellent in teaching OOP?</p>


答: You could create an empty file in each branch, e.g THIS_IS_TRUNK.txt in trunk, and THIS_IS_DEV.txt in DEV.</p>

Title: How do you avoid working on the wrong branch?

Body:
Being careful is usually enough to prevent problems, but sometimes I need to double check the branch I'm working on (e.g. "hmm... I'm in the dev branch, right?") by checking the source control path of a random file.

In looking for an easier way, I thought of naming the solution files accordingly  (e.g. MySolution_Dev.sln) but with different file names in each branch, I can't merge the solution files.

It's not that big of a deal but are there any methods or "small tricks" you use to quickly ensure you're in the correct branch?  I'm using Visual Studio 2010 with TFS 2008.


问:
What is the difference in meaning between "software", "program", "application", and "gadget"?
It seems to be a naive question, but I was unable to find an explicit definition and difference in meaning of the words "software", "program", "application", and "gadget". What is the correct (at least theoretically) way to use each of these words?</p>

答: I would say that the terms "program" and "application" are used synonymously. However, the term "software" can be more generic and does not necessarily always mean "program" or "application" (e.g. a software "library" or "framework" is not a "program" or "application", but are used to facilitate the functional requirements of "programs" or "applications").</p>


问:
Who invented pointers?
Pretty simple question, but something I haven't been able to find out. Who was the first person to describe the idea of a pointer? The abstract concept itself?</p>

答: Bud Lawson received the IEEE's Computer Pioneer Award a few years back, for inventing the pointer variable in 1964.

Title: Who invented pointers?


问:
Why is Tortoise SVN case sensitive?
I've recently encountered this using TortoiseSVN, but I assume it will be the same for CVS based programs (correct me?).

Out of pure curiosity, is there any reason why the CVS filesystem is case-sensitive? I.e. the following URLS are different:

```<code>svn://repo/branches/PROJECT
svn://repo/branches/project
</code>```

Is there some legacy reason for this? It gets more intriguing on a file basis. If 2 files exist in a directory, lets say ProjectOne.vbp and projectone.vbp, one will overwrite the other in a normal Windows filesystem (or, as I have encountered, throw a cryptic TortoiseSVN database error), but can co-exist peacefully in the repository.

Now obviously it's up to the user to not use ridiculous naming such as the above, but are there any advantages that I'm missing to having case-sensitivity?

答: With the new SVN 1.7 (and corresponding tortoise) this is no longer the case.</p>

Title: Why is Tortoise SVN case sensitive?


问:
Softpedia published some of my open source projects — how to react?
(FYI: I've just moved this question over from Stackoverflow on recommendation.)

I just received a few emails, informing me that softpedia.com has added some of my "products" to their "database of scripts, code snippets and web applications". My products are in this case some smaller open source projects, which I have hosted and published on github.

Now I'm wondering how to react to this. This site is indirectly making money of my free work through ads on three pages before the actual download. They also seem to "invent" version numbers and I can't find out if they're hosting the latest or all versions of my projects. — I can see how this could lead to problems in the future, since I don't control what's "the latest" everywhere.

On the other hand I don't mind some extra publicity. I want as many people as possible to know about the projects, use them, fork them and hopefully improve them.

The projects in questions are really fairly small, but this might not be the case in the future for me and/or other people reading this question.

I'm sure that this must have happened to others around here. What's your opinion? Should I try to get the downloads removed?

Update 1

I've requested the removal and mentioned that I don't feel that Softpedia can provide the right environment for this kind of project.

Their team got back to me instantly with a friendly email saying, that they'll remove the links for now:

If you are worried that your projects won't be updated, then I must
  tell you that I have them bookmarked in my RSS reader, so any version
  changes will be forwarded to me when needed. So I promise I'll keep
  your script up to date as soon as I see an update in the repository.

I have to say, that I appreciate this kind of reaction quite a lot and so I sent them another email, describing in more detail what I'm worried about and what bothers me. I also stated, that I'm aware that my license clearly permits them to host the projects in any case, but that I'd be even happy if they would host the projects as long as they could convince me of a few details and maybe make some small changes to the way the projects are represented. — Let's see where this goes.

Update 2

After discussing with their contact and requesting some changes regarding display of version (they had given the possibility to do so) and authorship they put the projects back up on their site.

All in all a positive and definitely interesting experience.

答:
If you feel so strongly about someone "making money of my free work", then you should contact them and politely ask them to remove your work from their site. If you released your open source software with a license that does not permit this kind of use, you have legal grounds to have them remove it from their site.

Be polite at first, because you may benefit from this if it does bring more publicity to your software. They might even be willing to work with you to clarify any irregularities. Otherwise, if they do not do as you ask, you should be a little more aggressive with them. IANAL, but you could accuse them of infringing your copyright, especially if you licensed the software to specifically prevent this situation.

Good luck!


答:
I personally would feel a bit wronged at someone making money off of my script unless I too benefit from it. For that reason I would consider having them remove the code.

The only way you have leverage* is if you put some license over your code that can be used to prevent them from hosting it. If you just said "Anyone can use it for whatever" for your code then your only hope is to politely ask them to not host your code.

*As usual, I'm no lawyer so you may want to contact an IP laywer.

Title: Softpedia published some of my open source projects — how to react?

Body:
(FYI: I've just moved this question over from Stackoverflow on recommendation.)

I just received a few emails, informing me that softpedia.com has added some of my "products" to their "database of scripts, code snippets and web applications". My products are in this case some smaller open source projects, which I have hosted and published on github.

Now I'm wondering how to react to this. This site is indirectly making money of my free work through ads on three pages before the actual download. They also seem to "invent" version numbers and I can't find out if they're hosting the latest or all versions of my projects. — I can see how this could lead to problems in the future, since I don't control what's "the latest" everywhere.

On the other hand I don't mind some extra publicity. I want as many people as possible to know about the projects, use them, fork them and hopefully improve them.

The projects in questions are really fairly small, but this might not be the case in the future for me and/or other people reading this question.

I'm sure that this must have happened to others around here. What's your opinion? Should I try to get the downloads removed?

Update 1

I've requested the removal and mentioned that I don't feel that Softpedia can provide the right environment for this kind of project.

Their team got back to me instantly with a friendly email saying, that they'll remove the links for now:

If you are worried that your projects won't be updated, then I must
  tell you that I have them bookmarked in my RSS reader, so any version
  changes will be forwarded to me when needed. So I promise I'll keep
  your script up to date as soon as I see an update in the repository.

I have to say, that I appreciate this kind of reaction quite a lot and so I sent them another email, describing in more detail what I'm worried about and what bothers me. I also stated, that I'm aware that my license clearly permits them to host the projects in any case, but that I'd be even happy if they would host the projects as long as they could convince me of a few details and maybe make some small changes to the way the projects are represented. — Let's see where this goes.

Update 2

After discussing with their contact and requesting some changes regarding display of version (they had given the possibility to do so) and authorship they put the projects back up on their site.

All in all a positive and definitely interesting experience.


答:
I don't work in a generic dev or trunk branch.

I ALWAYS do work in feature branches.  When a feature is done, I follow these steps.

Open Source Control Explorer.

Merge from dev into current feature branch.

Fix any conflicts and ensure everything still works.

Check in again. Merge feature into dev branch.

Open dev solution.

Checkin dev branch.

Close dev solution.

Let CI build and deploy.

I only have the dev branch open for a few minutes at a time and close it right away.


问:
AJAX driven "page complete" function? Am I doing it right?
This one might get me slaughtered, since I'm pretty sure it's bad coding practice, so here goes:

I have an AJAX driven site which loads both content and javascript in one go using Mootools' Request.HTML.

Since I have initialization scripts that need to be run to finish "setting up" the template, I include those in a function called pageComplete(), on every page

Visiting one page to another causes the previous pageComplete() function to no longer apply, since a new one is defined.

The javascript function that loads pages dynamically calls pageComplete() blindly when the AJAX call is completed and is loaded onto the page:

```<code>function loadPage(page, params) {
    // page is a string, params is a javascript object
    if (pageRequest && pageRequest.isRunning) pageRequest.cancel();
    pageRequest = new Request.HTML({
        url: '<?=APPLICATION_LINK?>' + page,
        evalScripts: true,
        onSuccess: function(tree, elements, html) {
            // Empty previous content and insert new content
            $('content').empty();
            $('content').innerHTML = html;
            pageComplete();
            pageRequest = null;
        }
    }).send('params='+JSON.encode(params));
}
</code>```

So yes, if pageComplete() is not defined in one the pages, the old pageComplete() is called, which could potentially be disastrous, but as of now, every single page has pageComplete() defined, even if it is empty.

Good idea, bad idea?

答:
You need a way for loadPage() to know when the user has taken some action which should effectively cancel the loading of the first page. For example, if they click on a "page 1" button and you call loadPage() and they then click "page 2" while the remote resources are still loading, loadPage() needs to know that this has occurred.

A simple way to do this would be to check in the onsuccess handler if a global pageName variable still has the same value as it did when the request was fired, or perhaps Mootools offers a way to cancel any pending http requests which you can invoke when changing pages.


问:
what are the mathematical formulas/concepts used in implementing Chart API (bar chart, pie chart etc.,)
Trying to implement chart API in Java. But I am unsure of the mathematical formulas/concepts used in drawing each of the chart type. Can someone specify the mathematical concepts to be known for drawing each sort of the chart.</p>

答:
Hm... very general question, so I can only answer equally general:

Take a look at gnuplot, which is a great mathematical plotting/charting api.

You can find out its concepts by looking at some plots and the manual, the corresponding formulas by reading the source code.


问:
What are ways I can speed of development time when building applications?
I noticed that overtime with experience that the curve of learning shifts from trying to learn a language or technology (the way it works) to how to develop applications faster and with less code. I am very interested to see how other developers have minimized the time it takes to get applications to market.

I know for a fact that by learning just one thing it can save you a ton of time. For example I started learning lambda expressions and code that normally took 3 lines now only takes 1 and is alot faster to type.

Another angle is shortcuts and tools in an IDE itself. For instance I can't believe I didn't know how to remove unused using statements from my source code so I used to do it manually until I found out there was a tool in VS for removing them.

Are there any resources for learing faster ways of developing applications? Keyboard Shortcuts, tools, programs, references? Is there like a reference where one can learn these things? If not can you please share how you learned some of these tips?

NOTE: This question is geared towards .NET, C# and the Visual Studio IDE

答:
We seem to be focusing on the coding aspect of development; so I'll stay there.

Learning C# (for example) is not the same thing as learning how to program. Badly written code is kwap no matter how fast it's written. And the idea that "well, the faster I can get it down on paper, the faster I can fix it" is a fool's errand. Hear me now and believe me later: Writing code well is far superior to writing code fast.

Learning HOW is a long road, but taking the time for that will make your development process faster.

A couple of practical insights from my journey:

Read Code Complete. This is the starting point for quality coding. This book really helped me understand those cute quips we've all heard - "write useful comments" for example. We all say it but it is rare to actually see it.

Thorough design. Within the same (larger) project I got to write code where the class design was pitiful, not object oriented, and moronic; in a different piece of the project the classes were very well designed.

Interestingly the designer (of the good stuff) was getting grief from developers and program management alike for "taking too long" and "it's not simple enough", etc. But the contrast in the speed of coding for these two vastly different baselines was astounding. Well designed classes makes for faster coding and FAR LESS ERROR PRONE code. The former piece spent months in vicious test/reject/fix cycling while the latter sailed through testing in days.

If given the opportunity re-write crapCode from scratch, do it. The before and after picture I got gave me a deep understanding of how all these coding principles, paradigms, etc come together holistically to make excellent code.


问:
How should I go about learning a very large and complex application?
Being a young and fairly inexperienced developer recently employed by a "real" software company I'd like some opinions and pointers on how to do the following:

Approaches on how to get familiar with a companies products , especially when you've no idea how it all works. The company I'm at now has one HUGE product , continually evolving and having been here for 2 weeks I've still no idea how it all sticks together apart from a special kind of glue made from the tears and frustration of young developers, it's incredibly fragmented and only 4 people in the office know the inner workings, all of them constantly busy

Give useful input on the product : Now, I know I'm just a kid in the company and I can't be expected to deliver anything ground-breaking in my first months, but  you have to give as much as you're paid. I'm getting around twice as much as at my previous job but objectively speaking I've not done anything to deserve it yet. Just sat around staring at my laptop screen trying to decipher code. Now you might say that this is what I'm here for , to start off with at least, but at my previous job I was something of a go-to-guy, making decisions and contributing to almost every aspect of the company's daily running. While that was a lot of work I enjoyed the feeling of being 'connected' in the inner workings of the company I have a stake in (a symbiotic relationship if you will).please edit this point down, I'll leave it up to you guys to decide what's important

I'll post more things as I think of them, have to get back to reading and writing something only vaguely resembling C#

答: Also, if it's a truly huge project, you may not ever know how all of it works.  You may only know the details of a few modules, and then just know how they interact with other modules.  Very few engineers are experts on an entire system.</p>


答:
I first tried to learn OOP in C++, but it didn't click for me until I learned it in perl, because perl requires (required?) an explicit call to associate an instance with a class, which helped me distinguish between them.  Then applying it to C++ was trivial.  It doesn't really matter what language you learn a concept in.

However, if C# is going to be your first language, I would recommend learning OOP in C# if you can.  It's enough to tackle without throwing two languages into the mix.


问:
What books or resources would you recommend to learn practical OO design and development concepts?
I'm a self taught programmer; I understand the foundations of programming and what classes are, but my code tends to be messy with class methods interacting with a half a dozen other classes, and my structure is terrible.  If someone else were to look at my code, I don't think they would be able to understand what was going on.</p>

答:
Read, in order:

Code Complete
    Is the first book you should read. It's about programming well. Regardless of what other book(s) you choose, read this.

Head First Object Oriented Design

      I like the "Head First" book series in general. I like how they teach. In fact the authors spend a few pages at the beginning explaining their teaching approach.

Head First Design Patterns

Note:
If you need a book to learn a language, look for one from the "How to program" series by Deitel and Deitel. After 30 years of reading computer books I've found these to be very excellent teaching books. There are volumes on Java, C#, C++, and others.  They are expensive as hell because they are so popular, so go with a used copy. I have 5 different editions on Java and one on C++.


答:
I do a lot of my (D)VCS work from the command line. I highly reccomend having your prompt display where you are at. For instance, my prompt when in a Git repo looks like (I do this for SVN too):

```<code>[BranchName]RepoTop/path/to/current/wd >>
</code>```

And if the repo is currently dirty (uncommitted changes):

```<code>[BranchName!!]RepoTop/path/to/current/wd >>
</code>```

I also have the background set to red if logged into prod, things like that. I find simple visual notifications to be super effective for me.

You mentioned that you often see this most after coming back to your computer. I find a post it note, with my current focus (branch, bug #, feature) stuck to my keyboard when I leave, to be super effective in allowing me to get back to work quickly, rather than recreate whatever it was I did last.

Body:
I do a lot of my (D)VCS work from the command line. I highly reccomend having your prompt display where you are at. For instance, my prompt when in a Git repo looks like (I do this for SVN too):

[BranchName]RepoTop/path/to/current/wd >>

And if the repo is currently dirty (uncommitted changes):

[BranchName!!]RepoTop/path/to/current/wd >>

I also have the background set to red if logged into prod, things like that. I find simple visual notifications to be super effective for me.

You mentioned that you often see this most after coming back to your computer. I find a post it note, with my current focus (branch, bug #, feature) stuck to my keyboard when I leave, to be super effective in allowing me to get back to work quickly, rather than recreate whatever it was I did last.


答:
I avoid working in the wrong branch by doing almost everything in one branch (in trunk - per so called "unstable trunk" branching strategy).

The cases when I am forced to update branches are pretty rare - these are pre-and post-production bugfixes (prod candidate code is isolated in branches). Since these fixes should be in trunk too, I typically draft, test and verify them right there in trunk, then port to prod branch. Porting as a rule involves just a straightforward copy of 1 to 5 files to branch and build check.

I am also somewhat lucky that in most of my projects management preferred to convince customers to use newer releases instead of patching old ones - this brings post-production part of updates in branches to almost negligible minimum.


答:
Short answer: One monolithic file with a far-future expires header.

Long answer: It depends. If you're Gmail and have over 1 megabyte of javascript in your application, then you're going to want to split that up to reduce load and improve user experience. For the rest of us though, the best solution I've found is to load your main library (such as jQuery) from a third-party CDN (like Google). Then split up your one monolithic file into two: lib.js and app.js. Lib should contain any third-party libraries, and app your site-specific code. The general idea being that you're very rarely going to be updating libraries or adding new ones, so that file will rarely ever have to be cache invalidated and re-downloaded by your users.

Use a technique such as the one described on this site to move almost all on-page
```

js_context is a variable I passed to my template from my backend, and is already a JSON object. The squiggly brackets and |safe are just from the front-end template engine I happen to be using (in this case, Django's built-in templates). Now my page-specific code, living in app.js, can look at the contents of Foo.Context after document.ready fires for any variables it needs while avoiding an initial AJAX request.

As usual for your static files, you should be serving them with far-future expires headers:

Cache-Control: public, max-age=31536000

When you update your scripts, your build step should either rename the concatenated and minified file or add a GET query parameter to the end of the

Title: Storing page-specific javascript on an AJAX driven site?

Body:
I have a general question about the placement of javascript code in a AJAX-driven web application. At a previous job, we tended to throw everything in one monolithic file. When maintaining that file became too difficult, we split it up into multiple smaller files and "glued" them back together with a php "loader" (pretty much just a bunch of include statements)

Since all of my pages are dynamically loaded through AJAX, I cannot simply have different files called separately per page.

The obvious disadvantage to this method is that all of your javascript is loaded by the end user, even if it is not required on first page load. (Which compounds the problem, the more pages you have)

To get around this, I started putting page-specific javascript on the template page itself, in a

Body:
Short answer: One monolithic file with a far-future expires header.

Long answer: It depends. If you're Gmail and have over 1 megabyte of javascript in your application, then you're going to want to split that up to reduce load and improve user experience. For the rest of us though, the best solution I've found is to load your main library (such as jQuery) from a third-party CDN (like Google). Then split up your one monolithic file into two: lib.js and app.js. Lib should contain any third-party libraries, and app your site-specific code. The general idea being that you're very rarely going to be updating libraries or adding new ones, so that file will rarely ever have to be cache invalidated and re-downloaded by your users.

Use a technique such as the one described on this site to move almost all on-page <script> tags without a src attribute to an external file:

http://paulirish.com/2009/markup-based-unobtrusive-comprehensive-dom-ready-execution/

So what you should be left with are <script> tags with a src, and the only inline ones remaining should be because you need to pass data from your backend code to javascript (and want to avoid an AJAX request on page load that will block rendering). Say the namespace of my project is Foo, then that one inline tag will look like:

<script type="text/javascript">
    Foo.Context = {{ js_context|safe }};
</script>

js_context is a variable I passed to my template from my backend, and is already a JSON object. The squiggly brackets and |safe are just from the front-end template engine I happen to be using (in this case, Django's built-in templates). Now my page-specific code, living in app.js, can look at the contents of Foo.Context after document.ready fires for any variables it needs while avoiding an initial AJAX request.

As usual for your static files, you should be serving them with far-future expires headers:

Cache-Control: public, max-age=31536000

When you update your scripts, your build step should either rename the concatenated and minified file or add a GET query parameter to the end of the <script> src, like so:

app.12345.js or app.js?v=12345

That way your users will request the new file, breaking the cache. As a caveat, please be aware that old versions of some reverse-proxies (such as Squid) don't play nicely with GET parameters on static files, so the latter of those two options wouldn't work. But I have never run into that issue yet, so your milage may vary.

When you do get to the Gmail level of script sizes, you can start looking at using a library like LABjs or RequireJS, to dynamically only load the pieces of app.js that you need for particular pages or functionality.

Last but not least, I hope your <script> tags are at the bottom of your page, right before the closing </body>. This prevents the browser from showing a blank white page while your scripts are downloaded, parsed, and executed. The only exception to this rule are libraries that absolutely must be in the <head> to function, such as Modernizr.


问:
Stuff every programmer needs while working
I've been tasked with creating a fun and relaxing environment, one thing I know that I want is ergonomic mice and keyboards, others have suggested exercise balls and bands.

What is it that every programmer needs while working? What might not be necessary but would be nice to have anyway?

Note: this question was asked previously, but has been recommended to be posted here. See this link for the previous responses: https://stackoverflow.com/questions/3911911/stuff-every-programmer-needs-while-working-closed

答: As much screen space as possible and big desks with space to put post it notes somewhere.</p>


答:
A specific answer depends on the version control software that you're using, but there's usually a command that lets you easily see the branch you're working on. For example, with Subversion, use the svn info command in a directory to see the URL for that branch. If you're more interested in a particular file, you can specify that too:

```<code>caleb-dev$ svn info foo.c
Path: foo.c
Name: foo.c
URL: https://svn.mycompany.com/repo/sample/branches/caleb-dev/foo.c
Repository Root: https://svn.mycompany.com/repo/sample
Repository UUID: d62f7aef-3ad2-6098-12a-c16647d854ab
Revision: 1042
Node Kind: file
Schedule: normal
Last Changed Author: caleb
Last Changed Rev: 1031
Last Changed Date: 2011-06-07 15:28:27 -0400 (Tue, 07 Jun 2011)
Text Last Updated: 2011-06-08 03:08:12 -0400 (Wed, 08 Jun 2011)
Checksum: 123456789098765432123456789098
</code>```

From the URL, I can see that my copy of foo.c is in the caleb-dev branch.

I don't need to do that very often because my local directory has the same name as the branch. A quick look at my command line prompt is usually enough to confirm that I'm in the right directory, and therefore working in the right branch.

Body:
A specific answer depends on the version control software that you're using, but there's usually a command that lets you easily see the branch you're working on. For example, with Subversion, use the svn info command in a directory to see the URL for that branch. If you're more interested in a particular file, you can specify that too:

caleb-dev$ svn info foo.c
Path: foo.c
Name: foo.c
URL: https://svn.mycompany.com/repo/sample/branches/caleb-dev/foo.c
Repository Root: https://svn.mycompany.com/repo/sample
Repository UUID: d62f7aef-3ad2-6098-12a-c16647d854ab
Revision: 1042
Node Kind: file
Schedule: normal
Last Changed Author: caleb
Last Changed Rev: 1031
Last Changed Date: 2011-06-07 15:28:27 -0400 (Tue, 07 Jun 2011)
Text Last Updated: 2011-06-08 03:08:12 -0400 (Wed, 08 Jun 2011)
Checksum: 123456789098765432123456789098

From the URL, I can see that my copy of foo.c is in the caleb-dev branch.

I don't need to do that very often because my local directory has the same name as the branch. A quick look at my command line prompt is usually enough to confirm that I'm in the right directory, and therefore working in the right branch.


答:
The differences are mostly connotative and contextual. </p>

<p>"Software" can refer to the entire field, or in the specific to the general part of something that isn't hardware or to a collection of things that aren't necessarily part of the same program/app.  ("An iPhone is great hardware, but it would be nothing without the software").  </p>

<p>"Application" is a complete unit that may consist of more than one module in more than one language on more than one computer, all working together.  It may not, in which case it is pretty much the same as a "program".  </p>

<p>"Program" has the connotation of being a discrete unit, and while it is used interchangeably with "application", it seems awkward to refer to a "web program" instead of a "web app", or a "client/server program", instead of a "client/server app". "Program" is often used to refer to a complete operational unit as seen from a developer rather than a user perspective (it seems old-fashioned to refer, as a user, to installing a "program" instead of an "app"), and often for things that are not intended for public use, such as a testing program or proof of concept program. </p>

<p>"Gadget" (which I take to mean the same as "widget") usually means something smaller than an app, (though it is one), usually because it has less than a full-featured gui, it often runs inside or attached to something else, or is used casually to do one single thing, like checking the weather, rather than with prolonged interaction. </p>

Title: What is the difference in meaning between "software", "program", "application", and "gadget"?

Body: It seems to be a naive question, but I was unable to find an explicit definition and difference in meaning of the words "software", "program", "application", and "gadget". What is the correct (at least theoretically) way to use each of these words?</p>

Body:
The differences are mostly connotative and contextual.

"Software" can refer to the entire field, or in the specific to the general part of something that isn't hardware or to a collection of things that aren't necessarily part of the same program/app.  ("An iPhone is great hardware, but it would be nothing without the software").

"Application" is a complete unit that may consist of more than one module in more than one language on more than one computer, all working together.  It may not, in which case it is pretty much the same as a "program".

"Program" has the connotation of being a discrete unit, and while it is used interchangeably with "application", it seems awkward to refer to a "web program" instead of a "web app", or a "client/server program", instead of a "client/server app". "Program" is often used to refer to a complete operational unit as seen from a developer rather than a user perspective (it seems old-fashioned to refer, as a user, to installing a "program" instead of an "app"), and often for things that are not intended for public use, such as a testing program or proof of concept program.

"Gadget" (which I take to mean the same as "widget") usually means something smaller than an app, (though it is one), usually because it has less than a full-featured gui, it often runs inside or attached to something else, or is used casually to do one single thing, like checking the weather, rather than with prolonged interaction.


答:
"Program" refers to an executable sequence of instructions that can be directly run by a computer (as opposed to a library, which can only be run by an outside program).

"Program" and "Application" are mostly interchangeable, though "Application" almost always refers to a program for a specific task that has some kind of user interface (as opposed to services/daemons, drivers, etc.).

"Software" is an umbrella term for all computer instructions, whether it be a program, library, framework, OS, or sometimes even the code itself.

"Gadget" is just a useful piece of electronic hardware, usually handheld, often shiny and overpriced.


问:
How are dates typically handled with testing?
I am writing an app at the moment that has some pretty extensive business logic based around dates. I have several hundred thousand records to test and testers who want to see how those records are handled, which has worked well so far, however, some edge cases are difficult to replicate. The reason is that most of the logic is related to today's date, in one way or another. What is the best way to handle this with both unit testing and for traditional testing? The only way I can really think of is allowing for today's date to be faked and fixed.</p>

答: Faking and fixing the date are the right way to do it. It can actually morph into a useful feature -- how many times have you wanted to be able to run a piece of logic using past data? </p>


答: By far the simplest thing is to intercept the function calls that return the current date, and when testing, always return the same date.  The technique for doing this will vary depending on your implementation language.</p>

Title: How are dates typically handled with testing?

Body: I am writing an app at the moment that has some pretty extensive business logic based around dates. I have several hundred thousand records to test and testers who want to see how those records are handled, which has worked well so far, however, some edge cases are difficult to replicate. The reason is that most of the logic is related to today's date, in one way or another. What is the best way to handle this with both unit testing and for traditional testing? The only way I can really think of is allowing for today's date to be faked and fixed.</p>


答:
You can use mocks (dependency injection) to return "today" date to be whatever you want it to be.  This will allow you to test problem dates and make sure that new additions will not break the old code. </p>

<p>There are plenty of mocking framework around and I am sure $language that you are using has at least a couple of good ones. </p>

Body:
You can use mocks (dependency injection) to return "today" date to be whatever you want it to be.  This will allow you to test problem dates and make sure that new additions will not break the old code.

There are plenty of mocking framework around and I am sure $language that you are using has at least a couple of good ones.


问:
Did concept of ViewModel exist before MVVM?
Today I was having a discussion with a colleague that ViewModel is a general concept and existed before MVVM pattern.

I believe ViewModel term is used anytime you create a class with Model like properties for showing on View that supports data binding like in ASP.NET and even in WinForms.

Is the opposite true? Did Microsoft name it the first time with MVVM?

答:
MVVM is generally accepted to be a derivation of the Presentation Model.

There is a reference to a View model from systems engineering, and I would say they're related, but it's not the same thing.  In the systems engineering View Model, it's a model of all the different Viewpoints.  The ViewModel in MVVM is more like a model of one viewpoint.

I found this ASP.NET MVVM framework from 2009.  However, I still think that was influenced by WPF's MVVM.

I can't seem to find references to ViewModel in ASP.NET stuff predating that.  I wouldn't rule it out though.