答:
Well, I'm the academic who posted the original tweet. Tweets are not meant to be scholarly articles. They are advertisements, and I think they can also be controversial. Here are my follow-up tweets:

1) UML was created to model OO designs. It effect you are modeling the code of a system, not the system's behavior. UML is at wrong level.

2) the idea that 7 (or 13) diagram formats in UML can cover everything is crazy. What about GUIs, web wireframes, authorization, etc. ???

3) UML has encouraged the idea that models must be graphical. Ridiculous! Text and graphic models are both useful and often interchangeable

4) UML is at once too large and complex and at the same time very limiited. Stereotype and profiles are not effective for usable extensions.

Note that I'm not necessarily saying UML is bad. I'm simply saying that it is not helping the goal of "model-driven development", which is what I'm interested in. I don't understand the comment about "holy grail".

Title: "UML is the worst thing to ever happen to MDD." Why?

Body:
William Cook in a tweet wrote that:

"UML is the worst thing to ever happen to MDD. Fortunately many people now realize this ..."

I would like to know the reasoning behind that claim (apparently, I'm not referring to his personal opinion).

I've noticed that many people out there don't like UML that much. Also it is worth mentioning that he is in academia, where UML is preety much the holy grail of effective design and modelling.


问:
"UML is the worst thing to ever happen to MDD." Why?
William Cook in a tweet wrote that:

"UML is the worst thing to ever happen to MDD. Fortunately many people now realize this ..."

I would like to know the reasoning behind that claim (apparently, I'm not referring to his personal opinion).

I've noticed that many people out there don't like UML that much. Also it is worth mentioning that he is in academia, where UML is preety much the holy grail of effective design and modelling.

答:
I think there's also a case to be made that MDD is the worst thing that happened to UML (why else would we have the UML2 that we have?), but ignoring that for the moment...

MDD = Model Driven <Design|Development>. The idea is to be able to develop solutions at a level of abstraction appropriate to the problem domain - that is, it is an attempt to express solutions to problems in the most natural syntax for expressing those solutions.  The problem domain itself is characterized with an operational model (that is, by a model that can be executed by computer).  So, MDD can be a very attractive approach, albeit one with two major requirements:

One must be able to compile that language into a form suitable for computer execution  (the model must be operational); and

One must create a modeling language for the problem domain.

It's my understanding that the UML2 effort was intended to address point 1, probably under the belief that industrial experience with UML showed that point 2 was satisfied for some large subset of problem domains.  Unfortunately, and this is what I think William Cook was getting at, UML does not satisfy point 2 for anywhere near the scope of problems that was thought.  I don't speak from personal experience, but I think the industrial experience of using MDD with UML has two common outcomes:

Either the source code generated from the UML needs to be tweaked to resolve those small gaps between the UML design and the program requirements (forcing developers to work with generated code that has different standards for maintainability and reducing the applicability of the UML artifacts to the implementation); OR

The UML gets cluttered up with a lot of detail that reduces its usability as a language for communicating about the design.

In either case, the promise of MDD is unfulfilled.  UML might be considered the worst thing that happened to MDD because it occupied the attention of MDD tool developers to the exclusion of models that might actually work (albeit for a smaller set of software problems).

ContentLicense: CC BY-SA 3.0


问:
Should each app have its own database, or should small apps be merged into one?

Possible Duplicate:

  Should I use one database per application or share a single database amongst multiple applications

We have a bunch of small to medium sized apps, each of which has its own database (MSSQL Server). There was a suggestion that we consoldate the 'related' databases into a smaller set amount of larger databases.

They don't particularly share a lot of data, they would just be under a similar business group. For example, using a 'Finance' database to hold the tables and procedures for finance apps.

Would it be appropriate to use a different schema for each app, e.g.

```<code>App1.SomeTable
App1.SomeOtherTable
AppTwo.SomeTable
</code>```

What are the pros and cons of this approach? What should I watch out for?

答: At the risk of stating the obvious, in general, if you share the DBs, you're coupling the applications and making DB changes more "global." In most situations, that's probably a bad idea, for the same reasons that broadly-scoped variables are generally a bad idea. However, if there is significant effort in maintaining or optimizing the DB, then you might have some gains (e.g., if your DBA tunes up the DB to perform better, everyone gets the boost, or if you spend a significant amount of effort auditing and cleaning the data).


问:
Looking for an example of how a software project can be managed/deployed
My company is evaluating adopting off-the-shelf ALM products to aid in our development lifecycle; we currently use our own homegrown solutions to manage requirements gathering, specification documentation, testing, etc. One of the issues I am having is understanding how to move code between stages of development. We have what we call a pipeline, which consists of particular stops:

[Source] -> [QC] -> [Production]

At the first stop, the developer works out a solution to some requested change and performs individual testing. When that process is complete (and peer review has been performed), our ALM system physically moves the affected programs from the [Source] runtime environment to the [QC] runtime environment. This movement of code is triggered by advancing the status of the change request to match the stage of the pipeline.

I have been searching the internet for a few days trying to find how the process is accomplished elsewhere -- I have read a bit about builds, automated testing, various ALM products, etc. but nowhere does any of this state how builds interact with initial change requests, what the triggers are, how dependencies are managed, how the various forms of testing are accommodated (e.g. unit testing, integration testing, regression testing), etc.

Can anyone point me to any resources detailing specific workflows or attempt to explain (generically) how a change could/should be tracked and moved though the development lifecycle? I'd be very appreciative.

Note: I've cleaned up the question to hopefully make it easier to understand. Also, I found another question (which I can't find now) that referenced this book, which sounds like it might be exactly what I am looking for -- not sure if I want to shell out the cash for it, though.

Additional details per @GlenH7's suggestion:

Our products are built with a proprietary language and set of translation tools -- the ultimately runtime environment is similar to a web site architecture, in that we have a bunch of 'code' files sitting out on a server, which our client app accesses on-demand (not unlike a GET request) and then interprets to provide the user experience. We sell an integrated product which is made up of a set of modules (most of which are optional), each module has a team of ~4 programmers and 2 QC testers devoted to the development/bug maintenance. There are around 30 modules per product line (and 3 product lines) -- some teams maintain multiple products lines for their given module. In total, we have 700 employees devoted to development and ~200 programmers. Certainly adopting any new processes or systems is going to involve buy-in, etc. but I'm tasked with simply understanding how the code will be managed so that we can speak intelligently about things. My first task was to learn how to adopt version control into our process (we do not yet use formal version control for most of our product lines, we rely instead of keeping around multiple copies of the entire codebase).

We follow the waterfall method pretty closely (which sucks, but the company has been producing software since 1969, so it was probably the natural fit back then and until now, there has been no need to change anything). Some folks are intrigued by the various offerings of the agile methodologies, but as has been noted by @Chad below, we're likely going to need to take incremental steps towards any such end goals (though if we adopt an ALM system, it might be the time to just force a whole new way to do things on everyone).

Now for a specific example of our current process, let's say we have a product called HIS, which has an MIS and ITS module (what these are/could be is not important -- think of them as just a collection of files) -- in our current process, if someone requests a change to ITS, a coder will modify some files (effectively) on the development server. When that change needs to be tested, transitioning the status of the change request from 'development needed' to 'qc needed' will trigger our tools to copy the affected files from the development server to the QC server. Now when QC testers signon to the QC testing environment, they will be able to see the effect of the changes. Once they signoff on the change, advancing the status of the request to 'production ready', our tools again copy the code files to the next stage. Once signed off there, a final copy is done to the holding location used for deliveries to customers.

We manage delivery of our releases by a major release number (e.g. 6.0) followed by a service release designation (e.g. 5) and a 'priority pack' number (e.g. 1) -- customers take delivery of priority packs, e.g. 6.0.5.1. As stated above, we simply push code from place to place on multiple servers, so we end up with a project folder for each major release and service release throughout the pipeline and end up with a final resting place for each of the ppacks, e.g.:

```<code>dev6.0
qc6.0
production6.0

dev6.0.5
qc6.0.5
production6.0.5

ship6.0.5.1
</code>```

I was thinking that under version control, we could simulate this kind of scheme as:

```<code>trunk
branches
--6.0.5
tags
--6.0.5.1
</code>```

but that seems to cover only half of the locations, i.e. where do the qc and production sources live? Would I create a separate trunk for each major and minor release of the product? Or would I rely on something outside of version control (e.g. the ALM system) to track the revision(s) interesting for testing done at the QC and production stops? We'd need a runtime environment for each, still, but that could be 'built' on-demand as bug fixes and features are made available -- which reinforces the idea that I need not keep any special 'copy' of these stages under version control (they are simply references to revision history of the trunk or branch).

Another thing that has thrown me for a loop as that a colleague is pretty adamant that you should not persist anything in branches, i.e. the branch folders should be ephemeral and used only during large changes that can't be committed directly to the trunk (with the expectation that the branch will eventually be merged into the trunk). In his scheme, the minor releases would necessitate a separate top-level with it's own set of trunk, branches and tags, e.g.:

```<code>product6.0
trunk
branches
--silly_new_feature
tags
--6.0.5

product6.0.5
trunk
branches
--crazy_bug_fix
tags
--6.0.5.1
</code>```

(sorry for the delay on adding these details -- got pulled away to meetings all day)

答:
The approach I have found works well is two build environments: development and testing.  Development build occur frequently and allow integration issues to be worked out and changes (including features) to be tested under the standard build.

Testing builds are triggered on demand, and if accepted the build will be promoted to production.  Testing builds may take place on a separate branch, especially near a planned release.  Changes on the branch will need to be integrated back into development.

There are some assumptions taken with this approach:

Mainline development is done on trunk.  (Feature development is either for the next release, or can be released in an inactive state.)

Any environment specific information is retrieved from the environment.  When changing environments no builds should be required.  Various mechanisms can be used.

Releases consist of a coordinated set of feature and bug changes. (If there are dependencies between features or bug fixes, pulling one can cause a cascade of changes.)

A separate branch is created for managing fixes to a released (or releasing) version.  This may include an additional development build environment.

Build tagging is done on testing builds.  This simplifies loading that code if changes are required, or code needs to be investigated.

I haven't used any ALM software, as it tends to be low on the budget wishlist.  The above approach is fairly easy to implement using standard build and configuration management tools.

One thing I have noticed with ALM is that retirement is often not well managed.  It is rare to see temporary features or bug fixed actually removed from the code.  This may result in part from change tracking closing the feature on implementation.  It may be a good idea to add a retirement change ticket when appropriate.

EDIT: I have seen a number of failures of tested code that requires a build to move into a new environment.  It is difficult to ensure only the environment configuration is included in the build and not other data.

Things that change between environments include and how I have provided them:

Database connections: The solution I usually use is to have the container provide a named connection pool. Different environments have different configurations, but this is transparent to the deployed application.

Directories: When appropriate, using relative directory paths works well.  Using environment provided variables as part of the path, covers most other
cases.

Properties: These can be used to help configure database connections, directories, and a whole variety of other settings.  There are a number of alternatives which can be used (possibly in concert):

Configure the container with the appropriate properties and read the properties from there.

Provide a properties file in a directory relative to the environments directory.

Read properties from a database connection.

In some implementations, one of the properties specifies the location.  This can be displayed in the the interface, to enable quick determination of which environment is being used.  Build version may also be shown, but that should be part of the build artifacts, and not the environment specification.

OwnerDisplayName: rguilbault


问:
How do you find time to work on Open Source Projects?
A bit of background: I've got a small open source project that I've started on, a basic framework which provides an object oriented means of generating HTML code (since I don't really like HTML, and I do like PHP). It has some released source, and a few downloads, but primarily, the project is for me, with the Open Source portion just being a side benefit.

The original project which caused me to be able to develop on this project has mostly gone into hibernation for the time being, which means that all the development I get to sink into it at this point is personal time only. Unfortunately, I'm currently working toward my bachelor's degree, studying for certifications, and I have a three month old baby at home. In short, by the time I get around to "me time", I rarely feel like doing work, but rather usually feel like just chilling out.

So, if there's anyone else out there who feels like they're in a similar position, what strategies have you used to keep yourself motivated toward working on the project? I would really like to at least be able to work on this until I have 100% spec coverage, but I haven't committed source in months. Anyone out there who can help?

答:
The time with your kids is the most precious in the world, and it never comes back.

Your degree will feed your family.

Prioritize accordingly :)

ContentLicense: CC BY-SA 2.5


问:
Why are effect-less functions executed?
All the languages I know of would execute something like:

```<code>i = 0
while i < 100000000
    i += 1
</code>```

..and you can see it take a noticeable amount of time to execute.

Why though, do languages do this? The only effect this code will have is taking time.

edit: I mean inside a function which is called

```<code>function main(){
    useless()
}
function useless(){
    i = 0
    while i < 100000000
        i += 1
}
</code>```

答:
2 reasons first is that to fully remove all dead code compilers would need to solve the halting problem which is impossible and many compilers don't even try

second sometimes the programmer want a delay/busy loop there for various reasons (including simply slowing everything down so when Mr. Boss tells you to speed it up you can remove a 0 from the upper bound)

Title: Why are effect-less functions executed?


答:
Integrating the source of information is a good thing to seek. In fact, organizations spend millions to integrate their disparate decision support systems and operational systems. One needs to determine:

1-What are the shared data?

2-How often does this data change?

3-How large is the volume of this data?

4-Can the data be re-entered manually or is that too time consuming and/or error-prone?

5-How sensitive is the shared data?

6-What is the cost of automation?

In some cases, specially with small business, the number of transactions is not that large and it would probably take some one less than 1 hour to enter the information manually. The cost of this effort can be measured in dollars against the proposed automation cost.

You may want to use a matrix similar to the crude example below (I know it is neither accurate nor complete!) to show the data shared and how this data is shared. The left hand side represents the table and horizontal column headers represent the different systems. There is an analysis technique called Clustering Analysis that could be used to show good system boundaries, but I don't have an electronic reference for it (it is old!).

Title: Should each app have its own database, or should small apps be merged into one?

Body:
Possible Duplicate:

  Should I use one database per application or share a single database amongst multiple applications

We have a bunch of small to medium sized apps, each of which has its own database (MSSQL Server). There was a suggestion that we consoldate the 'related' databases into a smaller set amount of larger databases.

They don't particularly share a lot of data, they would just be under a similar business group. For example, using a 'Finance' database to hold the tables and procedures for finance apps.

Would it be appropriate to use a different schema for each app, e.g.

```<code>App1.SomeTable
App1.SomeOtherTable
AppTwo.SomeTable
</code>```

What are the pros and cons of this approach? What should I watch out for?


答:
This drastic of a change should be done to solve a problem. There are pros and cons of multiple/more vs single/fewer databases. It depends on the problems you're trying to solve.

Do your developers struggle trying to find where the data are? It may be easier to work in the Finance app knowing there is a single Finance db.

Is referencing two tables in a query from different databases really that hard?

Backups - restoring at the database level is pretty easy. The fewer tables and other parts the easier it gets. Yes, you can break up large databases into multiple files. It's only going to make it harder to maintain a development database if you have to transfer massive files especially when you only need a specific section.

More Servers - it's easier to move a database to another server. It's much harder to put one database on several pieces of hardware.

I don't know what your situation is, but there just doesn't seem to be any justification for one database. If problems come up, reconsider.


问:
Should I pay my developers for bugs fixes for a project or work that's still in progress?
We are working with a group of developers on a project. The project is still in progress (not completed) and these developers charge us for time spent on fixing bugs on codes that were not written valid in the first place. I understand that we should pay for changes/new requests if any, but not bugs fixes for a work in progress. We also understand that once the assignment is being deployed to the live site, we may be liable for bugs fixes that may arise after a support period is being exhausted.

The question now is, is it appropriate for such charges to be levied upon us while the project is still in progress?

答:
To be blunt, this question implies a tremendous level of ignorance about the software development process. It might be wise to take your company web site off of your profile [especially since it doesn't exist], and go read a book on managing software development projects.

To address your specific question, as others have stated, if you want bug-free code and free bug-fixing, you have to specify acceptance tests for deliverables and negotiate fixed-bid contracts with the developers. If you hire people to put in hours on a project with no clearly-defined acceptance tests, you have incidentally agreed to pay them for their time, not their results. So yes, you should pay your developers to fix bugs. You also paid them to write the bugs. And if your project has no acceptance tests, you'll likely continue to pay them to write and fix bugs until they accidentally finish the project, or it runs out of money, or the client cancels it. None of which will reflect well on your organization.


问:
Using submitted code in a commercial product
I have made a product which I have used the GPL licence, and am now getting pull requests from other authors.

The product also has a less restrictive commercial license available for purchase.

Can I include the submitted code with the commercial licensed product?

答:
The short answer is "no."

The code that your submitters are writing is covered by copyright, and that copyright is assigned to the submitters. Since the project is GPL, they have agreed that the code may be released under the GPL. You will need to get permission from the submitters (all of them!) to release the code under a different license than GPL.

(I am not a lawyer, this is nowhere near legal advice, etc.)


问:
Fastest way to set up a JSON server on my local machine
I am a front-end developer. For many experiements I do I need to have a server that talks JSON with my client side app. Normally that server is a simple server that response to my POSTs and GETs.
For example I need to setup a server that saves, modifies and read data from a "library" database like this:

POST /books create a book

GET /book/:id gets a book

and so on...

What is the fastest to set up and easiest technology stack for database and server in this case? I am open to use Ruby, Nodejs and anything that do the job fast and easy.

Is there any framework (on any language) that do stuff like this for me?

答:
CouchDB. It's a document-oriented database server. Its network protocol is based on HTTP and JSON. It does exactly what you described.

The biggest drawback: it lacks a lot of the features that people take for granted when using relational databases. This may or may not be a problem for you.


问:
Does "Inversion of Control" promote "Anemic Domain Model"?
When I used IoC Container in my last project, I ended up with anemic entities and most of my business logic in Stateless Services.

I have seen projects written by other developers that utilize "Inversion of Control" and they are always "Anemic".

Since "Anemic Domain Model" is anti-pattern, is it possible to use IoC and Rich Domain?
Are their any good examples, open source projects that do that?

答:
Go to the source. Start with Fowler's piece on Anemic Domain Models. He references Eric Evan's Domain Driven Design as an example of good practice. The source code for that is here. Download it.

Observe that it uses Inversion of Control (search for @Autowired), and has service classes (BookingService), and "business process" classes (e.g. ItineraryUpdater).

Fowler's original article starts the trail to the example you are looking for.


问:
What's the term for re-implementing an old API in terms of a newer API
The reason for doing it is to solve the case when a newer API is no longer backwards compatible with an older API.

To explain, just say that there is an old API v1.0. The maker of this API decides it is broken and works on a new API v1.1 that intentionally breaks compatibility with the old API v1.0. Now, any programs written against the old API cannot be recompiled as-is with the new API.

Then lets say there is a large app written against the old API and the developer doesn't have access to the source code. A solution would be to re-implement a "custom" old API v1.0 in terms of the new API v1.1 calls. So the "custom" v1.0 API is actually keeping the same interface/methods as the v1.0 API but inside its implementation it is actually making calls to the new API v1.1 methods.

So the large app can be then compiled and linked against the "custom" v1.0 API and the new v1.1 API without any major source code changes.

Is there a term for this practice?

There's a recent example of this happening in Jamie Zawinski's port of XScreenSaver to the iPhone - he re-implemented the OpenGL 1.3 API in terms of the OpenGL ES 1.1 API. In this case, OpenGL 1.3 represents the "old" API and OpenGL ES 1.1 represents the "new" API.

答:
Thanks to Anna Lear and Yannis Rizos for their answer, i.e. that the API 1.0 has effectively become an adaptor for API 1.1.

I just wanted to put forward a more specific answer. In my case the API 1.0 has retained the same public interface, so the application doesn't need to change. The only thing that has changed is the internal implementation of the API 1.0 itself - it now has a dependency on the new API 1.1. So instead of "porting the application" to use API 1.1, we're "porting the API".


问:
The architecture and technologies to use for a secure, fast, reliable and easily scalable web application
^ For actual questions, skip to the lists down below

I understand, that his is a vague topic, but please, before you turn the other way and disregard me, hear me out. I am currently doing research for a web application(I don't know if application is the correct word for it, but I will proceed w/ that for now), that one day might need to be everything mentioned in the title. I am bound by nothing. That means that every language, OS and framework is acceptable, but only if it proves it's usefulness. And if you are going to say, that scalability and speed depend on the code I write for this application, then I agree, but I am just trying to find something, that wouldn't stand in my way later on.

I have done quite a bit reading on this subject, but I still don't have a clear picture, to what suits my needs, so I come to you, StackOverflow, to give me directions. I know you all must be wondering what I'm building, but I assure you, that it doesn't matter. I have heard of 12 factor app though, if you have any similar guidelines or what is, to suggest the please, go ahead.

For the sake of keeping your answers as open as possible, I'm not gonna provide you my experience regarding anything written in this question.

^ Skippers, start here

First off - the weights of the requirements are probably something like that (on a scale of 10):

Security - 10

Speed - 5

Reliability (concurrency) - 7.5

Scalability - 10

Speed and concurrency are not a top priority, in the sense, that the program can be CPU intensive, and therefore slow, and only accept a not-that-high number of concurrent users, but both of these factors must be improvable by scaling the system

Anyway, here are my questions:

How many layers should the application have, so it would be future-proof and could best fulfill the aforementioned requirements? For now, what I have in mind is the most common version:

Completely separated front end, that might be a web page or an MMI application or even both.

Some middle-ware handling communication between the front and the back end. This is probably a server that communicates w/ the front end via HTTP. How the communication w/ the back end should be handled is probably dependent on the back end.

The back end. Something that handles data through resources like DB and etc. and does various computations w/ the data. This, as the highest priority part of the software, must be easily spread to multiple computers later on and have no known security holes. I think ideally the middle-ware should send a request to a queue from where one of the back end processes takes this request, chops it up to smaller parts and buts these parts of the request back onto the same queue as the initial request, after what these parts will be then handled by other back end processes. Something map-reducey, so to say.

What frameworks, languages and etc. should these layers use?

The technologies used here are not that important at this moment, you can ignore this part for now

I've been pointed to node.js for this part. Do you guys know any better alternatives, or have any reasons why I should (not) use node.js for this particular job.

I actually have no good idea, what to use for this job, there are too many options out there, so please direct me. This part (and the 2. one also, I think) depend a lot on the OS, so suggest any OSs alongside w/ the technologies/frameworks.

Initially, all computers (or 1 for starters) hosting the back end are going to be virtual machines.

Please do give suggestions to any part of the question, that you feel you have comprehensive knowledge and/or experience of. And also, point out if you feel that any part of the current set-up means an instant (or even distant) failure or if I missed a very important aspect to consider.

I'm not looking for a definitive answer for how to achieve my goals, because there certainly isn't one, for I haven't provided you w/ all the required information. I'm just looking for recommendations and directions on what to look into. Also, bare in mind, that this isn't something that I have to get done quickly, to sell and let it be re-written by the new owner (which, I've been told for multiple times, is what I should aim for). I have all the time in the world and I really just want to learn doing something really high-end. Also, excuse me if my language isn't the best, I'm not a native.

Anyway. Thanks in advance to anyone, who takes the time to help me out here.

PS. When I do seem to come up w/ a good architecture/design for this project, I will certainly make it an open project and keep you guys up to date w/ it's development. As in what you could have told me earlier and etc.

For obvious reasons the very same question got closed on SO, but could you guys still help me?.

答:
Sir I recommend the following language because it is a full-stack language, it is growing enmasse, and as the most compiled language (among other characteristics) it has immense staying power for your long term plans.

/*************************3_REASONS***********************************/

Full-Stack. I started writing it, like many perhaps, in an internship around 2000. Under the impression, for many years, with many colleagues, that JavaScript was a "Toy-Language". A "Toy", like PlaySchool would make - plastic and shiny. Eating humble-pie a decade later, I slowly grew to realize that my long-held impression was wrong.

Prior to AJAX, we underestimated simplicity as disability because we were not seeing extensible flexibility. No one could have guessed how flexibile JS could be. Since the asynchronous adaptation of JS over HTTP, we now see it implemented in just about every environment, if not every environment, from Operating System, Database, Server, Front-End, to Mobile Operating System.

Wikipedia labels JS a multi-paradigm language. Frankly, as an old C++ guy, I find it impressive that JS has more than a single static paradigm, let alone, conducive to so many it encounters. But that is only half the story.

Flexibility - as it turned out, being a toy meant that the toy matchbox inspired a radio-controlled car, then a go-cart, on to a model-T, ferrari, a monster truck, street-bike, and what ever else anyone needed. Here is the centrifical point, CouchDB, MongoDB, RiverTrail, three.js, node.js, jQuery siblings, micro.js mobile libraries, PhoneGap, Compiled JavaScript, Testing frameworks, a new building framework(grunt.js), Boilerplates, Bootstraps, MVC derivatives, WebRT, and now Windows 8 - JS is everywhere. More than ever, JS is everywhere. One might ask why?

Staying Power - JS is not successful in so many diverse ecosystems because it is flexible; it is successful because it is capable.

Transmission - with JSON as an effective data-transmission mechanism, the same object-literal can be transferred Front-to-Back, OS-to-OS, without data-translation, without language-linking, and without re-interpretation. That is remarkable.

Education - if you had the opportunity to learn a single language and apply it cross-profession... wouldn't you? More than ever, JS is a learn once and apply anywhere language. Coming out of college, many of us experienced a painful gauntlet of learning-curves. If you could, would have traded for a single language? I would.

Growth - JS will continue to grow, and this is not to mention its current place of prominence as the behavior-layer of the Internet. Microsoft swallowed hard to adopt it into the operating system paradigm, not because they could; but because it is good. This, is precisely what we could not have anticipated, in 2004.

/********************HOW-DOES_THIS_PERTAIN-TO-US-NOW***************************/

As I mentioned in the comments, I am currently researching...for similar stack requirements unrelated to my personal insights above. I also need a '10' - score security clearance architecture.

Is JS capable or incapable of being secure? To me this is the
  challenge in this architecture.

Given the track record. I would not underestimate it again. Validation and Filtering are key. But then again the MySpace worm XSRF was unexpected and history repeats itself.

/*********************DIRECT-QUESTIONS_DIRECT-ANSWERS**************************/

that the program can be CPU intensive

Something amazing may be happening at IBM with RiverTrail. The notion is multi-threaded JS, but I am merely the messenger.

How many layers should the application have

A question of abstraction is a tradeoff, but I would point out that: If it has many layers, it has many 'interchangable-parts'. This worked out well for Eli Whitney, I propose the same holds true in the evolving-web. Especially JS.

so it would be future-proof

If you learn JavaScript, well, you can be virtually assured you will be using it until the web that we have, is no longer. JS is as "future-proof" as I think a case can be made (unless you read binary).

Completely separated front end

Yes, this is a beautiful thing. Options are AJAX via DWR. A popular oneis REST and data-transfer with JSON. Fully-duplex Web-Sockets sound good too.

Some middle-ware handling communication w/ the front end via HTTP.

Node.js is highly effective. It yields enormous potential.

The back end...various computations w/ the data.

Here is a description of what can be accomplished with CouchDB: It is basically a JSON database, that uses functions for stored-procedures.

must be easily spread to multiple computers later on

JSON.

and have no known security holes

I was informed on the IT Security exchange this seems to be the current industry response:

Anything can by made insecure through usage. You still need to
  validate all your inputs.

And validating inputs is like beating encryption. It is an arms race. So this is the challenge as I see it.

What frameworks, languages and etc. should these layers use?

My choice, given infinite resource, would be: AJAX via DWR. MVC via backbone.js, Template by _underscore.js, AMD with require.js (very important), RWD with CSS3 Modernizer and RESS, HTML5 with HTML5boilerplate, data-transfer with JSON. Server - Node, Database - Couch.

why I should (not) use node.js for this particular job

Exhibit A. It is command-line and less adopted on windows. If command line is entirely foreign to you. That is a good reason to not use it. The learning-curve would be a barrier of entry. It had some adoption by Microsoft last year, even now in Azure, evidently, but much remains to be seen. It may be safe to say that robust implementation is non-trivial.

Exhibit B. Node.js is still very early in it's overall potential lifespan. It is immature in some respects and I suppose Ryan Dahl, would be the first to point out which respects those are.

Exhibit C. We, as a community need to ask these security questions, in order to advance these topics. There is a saying that open-source is supposedly more secure because there are more eyeballs. I've seen this to be true in practice.

suggest any OSs alongside w/ the technologies/frameworks.

I would recommend a flavor of Linux/Unix. Perhaps a VM is sufficient for others.

point out if you feel that any part of the current set-up means an
  instant (or even distant) failure

Good question. To me, this is where interchangable-parts is key. Think of this question in regards to your car. Instant or distant failure. Is this traumatic to you? Well, no not really because we can generally get the new part at the corner mechanic. JS is like that. In Node.js it is called the npm. On the front it is micro.js. On the back it is the data versioning mechanism, SHA tags(I think).

One reason JS can continue to adapt, is that it can change out it's parts. When something better like AMD comes along, it can meld into the namespace at runtime and not fry everything else.

I'm just looking for recommendations and directions on what to look
  into. I have all the time in the world and I really just want to learn
  doing something really high-end.

It is important to mention the coding-enjoyment-factor. It is easy to discredit, but... if you are going to spend a significant portion of you life on this endeavor, you would do well to pick an architecture that is actually enjoyable to extend. This is not true of all languages. Some can be nightmarish, and to each his own. I very much enjoy the empowerment, and flexible freedom of Full-Stack JavaScript. Capability has only expanded to date.

I will certainly make it an open project and keep you guys up to date
  w/ it's development

If you haven't discovered it already, use GitHub. It is worth the command-line and bash scripting learning curve if you haven't ventured there already. I scaled-back tortoiseGit personally.

/*****APOLOGIES-FOR-LENGTH**********/
/*****And any typos*****/

I hope it helps.
All the best!
Nash


问:
Should a software developer get a yearly equipment budget?
I am looking at a new position with a new company.  I have talked to some people in the past (in general, not at this company) that they had been given a yearly budget to buy new computer stuff to keep up to date.

Now why I feel this question is worth asking here is that Joel comes right out and says an employer should pay for the best equipment money can buy... within reason of course.

From The Joel Test: 12 Steps to Better Code

9. Do you use the best tools money can buy?

Writing code in a compiled language is one of the last things that still can't be done instantly on a garden variety home computer...

Top notch development teams don't torture their programmers. Even minor frustrations caused by using underpowered tools add up, making programmers grumpy and unhappy. And a grumpy programmer is an unproductive programmer...

Does anyone know if the industry has such a standard to offer an allowance or budget?

I have never worked for a company like this, but I am thinking I should toss this in the ring for negotiations.  Seems reasonable.  How do bigger companies like MS, Google, and Apple handle this?  If you say yes, give a range... I have been told numbers from $5k to $10k.  Seems high to me, but hey I would gladly take it.

答:
A yearly upgrade is not necessary. I depends on the tools Vs system performance.

I prefer that Developer's system is upgraded as they need more powerful system to run all the development tools.

It basically good for organization as It reduces the development time.

also each organization should consider using centralized server like system that can be used to install software that can be used for testing purposes and reduce resource utilization on developer's system.


答:
I think it would be useful for you to look at the method by which some big players like Twitter, Google, Facebook, Amazon, etc. grew their applications from humble beginnings to global leaders. I recently went through articles on the High Scalability Blog - here's the points that came back again and again:

Keep it simple, complexity will come naturally over time.

Automate everything, including failure recovery.

Iterate your solutions, be prepared to throw away a working component when you want to scale it up to the next level.

Use the right tool for the job, but don't be afraid to roll your own solution.

Use caching, where appropriate.

Know when to favor data consistency over data availability, and vice versa.

Above all else, don't get hung up on the choice of web application framework and architecture when you are starting out, because you can always rewrite parts of it if required. Facebook famously used PHP in the beginning and then later wrote a PHP to C++ tool to allow them to compile in C++ to speed things up. When they got popular, Twitter moved its back end messaging platform from Ruby to Scala (a JVM language) for reasons of performance.

Title: The architecture and technologies to use for a secure, fast, reliable and easily scalable web application

Body:
^ For actual questions, skip to the lists down below

I understand, that his is a vague topic, but please, before you turn the other way and disregard me, hear me out. I am currently doing research for a web application(I don't know if application is the correct word for it, but I will proceed w/ that for now), that one day might need to be everything mentioned in the title. I am bound by nothing. That means that every language, OS and framework is acceptable, but only if it proves it's usefulness. And if you are going to say, that scalability and speed depend on the code I write for this application, then I agree, but I am just trying to find something, that wouldn't stand in my way later on.

I have done quite a bit reading on this subject, but I still don't have a clear picture, to what suits my needs, so I come to you, StackOverflow, to give me directions. I know you all must be wondering what I'm building, but I assure you, that it doesn't matter. I have heard of 12 factor app though, if you have any similar guidelines or what is, to suggest the please, go ahead.

For the sake of keeping your answers as open as possible, I'm not gonna provide you my experience regarding anything written in this question.

^ Skippers, start here

First off - the weights of the requirements are probably something like that (on a scale of 10):

Security - 10

Speed - 5

Reliability (concurrency) - 7.5

Scalability - 10

Speed and concurrency are not a top priority, in the sense, that the program can be CPU intensive, and therefore slow, and only accept a not-that-high number of concurrent users, but both of these factors must be improvable by scaling the system

Anyway, here are my questions:

How many layers should the application have, so it would be future-proof and could best fulfill the aforementioned requirements? For now, what I have in mind is the most common version:

Completely separated front end, that might be a web page or an MMI application or even both.

Some middle-ware handling communication between the front and the back end. This is probably a server that communicates w/ the front end via HTTP. How the communication w/ the back end should be handled is probably dependent on the back end.

The back end. Something that handles data through resources like DB and etc. and does various computations w/ the data. This, as the highest priority part of the software, must be easily spread to multiple computers later on and have no known security holes. I think ideally the middle-ware should send a request to a queue from where one of the back end processes takes this request, chops it up to smaller parts and buts these parts of the request back onto the same queue as the initial request, after what these parts will be then handled by other back end processes. Something map-reducey, so to say.

What frameworks, languages and etc. should these layers use?

The technologies used here are not that important at this moment, you can ignore this part for now

I've been pointed to node.js for this part. Do you guys know any better alternatives, or have any reasons why I should (not) use node.js for this particular job.

I actually have no good idea, what to use for this job, there are too many options out there, so please direct me. This part (and the 2. one also, I think) depend a lot on the OS, so suggest any OSs alongside w/ the technologies/frameworks.

Initially, all computers (or 1 for starters) hosting the back end are going to be virtual machines.

Please do give suggestions to any part of the question, that you feel you have comprehensive knowledge and/or experience of. And also, point out if you feel that any part of the current set-up means an instant (or even distant) failure or if I missed a very important aspect to consider.

I'm not looking for a definitive answer for how to achieve my goals, because there certainly isn't one, for I haven't provided you w/ all the required information. I'm just looking for recommendations and directions on what to look into. Also, bare in mind, that this isn't something that I have to get done quickly, to sell and let it be re-written by the new owner (which, I've been told for multiple times, is what I should aim for). I have all the time in the world and I really just want to learn doing something really high-end. Also, excuse me if my language isn't the best, I'm not a native.

Anyway. Thanks in advance to anyone, who takes the time to help me out here.

PS. When I do seem to come up w/ a good architecture/design for this project, I will certainly make it an open project and keep you guys up to date w/ it's development. As in what you could have told me earlier and etc.

For obvious reasons the very same question got closed on SO, but could you guys still help me?.


问:
For an ORM supporting data validation, should constraints be enforced in the database as well?
I have always applied constraints at the database level in addition to my (ActiveRecord) models. But I've been wondering if this is really required?

A little background

I recently had to unit test a basic automated timestamp generation method for a model. Normally, the test would create an instance of the model and save it without validation. But there are other required fields that aren't nullable at the in the table definition, meaning I cant save the instance even if I skip the ActiveRecord validation. So I'm thinking if I should remove such constraints from the db itself, and let the ORM handle them?

Possible advantages if I skip constraints in db, imo -

Can modify a validation rule in the model, without having to migrate
the database.

Can skip validation in testing.

Possible disadvantage?

If its possible that ORM validation fails or is bypassed, howsoever, the database does not check for constraints.

What do you think?

EDIT In this case, I'm using the Yii Framework, which generates the model from the database, hence database rules are generated also (though I could always write them post-generation myself too).

答:
Your guiding principle should be Don’t Repeat Yourself:

In software engineering, Don't Repeat Yourself (DRY) is a principle of software development aimed at reducing repetition of information of all kinds, especially useful in multi-tier architectures. The DRY principle is stated as "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system."

The ORM is essentially an extra layer (or tier if you prefer), sitting comfortably between your application and your data storage(s). Your constraints should be in one place, and one place only, be it the ORM or the data storage, otherwise soon enough you’ll end up maintaining different versions of them. You really don’t want to do that.

However, in practice, most half decent ORMs automatically generate a great deal of your models from your data schema. Although there’s still duplication, the chances for maintenance hell are minimal since the duplicated ORM code is generated following the same pattern each time. It would be ideal to have no duplicate code, but automatically generated constraints is the next best thing.

Also, having your constraints in one place doesn’t necessarily mean you should have all your constraints in the same place. Some, like referential integrity constraints, may be more fitting for the data storage (but may be lost if you move to another data storage), and some, mostly those that are about complex business logic, are more fitting for your ORM. It’d be preferable to have all your apples in the same basket, but…

Failures

You mention the ORM failing. That’s absolutely irrelevant to your question, your application should think of the ORM and the data storage(s) as a single entity. If it fails, it failed, bypassing the ORM to talk to the data storage directly is not a good idea.

Bypassing the ORM for anything else

Also not a good idea. However, it can happen for a variety of reasons:

Legacy parts of the application that were build before the ORM was introduced.

That’s a tough one, and exactly the situation I’m dealing with right now, hence my constant repeat of “maintenance hell”. Either you keep maintaining the non ORM parts, or you rewrite them to use the ORM. The second option might make more sense initially, but it’s a decision that’s solely based on what exactly those parts of your application are doing, and how valuable a complete rewrite would be in the long run.

Try changing a key in a badly designed 2*10^8 rows MySQL table (without downtime) and you’ll understand where I’m coming from.

Non legacy parts of the application that absolutely need to directly talk to the data storage:

Even trickier. ORMs are fancy tools, and they take care of almost everything, but sometimes they just get in the way or even are absolutely useless. The buzzword (buzzphrase really) is object-relational impedance mismatch, simply put it’s not technically possible for your ORM to do everything your relational database does, and for some of the stuff they do, there’s a significant performance penalty.

Comments

From the point of data integrity, constraints MUST be on the database, and SHOULD be on the application. What if your application is accessed from a web and a desktop applications, or a mobile app, or a webservice? – Luiz Damim

This is where adding an extra layer would be extremely helpful, and if we are talking about a web application I’d go with a REST API. An overly simplistic design for this would be:

The ORM would sit between the API and the data storages, and everything behind the API (including it) would be considered a single entity from the various applications.


问:
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!

答: Write once, debug everywhere.</p>

LastEditorDisplayName: Roger Pate

Body: Write once, debug everywhere.


问:
"Forgot Password" - How to handle this?
I read this answer and found a comment insisting not to send password by email:

passwords should not be able to be retrieved by email, I hate that. It means my password is stored in plain text somewhere. it should be reset only.

This raises me the question of handling Forgot Password option?

At any cost the raw password must be displayed in any UI so that user will be able to read it. So what would be the way to handle "Forgot Password"

答:
The comment is against sending the original password in email, not sending anything in email.  If the institution can send the original password, that means they have it, and that's a security problem.  The commenter was not arguing against sending a password through email, because that's pretty much necessary in most cases.

The proper way is to assign a new password that's usable once, for whatever reason.  Perhaps it's already marked expired by the system, perhaps it just logs into a page to change the password that's dynamically generated once and only once, whatever.

Title: "Forgot Password" - How to handle this?


答:
Fastest to develop whatever language your most familiar in. I can't think of a mature language without a json parser.

Fastest to run depends on your requirements (how big are the requests and how frequent?) and server architecture. Probably the fastest would be C++ or erlang but that would be a lot of work.

Personally I would be very tempted to go for Node.js and some nosql variant like MongoDb. They both have very good performance and it would be JavaScript all the way down to the database, no converting or parsing needed.

Title: Fastest way to set up a JSON server on my local machine

Body:
I am a front-end developer. For many experiements I do I need to have a server that talks JSON with my client side app. Normally that server is a simple server that response to my POSTs and GETs.
For example I need to setup a server that saves, modifies and read data from a "library" database like this:

POST /books create a book

GET /book/:id gets a book

and so on...

What is the fastest to set up and easiest technology stack for database and server in this case? I am open to use Ruby, Nodejs and anything that do the job fast and easy.

Is there any framework (on any language) that do stuff like this for me?


问:
What's the best way to manage list item sort order with Drag & Drop UI?
I have a list of Students that I should display to user on a web page in tabular format.

The items are stored in DB along with SortOrder information.

On the web page, user can rearrange the list order by dragging and dropping the items to their desired sort order, similar to this post.

Below is a screenshot of my test page.

In the above example, each row has sort order info attached to it. When I drop John Doe (Student Id 10) above the Student Id 1  row, the list order should now be: 2, 10, 1, 8, 11.

What's the optimistic (less resource hungry) way to store and update Sort Order information?

My only idea for now is, for every change in the list's sort order, every object's SortOrder value should be updated, which in my opinion is very resource hungry.

Just FYI: I might have at most 25 rows in my table.

答: Personally I would return a JSON array for the data from the back end. Then I would use JavaScript (JQuery or knockout) to display and sort and re-sort the data. That way the sorting has zero load on the server.</p>


问:
Dynamically vs Statically typed languages studies
Do there exist studies done on the effectiveness of statically vs dynamically typed languages?

In particular:

Measurements of programmer productivity

Defect Rate

Also including the effects of whether or not unit testing is employed.

I've seen lots of discussion of the merits of either side but I'm wondering whether anyone has done a study on it.

答:
Just yesterday I've found this study: Unit testing isn't enough. You need static typing too.

Basically the author used a tool able to convert automatically a project from a non-static typing language into a static typing one (python to haskell)

Then he selected a number of open source Python projects that also included a reasonable amount of test units, and automatically converted them to haskell.

The translation to Haskell revealed a series of errors related to the type of the variables: the errors weren't discovered by the test units.

ContentLicense: CC BY-SA 4.0


问:
Can the Turing machine be classified?
Can the Turing machine be classified e.g. as a Mealy machine? Why not? Can a Turing machine be input to another Turing machine without complication like halting problems?

Thanks

答:
This sounds awfully like some homework, so I'll refrain from giving a more detailed answer, but considering inputting a Turing machine:

You can encode every Turing machine into a string (read up on Gödel numbers on that)

The halting problem only ever becomes a problem at all, if a Turing machine is simulated/running in some way.

When you input a string into another Turing machine, the string may encode a Turing machine, but no one says that it has to execute this Turing machine. So your second question is essentially pointless, as you can obviously input a string to a Turing machine.

Title: Can the Turing machine be classified?


问:
Which language features are considered harmful?
Please, explain why and list which languages have the (mis)feature implemented As far you know.

Post what you consider a harmful feature, not what you dislike.

答:
magic_quotes in PHP.

Unexperienced developers either rely on it being enabled and thus assume all user input to be escaped for use in a SQL query or rely on it being disabled and thus always escape their input.

When assuming it's enabled and then running the code on a system where it's not it opens gaping wide SQL injection holes.

When assuming it's disabled and it's not, it will result in backslashes being actually stored in the DB, causing ugly/incorrect strings.

There is also no extremely simple way to handle both cases - you need to check if it's enabled using get_magic_quotes_gpc() and then apply stripslashes() on all values in the $_* arrays - since array_map is not recursive you need a custom function for this.


答:
My credit card provider has a "forgotten password" option that asks you some security questions ( this is not immensely secure in itself but lots of banks do it ) and then generates a new code and gives you half on screen and emails the second half to you. That way you can't break the account without access to both the web page and the email address.

I have asked a little about this from a usability perspective a while back.

Title: "Forgot Password" - How to handle this?

Body:
I read this answer and found a comment insisting not to send password by email:

passwords should not be able to be retrieved by email, I hate that. It means my password is stored in plain text somewhere. it should be reset only.

This raises me the question of handling Forgot Password option?

At any cost the raw password must be displayed in any UI so that user will be able to read it. So what would be the way to handle "Forgot Password"


答:
For your first question, consider, for example, Wikipedia's formal definition of a Mealy machine. Your question is precisely equivalent to "can a Turing machine be described in terms of that definition?" Looking at a formal definition of a Turing machine would be instructive.

For your second question, you may want to research Universal Turing Machines. They are a formulation of nearly exactly the idea of "inputting a Turing machine into another Turing machine", and any reasonable resource that discusses those more than in passing will certainly help give you some idea of how the halting problem relates to them.

Title: Can the Turing machine be classified?

Body:
Can the Turing machine be classified e.g. as a Mealy machine? Why not? Can a Turing machine be input to another Turing machine without complication like halting problems?

Thanks


答: Commonly (and probably the only valid use for this) used in micro-controllers to control timing accurately, however most likely to be written in Assembler (or inline assembler in a C programmer) as the programmer then has absolute control over the instructions used, hence the time taken. </p>

Title: Why are effect-less functions executed?

Body:
All the languages I know of would execute something like:

```<code>i = 0
while i < 100000000
    i += 1
</code>```

..and you can see it take a noticeable amount of time to execute.

Why though, do languages do this? The only effect this code will have is taking time.

edit: I mean inside a function which is called

```<code>function main(){
    useless()
}
function useless(){
    i = 0
    while i < 100000000
        i += 1
}
</code>```


问:
Do you check in bin or debug folders (and dlls) into your TFS?
Quick question about TFS -
Do you guys check-in bin/debug folders into TFS?
(if so, why?)
Since the content of those folders are dynamically generated is it better to leave them out so that the programmer will not run into read-only issues?</p>

答: In my opinion, not storing binaries in source control is one of the most common mistakes. They should be stored, versioned, baselined/labeled together with the sources and also build tools. Suite yourself with building not traceable software...</p>


问:
"UML is the worst thing to ever happen to MDD." Why?
William Cook in a tweet wrote that:

"UML is the worst thing to ever happen to MDD. Fortunately many people now realize this ..."

I would like to know the reasoning behind that claim (apparently, I'm not referring to his personal opinion).

I've noticed that many people out there don't like UML that much. Also it is worth mentioning that he is in academia, where UML is preety much the holy grail of effective design and modelling.

答:
UML is great as long as it is just a modeling language. If you try to connect MDD to UML in order to get a graphical view then it is useless.
MDD would be great without UML as well as UML without MDD.

Let's say UML and MDD have divorced today in order to have a better life not together anymore :-)


问:
Why are effect-less functions executed?
All the languages I know of would execute something like:

```<code>i = 0
while i < 100000000
    i += 1
</code>```

..and you can see it take a noticeable amount of time to execute.

Why though, do languages do this? The only effect this code will have is taking time.

edit: I mean inside a function which is called

```<code>function main(){
    useless()
}
function useless(){
    i = 0
    while i < 100000000
        i += 1
}
</code>```

答:
First languages have most probably nothing to do with the issue. Definitions of languages give the observable behavior and they don't consider duration as observable behavior excepted for very special purpose functions.

Thus you are speaking about implementation choice.

As a documented case, let's look at gcc.

In early gcc documentation, they stated that they purposely didn't remove empty loops as they were most probably there for a timing purpose.

In newer one, they now state they have reversed their decision as empty loops are now most often due to other optimizations (which may remove all existing content) and they warn that empty loops will be removed if gcc is able to show that they will terminate.

Title: Why are effect-less functions executed?


问:
Does it make sense to use jQuery in modern-webkit-only web applications?
I'm lately working on a few mobile web apps for Android (2.3+) and iOS (4+). Their browsers support most of ECMAScript5, which is very powerful, and I wanted to use language features where possible, resorting to jQuery only when I had to.

Turns out the only thing I use jQuery for is to have a shorter alternative for document.querySelectorAll. Might as well get rid of it.

If I only have to support modern WebKit browsers, is it a good idea to get rid of jQuery (and other general-purpose libraries)? They are a layer of indirection, after all.

(The apps don't have to make AJAX calls so far, I guess that's one thing that's going to get ugly. But is it worth keeping jQuery just for that?)

答:
I think it's still worth using. jQuery effectively makes your code more compact and more readable, resulting in faster development and less maintenance (taking into account you have some experience with it).

If jQuery is too heavy-weight for you, you should give Zepto a try, which is kind of a light-weight alternative for jQuery (with a similar api).


答:
No, it doesn't make sense.

jQuery is a bloated library. Everybody knows that. And everybody uses it because it's one the rare cross-browser libraries out there that just work (note that I didn't say framework).

If you don't need support for legacy browsers, you don't need jQuery.

Small needs such as QSA shortcut or an XHR helper are thin. They are easily added through such objects.

Then, if you like its API, go for it. But it's not needed.

I can understand that some people prefer:

```<code>$( '.table' ).addClass( 'active' );
</code>```

To (using By):

```<code>[].forEach.call( By.qsa( '.table' ), function( table ) {
    table.classList.add( 'active' );
} );
</code>```

I find the second way more explicit, other will disagree. It's a matter of preference.

Also, if your code has any chance of being ported to legacy browsers later (or other non-webkit/sucky mobile browsers), use jQuery. It will reduce your headache later.

Related: https://softwareengineering.stackexchange.com/a/148536/42132

Title: Does it make sense to use jQuery in modern-webkit-only web applications?

Body:
I'm lately working on a few mobile web apps for Android (2.3+) and iOS (4+). Their browsers support most of ECMAScript5, which is very powerful, and I wanted to use language features where possible, resorting to jQuery only when I had to.

Turns out the only thing I use jQuery for is to have a shorter alternative for document.querySelectorAll. Might as well get rid of it.

If I only have to support modern WebKit browsers, is it a good idea to get rid of jQuery (and other general-purpose libraries)? They are a layer of indirection, after all.

(The apps don't have to make AJAX calls so far, I guess that's one thing that's going to get ugly. But is it worth keeping jQuery just for that?)

Body:
No, it doesn't make sense.

jQuery is a bloated library. Everybody knows that. And everybody uses it because it's one the rare cross-browser libraries out there that just work (note that I didn't say framework).

If you don't need support for legacy browsers, you don't need jQuery.

Small needs such as QSA shortcut or an XHR helper are thin. They are easily added through such objects.

Then, if you like its API, go for it. But it's not needed.

I can understand that some people prefer:

$( '.table' ).addClass( 'active' );

To (using By):

[].forEach.call( By.qsa( '.table' ), function( table ) {
    table.classList.add( 'active' );
} );

I find the second way more explicit, other will disagree. It's a matter of preference.

Also, if your code has any chance of being ported to legacy browsers later (or other non-webkit/sucky mobile browsers), use jQuery. It will reduce your headache later.

Related: https://softwareengineering.stackexchange.com/a/148536/42132


答:
This code may do nothing as you think it does, but what if, taking C# as example, I had overloaded the + operator.

```<code>public static int operator +(int one, int two) {/* implement crazy operation here */}
</code>```

In the overload, I'd generate a frame and scale the operator to sync for 60fps.

This "useless" loop has now become a game that stops at the 100000000th frame. Not so useless heh?

Your inability to clearly define "useless code" is why the compiler can't deal with it.

Title: Why are effect-less functions executed?

Body:
This code may do nothing as you think it does, but what if, taking C# as example, I had overloaded the + operator.

public static int operator +(int one, int two) {/* implement crazy operation here */}

In the overload, I'd generate a frame and scale the operator to sync for 60fps.

This "useless" loop has now become a game that stops at the 100000000th frame. Not so useless heh?

Your inability to clearly define "useless code" is why the compiler can't deal with it.


问:
What are some practical uses of the "new" modifier in C# with respect to hiding?
A co-worker and I were looking at the behavior of the new keyword in C# as it applies to the concept of hiding. From the documentation:

Use the new modifier to explicitly hide a member inherited from a base
  class. To hide an inherited member, declare it in the derived class
  using the same name, and modify it with the new modifier.

We've read the documentation, and we understand what it basically does and how it does it. What we couldn't really get a handle on is why you would need to do it in the first place. The modifier has been there since 2003, and we've both been working with .Net for longer than that and it's never come up.

When would this behavior be necessary in a practical sense (e.g.: as applied to a business case)? Is this a feature that has outlived its usefulness or is what it does simply uncommon enough in what we do (specifically we do web forms and MVC applications and some small factor WinForms and WPF)? In trying this keyword out and playing with it we found some behaviors that it allows that seem a little hazardous if misused.

This sounds a little open-ended, but we're looking for a specific use case that can be applied to a business application that finds this particular tool useful.

答:
I think it is there in case you might need it to do something the language designers might not have thought of. C# was in many ways a reaction to early versions of java. And one thing java did was to very explicitly pigeonhole developers to eliminate possiblities of developers shooting themselves in the feet. C# took a slightly different approach and gave developers a bit more power at allowing developers a few more opportunities to shoot themselves in the feet. One example is the unsafe keyword. This new keyword is another.

Now, it probably isn't as useful as unsafe but once you get into a language spec it is hard to get out of a language spec.


答: It's telling the reader that "I deliberately hid the base class' implementation of this method", as opposed to accidentally.</p>

Title: What are some practical uses of the "new" modifier in C# with respect to hiding?

Body:
A co-worker and I were looking at the behavior of the new keyword in C# as it applies to the concept of hiding. From the documentation:

Use the new modifier to explicitly hide a member inherited from a base
  class. To hide an inherited member, declare it in the derived class
  using the same name, and modify it with the new modifier.

We've read the documentation, and we understand what it basically does and how it does it. What we couldn't really get a handle on is why you would need to do it in the first place. The modifier has been there since 2003, and we've both been working with .Net for longer than that and it's never come up.

When would this behavior be necessary in a practical sense (e.g.: as applied to a business case)? Is this a feature that has outlived its usefulness or is what it does simply uncommon enough in what we do (specifically we do web forms and MVC applications and some small factor WinForms and WPF)? In trying this keyword out and playing with it we found some behaviors that it allows that seem a little hazardous if misused.

This sounds a little open-ended, but we're looking for a specific use case that can be applied to a business application that finds this particular tool useful.


问:
Looking for an example of how a software project can be managed/deployed
My company is evaluating adopting off-the-shelf ALM products to aid in our development lifecycle; we currently use our own homegrown solutions to manage requirements gathering, specification documentation, testing, etc. One of the issues I am having is understanding how to move code between stages of development. We have what we call a pipeline, which consists of particular stops:

[Source] -> [QC] -> [Production]

At the first stop, the developer works out a solution to some requested change and performs individual testing. When that process is complete (and peer review has been performed), our ALM system physically moves the affected programs from the [Source] runtime environment to the [QC] runtime environment. This movement of code is triggered by advancing the status of the change request to match the stage of the pipeline.

I have been searching the internet for a few days trying to find how the process is accomplished elsewhere -- I have read a bit about builds, automated testing, various ALM products, etc. but nowhere does any of this state how builds interact with initial change requests, what the triggers are, how dependencies are managed, how the various forms of testing are accommodated (e.g. unit testing, integration testing, regression testing), etc.

Can anyone point me to any resources detailing specific workflows or attempt to explain (generically) how a change could/should be tracked and moved though the development lifecycle? I'd be very appreciative.

Note: I've cleaned up the question to hopefully make it easier to understand. Also, I found another question (which I can't find now) that referenced this book, which sounds like it might be exactly what I am looking for -- not sure if I want to shell out the cash for it, though.

Additional details per @GlenH7's suggestion:

Our products are built with a proprietary language and set of translation tools -- the ultimately runtime environment is similar to a web site architecture, in that we have a bunch of 'code' files sitting out on a server, which our client app accesses on-demand (not unlike a GET request) and then interprets to provide the user experience. We sell an integrated product which is made up of a set of modules (most of which are optional), each module has a team of ~4 programmers and 2 QC testers devoted to the development/bug maintenance. There are around 30 modules per product line (and 3 product lines) -- some teams maintain multiple products lines for their given module. In total, we have 700 employees devoted to development and ~200 programmers. Certainly adopting any new processes or systems is going to involve buy-in, etc. but I'm tasked with simply understanding how the code will be managed so that we can speak intelligently about things. My first task was to learn how to adopt version control into our process (we do not yet use formal version control for most of our product lines, we rely instead of keeping around multiple copies of the entire codebase).

We follow the waterfall method pretty closely (which sucks, but the company has been producing software since 1969, so it was probably the natural fit back then and until now, there has been no need to change anything). Some folks are intrigued by the various offerings of the agile methodologies, but as has been noted by @Chad below, we're likely going to need to take incremental steps towards any such end goals (though if we adopt an ALM system, it might be the time to just force a whole new way to do things on everyone).

Now for a specific example of our current process, let's say we have a product called HIS, which has an MIS and ITS module (what these are/could be is not important -- think of them as just a collection of files) -- in our current process, if someone requests a change to ITS, a coder will modify some files (effectively) on the development server. When that change needs to be tested, transitioning the status of the change request from 'development needed' to 'qc needed' will trigger our tools to copy the affected files from the development server to the QC server. Now when QC testers signon to the QC testing environment, they will be able to see the effect of the changes. Once they signoff on the change, advancing the status of the request to 'production ready', our tools again copy the code files to the next stage. Once signed off there, a final copy is done to the holding location used for deliveries to customers.

We manage delivery of our releases by a major release number (e.g. 6.0) followed by a service release designation (e.g. 5) and a 'priority pack' number (e.g. 1) -- customers take delivery of priority packs, e.g. 6.0.5.1. As stated above, we simply push code from place to place on multiple servers, so we end up with a project folder for each major release and service release throughout the pipeline and end up with a final resting place for each of the ppacks, e.g.:

```<code>dev6.0
qc6.0
production6.0

dev6.0.5
qc6.0.5
production6.0.5

ship6.0.5.1
</code>```

I was thinking that under version control, we could simulate this kind of scheme as:

```<code>trunk
branches
--6.0.5
tags
--6.0.5.1
</code>```

but that seems to cover only half of the locations, i.e. where do the qc and production sources live? Would I create a separate trunk for each major and minor release of the product? Or would I rely on something outside of version control (e.g. the ALM system) to track the revision(s) interesting for testing done at the QC and production stops? We'd need a runtime environment for each, still, but that could be 'built' on-demand as bug fixes and features are made available -- which reinforces the idea that I need not keep any special 'copy' of these stages under version control (they are simply references to revision history of the trunk or branch).

Another thing that has thrown me for a loop as that a colleague is pretty adamant that you should not persist anything in branches, i.e. the branch folders should be ephemeral and used only during large changes that can't be committed directly to the trunk (with the expectation that the branch will eventually be merged into the trunk). In his scheme, the minor releases would necessitate a separate top-level with it's own set of trunk, branches and tags, e.g.:

```<code>product6.0
trunk
branches
--silly_new_feature
tags
--6.0.5

product6.0.5
trunk
branches
--crazy_bug_fix
tags
--6.0.5.1
</code>```

(sorry for the delay on adding these details -- got pulled away to meetings all day)

答:
What you need to do is define your software development release process.

You can start by simply formalizing your existing process.  I would recommend getting your developers input on the process so that they feel like they had a voice in the process.  Have a regular review of the process with lessons learned.  What is working?  Where are our pain points?  What can we do to improve?

Make gradual improvements in the process with your teams buy in.  They are professionals and will probably understand the value in the controls being in place.

I suspect that book you list in your question will have a solution that will be beyond your reach for a first iteration of your process.  That does not mean you can not try and steer your team towards that solution, but proven, effective, and consistent process compliance does not happen overnight.  An iterative approach tends to work better, especially if you do not have any one with experience in the process you are trying to cram down their throats.  There are quite a few methodologies and write ups on the SLDC on the internet.  I would start with the free write-ups before I spent money on an advanced system that may or may not ever work in your environment.


问:
Using XSLT for messaging instead of marshalling/unmarshalling Java message objects
So far I have been using either handmade or generated (e.g. JAXB) Java objects as 'carriers' for messages in message processing software such as protocol converters. This often leads to tedious programming, such as copying/converting data from one system's message object to an instance of another's system message object. And it sure brings in lots of Java code with getters and setters for each message attribute, validation code, etc.

I was wondering whether it would be a good idea to convert one system's XML message into another system's format - or even convert requests into responses from the same system - using XSLT. This would mean I would no longer have to unmarshall XML streams to Java objects, copy/convert data using Java and marshall the resulting message object to another XML stream.

Since each message may actually have a purpose I would 'link' the message (and the payload it contains in its properties or XML elements/attributes) to EXSLT functions. This would change my design approach from an imperative to a declarative style.

Has anyone done this before and, if so, what are your experiences? Does the reduced amount of Java 'boiler plate' code weigh up to the increased complexity of (E)XSLT?

答:
using XSLT to transform messages is a very common technique that you'll find supported in most ESB frameworks such as Apache Camel, Mule, Spring Integration, Ikasan etc.

The trade off is that XSLT can be difficult to maintain and there can be a lack of flexibility in the programming model that it offers.  I've found that I'd often have to call out to a datasource to do a lookup or a POJO to perform some other complex transform. In the end up we only used XSLT for fairly simple transforms and had other components in the ESB flow do the rest.

There is also a performance cost in terms of performing the transform and the validation afterwards. There's a large array of libraries to choose from which perform the transform and validation with varying performance characteristics (think memory and CPU impacts).

There's another serialisation cost when you eventually transform back to a Java object.


答:
You can use it to imitate return type covariance (Note: After this answer was written, C# 9.0 added support for return type covariance).  Eric Lippert's Explanation .  Eric provides this example code:

```<code>abstract class Enclosure
{
    protected abstract Animal GetContents();
    public Animal Contents() { return this.GetContents(); }
}
class Aquarium : Enclosure
{
    public new Fish Contents() { ... }
    protected override Animal GetContents() { return this.Contents(); }
}
</code>```

This is a work-around.  public override Fish Contents() { ... } is not legal, despite being safe.

In general, you should not use method hiding, as it is confusing to consumers of your class (the specific example above does not suffer from this problem).  Just name your new method something else if you don't want to override an existing method.

A likely real-world situation where you would need method hiding is if the provider of a base class added a generic method which you had already added to a derived class.  Such a program will compile (and give warnings) without the new keyword, but adding new says, "I know my version of this method is replacing the base class's version.  This is horrible and confusing, but we're stuck with it." That's still better than forcing the derived class to rename their method.

Just allowing the derived method to be treated as being an override would cause problems.  Ignoring any concerns with implementing the compiler, the new method is semantically different from the base method, but polymorphism would cause the new method to be called when asked to call a method with the same name.

This situation is discussed in detail in this post by Eric Lippert.

Body:
You can use it to imitate return type covariance (Note: After this answer was written, C# 9.0 added support for return type covariance).  Eric Lippert's Explanation .  Eric provides this example code:

abstract class Enclosure
{
    protected abstract Animal GetContents();
    public Animal Contents() { return this.GetContents(); }
}
class Aquarium : Enclosure
{
    public new Fish Contents() { ... }
    protected override Animal GetContents() { return this.Contents(); }
}

This is a work-around.  public override Fish Contents() { ... } is not legal, despite being safe.

In general, you should not use method hiding, as it is confusing to consumers of your class (the specific example above does not suffer from this problem).  Just name your new method something else if you don't want to override an existing method.

A likely real-world situation where you would need method hiding is if the provider of a base class added a generic method which you had already added to a derived class.  Such a program will compile (and give warnings) without the new keyword, but adding new says, "I know my version of this method is replacing the base class's version.  This is horrible and confusing, but we're stuck with it." That's still better than forcing the derived class to rename their method.

Just allowing the derived method to be treated as being an override would cause problems.  Ignoring any concerns with implementing the compiler, the new method is semantically different from the base method, but polymorphism would cause the new method to be called when asked to call a method with the same name.

This situation is discussed in detail in this post by Eric Lippert.


答:
This is actually a very difficult question to answer and I have found it to be a very controversial subject.

As Yannis Rizos pointed out in his answer, having the constraint logic in both the database and the ORM layer would seem to violate DRY, which "can lead to maintenance nightmares, poor factoring, and logical contradictions".

However, removing the constraint logic from the database and keeping it only at the ORM layer would not work if you have any of the following conditions:

Manual DB updates (they seem to happen at every company)

DB updates from another system that cannot always share the ORM
constraint logic easily (ex/ a Perl script that performs routine tasks when
the ORM layer is implemented in Hibernate and used by a Java
application for day to day activity)

This would suggest that you only add the constraint logic to the DB and remove from your ORM layer in order to prevent a DRY violation. However, this can lead to cases where the application code cannot successfully capture the actual issue and relay to the user (though as a developer debugging the issue, you most likely can). This may not be acceptable for some projects.

Your last option is to automate the creation of the constraints in the ORM (and any other system) from the DB constraints (or, really...vice versa). Though you will eventually end up with two or more implementations of the constraints, it will not be a violation of DRY principle as described in "The Pragmatic Programmer" as they recommend the utilization of code generation to avoid DRY violations. Of course, it is not that simple because, for example, every change to a DB constraint may force a re-build and re-deploy of all of your applications which use it (not trivial to automate).

Really, it would have to be evaluated on a case by case basis. I can tell you that, to this point, I have been met with blank stares when I suggest that constraint logic not be repeated.

Title: For an ORM supporting data validation, should constraints be enforced in the database as well?

Body:
I have always applied constraints at the database level in addition to my (ActiveRecord) models. But I've been wondering if this is really required?

A little background

I recently had to unit test a basic automated timestamp generation method for a model. Normally, the test would create an instance of the model and save it without validation. But there are other required fields that aren't nullable at the in the table definition, meaning I cant save the instance even if I skip the ActiveRecord validation. So I'm thinking if I should remove such constraints from the db itself, and let the ORM handle them?

Possible advantages if I skip constraints in db, imo -

Can modify a validation rule in the model, without having to migrate
the database.

Can skip validation in testing.

Possible disadvantage?

If its possible that ORM validation fails or is bypassed, howsoever, the database does not check for constraints.

What do you think?

EDIT In this case, I'm using the Yii Framework, which generates the model from the database, hence database rules are generated also (though I could always write them post-generation myself too).


问:
Is there a point to writing in C or C++ instead of C# without knowing specifically what would make a program faster?
I wrote a small library in Python for handling the xbox 360's STFS files to be used on my web applications. I would like to rewrite it for use in the many desktop programs people are writing for 360 game modding, but I'm not quite if I should continue using C# or delve into C++ or even C. </p>

<p>STFS is an in-file file system used by the xbox 360 and the job of the library would be extracting/injecting files, which could take noticeable amounts of time to do. What I know in C# comes from internet tutorials and resources, as would anything I learn about C++, so what I'm asking is if it's better to bring myself to a slightly lower-level language without knowing beforehand the features of the language that increase performance, or continue assuming that compiler optimizations and that my lack of experience will mean that the language I choose won't matter. </p>

答:
I encourage you to write it in assembly lol. Bigger learning curve but if it is speed you want well written assembly can provide it.

The next runner up in speed would be C. Though everyone says that it is not that much faster than C++ it is not the only benefit. C is IMO has been written better and has much more potential for an increase in speed. Classes in C++ add quite a bit of overhead and unneeded complexity of learning the language. Without them you might as well be writing C and get that increase in speed.

Though I have not written any C# or even seen the source code for a C# program I know I don't like it as I'm a Linux guy. Thus why I strongly do not recommend C#. This sounds like it would be a useful program o many Linux users as well.

Python seem like a good choice though to me it seems more unstable due to the high level of abstraction for a lower level function. It would allow it to be moved back and forth between Linux Windows and Mac.


问:
What's your strongest opinion against functional programming?
Functional programming is one of the oldest programming paradigms. However it isn't used much in the industry compared to more popular paradigms. But it have largely been emphasized in academia.

What's your strongest opinion against functional programming?

答:
Time To Market

Difficult to rid a full IT landscape of procedural code and mantras.


问:
If I use Ruby Migrations, do I have to use the rest of Ruby on Rails?
I'm currently trying to come up with a database migrations strategy for my organization.  This includes getting the database scripts into source control, managing versioning, managing releases to QA / Production, managing branching and merging across different release branches, etc.

Ruby Migrations seems to offer solutions to a lot of those problems.  But, from looking at the Ruby on Rails docs, it is unclear to me whether Ruby Migrations can be separated from the rest of the framework.  I work in a primarily .NET shop, but with a lot of other technologies, and with multiple DBMS platforms (SQL Server, Oracle of various versions).  Ruby is not present in our portfolio at all right now, and we have no plans to use it.  If I was to use Ruby Migrations, it would be the only piece of the Ruby on Rails framework that we would want to use.

Can Ruby Migrations be effectively used to manage database changes independently of the rest of the Ruby on Rails framework?  Are there any docs or articles out there that describe this workflow?

(Yes, I know there are other options such as Liquibase but I'm specifically trying to learn about Ruby Migrations with this question.)

答:
Ruby on Rails is designed to be used as a big whole, so separating out a chunk of it tends to be more work than it is worth.

An alternative library is Datamapper, which has a standalone migrations module.


答: Ruby on Rails migrations are triggered through rake tasks, like rake db:migrate, rake db:reset and so on. You see a complete list with rake -T. You are not forced to ever start the Rails server. So the answer to your question is clearly yes.

Title: If I use Ruby Migrations, do I have to use the rest of Ruby on Rails?

Body:
I'm currently trying to come up with a database migrations strategy for my organization.  This includes getting the database scripts into source control, managing versioning, managing releases to QA / Production, managing branching and merging across different release branches, etc.

Ruby Migrations seems to offer solutions to a lot of those problems.  But, from looking at the Ruby on Rails docs, it is unclear to me whether Ruby Migrations can be separated from the rest of the framework.  I work in a primarily .NET shop, but with a lot of other technologies, and with multiple DBMS platforms (SQL Server, Oracle of various versions).  Ruby is not present in our portfolio at all right now, and we have no plans to use it.  If I was to use Ruby Migrations, it would be the only piece of the Ruby on Rails framework that we would want to use.

Can Ruby Migrations be effectively used to manage database changes independently of the rest of the Ruby on Rails framework?  Are there any docs or articles out there that describe this workflow?

(Yes, I know there are other options such as Liquibase but I'm specifically trying to learn about Ruby Migrations with this question.)


答:
XSLT can get really complicated really fast

Having spent a lot of time enduring the pain of poorly applied XSLT solutions I'd strongly counsel against them, unless your mapping transformations are brain-dead simple.

I would much rather try to work through a load of fairly simple, repetitive POJOs trying to find a transformation bug than fiddle endlessly with esoteric XSLT constructs.

Interesting side notes

Off topic, but might be worth mentioning, is that you can add custom code easily enough to your auto-generated JAXB classes using the techniques described in this article. Also, this article about Hypertext Application Language (HAL) contains some interesting bridging techniques using SAM Types, contracts and all driven through Guava Functions. Might make a dull job a lot more interesting.

Title: Using XSLT for messaging instead of marshalling/unmarshalling Java message objects

Body:
So far I have been using either handmade or generated (e.g. JAXB) Java objects as 'carriers' for messages in message processing software such as protocol converters. This often leads to tedious programming, such as copying/converting data from one system's message object to an instance of another's system message object. And it sure brings in lots of Java code with getters and setters for each message attribute, validation code, etc.

I was wondering whether it would be a good idea to convert one system's XML message into another system's format - or even convert requests into responses from the same system - using XSLT. This would mean I would no longer have to unmarshall XML streams to Java objects, copy/convert data using Java and marshall the resulting message object to another XML stream.

Since each message may actually have a purpose I would 'link' the message (and the payload it contains in its properties or XML elements/attributes) to EXSLT functions. This would change my design approach from an imperative to a declarative style.

Has anyone done this before and, if so, what are your experiences? Does the reduced amount of Java 'boiler plate' code weigh up to the increased complexity of (E)XSLT?