答:
What are the key aspects and contents of a good coding standards document?

Being supported by tools which enable automated checking of the code. If I know that I can't commit to version control any piece of code which doesn't match some rules, I would be encouraged to follow those rules in my code. If, on the other hand, some fellow programmer have written somewhere that I need to follow a rule, I don't give a crap about those rules.

Being well thought-out, instead of being your personal opinion. You don't plainly say: "from now on, we don't use regions any longer, because I don't like regions." Rather, you would explain that regions encourage code growth and don't solve any major problem.

The reason is that in the first case, your fellow colleague would answer: "well, I like regions, so I would still use them". In the second case, on the other hand, it would force people who disagree to come with constructive criticism, suggestions and arguments, eventually making you change your original opinion.

Being well documented. Lack of documentation creates confusion and room for interpretation; confusion and possibility of interpretation lead to style difference, i.e. the thing standards want to suppress.

Being widespread, including outside your company. A "standard" used by twenty programmers is less standard than a standard known by hundreds of thousands of developers all around the world.

Since you're talking about StyleCop, I suppose that the application is written in one of the .NET Framework languages.

In that case, unless you have serious reasons to do differently, just stick with Microsoft's guidelines. There are several benefits in doing it rather then creating your own standards. Taking the four previous points:

You don't need to rewrite StyleCop rules to fit your own standards. I don't say it's hard to write your own rules, but if you can avoid doing it, it means you have more time doing something useful instead.

Microsoft's guidelines are very well thought. There are chances that if you disagree with some of them, it might be because you don't understand them. This was exactly my case; when I started C# development, I found a few rules totally dumb. Now, I completely agree with them, because I finally understood why they were written this way.

Microsoft's guidelines are well documented, so you don't have to write your own documentation.

New developers who will be hired in your company later may already be familiar with Microsoft's coding standards. There are some chances that no one will be familiar with your internal coding style.

Title: Creating a coding standards document

Body:
I work in a control systems company, where the primary work is SCADA and PLC, along with other control systems stuff.

Software development is not really something the company does, apart from little bits here and there, until there was a decision to create an internal project management and appraisal system.

This project has been taken on by people who came here as software people originally and we are mostly junior.

The project started off small, so we only documented stuff like design, database stuff etc, but we never really agreed upon a coding format/conventions.

We started using StyleCop to make sure we had well documented code, but I feel we need an official document for coding conventions/practices so we can continue a good standard and if there is any more major development work in the future, whomever works on it has a good baseplate.

Therein lies the problem, I have no idea how to draft up a document for coding conventions and standards, all I can think of is examples of good vs bad practice (for example camel case when naming variables, avoiding Hungarian notation etc) we are all competent enough programmers (apparently) but we just don't have a charter for this kind of stuff.

To put a point on it, my question is: What are the key aspects and contents of a good coding standards document?


问:
Creating a coding standards document
I work in a control systems company, where the primary work is SCADA and PLC, along with other control systems stuff.

Software development is not really something the company does, apart from little bits here and there, until there was a decision to create an internal project management and appraisal system.

This project has been taken on by people who came here as software people originally and we are mostly junior.

The project started off small, so we only documented stuff like design, database stuff etc, but we never really agreed upon a coding format/conventions.

We started using StyleCop to make sure we had well documented code, but I feel we need an official document for coding conventions/practices so we can continue a good standard and if there is any more major development work in the future, whomever works on it has a good baseplate.

Therein lies the problem, I have no idea how to draft up a document for coding conventions and standards, all I can think of is examples of good vs bad practice (for example camel case when naming variables, avoiding Hungarian notation etc) we are all competent enough programmers (apparently) but we just don't have a charter for this kind of stuff.

To put a point on it, my question is: What are the key aspects and contents of a good coding standards document?

答:
The first important thing to note is that a coding standards document is not about right and wrong. It's not about good and bad or which method is better.

A coding standards document's purpose is to make sure that all code is designed, written and laid out the same to make it easier for a developer to switch from one persons work to another without the needed change of mentality to read someone else's style.

It's all about uniformity, and nothing about "Right and wrong"

With that in mind some things you should clarify in a coding standards document are:

Naming Conventions

How will you name your methods, variables, classes and interfaces? Which notation will you be using?

Also something else included in our standards was a split off standards for SQL, so we had similar names for tables, procedures, columns, id fields, triggers, etc.

Indentation

What will you be using for indentation? A single tab? 3 spaces?

Layout

