答:
I treat BDD as a way of reasoning about a problem from the perspective of the value a feature or similar will ultimately provide.

The basic premise of TDD was essentially a pattern or process for doing testing: write just enough test code to fail the test, write just enough code to make that test pass, refactor, repeat. It focussed on how, not why. In that light, I find BDD more useful, as it forces people to think about why they're even testing at all, and what net benefit -- what useful behaviour -- will be provided by their code once those tests pass.

Title: What are the advantages to BDD for a solo developer?

Body:
I have found this lines below about the advantages of BDD (Behavior Driven Development)

The domain experts define what they need in the program in a way that
  the developers can not misinterpret (or at least not as much as in
  most other approaches).

Are there any more advantages apart from that?

If I'm working alone (I'm not in contact with managers that could write BDD features),

do I need to use BDD?

OwnerDisplayName: Chris


问:
What are the advantages to BDD for a solo developer?
I have found this lines below about the advantages of BDD (Behavior Driven Development)

The domain experts define what they need in the program in a way that
  the developers can not misinterpret (or at least not as much as in
  most other approaches).

Are there any more advantages apart from that?

If I'm working alone (I'm not in contact with managers that could write BDD features),

do I need to use BDD?

答: a strong benefit i see in TDD and BDD is, that you have to clarify your requirements. a thing i often see with non-BDD, are unclear or even contradicting requirements. BDD 'forces' you to write them down and thus think them through, before writing any line of code. i've seen non-TDD code taking several turns, and a lot of YAGNI, because of changing or unclear requirement. you can avoid that and safe you some trouble by writing down the requirements first as a runnable test/feature.</p>

ContentLicense: CC BY-SA 3.0

OwnerDisplayName: Marian Theisen


答:
You say you're working alone, but it certainly sounds like you're writing code for other people, so there must be some communication of requirements going on.

Writing down acceptance criteria before starting a piece of work is just common sense. If you can then take that a step further and automate that, then great.

However, learning how to write acceptance criteria at a suitable level to be of interest to your stakeholders takes skill and practice.

OwnerDisplayName: Andy Waite


问:
Server-side event logs through DB or writing to file?
I am developing a web application as well as the API the web application uses.  I'm trying to determine whether it is better to log events (to determine the path that leads to an error as well as to determine whether the site has been compromised) in a database or simply by writing to a file.

On the one hand, I don't want to bog down my database with a queries every single time I need to log an error.  On the other hand, I don't want to have to dig through a giant event / error log file.  I'm thinking of turning into re-write mode once the file / table reaches 10,000 or 100,000 events.

I know the general factors I should consider:

Performance (both DB and general--in my case I'm using PHP and Postgres)

Ease of finding the path a user took to create a bug or error (I'm almost certain DB is better for this)

Scalability - Is this the same solution I'm going to be using with 20 users as I am with 100,000 users?

Can you tell me how these two possible solutions fit in with the above--really, I think the most important one for me is performance.  How demanding is it to write to a file vs. writing to a DB and if every single event and command sent by the user (and there will be many) is logged (before a re-write limit), which solution will end up being faster?

答:
I would take the database logging approach.  If you are throwing so many errors that it affects database performance, then you most definitely need to revisit the source of these errors.

Storing logging (and auditing) data in the database allows for easy access, ad hoc queries (as well as stored procs and/or functions) to pull often-queried error reports.


问:
Any experience porting a Powerbuilder application to Java (or another language)?
Does anyone out there have any experience porting a large Powerbuilder client/server application to a Java application (or another language)? By large I mean something on the order of 2 million lines of code and literally hundreds of database tables. How did you do it? How long did it take and how much did it cost? What were the biggest challenges? </p>

答:
10+ years ago we started a transition from Powerbuilder to Tomcat. Have no idea of the LOC, we had approx 600 tables. It was a transition from Windows UI to a web UI and we did it with a small team over 2-3 years. The Powerbuilder code and Java code interacted with the same backend database during the transition. Was a great day when we could decommission the Windows client and be done with it.

The product was not transaction intensive, just lots and lots of screens to be converted into web pages. Do you use the DW for displays, updating data, on-screen sorting? Nowadays there are lots of jquery or Google web toolkit things for easy UI tricks.

Would recommend Struts, hibernate, spring or any other MVC tool. In Java we built an API layer that talked to the database, and then a UI layer that talked with the JSPs. You want to corral your database connections into one set of objects rather than opening/closing db connections all over the code.

Your solution depends on the requirements of your product/application and whether it is going to be a desktop app or a web based app. We went web-based and the deployment is a lot easier. Good luck.

ContentLicense: CC BY-SA 2.5


答:
Only if most of your team members don't know how to handle text file in command line can you justify the use of a db based log. For concerns you have listed:

Performance: for appending information row by row, I think no db does it faster than a text file.

Easy query: how are you so sure db is better in this case if most likely it will do table scan anyway? I would avoid writing sql if regular expression does it better for filtering logs, which, from my experience is almost certain.

Scalability: not sure what's your concern here but for logging, anything db can do, text file can do it faster, which should address any scalability problem.

UPDATE:
Just show an example that you may want to do with your log but db sucks in that case: list the last 20 log entries for user id 28465283 before the null reference exception log entry:

grep -B 20 "28465283.*NullReferenceException" log.txt > to-the-grease-monkey.txt

I guess it will take me a while to figure out how to write a SQL for the same query.

Title: Server-side event logs through DB or writing to file?

Body:
I am developing a web application as well as the API the web application uses.  I'm trying to determine whether it is better to log events (to determine the path that leads to an error as well as to determine whether the site has been compromised) in a database or simply by writing to a file.

On the one hand, I don't want to bog down my database with a queries every single time I need to log an error.  On the other hand, I don't want to have to dig through a giant event / error log file.  I'm thinking of turning into re-write mode once the file / table reaches 10,000 or 100,000 events.

I know the general factors I should consider:

Performance (both DB and general--in my case I'm using PHP and Postgres)

Ease of finding the path a user took to create a bug or error (I'm almost certain DB is better for this)

Scalability - Is this the same solution I'm going to be using with 20 users as I am with 100,000 users?

Can you tell me how these two possible solutions fit in with the above--really, I think the most important one for me is performance.  How demanding is it to write to a file vs. writing to a DB and if every single event and command sent by the user (and there will be many) is logged (before a re-write limit), which solution will end up being faster?


问:
Is it legal to recreate/opensource a program that you previously coded for another company
At my previous job I created a generic dashboard for automating tasks and it that turned out to be quite useful - and of course my previous employer owns all the code I wrote while I worked there. Now that I'm no longer there, is it legal for me to recreate that dashboard from memory and open source the code? If I do recreate it, the code (maybe 2k-3k lines) could be almost identical to the original since I have pretty good memory and tend to follow my usual coding style and naming conventions.

Edit: a little more background - this is a pretty generic piece of software that's used only internally by a small team (<10) within a global corporation. "The company" is not even aware of this system since it's I create it on my own initiative. It's built on python/django. And by almost identical I mean that for example the django models will have the same name/fields and views will use similar queries to return the same sets of objects.

答:
Good question, but it's probably the wrong place to ask because you won't get good legal advice from programmers. IANAL, seek proper legal advice.

It doesn't feel legal.  There's a very good chance that if you release an almost identical program to the one that your old company owns you could be sued.  That said I'm sure it happens a lot.

One thing you could do is recreate the program in a different language.  That way it's clear that you didn't walk out of the company with the source code & then open-source it.  It's also educational to solve a problem you are familiar with in a different language.

I'd also suggest thinking about ways to improve the program, make it more extensible etc.  The second time you do something is almost always a lot better than the first because you can avoid all of the "I wish I'd done it that way" design decisions that you may have made the first time.

Even if you never release it it would be a good exercise.  If ultimately you get legal advice & choose to release it you will be better protected.


问:
How can dev teams prevent slow performance in consumer apps?
When I previously asked what's responsible for slow software, a few answers I've received suggested it was a social and management problem:

This isn't a technical problem, it's a marketing and management problem.... Utimately, the product mangers are responsible to write the specs for what the user is supposed to get. Lots of things can go wrong: The product manager fails to put button response in the spec ... The QA folks do a mediocre job of testing against the spec ... if the product management and QA staff are all asleep at the wheel, we programmers can't make up for that. —Bob Murphy

People work on good-size apps. As they work, performance problems creep in, just like bugs. The difference is - bugs are "bad" - they cry out "find me, and fix me". Performance problems just sit there and get worse. Programmers often think "Well, my code wouldn't have a performance problem. Rather, management needs to buy me a newer/bigger/faster machine." The fact is, if developers periodically just hunt for performance problems (which is actually very easy) they could simply clean them out. —Mike Dunlavey

So, if this is a social problem, what social mechanisms can an organization put into place to avoid shipping slow software to its customers?

答:
I remember once in the mid-90s and I was spending some time trying to optimize something and a coworker told me, "This is running on pentiums, who cares?"  .... that was an eye opener.  Sadly, it was just the tip of the iceberg, I've heard that attitude throughout my career - albeit the "pentium" part has changed over time.

The only way to get the average developer to care is to get lack of performance to be viewed as a bug on the part of the customer.  Depending on the application and audience this can either be an easy or a hard task (I've seen both).  If the audience doesn't care about the poor performance, the developers never will (quickly, good, fast - choose two).


答:
Your application should be capable of doing both. Then tweak accordingly. If you are hitting the database too much (really can't see how this would happen unless you are planning on a ton of traffic) you can switch over to .log file. In addition to this you could also log to a format such as JSON and off load the data load into another database in the background/later.

With the applications I write I usually keep the last N debug calls in an array of something and dump it when I encounter an error.


答:
Some databases like Oracle and MySQL allows you to treat a regular txt file as a table, so you can run SELECT statements on it.

If you intend to use a file, then you need to consider:

0-Concurrency issues (what if 2 records need to go to the file at the same time)?

1-How to search it?

2-How large will you allow it to grow - You may need a special script for this

3-Where to store it?

4-How to back it up (if needed) - You may need special script for this.

I see that using a regular database table is the most practical approach.
It reduces the complexity of managing data. That is what databases are for.
To enhance the performance of your log table, place it away from your database space and build no index on it.


问:
Methodologies/tools for when developing on your own
Suppose you have to develop a medium+ sized software, fully on your own. Like if it was a personal project you want to accomplish.

What methodologies/tools would you use to define what needs to be developed, learned and have a global idea of what the system is as well in its details?

Basically to keep yourself in track and not get lost on the way.

答:
If you want to write down your ideas you could use a mind mapping tool such as XMind or FreeMind. Both tools are free (for individuals for XMind), and they are great when brainstorming and organizing your ideas. The thing about these tools is just that you have less chances to forget something.

I personally used Freemind before starting my last personal project. I had no particular methodology per se. I just laid out my ideas during one hour sessions once per two days. I think that spacing the brainstorming sessions helped me better see what was wrong, what was non-essential but could be useful in subsequent versions, etc.

On my first code commit I also saved the brainstorming file in the source code repository (I used bitbucket) and kept it up-to-date with my newest ideas.


答:
How much are you willing to pay for better software? How much will the market wait for better software? How little cruft will want adding to the next release?

It is a cut-throat market out there where many compromises are made. If it is truly crap then the market will (or should) fail the product. Maybe there are enough customers who can live with the status-quo?

Title: How can dev teams prevent slow performance in consumer apps?

Body:
When I previously asked what's responsible for slow software, a few answers I've received suggested it was a social and management problem:

This isn't a technical problem, it's a marketing and management problem.... Utimately, the product mangers are responsible to write the specs for what the user is supposed to get. Lots of things can go wrong: The product manager fails to put button response in the spec ... The QA folks do a mediocre job of testing against the spec ... if the product management and QA staff are all asleep at the wheel, we programmers can't make up for that. —Bob Murphy

People work on good-size apps. As they work, performance problems creep in, just like bugs. The difference is - bugs are "bad" - they cry out "find me, and fix me". Performance problems just sit there and get worse. Programmers often think "Well, my code wouldn't have a performance problem. Rather, management needs to buy me a newer/bigger/faster machine." The fact is, if developers periodically just hunt for performance problems (which is actually very easy) they could simply clean them out. —Mike Dunlavey

So, if this is a social problem, what social mechanisms can an organization put into place to avoid shipping slow software to its customers?


答:
Technically, you're creating a derived work - you are familiar with the existing solution, and you are recreating it from memory. The usual IANAL applies, but if your former employer sues you over copyright infringement, my guess is that they have a pretty strong argument, and it's going to be up to you to come up with a plausible explanation as to why your recreated program should not be considered a derived work.

Legal technicalities aside, getting into a lawsuit with a former employer is not where you want to be, ever - even if you win, you'll be 'that guy', which I doubt would be a smart career move.

Title: Is it legal to recreate/opensource a program that you previously coded for another company

Body:
At my previous job I created a generic dashboard for automating tasks and it that turned out to be quite useful - and of course my previous employer owns all the code I wrote while I worked there. Now that I'm no longer there, is it legal for me to recreate that dashboard from memory and open source the code? If I do recreate it, the code (maybe 2k-3k lines) could be almost identical to the original since I have pretty good memory and tend to follow my usual coding style and naming conventions.

Edit: a little more background - this is a pretty generic piece of software that's used only internally by a small team (<10) within a global corporation. "The company" is not even aware of this system since it's I create it on my own initiative. It's built on python/django. And by almost identical I mean that for example the django models will have the same name/fields and views will use similar queries to return the same sets of objects.


答: There is probably a legal difference between recreating the solution from memory, and creating an original solution to the same specification (but IANAL, so ask one).  To prove the latter, you might want to publish an original and complete spec of the tool you plan on developing on your blog.  Then it's possible for some other developer who's never seen your earlier work to code it.</p>


答:
If logging to the DB, where would you log db failures, like the DB being unavailable?

Yes, if logging to the file system, the file system could become unavailable, but my guess is that you then would have other things to worry about...

In a server application (not a web server, but one under heavy load anyway), we log to files (several), using a specialist logging component. And while performance is a crucial factor in many parts of the code, we have yet to feel the need to decrease our logging because of performance considerations.

Probably because most logging is done outside of the time critical code. Which is only "natural" because time critical code often would produce way too many log messages to be of any practical use.


问:
Quit my job (for a new job). Old job wants me to be available for contracting. Steps to take?
The company I am leaving has asked that I make myself available to answer questions and/or debug programs occasionally should the need arise. I'm not opposed to this. After searching google for some kind of standard contract for this sort of thing, I didn't see any.

Is there a standard contract for this sort of thing that you use?

Are there any other steps I should take to ensure this kind of arrangement works smoothly?

答:
I'm in the same situation. I have a work request sheet, which is basically like a detailed case diagram. Whenever they want me to do work, they fill out:

Name

Pre-Conditions

Steps to perform

Post-Conditions

I know the internals a bit better, so I'll adjust the pre/pos conditions and maybe add/remove some steps as necessary. They OK the changes, and I provide an estimate of how long it'll take. They agree to that, and I start working. And I bill through the nose. I left there for a reason.


答:
For events inside your application, I'd go the DB route.  This will let you more easily search, sort, and report on them.

I dont know about Postgres, but MySQL has an 'INSERT DELAYED' command, which tells the db to commit the inserted row when the server is idle.  This is great for logging as you arent holding up your web page/application by waiting for the insert to complete.   So I'd check into whether postgres supports something like that.


问:
What is the industry definition of an interpreter (as opposed to a compiler)?
In my compiler design courses, I have learned about and worked with a clear academic definition of an interpreter and a compiler, with an interpreter being

a program Pi from a language M capable of taking a program i from a language I and an input and executing i with the given input and the correct semantics for I on a machine capable of running programs from M

and a compiler being

a program Pc that, when given a valid program i from a language I as an input, produces a semantically equivalent program o in a language O

This definition would clearly put the usual execution of Java bytecode by a JVM in the domain of interpretation, no matter how much JIT compilation is done. (Of course, Java is also compiled before, from Java code to Java bytecode.) I have encountered opinions in discussions on this site that clearly and vehemently state the opposite, i.e. that Java Bytecode execution thingies are compilers. Since I am about to make the leap from academics to industry, I am a little bit confused here:

Is the above definition of interpreters false from the viewpoint of industry people in general? Or is it just false for Java people? Is the view of Java as a fully compiled language an alternate, but minority view? Or just a few loonies?

(PS: Please do not move this to cstheory. I have deliberately put this question here since I would really like to get the view of the professional industrial, not the academic community.)

答:
This definition would clearly put the usual execution of Java bytecode in the domain of interpretation, no matter how much JIT compilation is done. I have encountered opinions in discussions on this site that clearly and vehemently state the opposite, i.e. that Java Bytecode execution thingies are compilers.

Well, the two definitions aren't mutually exclusive. An interpreter can contain a compiler (in fact, most modern interpreters contain at least a bytecode compiler).

But I think the intuitive definition most people here use is something like:

a compiler creates native code that is then run directly by the CPU

an interpreter has some kind of "interpreter main loop" that reads instructions (either source code statements or something like precompiled P-Code or bytecode) and performs instructions accordingly.

By this distinction, an "interpreter" is usually an order of magnitude slower than a "compiled" program. So when we're talking about performance, this definition is more useful than the classic CS definition.


答:
Is the above definition of interpreters false from the viewpoint of industry people in general?

No

Or is it just false for Java people?

No

Is the view of Java as a fully compiled language an alternate, but minority view?

No

Or just a few loonies?

No

The Java execution environment is more complicated than is envisaged by those theoretical CS definitions.  But both theoreticians and practical developers are cool with this.

Theoretical definitions like these are designed for a particular purpose; i.e. formal reasoning about how programs are "compiled" and "run".  If you need to model Java in that way, and include JIT compilation in the modelling, then there are ways to handle this.  For instance you could make "call native compiled method" a primitive operation of the interpreter.

The reality is that the Java execution platform uses both compilation and interpretation in both the intuitive and theoretical sense.  So if you need to model the Java platform to that level of detail, you need to incorporate this into the modelling.

Title: What is the industry definition of an interpreter (as opposed to a compiler)?

Body:
In my compiler design courses, I have learned about and worked with a clear academic definition of an interpreter and a compiler, with an interpreter being

a program Pi from a language M capable of taking a program i from a language I and an input and executing i with the given input and the correct semantics for I on a machine capable of running programs from M

and a compiler being

a program Pc that, when given a valid program i from a language I as an input, produces a semantically equivalent program o in a language O

This definition would clearly put the usual execution of Java bytecode by a JVM in the domain of interpretation, no matter how much JIT compilation is done. (Of course, Java is also compiled before, from Java code to Java bytecode.) I have encountered opinions in discussions on this site that clearly and vehemently state the opposite, i.e. that Java Bytecode execution thingies are compilers. Since I am about to make the leap from academics to industry, I am a little bit confused here:

Is the above definition of interpreters false from the viewpoint of industry people in general? Or is it just false for Java people? Is the view of Java as a fully compiled language an alternate, but minority view? Or just a few loonies?

(PS: Please do not move this to cstheory. I have deliberately put this question here since I would really like to get the view of the professional industrial, not the academic community.)


答:
But it shouldn't take a letter from QA for a programmer to realize that a 3 second lag between keypress and response is unacceptable

Agree it shouldn't. It should take more than that: a proof that obtained lag is relevant for end users.

Given that you provided no context, it looks entirely possible that lag in dev/QA environment is caused by their local issues of slow disk / memory / network access. If that's the case, your QA and dev will be simply wasting their efforts fixing things that just don't matter to end users.

Relying on developers in performance testing is about as productive as rolling a dice to pick a piece of functionality to speed up. Oh and it's about as reliable as that - "developers generally have horrible intuition about where the performance problems in an application will actually be" (Brian Goetz).

I've been in a project where lame management once decided their bright marketing guys and smart programmers are good enough to handle performance concerns of the customers. What a great lesson it was. Rejected release, half year of efforts gone to trash bin, and company almost lost a strategic partner. In the end, they invited professionals (experts in benchmarking, statistics, UX, low level optimization, stuff like that) and professionals fixed that mess.

should all programmers do their own QA so they see such issues immediately?

Fact that it's doable doesn't mean it's the way to go. Rather opposite - in my experience this was one of the most reliable ways to lose on programmers productivity. Almost as good as endless meetings and even better than interviewing candidates.

As an ex-tester I once thought it shouldn't be a problem to combine development and QA activities. It looked like the difference between routine dev testing and systematic QA won't matter much. I thought that dev/QA separation is merely a tradition in software industry. Learned rather hard way that this ain't so. Separation turned out to be a matter of focus and productivity, and quite a serious one.

If there's a performance issue, just give me a benchmark and set target performance and I'll do my best to hit it. I'm not that good in performance testing but know a bit or two about optimization.


答:
I generally consider any program that parses and converts code into a lower level form a compiler.  So I'd definately consider Java a compiler.  As would be C#, Python, PHP, etc compilers, as they all reduce source code down to bytecode, which is then executed.  C++, Delphi, and a few others that compile directly to natively executed code I'd call (and I see a lot of people call) 'native code compilers'.

An interpreter, at least the way I learned it way back when, is a program that parses lines of a script one at a time and executes them directly.  That is, there's no intermediate or lower level code.  I'm not aware of any 'modern' languages that are interpreters.

Regarding your definition of 'compiler', I dont think that necessarily implies that Java code isnt compiled.  You just need to interpret 'language O' as the bytecode instruction set.


答:
In France, it is illegal.

The owner of the code is your former boss. No matter how you retrieve it, from a USB thumb drive or from your memory.

If you want to use that dashboard, you have to set an agreement with the owner.


答:
In the US, if your former employer decides to sue you, you will be in trouble no matter what the judges think.

Theoretically, your company owns your work, not your brain. Hence, if you do the work again in your own time, they should not have any ownership of that. After all, they hired you because of what you knew before they hired you. It seems unlogical to assume that they can take advantage of your prior knowledge but at the same time deny you to do the same after you left. But IANAL, either.

Unless of course they made you sign some crazy stuff. Or unless they filed a patent. If they did that, they do own that part of your brain. In that case, those patterns of nerve cells that make up that knowledge inside your brain are not yours any more and you should refrain from using them ever again. Talk about selling your soul.


答: What type of programmer given the chance to recreate something they did previously (the lessons learnt etc.. ) would produce something "almost identical". Unless you believe you coded something perfect??? At which point you have bigger questions to ask yourself. </p>


问:
What are good techniques for keeping your place in code?
I understand using bookmarks to remember a single point in your code. However, how does one keep track of the flow of the code they are investigating? Eg: multiple bookmarks and the order in which they were made.

Example:

Bug report: "Collisions aren't working on the corners of walls"

Reproduction of the bug puts it down to certain polygons not colliding.

The collision code was written by an unavailable dev. So investigation goes something like:

During the investigation, especially when reviewing non-code items such as Google, one may reasonably be expected to loose their place in the code (Have I already looked at this code path? or Which code path was I investigating? There are multiple that lead to this function, etc).  The same goes for unavoidable interruptions (Boss: I need [Lengthy Pointless Report] NOW, etc)

It would be useful to have a resource of techniques or tools for providing a way to keep track of one's place in the code.

Edit: The above example is meant as a potential illustration, not as an actual problem that needs answering.

Another way to phrase this question is:

When learning a new system, how do you keep track of where you are up to in learning the code? It's not about understanding why the code does what it does (which is what comments should be for), but how it does it (which is only learned through reading the code, not comments).

答:
Get a real developers tool / IDE, what ever takes you fancy. Vi, Emacs, Eclipse or whatever (The choice is as large as the arguements over which is best, but thats another problem), and learn to use it properly. dont, like too many do, use it like Notepad with syntax highlighing. Learn to use hotkeys, and not rely on the mouse for common actions (It's too slow). A big screen (1920x1200 minimum) is benficial.

My dev tool has named (Slower but useful names make them persistant) and unnamed (Quick to insert and delete) bookmarks, forward and back browsing and reference look up all in one, todo and developer (personal and group wide) notes attached to a particular line of source code. It does every language under the sun, without having to install yet another plugin.

I work on a code base consisting of a dozen or more 1 Million plus SLOC modules, using half a dozen languages. Obviously I don't work on all of them at a time, rather focus on small parts of one or two, but I can navigate with a few actions to any point in the code that is relivent to what I am doing.

OwnerDisplayName: Jess Telford


问:
Steps to ensure important details aren't edited out of technical documents?
Like many here, I'm sure, my company has a person that acts as liason between development and most other areas of the company, as well as our clients. Most communication regarding new releases, fixes, known issues, etc. goes through this person.

However, because this person is not a developer and not deeply involved in the development projects, sometimes what developers submit for dissemination is edited for brevity or simplicity, and in the process, key details or subtleties are lost.

I've been pushing for a review process that includes the author of the original document, whatever it was, before the material is released. Among other things this would, I feel, allow the person with the greatest technical knowledge about what's being talked about (the one who actually wrote the code for the new program, feature or fix) to weigh in on anything that may have been oversimplified or been given a factual error by the editing process.

The person handling the communication, for their part, feels that the problem is education; the person is relatively new to the company and doesn't have extensive experience with all of the software applications and other products that development produces and supports. The person feels that as they gain this experience through training and reading the material that comes through their hands, the problem will resolve itself. They also feel that the back-and-forth would waste time.

I think there's merit both ways. What do you guys think?

答:
pushing for review process that includes the author of the original document, whatever it was, before the material is released

Word pushing somehow makes me feel you're experiencing certain difficulties in getting there, right? If that's the case, I'd prefer instead pulling a reverse process of reviewing the documents past release.

That pulling way is an easy one - one generally doesn't need approvals to just review released document and pass their feedback. And you can even keep a nice track of it without resorting to someone else outside of dev team. Just use your issue tracker (I assume you have one, don't you?) to collect the data.

"Issue #1234 created to review Memo 666 and provide feedback. - Issue 1234 assigned to Bob Programmer. - Bob Programmer spent 2 hours on analysis requested per Issue 1234. - Bob updated Issue 1234 with a copy of mail Memo 666: dev team notes sent to Jane Liason CCed to dev team, containing 56 corrections, clarifications and amendments. - Issue 1234 closed."

On a related note, lost details or subtleties might be not as severe issue as you perceive. I mean if you convince that liason guy that her prior message missed something really important, it might be easy for her to pass the correction. This is especially true if that guy specializes in communication.

I once have been closely working with marketing pro and she demoed me some of the typical tricks they use in communications practice. Like saying assertive things that turn out easy to dismiss later. Or like phrasing ruthless corrections of dumb mistakes in a way that sounds like expanding of what was previously said. Pretty amazing.


问:
When would be the best time to start porting the code of my own project?
If I have a personal programming project that I plan to port in another language so it could run in other environments, would it be more ideal to start porting the code as soon as possible and work on two versions concurrently? Or would that slow down my production a lot, and should I wait until I have finished some key components of the program? </p>

答:
I'd reply in a consultant's favorite way: "It depends" ;)

Namely, upon the following parameters:

do you need a small time to market?

how much additional work will you cause by waiting with the port? How much architecture and implementation specific to C#(-libraries) are you doing?

have you gained enough experience with your C# solution yet so that you are confident that you will do most things right when reimplementing in C++?


答:
Here is a simple way:
-Open the dashboard from publicitly available url.
-Think about best ways to make it easier/better/so on.
-Rewrite it on different language, as previously suggested. Good reason to learn ruby, haskell, lisp and so on.
-Then make a project open source. feel free to add 'inspired by ...' and link to the original site.     </p>


答: Aside from all the great technologies mentioned, I've found that the old-fashioned A3 piece of paper is an excellent help in these issues. Write down your ideas and organize them mindmap-style.</p>

Title: What are good techniques for keeping your place in code?

Body:
I understand using bookmarks to remember a single point in your code. However, how does one keep track of the flow of the code they are investigating? Eg: multiple bookmarks and the order in which they were made.

Example:

Bug report: "Collisions aren't working on the corners of walls"

Reproduction of the bug puts it down to certain polygons not colliding.

The collision code was written by an unavailable dev. So investigation goes something like:

During the investigation, especially when reviewing non-code items such as Google, one may reasonably be expected to loose their place in the code (Have I already looked at this code path? or Which code path was I investigating? There are multiple that lead to this function, etc).  The same goes for unavoidable interruptions (Boss: I need [Lengthy Pointless Report] NOW, etc)

It would be useful to have a resource of techniques or tools for providing a way to keep track of one's place in the code.

Edit: The above example is meant as a potential illustration, not as an actual problem that needs answering.

Another way to phrase this question is:

When learning a new system, how do you keep track of where you are up to in learning the code? It's not about understanding why the code does what it does (which is what comments should be for), but how it does it (which is only learned through reading the code, not comments).


答:
Legal or not, if your employer finds out and decides to press the issue you will be in a world of hurt. Even if you end up being judged right, the potential litigation can end up being completely ruinous for you. You also risk incurring the wrath of the OSS community for polluting it with copyrighted code as well as the loss of reputation from being viewed as dishonest by your employer.

You also risk action from anyone who adopts your product. Worst case, anyone using your product will be faced with either having to license it from your previous employer or removing it from their solution, costing time and money - either way they may end up suing you for damages.

It seems it would easier to do the right thing - talk with your previous employer, get their consent to re-use the product you developed for them with the intention of open-source distribution. They may just say "go ahead". Doing it behind their backs is generally a bad idea, legal issues aside.


问:
Java and .NET: Why different sorting algorithms are used by default?
Just wondering why Java and .NET Framework uses different sorting algorithm by default.

In Java Array.Sort() uses Merge Sort algorithm by default and as Wikipedia.com says:

In Java, the Arrays.sort() methods use merge sort or a tuned
  quicksort depending on the datatypes and for implementation efficiency
  switch to insertion sort when fewer than seven array elements are
  being sorted

In .NET Framework Array.Sort/List.Sort() uses Quick Sort as default sorting algorithm (MSDN):

List.Sort() uses Array.Sort, which uses the QuickSort algorithm. This
  implementation performs an unstable sort; that is, if two elements are
  equal, their order might not be preserved. In contrast, a stable sort
  preserves the order of elements that are equal.

By looking at the great "Comparison of algorithms" table we can see that both algorithms has pretty different behaviour from Worst Case and Memory Usage perspectives:

Both Java and .NET are great Frameworks for Enterprise Solutions development, both has platforms for embedded development. So why they are using different sorting algorithm by default, any thoughts?

答:
This question is a bit out of date, since Java now uses Timsort (as of Java 7)

Of the specific algorithms mentioned:

Quicksort has unfavourable worst-case performance at O(n^2), but is a bit more lightweight / less memory-consuming so offers better performance in a typical case.

Mergesort has guaranteed worst-case performance at O(n log n), but carries a bit more overhead and memory requirements. It is also automatically stable (i.e. maintains equal elements in the same order).

The Java designers seem in general to be a bit more conservative / focused on the "right thing" so it's not surprising that they chose Mergesort out of the two since it offers better guarantees.

Not sure why Microsoft chose Quicksort, maybe they though it would make them look better in some micro-benchmarks?


答:
From Michael Scott's Programming Language Pragmatics, Third Edition.

The high-level explanation of compilation is:

The compiler translates the high-level source program into an equivalent target program (typically in machine language), and then goes away. At some arbitrary later time, the user tells the operating system to run the target program. The compiler is the locus of control during compilation; the target program is the locus of control during its own execution.

A high-level explanation for interpretation is:

Unlike a compiler, an interpreter stays around the the execution of the application. In fact, the interpreter is the locus of control during that execution. In effect, the interpreter implements a virtual machine whose "machine language" is the high-level programming language. The interpreter reads statements in that language more or less one at a time, executing them as it goes along.

However, some language implementations also mix compilation and interpretation, so the lines get a little more blurry. In such an instance, the source program is translated into an intermediate program that is run by a virtual machine. The source code is compiled, and the output of compilation is interpreted.

Compilation happens when a translator thoroughly analyzes the input source files and creates some output that does not resemble the original source. That means that compilation requires, according to Scott, "analysis and nontrivial transformations".


答:
C# and C++ are more than different enough that I'd advise just skipping C#. You'll only get into habits that you will have to quickly unlearn once you get to C++- like excessive dynamic allocation and inheritance, for example, and programming to a framework is very different to programming without one. You won't really learn any useful skills.

The two are vastly more different than you appear to realize. Unless you actually will still need the C# version when you're finished in C++, I'd just never make the C# one to begin with.

Title: When would be the best time to start porting the code of my own project?

Body: If I have a personal programming project that I plan to port in another language so it could run in other environments, would it be more ideal to start porting the code as soon as possible and work on two versions concurrently? Or would that slow down my production a lot, and should I wait until I have finished some key components of the program? </p>


问:
C++ Renaissance - marketing slogan?

Possible Duplicate:

  What does the latest “C++ Renaissance” mean?

Lately, I hear a lot about C++ Renaissance. What is that?

C++ is currently undergoing a renaissance. This means that, by definition, the language, compilers and compositional tooling are evolving and coalescing into a state that maximizes native developer efficiency, productivity, and creativity across hardware and software domains.

I agree that C++ needs a lot of improvements, mainly, because it was updated in Neolithic Age (98,03).
What really bugs me is the Build conf. They've showed a few metro style apps written in C++ and XAML - like RSS reader or Piano.

I have a feeling that C++ is an overkill for this kind of apps and only case when I see the advantage is battery power, but is it true? C# as well as C++ calls WinRT which is native and C# has only tiny runtime overhead.

Can someone provide case study or hard data where use C++ in windows 8?

I think it will be status quo (games, servers, OSes, databases, apps like Photoshop will be C++ and other client apps run .Net) and renaissance is just a marketing slogan.

答:
I believe that every senior programmer / architect should watch Herb Sutter's presentation at  C++ and Beyond 2011.

Basically, he claims that .NET and Java indeed offer better productivity. However productivity is not all. Battery power and performance are becoming more important for hand-held devices. For big-data server-farms, if you can squeeze your processing to 1000 cores instead of 2000 cores - you'll save more money on energy and maintenance than the money you'll lose on the extra programming hours.

So both for small and large systems - productivity is not everything, and even not the most important factor. When it comes down to processing power and battery power - C++ wins.

The new C++ standard offers extra productivity, without sacrificing performance. It shifts the balance even more.

OwnerDisplayName: lukas

Title: C++ Renaissance - marketing slogan?


答:
Speaking from experience, you do not want to get yourself caught maintaining two separate versions of your pet program.

Adding new funcionnalities becomes a pain. If you're lucky, it would take twice the time to implement. If you're not, you would find limitations in one language and have disparities between the two versions of the program.

Bug tracking gets very tricky, as you inevitably will have to deal with implementation specific details.

As mentionned C++ anc C# are far more different than they look.

I would suggest you start porting to C++ as soon as possible, as it will probably be easier to port something small and concise.


答:
From practical point of view you can think that something is interpreted as soon as you can do this pseudo code:

```<code>a = 6
b = 7
eval("c = a + b")
print c
</code>```

I will not discuss security issues, best practices when to use and when not to use eval and so on.

JVM and .NET allows (with some call to standard library functions, wrappers and other issues) to compile code on the fly:

```<code>a = 6
b = 7
assembly = my_implementation_of_eval("function sum(x,y) { return x + y} ")
print assembly.call("sum",a,b);
</code>```

But that is just a compiler with ability to dynamically load a module. Compare deep integration to local vars and creating new variables in interpreter.

Body:
From practical point of view you can think that something is interpreted as soon as you can do this pseudo code:

a = 6
b = 7
eval("c = a + b")
print c

I will not discuss security issues, best practices when to use and when not to use eval and so on.

JVM and .NET allows (with some call to standard library functions, wrappers and other issues) to compile code on the fly:

a = 6
b = 7
assembly = my_implementation_of_eval("function sum(x,y) { return x + y} ")
print assembly.call("sum",a,b);

But that is just a compiler with ability to dynamically load a module. Compare deep integration to local vars and creating new variables in interpreter.


答:
I agree that C++ needs a lot of improvements, mainly, because it was
  updated in Neolithic Age (99).

C++ was never updated in 99. The first C++ Standard was 98. And then another one in 2003. And a new one has just come out this year. That's not exactly neolithic. More importantly, it's worth noticing that programming techniques that C++ had since well before 98 have, relatively speaking, only just come into .NET languages, like generics and functional APIs. C++ has had templates for vastly longer than generics have existed in C# - and generics aren't even as powerful as templates. Arguably, it's C# that's playing catchup, decades later.

I have a feeling that C++ is an overkill for this kind of apps

Overkill how? Apart from the idea that some people might prefer C++ for subjective reasons (which I could give a dozen of if you're interested), plus the fact that it doesn't require a 100MB install to get running on a consumer's computer, for example, or works on many more platforms than C#.

And C#'s runtime overhead is not tiny. At all. In fact, the smaller the app, the greater the proportion of time is spent just loading up the CLR.

As far as I can tell, the fundamental problem is that Microsoft has two divisions - WinDiv and DevDiv, I believe.

WinDiv can't be bothered and feels compelled to lump C++ in with another language- first it was C with the Win32 API, and now it's C# with the Metro APIs, which are C++ APIs only in the sense that technically, they're compiled by a C++ compiler and actually have very little in common with a C++ design. In addition, WinDiv doesn't learn from their mistakes- for example, even in the new Metro APIs, you can't mix Metro controls and DirectX rendering. Seems to be the kind of thing you would have fixed after the airspace problems with the previous generation of native controls.

DevDiv on the other hand seems to actually know wtf they're doing, for example, see the Concurrency runtime in Visual Studio 2010 and C++ AMP in vNext, which are awesome. They also produce some pretty sweet tools- the IDE improvements for C++ in vNext are quite good, and AMP is a big deal, even if unfortunately, that means few new C++11 features.

The problem is that WinDiv produces a lot more content than DevDiv, for example, sockets and UI libraries. So there is a C++ renaissance- it just only applies to the stuff that the unfortunately tiny DevDiv library team managed to paste over the WinDiv stuff.

Title: C++ Renaissance - marketing slogan?

Body:
Possible Duplicate:

  What does the latest “C++ Renaissance” mean?

Lately, I hear a lot about C++ Renaissance. What is that?

C++ is currently undergoing a renaissance. This means that, by definition, the language, compilers and compositional tooling are evolving and coalescing into a state that maximizes native developer efficiency, productivity, and creativity across hardware and software domains.

I agree that C++ needs a lot of improvements, mainly, because it was updated in Neolithic Age (98,03).
What really bugs me is the Build conf. They've showed a few metro style apps written in C++ and XAML - like RSS reader or Piano.

I have a feeling that C++ is an overkill for this kind of apps and only case when I see the advantage is battery power, but is it true? C# as well as C++ calls WinRT which is native and C# has only tiny runtime overhead.

Can someone provide case study or hard data where use C++ in windows 8?

I think it will be status quo (games, servers, OSes, databases, apps like Photoshop will be C++ and other client apps run .Net) and renaissance is just a marketing slogan.


答:
Literate Programming.

The practitioner of literate programming can be regarded as an
  essayist, whose main concern is with exposition and excellence of
  style. Such an author, with thesaurus in hand, chooses the names of
  variables carefully and explains what each variable means. He or she
  strives for a program that is comprehensible because its concepts have
  been introduced in an order that is best for human understanding,
  using a mixture of formal and informal methods that reinforce each
  other.

If you're writing a paper (or book or report or document) about your project, then you tend to stay on task.

Start with an outline of what you're doing: use case overview, release 1, release 2, release n.  Write down an summary of the use cases.  Prioritize them.  Get them into sprints and releases.

Each release has a use case view, logical view, processing view, component view, deployment view.   For the sprint, detail the use cases.  Publish the HTML document to show what you're going to do.  After detailing the use cases for the sprint, write the logical model.  Write code to support this.  Write the processing documentation.  Write code to support it.   Create modules.  Write the component view documentation.  Write the tests and supporting documentation.  Publish the sprint results as an HTML document.

Repeat for each sprint.  Review and edit your document from time to time.

There are lots and lots of literate programming tools.  They can help you produce a source that creates the documentation and the code both from a single text.

I use sphinx and PyLit but that's because I'm a Python programmer.

Title: Methodologies/tools for when developing on your own

Body:
Suppose you have to develop a medium+ sized software, fully on your own. Like if it was a personal project you want to accomplish.

What methodologies/tools would you use to define what needs to be developed, learned and have a global idea of what the system is as well in its details?

Basically to keep yourself in track and not get lost on the way.


答:
Dashboards are a dime a dozen. Your employer never owned the IP on that idea. Your employer did own the copyright on the specific implementation.

You can write the new code from scratch. That means the work is not a derived work. It's smart to keep notes so you can prove this.


答:
I'm going to go against the grain here a little bit here...

You've got a new job. You had good reasons to leave the last place and go find a new job - whether it be topic, pay, conditions, lack of career progression opportunities, etc.

Your new job requires 100% of your attention while you're there. If they sense you are 'moon lighting' by keeping the old job going, they'll be annoyed and you'll be in trouble. Do you want this?

As you've already left your previous job, if the post matters to them, they'll be looking to hire someone to take over from where you left off.

If not, they'll be looking to get away from whatever projects you were keeping going before you left.

Either way, the amount of work your previous employer has for you to do is probably quite low and you will have to give up your evenings and weekends to work for them, so you are perfectly entitled to charge whatever you like for contract rates, but please bear in mind the following:

Whatever you charge (say $180/hour), you have to deliver good value on this. You are not going get paid to read email or do on-line learning.

Emails and phone calls to arrange, hand-over, clarify the work shouldn't really be billed, but use some common sense here.

No expenses claims - how much is a phone call, really?

Good luck!

Title: Quit my job (for a new job). Old job wants me to be available for contracting. Steps to take?

Body:
The company I am leaving has asked that I make myself available to answer questions and/or debug programs occasionally should the need arise. I'm not opposed to this. After searching google for some kind of standard contract for this sort of thing, I didn't see any.

Is there a standard contract for this sort of thing that you use?

Are there any other steps I should take to ensure this kind of arrangement works smoothly?


答:
I'm going to deviate from the main topic to say that I feel all this is really sad.

Now on the question:

If you were a carpenter making pieces of furniture, and the former company provided you with blueprints and designs, then you get hired by another company, clearly you are in trouble if you start making exactly the same stuff.

If your former company only bought the product of your work, and you designed and "invented" them (and you can prove it) then the law should be with you.

The moral of the story: next time do it open source from the beginning.


问:
Tabs versus spaces—what is the proper indentation character for everything, in every situation, ever?
The coding standards for the code hosted in drupal.org suggest to use two spaces to indent the code; other sites suggest to use tabs to indent the code.

What is the proper indentation character for everything, and in every situation? Please explain the answer you give.

答:
Neither is better, neither is worse. The only important thing is to be consistent.

If you are a team of one, pick whatever you personally like. Consider what the default behavior of your favorite editor, but pick whatever you like.

If you are on a team, do what the team does. Period.

In my various jobs I've used two spaces, four spaces, eight spaces, tabs, spaces-and-tabs, I think I may have also used one space. I tell my editor what to do then I don't think about it again, the editor works out the details.

The only other thing is to make sure you pick a smart editor. Emacs or vi? Now that's a holy war I'm willing to fight :-)


答:
Treat it like a real software project (because it is one). There are only a few things that change because the number of developers is one. You still need source control. You still need a way to organize features to be added an bugs to fix. You still need automated test to check that you don't create regressions in the code. You should also have an automatic way to compile the code (if necessary), run the tests and view the reports.

I am working on a personal project just like you described. I'm using Git, Redmine, JUnit, and Jenkins to satisfy all the categories I described. My work flow is:

Pick a ticket to work on

Branch the code base

Develop code and tests for the task (commit changes to the branch at good save points)

Merge branch back to trunk

Verify that the build was successful, the tests passed and there were no other issues

Repeat

Keeping everything managed and organized is just as important as when there are many developers. With many developers, you need to organization so information is spread to everyone. When it is just you, you already have all the information, but remembering every part of the system is hard. A managed system makes it easier on you and you can focus on the task at hand.


答:
A Compiler usually translates something from language A to language B. Language B can be machine code (for an existing or virtual CPU), but there are compilers that output source code in a different language.

An Interpreter usually executes a program written in language X.


答: I log to a central log file using syslog, as well as a local file per-server (in case syslog fails). Then offline I import the centrally logged files into a database for analysis (usually applying some kind of transformation - e.g. tallying events, etc), depending on requirements.</p>


问:
What traits do the best testers you've worked with have in common?
Tester and blogger Lanette Creamer recently posted this question on Twitter:

If you are a professional software developer who works with testers, think of the best testers you know. What traits do they have in common?

I thought it would make an excellent question for here.

My thoughts are:

They want to remove ambiguity from requirements even if it means asking awkward questions.

They create new features by seeing the way software "should" work, rather than just how it's documented.

They demonstrate honesty and integrity and encourage but not demand it from those around them. In other words, they model behavior.

What are the traits of the best testers you've worked with?

答:
The best tester I ever worked with was extremely good at one thing: breaking software in a repeatable way. We could give him pretty much any software and he'd kill it within minutes. He's got the kind of skills that could probably find cheat codes on Nintendo games and Easter Eggs in professional software - just a natural, inquisitive nature and a good memory for what he tried before and didn't work.

Note that his goals were the exact opposite of the programmers - he had a good day if he broke the software; the programmers had a good day if he didn't.


问:
Five or fewer tips to writing good JavaScript?
JavaScript has obviously become pretty indispensable; however, I'm still new to it, and I've found it's hard to fight the feeling that it seems such a mess and I don't want to deal with it right now. I'm much further in my understanding of other languages than I am with JavaScript, because I can't seem to get a handle on this fear. I get a feeling that, when I'm writing JavaScript, I'm trying to paint a portrait of Weimaraner puppies.

It usually helps me to keep a handful of the most important directives in mind that I can ask myself for each move I make. (To my mind, a handful is five or less.)

Can you list five (or fewer) questions specific to JavaScript I should ask myself for each move I make, when I'm coding JavaScript? What would they be?

Update: to clarify, I'm not asking for five things to keep in mind when learning JavaScript; I'm asking for five questions to always ask myself going forward, that everyone should alsways ask. High-level questions like: "Am I likely to repeat this somewhere else?" or "is this variable/function name specific enough (or too specific)" <== except these example questions are not peculiar to JavaScript. I'm looking for directives that are peculiar to JavaScript.

答:
Read Douglas Crockford's Javascript: The Good Parts. That's quite a tip, but honestly, its the best piece of advice I've ever heard for writing good javascript.

Relatedly, read Douglas Crockford's articles on Javascript.


答:
Here are some questions that should get you going on JavaScript.

How does JSON work and what is it good for?

Why are functions objects in Javascript?

Why shouldn't I use eval?

How do I create events in javascript?

How do I feature detect in javascript?

Pretty much covers most things you need to do in Javascript.

Title: Five or fewer tips to writing good JavaScript?

Body:
JavaScript has obviously become pretty indispensable; however, I'm still new to it, and I've found it's hard to fight the feeling that it seems such a mess and I don't want to deal with it right now. I'm much further in my understanding of other languages than I am with JavaScript, because I can't seem to get a handle on this fear. I get a feeling that, when I'm writing JavaScript, I'm trying to paint a portrait of Weimaraner puppies.

It usually helps me to keep a handful of the most important directives in mind that I can ask myself for each move I make. (To my mind, a handful is five or less.)

Can you list five (or fewer) questions specific to JavaScript I should ask myself for each move I make, when I'm coding JavaScript? What would they be?

Update: to clarify, I'm not asking for five things to keep in mind when learning JavaScript; I'm asking for five questions to always ask myself going forward, that everyone should alsways ask. High-level questions like: "Am I likely to repeat this somewhere else?" or "is this variable/function name specific enough (or too specific)" <== except these example questions are not peculiar to JavaScript. I'm looking for directives that are peculiar to JavaScript.


答:
Always use semicolons. Implicit semicolons (in JS) are a horrible idea, especially with some of the interesting syntax floating around in common usage. They are also generally required by any JS minifier.

Avoid eval(). This causes all sorts of problems, and is a very quick way to slow down your application. Most uses are actually abuses. Every time you think you need to use eval(), double and triple check for another way; there is almost always a cleaner, easier way unless you are actually trying to execute an entire string worth of JavaScript.

(function() {/* stuff */})() is a good way to encase a set of code and create a local scope for it. Using objects is another, often better, way; objects are more analogous to namespaces in other languages when used in this way. Just watch out for this. Unlike most other languages, this doesn't always reference what you might intuitively think it does. Also remember that unless otherwise specified all JS variables, functions and other objects are all global, even across multiple .js files.

Find and learn/use a good JS library. jQuery is one of the more popular ones. These will do a lot of the heavy lifting for you including things like feature detection and abstracting away DOM manipulation and the multiple ways different things have been implemented in different browsers.

Always use semicolons. Seriously. Get an IDE that warns you when you forget them. I don't want to sound ranty, but there's been a few times where bugs have been introduced just for the lack of a semicolon and the browser won't warn you about these.

ContentLicense: CC BY-SA 4.0


答:
I'm going to answer this in two parts. One is "Five or fewer tips on learning to write good JavaScript". The other is "Five or fewer tips on writing good JavaScript".

Learning:

Ask Questions

Listen

Read

Make Stuff

Doing:

Avoid globals (modularize)

Do the hard stuff outside of loops (DOM selection, function declarations, etc.)

Learn how scope works

Learn when and how to use closures

Learn how Object Oriented JS works

EDIT (adding questions to comply with the OP):

What scope am I referencing?

This should help with leaked globals, event handlers, and when to use closures.

Am I repeating myself?

Proper abstraction and use of OO techniques is important. Use them wisely.

Is my code repeating itself?

It is remarkably easy to find yourself putting DOM access into a loop, or creating functions (anonymous or otherwise) in a loop. Note that this can be true of code that uses setTimeout or setInterval as well as traditional loops.

Does this mean what I think it means?

Truthy and falsy values in JS can be a little tricky, especially when using non-strict comparisons (== as opposed to ===). Dynamic typing, type coercion, and whether you're referencing objects or literals can be relevant as well.


答:
Of course it is a marketing slogan, but it shows that Microsoft is (again) committed to support native code as a first class citizen on the new platform.

Whether it is of any interest to you personally, that is another question - if you prefer some other language and it does the job for you, feel free to ignore the "C++ Renaissance".

Title: C++ Renaissance - marketing slogan?


问:
How do you put different versions of your library under version control? Do you use tags? Or branches? Or another method?
I have recently started putting my code under version control (in the lab I'm working, under SVN, and my own codes in github (obviously with git)). Before using version control, I used to do something like this. I had a folder with the name of the library, inside many folders with the version number. Every time I wanted to start working on a newer version, I would make a copy of the last version, change the name to the new version and start implementing.

This however seems way redundant when the folder is put under version control. Apart from redundancy, if someone wants to get the latest version, they would be downloading all versions if they just import/clone.

Now I see many ways to doing this with version control but since I'm new to it, I don't know which would be more maintainable.

Method 1: Using tags

If I understood tags correctly, you would have your main branch, you commit whatever change you got and tag them with a version. Then, when you want to get a working copy of it, you get the one with a certain tag. (correct me if I'm wrong)

Method 2: Branching versions

In this method, the main branch would be the development branch. Every now and then that a stable version is made (let's say v1.2.0), you create a branch for that version and never commit to it. That way, if you want to download a certain version, you get the code from that branch. Although I said you never commit to it, it may be possible to do bug fixes and commit to an old version's branch to keep the old version running. For example if the current version is v2.0, but there are people who want to use v1.2, you can get another branch from v1.2, namely v1.2.1 and commit the bug fixes, or just keep the version the same as v1.2 and just commit the bug fixes.

So the branches would look like this:

```<code>                  v1.2.1  v1.2.2
                 /       /
 v1.0.0   v1.2.0---------     v2.0.0
/        /                   /
-------------------------------------- dev
</code>```

This way you have branches for every minor version update. (Note that in the graph above, v1.2.1 and v1.2.2 or created after v2.0.0 was released, so they were not part of the development between v1.2.0 and v2.0.0. Think of it as support for older versions)

Method 3: Branching development

This method is the opposite of the previous. The main branch would be the latest stable version. Whenever you are working on a new version, you create a branch (for development), work on your code and when it is stable, merge it with the main branch.

In this case, the branches would look like this:

```<code> ________  ____  ________________  _____ dev
/        \/    \/                \/
---------------------------------- latest_version
</code>```

Probably this one needs to be done in conjunction with tags right?

The question!

Anyway, my question is that based on your experience, which of these methods proves more practical? Is there a known best method out there (that possibly I didn't figure out myself)? How are these things commonly done?

答:
I had a folder with the name of the library, inside many folders with the version number.

This is effectively, as you note, a wrong approach, since you have already the version control to... control the versions.

Now, different techniques you enumerate seem all equally right. You can read a very detailed article, Source Control Done Right, which includes information about tags and branches.


答: You left. They obviously don't manage well, and hadn't balanced the risk of you leaving against the potential loss of productivity your departure leaves them faced with. You don't owe them any favours, and frankly, a new job generally needs all your attention especially if it's a full-time position. I'd be really unhappy if I found that one of ours is moonlighting. I wouldn't bother with it. You've left that mess behind, right?</p>


答:
Tags and branches aren't mutual, you can (and IMO usually should) use them both. Tags are there to mark milestones in development. E.g. you open a branch for version 1.2 of your product, and you mark v1.2 Beta, RC1, RC2, Final (and then, if needed, SP1 etc.) with tags on that same branch.

I personally prefer Method 2 as the default approach (although I try to avoid multiple levels of branches, to keep life as simple as possible). Method 1 is just not going to work in real life - tags aren't enough, you need branches. And method 3 is inflexible in that it has only a single stable version at all time, so (unless you combine it with Method 2), you can't maintain multiple (latest and older) versions in parallel. This is required for almost all projects in real life - while you are working on version 2, you should still be able to publish patches / upgrades for v1.9, and often even earlier versions. A lot depends on the type of application of course. We develop a web app, so there is only one production version at any given point in time, still we often juggle with 3 different versions (one in production, one is in UAT getting ready for deployment, one is the latest version on the trunk). It can get way more complex for a desktop/client app with multiple older versions being used - and maintained - in parallel.

Title: How do you put different versions of your library under version control? Do you use tags? Or branches? Or another method?

Body:
I have recently started putting my code under version control (in the lab I'm working, under SVN, and my own codes in github (obviously with git)). Before using version control, I used to do something like this. I had a folder with the name of the library, inside many folders with the version number. Every time I wanted to start working on a newer version, I would make a copy of the last version, change the name to the new version and start implementing.

This however seems way redundant when the folder is put under version control. Apart from redundancy, if someone wants to get the latest version, they would be downloading all versions if they just import/clone.

Now I see many ways to doing this with version control but since I'm new to it, I don't know which would be more maintainable.

Method 1: Using tags

If I understood tags correctly, you would have your main branch, you commit whatever change you got and tag them with a version. Then, when you want to get a working copy of it, you get the one with a certain tag. (correct me if I'm wrong)

Method 2: Branching versions

In this method, the main branch would be the development branch. Every now and then that a stable version is made (let's say v1.2.0), you create a branch for that version and never commit to it. That way, if you want to download a certain version, you get the code from that branch. Although I said you never commit to it, it may be possible to do bug fixes and commit to an old version's branch to keep the old version running. For example if the current version is v2.0, but there are people who want to use v1.2, you can get another branch from v1.2, namely v1.2.1 and commit the bug fixes, or just keep the version the same as v1.2 and just commit the bug fixes.

So the branches would look like this:

```<code>                  v1.2.1  v1.2.2
                 /       /
 v1.0.0   v1.2.0---------     v2.0.0
/        /                   /
-------------------------------------- dev
</code>```

This way you have branches for every minor version update. (Note that in the graph above, v1.2.1 and v1.2.2 or created after v2.0.0 was released, so they were not part of the development between v1.2.0 and v2.0.0. Think of it as support for older versions)

Method 3: Branching development

This method is the opposite of the previous. The main branch would be the latest stable version. Whenever you are working on a new version, you create a branch (for development), work on your code and when it is stable, merge it with the main branch.

In this case, the branches would look like this:

```<code> ________  ____  ________________  _____ dev
/        \/    \/                \/
---------------------------------- latest_version
</code>```

Probably this one needs to be done in conjunction with tags right?

The question!

Anyway, my question is that based on your experience, which of these methods proves more practical? Is there a known best method out there (that possibly I didn't figure out myself)? How are these things commonly done?


答:
```<code>alert('This illustrates how JavaScript has first-class functions');
alert('It also illustrates how to use closures.  Try running this code in your browser.');

var funky = function(s) {
    alert("We're getting funky with " + s);
};

var makeFunkyObject = function(funkyFunction) {
    var numberOfTimesAlerted = 0;
    var fn = { };
    fn.alertFunky = function(s) {
        funkyFunction(s);
        numberOfTimesAlerted++;
    }
    fn.getNumberOfTimesAlerted = function() {
        return numberOfTimesAlerted;
    }
    return fn;
}

var funkyObject = makeFunkyObject(funky);

funkyObject.alertFunky('Alice'); // alerts We're getting funky with Alice
funkyObject.alertFunky('Bob'); // alerts We're getting funky with Bob
alert(funkyObject.getNumberOfTimesAlerted()); // alerts 2

alert('Also, be sure to distinguish between learning about JavaScript and learning about the DOM');
alert('The former is awesome; the latter, not so awesome.');
</code>```


答:
I would use Method 2. I've used this and found it to be an effective way to manage and maintain multiple versions while still allowing current development to move forward. You can also use tags in conjunction with this method if you need them.

See my answer here for more information on using branching to maintain multiple release versions.