Will braces be kept on the same line as the opening method line? (generally java)
or on the next line or a line of its own? (generally C#)

Exception Handling / Logging

What are your standards for exception handling & logging, is it all home grown or are you using a third party tool? How should it be used?

Commenting

We have standards to dictate grammatical correctness, and that comments begin on the line before, or after, not on the same line, this increases readability. Will comments have to be indented to the same depth as the code? Will you accept those comment borders used around larger texts?

How about the \\\ on Methods for descriptions? Are these to be used? When?

Exposure

Should all of your methods and fields be implementing the lowest level of access possible?

Also an important thing to note. A good standards document can go a long way in helping review code, does it meet these minimum standards?

I've barely scratched the surface of what can go into one of these documents, but K.I.S.S.

Don't make it long, and boring, and impossible to get through, or those standards just wont be followed, keep it simple.

ContentLicense: CC BY-SA 3.0

Title: Creating a coding standards document


问:
how safe/sane is it to use git for deployment on my webapp production server?
I started with sftp, then switched to WebDAV and I'm currently using rsync through ssh to deploy any updates/upgrades from my development server into my production server.

I'm still not very happy using this system and think using git to deploy may be better, mainly because of the possibility of rolling back any changes instantly with just one command.

Appart from using ssh tunnel to pull and push to the production server (leaving the git service behind the firewall), I've also realized I have to edit .htaccess to deny web access to .git folder.

Is this the correct approach, should I check anything else, do something in a different way, or should I go in a totally different direction?

答:
That depends on your exact way of doing it. Right now it seems to me you have a git repo in your httpdocs that you deploy to, basically using HEAD as your actual website - that is NOT the correct way. I'm not sure how you are able to push to this configuration at all?

What you want to do is use a bare repo somewhere outside the httpdocs-folder, and checkout the files to httpdocs after pushing. While this sounds complicated, its pretty easy to do, here is a step-by-step tutorial: http://caiustheory.com/automatically-deploying-website-from-remote-git-repository

If your webserver needs access to some files, such as a wordpress installation, you need to add chmod and chgrp commands to the post-receive hook, otherwise your files belong to the wrong user (the one you used to push the commit, not the webserver).

Simply make a new script to change ownership that you call from the post_receive hook via sudo scriptname.sh  (name it change_own.sh or whatever) :

```<code>chown -R wwwrun /path/to/httpdocs
chgrp -R www /path/to/httpdocs
</code>```

and allow the script to be run without password via visudo by adding gituser ALL=(ALL) NOPASSWD: /path/to/change_owner.sh at the end.

Assumptions made: wwwrun - webserver user; www - webserver group; gituser - user to push commits

Addendum: A friend used this method and complained about how he had to update Wordpress over and over again. The obvious reason is that if the Webapplication updates itself, und thus replaces its code, these changes will not be transferred back into the repository, because the hook only works one way. Thus after each commit, the hook overrode all changes the Wordpress-Installation made through updates. The imho quickest workaround is to run the updates on the developer machine, then commit to deploy.

Body:
That depends on your exact way of doing it. Right now it seems to me you have a git repo in your httpdocs that you deploy to, basically using HEAD as your actual website - that is NOT the correct way. I'm not sure how you are able to push to this configuration at all?

What you want to do is use a bare repo somewhere outside the httpdocs-folder, and checkout the files to httpdocs after pushing. While this sounds complicated, its pretty easy to do, here is a step-by-step tutorial: http://caiustheory.com/automatically-deploying-website-from-remote-git-repository

If your webserver needs access to some files, such as a wordpress installation, you need to add chmod and chgrp commands to the post-receive hook, otherwise your files belong to the wrong user (the one you used to push the commit, not the webserver).

Simply make a new script to change ownership that you call from the post_receive hook via sudo scriptname.sh  (name it change_own.sh or whatever) :

chown -R wwwrun /path/to/httpdocs
chgrp -R www /path/to/httpdocs

and allow the script to be run without password via visudo by adding gituser ALL=(ALL) NOPASSWD: /path/to/change_owner.sh at the end.

Assumptions made: wwwrun - webserver user; www - webserver group; gituser - user to push commits

Addendum: A friend used this method and complained about how he had to update Wordpress over and over again. The obvious reason is that if the Webapplication updates itself, und thus replaces its code, these changes will not be transferred back into the repository, because the hook only works one way. Thus after each commit, the hook overrode all changes the Wordpress-Installation made through updates. The imho quickest workaround is to run the updates on the developer machine, then commit to deploy.


问:
What's the best documentation you produce and why?
I think it's safe to assume that for most programmers, producing documentation is not as fun as actually coding. I think it's also safe to assume that most good programmers recognize the need for useful documentation, and the code that they write is not an exception by any stretch of the imagination.

So, I'd like to know: what's the best documentation you produce (and source code doesn't count). Answer can be anything from comments to unit tests.

The bigger question is why is that the best documentation you produce?

答:
One of my pets peeves is the absent-or-afterthought nature of the documentation that goes along with virtually all open source software. While I think that it is great that other engineers release their code so that I can avoid reinventing the wheel, it is teeth-grindingly frustrating to find the code accompanied by nothing but a README file with little or no usage examples.  Yes, I can read the source code, but code examples and some thoughts about the code strengths and liabilities would make all the difference in the world.

So, when I ventured into making my own projects open-source, I didn't release the code until I had written thorough documentation including extensive code samples, a step-by-step implementation guide and a real API reference. I did it in TiddlyWiki, a self-contained Wiki in a single HTML file, and I even used tags and built an index.

It was a lot of work, and it was not the kind of work that I really enjoy (coding), but it seemed irresponsible not to include truly useful documentation, and in the end, I did it because I was proud of the project. I wanted it to be of the greatest possible use to my peers.

ContentLicense: CC BY-SA 2.5


问:
In a functional requirements document, is the Assumptions section dangerous?
I am currently a reviewer on a Best Practices document for Developers or Business Analysts in writing a Functional Requirements document.  This document is not necessarily a template for functional requirements documents, but a guide to what elements are necessary, optional, and dangerous to include a Functional Requirements document.

The author of the document states that:

Functional Requirements documents should NEVER have an Assumptions section!  Do not assume anything about what people know about this application or any external issues surrounding it.

I am not sure that I agree with this sentiment but don't really have the words to refute it either.  In a perfect world the analyst will have time to properly analyze every stakeholder input and every possible external issue but inevitably due to time constraints and other issues some assumptions need to be made.

Is this a bad idea because it is too easy for the intellectually lazy to declare assumptions rather than requirements?  If not then why do you think Assumptions are a good idea?

EDIT: To clarify, I am not asking about the Assumptions section of technical documentation but of an Assumptions section in a requirements document written by a non-technical business analyst.

答:
If you don't have an assumptions section you will just have the unknown assumptions of the programmers while they were coding.

You have to constantly make deliberate and unconcious assumptions when you are building something - you might as well have them written down.


问:
Etymology of "String"
So it's obvious that a string of things is a sequence of things, and so a sequence of characters/bytes/etc. might as well be called a string. But who first called them strings? And when? And in what context such that it stuck around? I've always wondered about this.</p>

答:
Can we get a real citation before Hugo's 1963 reference? Yes. John McCarthy used the word "string" in Recursive functions of symbolic expressions and their computation by machine, Part I, from April 1960.

For atomic symbols, we shall use strings of capital Latin letters and digits…

but more usefully for this question, a reference to a string as a datatype:

Any string of admitted characters [is] an L-expression.

That's not a great example. By saying "a string of characters", McCarthy is not using "string" in the specialised sense programmers mean it today. You can easily say "a string" to a Java programmer and they'll know that the "of characters" part is implicit: McCarthy's use doesn't demonstrate this feature. Let's try to push back to the 1950s, to see whether McCarthy was playing it safe or whether the term genuinely didn't exist then. LISP probably isn't going to help much here, as it's based on a mathematical calculus so McCarthy's string functions may have been the first application of the idea to string processing.

An important string-processing system of the 1960s was 1964's SNOBOL, A String Manipulation Language. This cites McCarthy's paper above, but also discusses COMIT and SCL. The work they cite on SCL is unpublished: an unfortunate dead end.

COMIT is easier to track down. The Art of Computer Programming (Volume 1, third edition, p.461) tells us that V. H. Yngve wrote a 1963 CACM article on it. But I'm looking for the earliest use of "string", so I'll do an author search for earlier publications.

The first I can find is A Programming Language for Mechanical Translation, from July 1958. This only contains one use of the word "string":

Each continuous string of letters between punctuation marks or spaces is looked up in the dictionary.

Again, this use is like McCarthy's: this is not evidence for "string" being used in its present day sense. Looking at the paper in detail, we see that the data structure is a "line" on a card (allowing for continuations for longer "lines").

OK, we'll move forward in COMIT's history and see what we can get. The first useful reference is The COMIT system for mechanical translation, from the proceedings of a June, 1959 conference.

If we want to replace D SIN(F) by COS(F) D (F), where F is unrestricted and may be any arbitrary sequence of constituents, we use the notation $ to stand for this string.

This seems more akin to the way we use it today: "string" stands alone and as a bonus has a recognisable special symbol: the dollar sign is still used in some BASIC flavours to signify a string variable.

From around this time, the word "string" also appears many times in A command language for handling strings of symbols by Perlis and Smith from the ACM '58 Proceedings, and once in The Share 709 System: Machine Implementation of Symbolic Programming by Boehm and Steel.

Searching the ACM digital library for 'string' in the early 1960s yields 62 results, including titles like "String handling in ALGOL", "String Manipulation in the New Language" and "A list-type storage technique for alphanumeric information". It seems that the idea has become entrenched by then.

I would argue that "string" in its computer science jargon sense as an ordered list of characters became common over a couple of years around 1960. Before that, authors like Yngwe and McCarthy could say "string of characters" and be sure that they were understood, but could not use "string" as a bare word in the sense it's used today.

The shorthand was probably introduced to the computing mainstream by the Perlis and Smith paper. It hasn't been widely cited, but one important citation is Syntactic and semantic augments to ALGOL by Joseph W. Smith in April 1960 (in the same issue of CACM as McCarthy's description of LISP). From that paper:

The purpose of this paper is to propose a set of syntactic and semantic augments to ALGOL. The proposed extensions are designed to facilitate the description of "string" manipulation in that language; they do not constitute a comprehensive language for symbol manipulation.

To me, this constitutes evidence of "string" meaning a datatype for symbolic computation being affirmed in the academic lexicon, and importantly introduced to the tools used for commercial computation.

Incidentally, Programming Languages: History and Future by Jean Sammet (1972) suggests that COMIT and SNOBOL were the progenitors of string manipulation, so I'm fairly confident that there won't be earlier examples.

Title: Etymology of "String"


问:
What do small business people do with regards to 'legal' when selling software
For those who have sold software successfully over the Internet, after going to the effort of writing the software, creating a website, get a domain name, hosting the website, setting up a merchant facility, creating a trial version, etc - what do you do about the legal aspect of allowing the version downloaded from the Internet to be used only within the intended scope.  That is from the perspective of say:-

each workstation, or server, or CPU, etc counts as a CAL

Development Vs Evaluation Vs Production

support and upgrades

not allowing the user to on-sell

disallow modifying/extending

Is there a standard procedure / contract for this - i.e. are there documents in the public domain for this or can I take one from another software vendor, tailor it, etc.  Or, do I need to hand crank it - i.e. get an accountant/legal-person to write it up

答:
...what do you do about the legal aspect of allowing the version downloaded from the Internet to be used only within the intended scope

One does not allow a version to be downloaded from the Internet to be used only within the intended scope.  Produce a product that can only be used within the intended scope because users will not oblige themselves to your software license if they can re-purpose your software for other means.

In general, a software license is just words and numbers, glossed over and skipped during installation or never read altogether.  Though legally binding under the DMCA, it is better to ensure any functionality you desire to and desire not be designed upfront.

The only good a software license represents is to prevent your intellectual property from becoming mine. However, I can always run your software and produce a competing product off your ideas from what I see (not from code through de-compilation).

Thus, try to protect yourself as much as you can to the extent of your resources and the law.

Is there a standard procedure / contract for this - i.e. are there documents in the public domain for this or can I take one from another software vendor, tailor it, etc. Or, do I need to hand crank it - i.e. get an accountant/legal-person to write it up

Depends upon what you are trying to achieve.  From your question within the bulleted section, you would need to tailor your software and your software licenses to support those but know it is not entirely possible to constrain user action in all circumstances.  Microsoft can certainly attest to that but they have the means to legally prosecute infringements and that, I think, is where you should focus.

Certainly get legal counsel or advice from a trusted source and do whatever else you feel necessary.


答:
Adhering to the recommended guidance to exclude assumptions from a functional requirement document depend on a few things.

First, how strict is the culture and the project?

Sometimes recommended practices are treated as defacto required practices.  It is 'good practice' to ensure how strongly such things are merely recommended, and which are in practice, required.  Endeavour to have some idea what any consequences might consist of if you do or do not adhere to the 'guidance'.  That is my disclaimer.

Second, what is the rationale behind the guidance?

So what might be the rationale for steering functional requirements document preparers and contributors away from including a section devoted to assumptions?

In my experience, people and projects view functional requirements differently at times.  In some cases, functional requirements (what happens and sequencing or when something  happens) are clearly distinct from system or service requirements (where or how something happens).  Finding the distinction when the system or environment is central to the effort (device or service interfaces or device drivers, for example) may prove to be more effort than it's worth, and so in those cases I would state that as my first assumption and then move forward.

In the case of the functional requirements document, the rationale for not including an assumptions section may be presumed that if a section for assumptions feels required, then perhaps the requirements are not functional.  In other words, if you feel that there are relevant assumptions that should be documented pertaining to the included requirements; the requirement may be too specific to an implementation or a particular service, and perhaps do not belong in that particular document.  On the other hand, maybe the requirements do belong but just rewritten in a different manner as to not be so specific that a particular implementation and related assumptions would then cease to apply.  It is probably intended that the guidance is not a prohibition, but rather as a sanity check or an orange flag to the document preparers and contributors.

If I were to approach a functional requirements document in the strictest sense, system and service requirements would not appear there.  If those types of requirements are not included within the functional spec, it is lot less likely that you would need to make or declare any sort of global assumptions (often pertaining to the environment or user).  If you find that global assumptions start applying to the requirements being included, it may indicate the requirements are not written as functional requirements, or that the environment or user are central to the effort.

Title: In a functional requirements document, is the Assumptions section dangerous?

Body:
I am currently a reviewer on a Best Practices document for Developers or Business Analysts in writing a Functional Requirements document.  This document is not necessarily a template for functional requirements documents, but a guide to what elements are necessary, optional, and dangerous to include a Functional Requirements document.

The author of the document states that:

Functional Requirements documents should NEVER have an Assumptions section!  Do not assume anything about what people know about this application or any external issues surrounding it.

I am not sure that I agree with this sentiment but don't really have the words to refute it either.  In a perfect world the analyst will have time to properly analyze every stakeholder input and every possible external issue but inevitably due to time constraints and other issues some assumptions need to be made.

Is this a bad idea because it is too easy for the intellectually lazy to declare assumptions rather than requirements?  If not then why do you think Assumptions are a good idea?

EDIT: To clarify, I am not asking about the Assumptions section of technical documentation but of an Assumptions section in a requirements document written by a non-technical business analyst.


答:
Assumption is a strong word.  You definitely do want an assumptions section.  But you also definitely do want that section to be validated for accuracy.

If, for example, you are designing an app with the assumption that all of its users will be power users, then it had better be true.

So basically, call it what you want (assumptions, prerequisites, whatever), but it needs to be there so that people are aware of what is driving your design choices.


问:
Is JSF really ready to deliver high performance web applications?
I have heard a lot of good about JSF but as far as I know people also had lots of serious complains with this technology in the past, not aware of how much the situation has improved. We are considering JSF as a probable technology for a social network project. But we are not aware of the performance scores of JSF neither we could really come across any existing high performance website that had been using JSF. People complain about its performance scalability issues.

We are still not very sure if we are doing the right thing by choosing jsf, and thus would like to hear from you all about this and take your inputs into consideration.

Is it possible to configure JSF to satisfy the high performance needs of social networking service ? Also till what extent is it possible to survive with the current problems in JSF. What exactly are its problems ?

I am not  worried about the development complexities with JSF what others usually complain about because as per my personal experience I believe that's not at all true, but I am more concerned about what performance and scalability issues. And please don't just abuse it on its old issues linked to previous versions. I just care about the present state whatever had been its past.

答:
So I wanted to throw a similar benchmark in. I took a twitter bootstrap example page and converted it into xhtml strict. After that, I setup exactly one ApplicationScoped CDI bean that returned Hello, World. I put the EL expression on the page. For the JSF version, I used the JSF resource handler, for the JSPX version, I used HTML style css and js includes.

I used apache bench to test the main page load time. The test was performed on an un-optimized TomEE+ v1.5.2 server. I ran each benchmark 5x, then ran a full GC before taking a measurement. Bost tests were done in the same JVM instance without restarting the JVM. I have the APR available on the libpath, but I'm not sure that affects this test.

JSF is slower, but not by a whole lot, since we're dealing with very small quantities. What is not demonstrated is as the pages get more complex, does JSF/JSPX scale linearly or exponentially.

One thing I noticed is that JSPX is produces very little garbage compared to JSF. Running the benchmark on the JSPX page caused the used heap to jump from 184mb to 237mb. Running the benchmark in the same JVM on the JSF page causes the used heap to jump from 108mb to at least 404mb, but an automatic garbage collection kicked in at that point. It would seem tuning your garbage collector for JSF is an absolute necessity.

JSF

```<code>jonfisher@peanut:~$ /usr/local/bin/ab -n 10000 -c 100 http://localhost:8080/cdi-jsp/index.jsf
This is ApacheBench, Version 2.3 <$Revision: 1373084 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests

Server Software:        Apache-Coyote/1.1
Server Hostname:        localhost
Server Port:            8080

Document Path:          /cdi-jsp/index.jsf
Document Length:        2904 bytes

Concurrency Level:      100
Time taken for tests:   2.138 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      32160000 bytes
HTML transferred:       29040000 bytes
Requests per second:    4677.27 [#/sec] (mean)
Time per request:       21.380 [ms] (mean)
Time per request:       0.214 [ms] (mean, across all concurrent requests)
Transfer rate:          14689.55 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   1.3      1      21
Processing:     1   20   9.0     18      63
Waiting:        1   19   8.8     17      62
Total:          2   21   8.8     20      64

Percentage of the requests served within a certain time (ms)
  50%     20
  66%     23
  75%     25
  80%     27
  90%     32
  95%     39
  98%     46
  99%     50
 100%     64 (longest request)
</code>```

JSPX

```<code>jonfisher@peanut:~$ /usr/local/bin/ab -n 10000 -c 100 http://localhost:8080/cdi-jsp/page2.jspx
This is ApacheBench, Version 2.3 <$Revision: 1373084 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests

Server Software:        Apache-Coyote/1.1
Server Hostname:        localhost
Server Port:            8080

Document Path:          /cdi-jsp/page2.jspx
Document Length:        2440 bytes

Concurrency Level:      100
Time taken for tests:   1.273 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      26290000 bytes
HTML transferred:       24400000 bytes
Requests per second:    7856.63 [#/sec] (mean)
Time per request:       12.728 [ms] (mean)
Time per request:       0.127 [ms] (mean, across all concurrent requests)
Transfer rate:          20170.98 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    5   2.3      6      20
Processing:     1    8   4.6      6      40
Waiting:        1    8   4.3      6      40
Total:          2   13   3.8     12      41

Percentage of the requests served within a certain time (ms)
  50%     12
  66%     12
  75%     13
  80%     13
  90%     17
  95%     20
  98%     24
  99%     28
 100%     41 (longest request)
</code>```

Body:
So I wanted to throw a similar benchmark in. I took a twitter bootstrap example page and converted it into xhtml strict. After that, I setup exactly one ApplicationScoped CDI bean that returned Hello, World. I put the EL expression on the page. For the JSF version, I used the JSF resource handler, for the JSPX version, I used HTML style css and js includes.

I used apache bench to test the main page load time. The test was performed on an un-optimized TomEE+ v1.5.2 server. I ran each benchmark 5x, then ran a full GC before taking a measurement. Bost tests were done in the same JVM instance without restarting the JVM. I have the APR available on the libpath, but I'm not sure that affects this test.

JSF is slower, but not by a whole lot, since we're dealing with very small quantities. What is not demonstrated is as the pages get more complex, does JSF/JSPX scale linearly or exponentially.

One thing I noticed is that JSPX is produces very little garbage compared to JSF. Running the benchmark on the JSPX page caused the used heap to jump from 184mb to 237mb. Running the benchmark in the same JVM on the JSF page causes the used heap to jump from 108mb to at least 404mb, but an automatic garbage collection kicked in at that point. It would seem tuning your garbage collector for JSF is an absolute necessity.

JSF

jonfisher@peanut:~$ /usr/local/bin/ab -n 10000 -c 100 http://localhost:8080/cdi-jsp/index.jsf
This is ApacheBench, Version 2.3 <$Revision: 1373084 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests

Server Software:        Apache-Coyote/1.1
Server Hostname:        localhost
Server Port:            8080

Document Path:          /cdi-jsp/index.jsf
Document Length:        2904 bytes

Concurrency Level:      100
Time taken for tests:   2.138 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      32160000 bytes
HTML transferred:       29040000 bytes
Requests per second:    4677.27 [#/sec] (mean)
Time per request:       21.380 [ms] (mean)
Time per request:       0.214 [ms] (mean, across all concurrent requests)
Transfer rate:          14689.55 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   1.3      1      21
Processing:     1   20   9.0     18      63
Waiting:        1   19   8.8     17      62
Total:          2   21   8.8     20      64

Percentage of the requests served within a certain time (ms)
  50%     20
  66%     23
  75%     25
  80%     27
  90%     32
  95%     39
  98%     46
  99%     50
 100%     64 (longest request)

JSPX

jonfisher@peanut:~$ /usr/local/bin/ab -n 10000 -c 100 http://localhost:8080/cdi-jsp/page2.jspx
This is ApacheBench, Version 2.3 <$Revision: 1373084 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests

Server Software:        Apache-Coyote/1.1
Server Hostname:        localhost
Server Port:            8080

Document Path:          /cdi-jsp/page2.jspx
Document Length:        2440 bytes

Concurrency Level:      100
Time taken for tests:   1.273 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      26290000 bytes
HTML transferred:       24400000 bytes
Requests per second:    7856.63 [#/sec] (mean)
Time per request:       12.728 [ms] (mean)
Time per request:       0.127 [ms] (mean, across all concurrent requests)
Transfer rate:          20170.98 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    5   2.3      6      20
Processing:     1    8   4.6      6      40
Waiting:        1    8   4.3      6      40
Total:          2   13   3.8     12      41

Percentage of the requests served within a certain time (ms)
  50%     12
  66%     12
  75%     13
  80%     13
  90%     17
  95%     20
  98%     24
  99%     28
 100%     41 (longest request)


答:
I hate most standards documents as they usually try to sweat the small stuff and ignore the bigger picture.

For example, nearly all of them will say how to name variables or place brackets. This is pure style and does little to really help a group of devs code correctly. They ignore stuff like directory structure and code layout. I've seen standards documents that told you exactly how many spaces to put between operators and how many blank lines to put between methods. All of these usually end up with a ton of exceptions to the rule which just shows how pointless they really are, and then they are so big no-one can follow them, which again, makes a mockery of the point they are trying to make.

Now for me, I use many different bits of software from lots of different people and they  all have different styles. I simply get used to this, I don't complain that there isn't a common style across all development groups. As long as the code is a common style throughout a project, I really don't care what that style is. So my first rule for all standards documents is: Keep a consistent coding style within the project. no-one should give a fig where the brackets are, as long as they are all the same. Take the religious wars and shove them :)

The second is code layout. When I pick up a piece of code, I want to see that its laid out along similar lines as other, similar pieces of work. If I have a web service I want the name of the wsdl contract to be clear, I want the name of the implementation to be clear. I do not want someone to come up with a brand new and different layout for files and classes. That means I have to play "hunt the code" which is a nuisance. If it looks the same as the last project I worked on, I can immediately know where to find what I'm looking for and it is probably the biggest help to working with other people's code that I know. So, keep a structure of how the code is laid out (eg Documentation folder for docs, interfaces for interfaces etc - whatever it is that works for you, but stick to it).

Code artifacts should be present too, so you need to say whether the expected error handling is exceptions or error codes - ie. document architectural functionality that's in use. It should also say what kind of logging to use and how to present logs/error handling to the user or whatever subsystem is used to manage code in the wild. I worked in a place where every project did logging differently - it was pathetic how each code release had to have its own, different, operations document telling the ops guys how to tell if it had gone wrong. Event log, log file (in which case where), etc are all valid here. The same applies to other common aspects to code - how to configure it (no point using a .config file for some programs, or a custom DB, or command line params, or registry for others).

In short, the only thing that matters is Consistency. And as huge standards documents are too much to read and memorise, I prefer to just inform people of the stuff they cannot see (eg architectural standards like logging) and tell them to keep the code they write consistent with what is currently there. And if you don't have code already then you don't need a standards document! (well, not until you've written enough to make it useful).

So take from that the main points: don't try to make a legal document, think of things that aren't just coding but also how the code works and how the code fits with other people's expectations. Then trust people to do good code and you'll see that they do. (and if they don't you can have words with them, no need to lay it down like law).

Title: Creating a coding standards document


问:
Looking for a freeware NoSql key-value database to offload a Java HashMap
I have a Java HashMap with a String key and POJO value in a long-running application, and it's taking up a large chunk of memory (over 500mb, and this number is expected to grow - I'm guesstimating that it will exceed 2GB in two to three months); this is used to memoize the results of an expensive calculation (typically 2-4 seconds, but up to 20 seconds), so I'd like to offload the HashMap to the hard drive rather than replace it with a [Soft/Weak]HashMap with the expectation that external lookup will be less expensive than recalculation; I'd also like to make the map persistent in case the app crashes.

My only experience with NoSql databases has been with DynamoDB, but I'd like a freeware database rather than trying to restrict myself to DynamoDB's free tier.

The app is written in Java, so I'll need a Java API for the database

The app runs on a single machine, with no expectation of migrating to a distributed architecture

I prefer the database be strongly consistent, but eventual consistency is acceptable

The machine has a traditional (non-SSD) hard drive

The map's keys are strings (length < 40), and its values are POJOs; if need be I can serialize the POJOs to strings with Jackson before persisting them, though I'd prefer the database handle this

The POJOs belong to several different subclasses with a common abstract parent class; all of the fields are in the parent class (the subclasses only add/override methods, any fields they add are transient)

There aren't any security requirements - the data I'd be storing doesn't need to be password-protected or anything

The values in the database won't expire (I'll take care of stale values in application code - if POJO.someProperty != someOtherProperty then I recalculate the POJO)

答:
CouchDB and MongoDB seem to be the leaders of the packs of NoSQL DBs today (IMHO, obviously).

Mongo has the backing of a company, but its still free - they make their money via support services. The documentation is good.
Couch is an Apache project, so free.

You could use PostgreSQL which has hstore and a json data type column that gives you a lot of noSql functionality.


答:
I use Apache CouchDB often, accessing it through Ektorp. Ektorp uses Jackson JSON serialization and de-serialization natively. It makes reading and writing POJOs very easy. Each document's _id would likely be your hash map key.

I don't know what your algorithm is, but you might even benefit from using CouchDB's map-reduce views to implement all or part of the algorithm. The results of a view in CouchDB are persisted, and the database handles updating the results for you.

You could probably use MongoDB just as well, but I've not used it personally.

Also, Apache Cassandra is a key-value store based on Amazon's Dynamo and Google's BigTable papers. So it fits the map paradigm well. It does not store data as JSON, but you can do this yourself by saving the data as a JSON string. It is similar to DynamoDB, but is freely available as open source.

Title: Looking for a freeware NoSql key-value database to offload a Java HashMap

Body:
I have a Java HashMap with a String key and POJO value in a long-running application, and it's taking up a large chunk of memory (over 500mb, and this number is expected to grow - I'm guesstimating that it will exceed 2GB in two to three months); this is used to memoize the results of an expensive calculation (typically 2-4 seconds, but up to 20 seconds), so I'd like to offload the HashMap to the hard drive rather than replace it with a [Soft/Weak]HashMap with the expectation that external lookup will be less expensive than recalculation; I'd also like to make the map persistent in case the app crashes.

My only experience with NoSql databases has been with DynamoDB, but I'd like a freeware database rather than trying to restrict myself to DynamoDB's free tier.

The app is written in Java, so I'll need a Java API for the database

The app runs on a single machine, with no expectation of migrating to a distributed architecture

I prefer the database be strongly consistent, but eventual consistency is acceptable

The machine has a traditional (non-SSD) hard drive

The map's keys are strings (length < 40), and its values are POJOs; if need be I can serialize the POJOs to strings with Jackson before persisting them, though I'd prefer the database handle this

The POJOs belong to several different subclasses with a common abstract parent class; all of the fields are in the parent class (the subclasses only add/override methods, any fields they add are transient)

There aren't any security requirements - the data I'd be storing doesn't need to be password-protected or anything

The values in the database won't expire (I'll take care of stale values in application code - if POJO.someProperty != someOtherProperty then I recalculate the POJO)


问:
Distributed SVN via file transfer?
I work for a large bureaucratic (and security paranoid) organisation that provides SVN for its development teams to use.

I am working with a 3rd party vendor (at their site) and we currently share code via SVN export and patch files. The only way I have for transferring files is by a FTP drop box or email. I would like a better way to work.

I am currently lobbying to get some kind of DCVS system setup, ideally cloud hosted. Failing that I want a better way to manage keeping SVN repositories in sync.

In the meantime (or if I fail to get DCVS) how do I keep two SVN repositories in sync?
How do I best manage exporting the repository?
How do I manage incoming changes?

答:
Easiest way, if you have location,from which both repos (organisation's and vendor's) are reachable by svn-client is

Create local repository, in this repo map two any nodes to the external repositories (via svn:externals)

If you worry about only content, you can periodically perform sync-merge from Vendor Branch to Organisation Branch (merge transfer all changes from all newest revisions). If both content and history are important, you can perform cherry-pick merge (one revision per merge).

Merged to Organisation Branch (from your POV) and committed will appear in organisation's repository as natural commit

ContentLicense: CC BY-SA 4.0

Title: Distributed SVN via file transfer?


问:
What are the 'must know' Emacs commands?
I'm a fairly new convert to Emacs and I really love it as an editor, primarily because I keep finding new and super-useful commands. Are there any other programmer 'must known' commands missing from my list?</p>

```<code>M-x replace-string     - Find and replace a given string.
M-x goto-line          - Goto a specific line
M-x column-number-mode - Show the current column number in text bar
</code>```

答:
C-h a -- Apropos search functions

C-h b  -- runs describe-binding

C-h k  -- runs describe-key

C-h f  -- runs describe-function

C-h v  -- runs describe-variable

If you know those, you can explore emacs and find things you still don't know. Learn how to learn, thats essential. Everything else can be found out later.


问:
Form validation and file structure
I have a form (lets say a registration form) and onsubmit, it calls a function to validate as follows:

```<code>$.ajax({
        url : "/ajax/validate.php",
        type : "POST",
        data : $(".form").serialize(),
        success : function(data) {
            data = $.parseJSON(data);
            $.each(data, function(i, item) {
                $('#' + i).addClass('errors');
            });
        }
    });
</code>```

The validate.php looks something like this:

```<code>if ($_POST['email'] == '' || filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) == false) {
    $errors['email'] = 'Not a valid email';
}
if ($errors) {
    echo json_encode($errors);
} else {
    // insert to db
}
</code>```

Now all of this code is specifically for the registration form. I'll have many forms on my site. My question is, do I make a new file (like validate.php) for each individual form? Such as /ajax/save_profile_data.php etc? Do I keep each form validation separate or is there a clever way to approach this? I don't know if having a validate file for each form on my site is the correct way to do it.

答:
If we're talking about a simple web page, your method should be sufficient.

If we're talking about something of a webapp that is AJAX-heavy, however, it might make sense to redirect all AJAX calls to a single ajax.php. The call should contain the action indicator (e.g. {ajax-action: "validate", form-data: "..."}).

ajax.php then decides what to do based on the action indicator, processes the call and outputs the response. It might be useful, then, to create an ajax_functions.php file which would contain all the functions that might be invoked through AJAX (split it if it becomes too large).

This way, you become more flexible with AJAX calls. For example, you can:

attempt to authorize the user before performing the action;

efficiently log the AJAX calls;

abstract AJAX functionality in Javascript into a single function or class customized to your needs.

Title: Form validation and file structure


答: You just need a cache with disk persistence. EhCache is a glorified HashMap that supports disk persistence with a host of configuration options. It will probably be the simplest option because your code will change very little.</p>


问:
How the cross programming language compiler or translator works
These days there are more cross programming language compilers (specially from some 'X' language to JavaScript). I wonder how these are developed? What are the general steps to be taken care to write algorithms if I were to develop one?

Do I need to be completely thorough in Lexical Analysis?

As far as my knowledge is concerned they should follow the same steps of translating some 'X' language to Assembly language (basic compilation). Is that how they actually been developed? OR there is some different way?

Thanks

答:
All compilers compile from a source language to a target language, the only difference with these translators is the target language is much higher level than with a traditional compiler. Consequently you should look for general compiler resources.

Lexical analysis is not strictly speaking necessary (at least not as a separate step) however it is often used to speed up the parsing phase


答:
You're essentially right.  A "standard" compiler can be thought of as a cross-language compiler that translates [input language] into machine code.  Once you understand that, the rest becomes clear.

The front-end (lexical, syntactical and semantic analysis) is all the same.  You read the input language and develop an abstract syntax tree from it.  What's different is the backend.  Once you've got your AST, the code generator outputs code that expresses the same concepts in a different human-readable programming language, instead of machine code.

Title: How the cross programming language compiler or translator works

Body:
These days there are more cross programming language compilers (specially from some 'X' language to JavaScript). I wonder how these are developed? What are the general steps to be taken care to write algorithms if I were to develop one?

Do I need to be completely thorough in Lexical Analysis?

As far as my knowledge is concerned they should follow the same steps of translating some 'X' language to Assembly language (basic compilation). Is that how they actually been developed? OR there is some different way?

Thanks


问:
Pair programming when driver and observer have different skill level and experience
I know pair programming is an agile software development technique in which two programmers work together at one workstation. One, the driver, writes code while the other, the observer, reviews each line of code as it is typed in.

But I just wonder the strategy still work in the case. For example

if they have a very different programming skill level.

if one never experience in the problem domain while another have.

Is it still OK if they have low programming skill level?

Could you suggest the pair programming strategy in the case above?

答:
So long as the team members have respect for each other, pair programming can be beneficial regardless of the programmers' experience levels. Even if a junior programmer just spots a few syntax errors (which we all make!) before the more experienced programmer, that's still time saved in compiling code.

I also think it can open up a programer's attitude towards the capabilities of other members of their team, especially if they have an open mind and expect that everyone can teach you something.


问:
better method to revert state if failure occures during add/delete
So I have a generic framework with a concept of children and parent objects, the objects don't have to be the same type, and I can add or remove any of them.  Adding calls add on all the children, and informs the parents, inverse for remove.

the concept of Parent is generic enough that there can be a loop across classes.  A may be a parent of B which is a parent of C which is a parent of A.  This still works, since I mark an object as added or removed as the first step in the abstract class; so even if a circular dependency calls Add a second time on the same object the second time through the add will return without doing anything (because the added boolean is already set) and we halt our recursion.

If some unexpected exception occurs I want to revert my state back to what it was before the exception occurs.  I was doing this with exception handling, if I catch a run time connection I remove objects I added and update parents before throwing the exception.  This is where my logic can fail.  As of now I 'revert' the AddObject method by calling removeObject and vice versa.  If my state somehow ended up in a truly bizarre state I could keep throwing exceptions, add throws and calls remove, remove throws and calls add, etc etc.  I think this still has a chance for infinite recursion; though admittedly something would already have to be pretty messed up in my state for it to happen.

Is there a cleaner way to do my rollback logic to avoid this potential?  At a point like this what should I say my state should be once I recover anyways?

答:
There are two design patterns available for Undo / Redo operations that are worth looking into. The first is the Command Design Pattern: -

http://en.wikipedia.org/wiki/Command_pattern

And the 2nd, is the Memento design pattern: -

http://en.wikipedia.org/wiki/Memento_pattern

Hope that helps.


答:
I think using git to manage the set of files needed to run your site is a clever idea.. as a matter of fact there are several services already doing this (as far as I know): microsoft's azure and some node.js hosting sites like nodester.com, just to name a couple..

As also @phi said, I'd not place the repository on the very same folders you publish through the web server, but have instead some kind of procedure which lets you "get the files" from the git repository and place where your web server will use them.

Just be sure to think all the details.. for instance:

if you have user-generated files, when you rollback or otherwise re-publish your site are they to be overwritten or kept in place?

if you have database data, when you republish your site will everything match and be ok, or should you handle the possible mismatch in some way?

There might be other culprits to think about, but the general idea is nice =)

Title: how safe/sane is it to use git for deployment on my webapp production server?

Body:
I started with sftp, then switched to WebDAV and I'm currently using rsync through ssh to deploy any updates/upgrades from my development server into my production server.

I'm still not very happy using this system and think using git to deploy may be better, mainly because of the possibility of rolling back any changes instantly with just one command.

Appart from using ssh tunnel to pull and push to the production server (leaving the git service behind the firewall), I've also realized I have to edit .htaccess to deny web access to .git folder.

Is this the correct approach, should I check anything else, do something in a different way, or should I go in a totally different direction?


问:
Opinions on distribution of software via virtual appliance
I've created a distribution of my open source application framework in a working virtual appliance.  It includes everything to get started with the tutorial.  The distribution is Fedora 14 running Tomcat 5.5 and Oracle 10g Express Edition, plus my framework.  It is completely preconfigured and boots into a working running copy.

Would this be something you might try?

What assurances might you need to get you to try it?

Edit: The VM is just over a 2Gb download.  Alternatively it is also available via 23Mb download for the source and a PDF detailing how to configure the Tomcat and Oracle dependencies.

答:
Well, I would have a couple barriers to entry:

Configuration would be significantly troublesome that I wouldn't want to do it on my own.

I have a beefy enough system to run a VM. My work machine is beefy enough, only 1 of my home machines is.

Configuration of the VM wouldn't fry my existing configurations.

It's an uncommon approach for open-source distribution, certainly.  Typically I would prefer to just ./configure && make && make install software.

On the enterprise consumption front, it would probably go over better due to the existing VM infrastructure.

HTH.


问:
Pairwise testing, not possible to say which combinations is faulty?
Let's say I have 4 (A,B,C,D) parameters with 3 possible values, also 81 unique combinations. With e.g. orthogonal array, I will end up with 9 test cases, each combining 3 pairs. But that means that if one test case fails, I do not know which combination in the test case is faulty, right? Whether values of A,B or A,C or BC. Just wanted to be sure I understood it well.

edit: Corrected (thanks GlenH7).

答:
Have a look at the Wikipedia article on Orthogonal Array Testing as well as the linked PDF from 51 testing

Some of your numbers are wrong.

Original version:  3 parameters (factors) with 4 values (levels) each, results in 4^3 combinations or 64 unique combinations, not 81.

Updated version:  4 parameters with 3 values each results in 3^4 combinations, or 81 as you asked.

Original: The minimum number of test cases to check all the pairings is factors * levels or 12 runs, not 9.  Note that if you had differing number of levels, you would need to calculate that in a different manner.  The explanatory PDF goes into more detail.

Update:  The minimum number of pairings drops to 9.  However, if only one test fails, you'll still be able to identify the faulty pairing by comparing it against the ones that cleared.

I think that the incorrect numbers you were using threw off your reasoning and your question about knowing which pair failed.  With the those 12 minimum runs (also listed below), you will know the pairing that failed.

Original version:

A  B  C

0  0  0

0  1  1

0  2  2

0  3  3

1  1  0

1  2  1

1  3  2

1  0  3

2  2  0

2  3  1

2  0  2

2  1  3

3  3  0

3  0  1

3  1  2

3  2  3

Updated version:

A B C D

0 2 0 0

0 1 1 1

0 0 2 2

1 0 1 0

1 2 2 1

1 1 0 2

2 1 2 0

2 0 0 1

2 2 1 2


问:
IEC 62304 compliant Architecture definition
I am currently tasked with creating a software architecture for compliance with IEC 62304.  These regulations are notoriously vague, and do not provide any real substance as to what is required for a "software architecture".  The standard states

The manufacturer shall transform the requirements for the medical device software into a documented architecture that describes the software's structure and identifies software items.

Now I went to an applied computer science school, so the vast majority of my teachings were around how to actually write code and working on projects, so as far as I can remember, we never covered anything involving creating software architecture diagrams.

I've already basically written all of the software, but for regulatory submission purposes I need to create this documentation for the project.

So in short my question is this:  What exactly does a "software architecture" consist of?

答:
We're going though the 62304 learning curve right now.

As the previous answer suggests it is just the high-level view of your medical device software.

According to the standard you should at minimum list the various modules/components. Components are defined as being made of software items. However, how you define components and items is entirely up to you.

In our case, products often have one component and rarely more than three.

In the case of a engineer-workstation-based  GUI project, we have four component. The GUI, the product logic, and an existing DLL we are required to integrate, and the underlying mathematical modelling engine that the whole system is based upon.

The architecture consists of

description of the GUI,

basically a list of screens and their associated workflow

a description of the objects(software items) associated with each screen

a description of the product logic

a description of the state machine, and how it interacts with the GUI workflow

a description of the state machine class (a software item)

a description of the mathematical-modelling operations being performed for the client. (broken down into stages - each stage is a software item)

a description of a required DLL, its SOUP status, etc. (one software item)

a reference to another software component developed under 62304

One thing to bear in mind is that (despite the heavy implication of the way the 62304 standard is written) you don't have to create the architecture diagram up front and then fix it in stone in a waterfall coding model. The FDA have encouraged the use of more agile approaches, allowing you to develop the architecture along with the code, so long as your validate the final architecture against the final design. So start with a simple architecture that allows you to make progress, and keep it up to date as you develop the code. See the AAMI's TIR45 publication for some documented justification.


问:
What's a good way for a program to process an email mailbox?
Let's have a program that checks an email mailbox and then "processes" the messages contained there. (For this question it doesn't really matter what it actually does with the message). The program will run once per hour and can easily handle the volume of new messages and there is no penalty for processing a message twice. Let's say it will be using the IMAP protocol and can perform any of the standard functions that an email application can do.

What mechanism would you recommend for processing the email?

Mark as read - the program marks a message as read after processing it.

Unmodified mailbox - the program doesn't modify the mailbox at all.

Something else - some other method I haven't thought of yet.

Suggestions welcome.

答:
The best option will depend on what else you plan to do with the mailbox. If the answer is "nothing" then you should have your program delete mails from the mailbox. If the answer is "something" then your program should modify the mailbox in a way that plays nicely with the other clients that will be accessing the mailbox.

Delete the mail

Mark as read

Move to a folder

Apply an IMAP keyword


问:
Design pattern to dynamically create patterns found in a list of links
Can anyone help me think of a way to dynamically generate the patterns section of a tool I am creating? I'm not sure how to store and generate these "patterns" dynamically.

What the program does is take a big list of links (100,000), puts them in a database, groups them by domain and then curls a page from each domain looking for backlinks.

Here is the database scheme, you can see that the Domains table is were most of the information is stored because we group the URLs together by the domain: http://sqlfiddle.com/#!2/9a4d7

So now we know that some domains are live (and have a backlink) and some are dead (no backlink). This is relatively easy but now for the fun part.

I need to derive "patterns" from the live links. For example find a list of all live link domains that have more than 25 links from that domain. So if joesblog.blogspot has 33 pages that link to my domain that matches this pattern. Here is my list of patterns:

Domains that include a homepage link

Domains grouped by top level domain (.com, .org etc)

Domains that returned a 405 header response

URLs with matching directory structures

Domains that contain the word _ _ _.

URLs that contain the word _ _ _ in their path.

Common anchor text.

Common title tags.

Common backlink targets (what page of your site does the link point to).

The problem is that the patterns are changing CONSTANTLY. There being moved around, added, edited, removed and anything else you can think of. I really need a to build a content management system of sorts to handle these patterns. But how would I store something this intricate in a database?

Has anyone ever delt with a similar problem and how did you solve it?

If I could just store whole functions and MySQL statements in the database that would be great (but horrible wrong).

(PHP, MySQL, JavaScript / JQuery)

DISCLAIMER: This is an internal tool. Please don't ask me why I'm building this or claim that the requirements are wrong. This was designed by my manager and its my task to make it work because I am a developer at the company that needs this tool. Thank you!

答:
It seems like there are a few types of patterns. I can see some that are simple text-matching patterns (such as "domain name contains $word"), some which are based on interaction with the host (Domains that return a 405), TLD-based patterns....

I agree that storing executable code in the database is probably not the best approach. You might first need to find ways to categorize different patterns into more general templates. Then, have a database schema to store the pattern metadata, and then a UI to let users work with the patterns. You'd also have to write code for each type of pattern to execute the pattern metadata in the pattern schema and process the data in your main schema.

You could also do this entirely in code instead of the database, by having different class structures to represent different types of patterns, then read the configuration for different patterns from an XML file. The drawback of this is that pattern config is done in XML which is probably slightly less user-friendly than a web-based CRUD interface. It also means that when a user wants to change/create a pattern, the XML config files need to be deployed (because of course they won't have access to the production server, right? ;) ), whereas if it's all done in a database, there is no need to redeploy the changed config (unless  you  build a tool to deploy changes automatically), it's available immediately.


答:
It sounds like you want a graph database.  They basically track nodes and their relationships separately, and most of your queries could be done with their native query languages, if you design the database correctly.

For example, your nodes could be pages, and your relationships could be links to, has TLD, responds with, etc.  Graph databases can follow relationships equally well in both directions, so finding all the links on a page is just as easy as finding all the links to a page.

Title: Design pattern to dynamically create patterns found in a list of links

Body:
Can anyone help me think of a way to dynamically generate the patterns section of a tool I am creating? I'm not sure how to store and generate these "patterns" dynamically.

What the program does is take a big list of links (100,000), puts them in a database, groups them by domain and then curls a page from each domain looking for backlinks.

Here is the database scheme, you can see that the Domains table is were most of the information is stored because we group the URLs together by the domain: http://sqlfiddle.com/#!2/9a4d7

So now we know that some domains are live (and have a backlink) and some are dead (no backlink). This is relatively easy but now for the fun part.

I need to derive "patterns" from the live links. For example find a list of all live link domains that have more than 25 links from that domain. So if joesblog.blogspot has 33 pages that link to my domain that matches this pattern. Here is my list of patterns:

Domains that include a homepage link

Domains grouped by top level domain (.com, .org etc)

Domains that returned a 405 header response

URLs with matching directory structures

Domains that contain the word _ _ _.

URLs that contain the word _ _ _ in their path.

Common anchor text.

Common title tags.

Common backlink targets (what page of your site does the link point to).

The problem is that the patterns are changing CONSTANTLY. There being moved around, added, edited, removed and anything else you can think of. I really need a to build a content management system of sorts to handle these patterns. But how would I store something this intricate in a database?

Has anyone ever delt with a similar problem and how did you solve it?

If I could just store whole functions and MySQL statements in the database that would be great (but horrible wrong).

(PHP, MySQL, JavaScript / JQuery)

DISCLAIMER: This is an internal tool. Please don't ask me why I'm building this or claim that the requirements are wrong. This was designed by my manager and its my task to make it work because I am a developer at the company that needs this tool. Thank you!


答:
But how would I store something this intricate in a database?

You don't.  Each pattern is a combination of program code and SQL queries that produce a certain result.

In PHP, you can write an abstract class that models a set of classes.  You write an abstract class that takes a String that gives a short description of the method.  This class also has an execute() function that gives the result as an array.

You write a concrete pattern class for each of the patterns you know about, extending the abstract class.  That way, all of your pattern classes have the same methods and results.

You write one more loop class that loops through all of these pattern classes with an array of the Strings of the short descriptions you want to execute.

Finally, you set up a main class where you can specify the array of short description Strings.  The strings can be read from a file, so you don't have to modify the main class.

This way, when someone comes up with a new pattern, you create a new pattern class, add the pattern class to the loop class, and you're done.

OwnerDisplayName: Gilbert Le Blanc


问:
Is it better to save output from command in memory and store later or save in a temporary file and then move to final location?
I hope this is not off topic.

I have to save output from a command to file, but only if length of this output is positive. I've thought about two solutions:

save output to a python variable, check length, if positive save to destination file;

save output to a temporary file, check length, if positive rename to destination file.

Is there any best practice for this little problem, or which one usually performs better between my proposed solutions?

Typical configuration:

file length is usually 1KB

we are not using ssds, usually 7200rpm hard disk

average RAM is usually 10-20 GB

I don't know if filesystem is important, anyway ext3

I know this is a bit unclear, but I was hoping there was some best practice to apply in this case.

Thanks

答:
For Little problems I would suggest storing in memory because memory is cheap and fast and storing in Disk is slow and a costly operation.

32 GB of RAM memory are more common nowadays than solid state drives.


答:
Well, First You need to know some of the basics of text editing:

```<code>C-w : Cut
M-w : Copy
C-y : Paste
C-x s : save
C-x c : save all and close
</code>```

Then, it's handy to learn how to move around the file:

```<code>M-b : back one word
M-f : foward one word
C-a : beginning of line
C-e : end of line
C-n : next line
C-p : previous line
M-< : beginning of buffer
M-> : end of buffer
</code>```

Then, It's good to start learning how to navigate with multiple files/buffers and windows

```<code>C-x C-f : find file
C-x b : switch buffer
C-x k : kill buffer
C-x 2 : split-window-vertically
C-x 3 : split-window-horizontally
C-x o : switch window
C-x 0 : kill this window
C-x 1 : kill all other windows
</code>```

After that, here are a few other misc. commands that can come in handy:

```<code>C-s : search
C-r : search backward
M-/ : autocomplete word (based on previous words in the file)
M-x : align-regexp
M-( : start keyboard macro
M-) : end keyboard macro
C-x e: execute keyboard macro.
</code>```

For a complete reference: link

Title: What are the 'must know' Emacs commands?

Body:
I'm a fairly new convert to Emacs and I really love it as an editor, primarily because I keep finding new and super-useful commands. Are there any other programmer 'must known' commands missing from my list?</p>

```<code>M-x replace-string     - Find and replace a given string.
M-x goto-line          - Goto a specific line
M-x column-number-mode - Show the current column number in text bar
</code>```

Body:
Well, First You need to know some of the basics of text editing:

C-w : Cut
M-w : Copy
C-y : Paste
C-x s : save
C-x c : save all and close

Then, it's handy to learn how to move around the file:

M-b : back one word
M-f : foward one word
C-a : beginning of line
C-e : end of line
C-n : next line
C-p : previous line
M-< : beginning of buffer
M-> : end of buffer

Then, It's good to start learning how to navigate with multiple files/buffers and windows

C-x C-f : find file
C-x b : switch buffer
C-x k : kill buffer
C-x 2 : split-window-vertically
C-x 3 : split-window-horizontally
C-x o : switch window
C-x 0 : kill this window
C-x 1 : kill all other windows

After that, here are a few other misc. commands that can come in handy:

C-s : search
C-r : search backward
M-/ : autocomplete word (based on previous words in the file)
M-x : align-regexp
M-( : start keyboard macro
M-) : end keyboard macro
C-x e: execute keyboard macro.

For a complete reference: link


问:
Feature branches, beta branches, and scrapped features
I've been thinking a lot about best practices regarding branching in distributed version control systems such as git an mercurial (the two dvcs's I have experience with and use on a daily basis).

The way I've been doing it is slightly different in each of these, but generally follows these guidelines:

master branch - concurrent with production code

development branch - concurrent with "beta" code

feature branches - for feature development

Development is done in a feature branch (usually created off of the master branch, so we know we're working with a stable code base), and when dev is completed, reviewed, and developer-tested, it's pushed/merged into the development/beta branch, put out on a beta server, and tested.

If all goes well, the feature is approved, and we can merge it into the master/stable branch, stage it, do final testing, and get it into production.

If it doesn't go well, though, things break down. If, for instance, a feature is scrapped or just delayed indefinitely, we probably want to remove it from the dev/beta branch. However, since merges from master/stable (hotfixes, content changes, etc.), and other new features have probably been put into the dev branch, it becomes difficult to remove a single feature from that branch.

I'm coming to the conclusion that this workflow is just broken, but it seems like it should work. So, specifically:

Is it possible to remove a particular feature from this type of branch?

Is this just a broken workflow?

And more generally:

Given long-term development of features, and a need to have a branch concurrent with live, what are the best practices involved in dvcs?

答:
I think removing an already integrated feature after a merge is hard with most VCS (or DVCS), so you should make sure that this situation happens as seldom as possible. Some ideas:

If you have a feature for which the approval is at stake (for example, you need a usability test first before you are sure that you are creating the "right" thing), make sure your testers make that usabilty test already with a version from the feature branch, before integrating it into development branch. So you can avoid the integration if the feature is at stake

To my experience small feature slices have a lower risk of getting scrapped or delayed than big ones, since one can make them much easier and quicker production-ready. So try harder to make feature slices as small as possible.

If you have a more complex feature, consisting of a dozen (or more) feature slices, and you want the final user to see that complex feature only as all-or-nothing, introduce feature toggles into your code, and use a feature branch for each slice, not for the whole thing. This does not really make it easier to "unmerge" any feature code afterwards, but if, for example, after the integration of half of the feature slices into the dev branch someone decides not to complete the whole thing for the next release, you can leave the finished feature slices in the dev branch, without activating the feature toggle. So your users will not notice that there is a half-completed feature in there.

EDIT: If you really get into the need of "dismanteling" a feature at a point in time where parts of it have been integrated into the dev branch and got mixed-up with other changesets, you have the option of using a separate feature branch (or should I say "feature-like branch"?) for that task. You change and/or delete the relevant parts of the code within that branch, developer-test it and then integrate that change set into the dev branch again.

EDIT2: read this blog post of Martin Fowler for more information about feature toggles.


问:
Decrement operator difference between C++ and Java?
Please tell me why the same piece of code behaves differently in C++ and JAVA.

Ok first I implement a function to calculate the factorial of an Int RECURSIVELY

In JAVA:

```<code>int f(int x)
    {

        if(x==1)return 1;
        return(x*f(x-1));
    }
</code>```

System.out.println(f(5)); -----> outputs 120, ok that makes sense.

JAVA METHOD 2:

```<code>int f(int x)
    {

        if(x==1)return 1;
        return(x*f(--x));
    }
</code>```

System.out.println(f(5)); -----> outputs 120, ok that makes sense too.

But here is a twist in C++:

C++ METHOD 1:

```<code>int f(int x)
{
    if(x==1)return 1;
    return (x*f(x-1));

}
</code>```

cout << f(5) ; -----> outputs 120, ok now keep reading!

C++ METHOD 2:

```<code>int f(int x)
{
    if(x==1)return 1;
    return (x*f(--x));

}
</code>```

cout << f(5) ; -----> outputs 24. This is surprising. But Why??

I have tried tracing this multiple times and have failed. It makes sense in java because each recursive call gets its own piece of memory and pre decrement operator -- will decrease and yield the decreased value. Why does it work as expected in JAVA but not In C++?

答:
```<code>f1(int x)
{
  if(x = 1) return 1;
  return (x * f1(--x));
}
</code>```

vs

```<code>int f2(int x)
{
    if(x==1)return 1;
    return (x * f2(x-1));
}
</code>```

The inner bit of the f1 code compiles to (gcc -S ...):

```<code>.L2:
    subl    $1, -4(%rbp)
    movl    -4(%rbp), %eax
    movl    %eax, %edi
    call    f1
    imull   -4(%rbp), %eax
</code>```

While f2 compiles to

```<code>.L2:
    movl    -4(%rbp), %eax
    subl    $1, %eax
    movl    %eax, %edi
    call    f2
    imull   -4(%rbp), %eax
</code>```

You can see that the operations of the subl and movl are in a different order between the two.  In paticular, f1 is subtracting first before the value is moved for it to be used in calculation.

f1 has a side effect of modifying the value of x when it invokes --x.  This side effect is being order so that it happens to the value before the multiply is being evaluated with the same value.

In f1, you have:

First invocation

  x = 5; x * f1(--x) --> x = 4 ; x * f1(4)

Second invocation

    x = 4; x * f1(--x) --> x = 3 ; x * f1(3)

Third invocation

      x = 3; x * f1(--x) --> x = 2 ; x * f1(2)

Fourth invocation

        x = 2; x * f1(--x) --> x = 1 ; x * f1(1)

Now, you populated these values up:

x = 1 ; x * f1(1) ; 1 * 1 --> return 1

x = 2 ; x * f1(2) ; 2 * 1 --> return 2

x = 3 ; x * f1(3) ; 3 * 2 --> return 6

x = 4 ; x * f1(4) ; 4 * 6 --> 24

This is because you are in an undefined area of the compiler when you do x * --x.  To allow certain optimizations, some things have to be undefined.  This is one of them - the compiler is allowed to process it any way it wants.

Don't use --x or x-- unless you want the change in the assignment.

so I was thinking that x will be always evaluated before --x. please tell me why I am wrong here? The compiler should not therefore try to optimize in these types of situations

From wikipedia:

A sequence point defines any point in a computer program's execution at which it is guaranteed that all side effects of previous evaluations will have been performed, and no side effects from subsequent evaluations have yet been performed.

There is no sequence point in the expression x * --x, so that there is no spot at which the c compiler will guarantee that the evaluation happens in a certain order.

The associativity of an operator has to deal with how an expression is parsed.

Consider 4 * 3 + 2.  The associativity and precedence of * and + guarntees that this is parsed as (4 * 3) + 2.

Math operators are left associatve, while assignment are right associative.  While 4 + 3 + 2 + 1 is parsed as (((4 + 3) + 2) + 1) - it doesn't matter too much with this.  Assignments are right associatve.  a = b = c = 4 becomes (a = (b = (c = 4))).  Notice which way the parentheses group.

This has no bearing on the question of which side of a mathematical term is evaluated first in the context of x * --x.

Body:
f1(int x)
{
  if(x = 1) return 1;
  return (x * f1(--x));
}

vs

int f2(int x)
{
    if(x==1)return 1;
    return (x * f2(x-1));
}

The inner bit of the f1 code compiles to (gcc -S ...):

.L2:
    subl    $1, -4(%rbp)
    movl    -4(%rbp), %eax
    movl    %eax, %edi
    call    f1
    imull   -4(%rbp), %eax

While f2 compiles to

.L2:
    movl    -4(%rbp), %eax
    subl    $1, %eax
    movl    %eax, %edi
    call    f2
    imull   -4(%rbp), %eax

You can see that the operations of the subl and movl are in a different order between the two.  In paticular, f1 is subtracting first before the value is moved for it to be used in calculation.

f1 has a side effect of modifying the value of x when it invokes --x.  This side effect is being order so that it happens to the value before the multiply is being evaluated with the same value.

In f1, you have:

First invocation

  x = 5; x * f1(--x) --> x = 4 ; x * f1(4)

Second invocation

    x = 4; x * f1(--x) --> x = 3 ; x * f1(3)

Third invocation

      x = 3; x * f1(--x) --> x = 2 ; x * f1(2)

Fourth invocation

        x = 2; x * f1(--x) --> x = 1 ; x * f1(1)

Now, you populated these values up:

x = 1 ; x * f1(1) ; 1 * 1 --> return 1

x = 2 ; x * f1(2) ; 2 * 1 --> return 2

x = 3 ; x * f1(3) ; 3 * 2 --> return 6

x = 4 ; x * f1(4) ; 4 * 6 --> 24

This is because you are in an undefined area of the compiler when you do x * --x.  To allow certain optimizations, some things have to be undefined.  This is one of them - the compiler is allowed to process it any way it wants.

Don't use --x or x-- unless you want the change in the assignment.

so I was thinking that x will be always evaluated before --x. please tell me why I am wrong here? The compiler should not therefore try to optimize in these types of situations

From wikipedia:

A sequence point defines any point in a computer program's execution at which it is guaranteed that all side effects of previous evaluations will have been performed, and no side effects from subsequent evaluations have yet been performed.

There is no sequence point in the expression x * --x, so that there is no spot at which the c compiler will guarantee that the evaluation happens in a certain order.

The associativity of an operator has to deal with how an expression is parsed.

Consider 4 * 3 + 2.  The associativity and precedence of * and + guarntees that this is parsed as (4 * 3) + 2.

Math operators are left associatve, while assignment are right associative.  While 4 + 3 + 2 + 1 is parsed as (((4 + 3) + 2) + 1) - it doesn't matter too much with this.  Assignments are right associatve.  a = b = c = 4 becomes (a = (b = (c = 4))).  Notice which way the parentheses group.

This has no bearing on the question of which side of a mathematical term is evaluated first in the context of x * --x.


答:
Firstly, do you really need to revert the state? When something has just gone wrong in your program, does it makes sense to try to stay up rather than crash and burn? It can be a lot of work to try and make your program resilient to that sort of thing, and you have to gauge whether you'd be better off spending that time fixing the bugs causing the exceptions.

I suggest doing something related to the technique used by a database. Databases keep a log of all the changes that are made so that they can back through the log and undo all the changes. So I'd have code that looks like

```<code>transaction = TreeTransaction()
try
{
    foo.add(bar, transaction);
    bar.add(goat, transaction);
    transaction.commit();
}
catch(...)
{
    transaction.rollback();
}
</code>```

Depending on your language there is usually some ways to improve the pattern. The idea is that all changes are made within the context of a transaction. When an unexpected error occours, the rollback method puts everything back the way it was. Commit can make changes official, if that makes sense.

Title: better method to revert state if failure occures during add/delete

Body:
So I have a generic framework with a concept of children and parent objects, the objects don't have to be the same type, and I can add or remove any of them.  Adding calls add on all the children, and informs the parents, inverse for remove.

the concept of Parent is generic enough that there can be a loop across classes.  A may be a parent of B which is a parent of C which is a parent of A.  This still works, since I mark an object as added or removed as the first step in the abstract class; so even if a circular dependency calls Add a second time on the same object the second time through the add will return without doing anything (because the added boolean is already set) and we halt our recursion.

If some unexpected exception occurs I want to revert my state back to what it was before the exception occurs.  I was doing this with exception handling, if I catch a run time connection I remove objects I added and update parents before throwing the exception.  This is where my logic can fail.  As of now I 'revert' the AddObject method by calling removeObject and vice versa.  If my state somehow ended up in a truly bizarre state I could keep throwing exceptions, add throws and calls remove, remove throws and calls add, etc etc.  I think this still has a chance for infinite recursion; though admittedly something would already have to be pretty messed up in my state for it to happen.

Is there a cleaner way to do my rollback logic to avoid this potential?  At a point like this what should I say my state should be once I recover anyways?

Body:
Firstly, do you really need to revert the state? When something has just gone wrong in your program, does it makes sense to try to stay up rather than crash and burn? It can be a lot of work to try and make your program resilient to that sort of thing, and you have to gauge whether you'd be better off spending that time fixing the bugs causing the exceptions.

I suggest doing something related to the technique used by a database. Databases keep a log of all the changes that are made so that they can back through the log and undo all the changes. So I'd have code that looks like

transaction = TreeTransaction()
try
{
    foo.add(bar, transaction);
    bar.add(goat, transaction);
    transaction.commit();
}
catch(...)
{
    transaction.rollback();
}

Depending on your language there is usually some ways to improve the pattern. The idea is that all changes are made within the context of a transaction. When an unexpected error occours, the rollback method puts everything back the way it was. Commit can make changes official, if that makes sense.


答:
I think the workflow at its core is fine and basically follows the ideas presented here: A successful Git branching model. However, I think the reason it breaks down for you is because you are essentially "off by one" in the merging and testing process:

Feature branches should be based off of the development branch instead of the stable/master branch. Long-term features are continuously rebased on top of the development branch.

Feature branches should only be merged into the development branch when they are ready and approved for next release (i.e. when merged, it will definitely go into the next release.)

When preparing a new release, a release branch is made off the development branch where final testing is done before merged into the stable/master branch for production.

Things definitely gets a little more complicated when a feature depends on another feature not yet merged into development, but as Doc Brown mentioned in his answer, I think "feature toggles" is a good idea here. The nearly completed features are merged into development, but disabled for production use. Dependent features are then rebased on top of development and merged when ready.

Title: Feature branches, beta branches, and scrapped features

Body:
I've been thinking a lot about best practices regarding branching in distributed version control systems such as git an mercurial (the two dvcs's I have experience with and use on a daily basis).

The way I've been doing it is slightly different in each of these, but generally follows these guidelines:

master branch - concurrent with production code

development branch - concurrent with "beta" code

feature branches - for feature development

Development is done in a feature branch (usually created off of the master branch, so we know we're working with a stable code base), and when dev is completed, reviewed, and developer-tested, it's pushed/merged into the development/beta branch, put out on a beta server, and tested.

If all goes well, the feature is approved, and we can merge it into the master/stable branch, stage it, do final testing, and get it into production.

If it doesn't go well, though, things break down. If, for instance, a feature is scrapped or just delayed indefinitely, we probably want to remove it from the dev/beta branch. However, since merges from master/stable (hotfixes, content changes, etc.), and other new features have probably been put into the dev branch, it becomes difficult to remove a single feature from that branch.

I'm coming to the conclusion that this workflow is just broken, but it seems like it should work. So, specifically:

Is it possible to remove a particular feature from this type of branch?

Is this just a broken workflow?

And more generally:

Given long-term development of features, and a need to have a branch concurrent with live, what are the best practices involved in dvcs?


问:
Is Agile the new micromanagement?
This question has been cooking in my head for a while so I wanted to ask those who are following agile/scrum practices in their development environments.

My company has finally ventured into incorporating agile practices and has started out with a team of four developers in an agile group on a trial basis. It has been four months with three iterations, and they continue to do it without going fully agile for the rest of us. This is due to the fact that middle management is entrusted to meet business requirements with quite a bit of ad hoc requests from upper management.

Recently, I talked to the developers who are part of this initiative; they tell me that it's not fun. They are not allowed to talk to other developers.  Their Scrum master enforces this restriction. And they are not allowed to take any non-business-related phone calls in the work area. For example, if I want to talk to my friend, who is in the agile team, just for kicks -- I am not allowed without the approval of the Scrum master; who is sitting right next to the agile team.

The idea of all this (or the agile, in general) is to provide a complete vacuum for agile developers from any interruptions, and to have them put in good 6+ productive hours. Well, guys, I am no agile guru but what I have read Yahoo agile rollout document and similar for other organizations, it gives me a feeling that agile is not cheap. It require resources and budget to instill agile into the teams and correct issue as they arrive to put them back on track.

For starters, it requires training for developers and coaching for managers and etc, etc... The current Scrum master was a manager who took a couple days agile training class paid by the management is now leading this agile team. I have also heard in the meeting that agile manifesto doesn't dictate that agile is not set in stone, and is customized differently for each company. Well, it all sounds good and reasonable.

In conclusion, I always thought the agile was supposed to bring harmony in the development teams which results in happy developers. However, I am getting the very opposite feeling when talking to the developers in the agile team. They are unhappy that they cannot talk about anything but work, sitting quietly all day just working, and they feel it's just another way for management to make them work more.

Tell me please, if this is one of the examples of good practices used for the purpose of selfish advantage for more dollars? Or maybe it's just us, the developers like me and this agile team, which feels that they don't like to work in an environment where they only breathe work while they're at work.

It's a company in the healthcare domain that has offices across the US. It definitely feels like a cowboy style agile, which makes me really not want to go for agile at all, especially at my current company.

All of it has to do with the management being completely cheap. Cutting out expensive coffee for a cheaper version, emphasis on savings and being productive while staying as lean as possible.

My feeling is that someone in the management behind closed doors threw out this idea: agile makes you produce more, so we can show our bosses we're producing more with the same headcount. Or, maybe, it will allow us to reduce headcount if that's the case.

They are having their 5 min daily meeting. But not allowed to chat or talk with someone outside of their team. All focus is on work.

答: Agile is micromanagement in disguise. There is no place for initiative or creativity in Agile, it has removed the fun from programming to allow incompetent managers to keep control even without  having a clue from the technical point of view.</p>

OwnerDisplayName: Smith James

Title: Is Agile the new micromanagement?


答:
For problems of this size (few kilobytes to several megabytes), I would say store it in memory, check the length condition, and if it's successful, save it to the disk as a permanent file. Unless the output data retrieved from the command line is very important, it's better to verify the data on the memory. In fact, I would also say that unless the operation performed is "risky" (high chance of data corruption or similar) or there's a noticeable chance of data or power failure, to use the memory first, and then flush it to the disk. RAM is inexpensive and fast but, temporary. Whereas, the hard drive is slow, expensive, but, (more) permanent.

Overall, it's a matter of how big your data is, and how many risks are involved in the process (and you are willing to take).

Title: Is it better to save output from command in memory and store later or save in a temporary file and then move to final location?

Body:
I hope this is not off topic.

I have to save output from a command to file, but only if length of this output is positive. I've thought about two solutions:

save output to a python variable, check length, if positive save to destination file;

save output to a temporary file, check length, if positive rename to destination file.

Is there any best practice for this little problem, or which one usually performs better between my proposed solutions?

Typical configuration:

file length is usually 1KB

we are not using ssds, usually 7200rpm hard disk

average RAM is usually 10-20 GB

I don't know if filesystem is important, anyway ext3

I know this is a bit unclear, but I was hoping there was some best practice to apply in this case.

Thanks