答:
If you're going with a Microsoft solution, one great option is to use Windows Workflow Foundation.  It already has tons of features to develop complex workflows like the ones you've described above.  It's already built into the .NET Framework, too.

Developing a WF application basically has two parts:

Develop the "host" application, like an ASP.NET application.  This has the responsibility of loading and unloading data from a database, as well as providing a user interface (like showing a list of workflows in progress, showing assigned tasks, etc.).  http://msdn.microsoft.com/en-us/library/ms735891(v=vs.90).aspx

Design the workflows.  The workflows can be designed in Visual Studio (similar to developing a Windows Forms application or Visio document), designed entirely in C# code, or in XML.  Your host application will then load these workflows and be able to manage and kick off new instances of them.  http://msdn.microsoft.com/en-us/library/ms734628(v=vs.90)

There is a bit of a learning curve, but ultimately it will save you plenty of time having to redesign a workflow solution up from the ground up, letting you focus (mostly) on coming up with great and flexible business logic.

Title: Web workflow solution - how should I approach the design?

Body:
We've been tasked with creating a web based workflow tool to track change management. It has a single workflow  with multiple synchronous tasks for the most part, but branch out at a point to tasks running in parallel which meet up later on. There will be all sorts of people using the application, and all of them will need to see their outstanding tasks for each change, but only theirs, not others. There will also be a high level group of people who oversee all changes, so need to see everything. They will need to see tasks which have not been done in the specified time, who's responsible etc.

The data will be persisted to a SQL database. It'll all be put together using .Net.

I've been trying to learn and implement OOP into my designs of late, but I'm wondering if this is moot in this instance as it may be better to have the business logic for this in stored procedures in the DB. I could use POCO's, a front end layer and a data access layer for the web application and just use it as a mechanism for CRUD actions on the DB, then use SP's fired in the DB to apply the business rules.

On the other hand, I could use an object oriented design within the web app, but as the data in the app is state-less, is this a bad idea? I could try and model out the whole application into a class structure, implementing interfaces, base classes and all that good stuff. So I would create a change class, which contained a list of task classes/types, which defined each task, and implement an ITask interface etc. Put end-user types into the tasks to identify who should be doing what task.  Then apply all the business logic in the respective class methods etc.

What approach do you guys think I should be using for this solution?


问:
Is there a pattern or logical structure I can follow for Event Log Numbers?
What are some ideas or structure I can use when assigning  EventID to events that will be saved to the Windows Event Log?

Some options I've considered

Sequential  (0... int.Max)

Multiple of 10, where the "0" is replaced with how noisy the debugLevel is set.

xxx0 may represent exceptions, critical information, start, stop etc.

...?

What numbering approach gives you the most insight when a user describes the event in an email or phone?

What is the most useful to support staff?

答:
Sequential increment by 10, but don't use the 1s column until you need to.  It's a (very) simple safeguard for future granularity and grouping similar events.

For example, we have statuses 100 for "new record", 200 for "in progress", 300 for "submitted", and so on.

Recently, 210, 220, and 230 were added because extra steps were introduced in the editing process.  Because we left gaps in the IDs, we were able to insert the them in a logical place - the range 2* all have to do with "in progress" somehow.

But these additions tend to be rare, which is why I suggest using 10s instead of 100s like we did.

Queries for "all in progress states" are then a simple BETWEEN 200 AND 299.  (or, 20 and 29 if you use 10s)

ContentLicense: CC BY-SA 3.0


答:
Fair warning: Coming up with a scheme like this will require governance in order to keep the scheme useful.

I have been on a number of projects that use a similar scheme as what you're describing.  It's very helpful for help desk, L2, and L3 when the scheme is enforced.  One of the big advantages is HD can quickly tell to pass on certain messages and pass them up the chain because they indicate more severe problems than what they are trained for.

I would recommend breaking down first by area, then by severity.

Leave yourself LOTS of room between major areas as it's a real PITA, if not downright impossible, to move error numbers around after they are set.  It's not a technical challenge, but more of a documentation and re-training challenge.

A simple scheme could be this:

- 1,000's belong to "base application messages"

- 2,000's belong to IO

- 3,000's belong to DB comms

...

- 9,000's belong to ugly abends that require immediate L3 investigation

where each of the blocks is a major area of your application.  User Interface / DB hooks / Config mgmt / file IO / etc... are just a few examples of areas that could receive their own block of message numbers.

Within those groups:

0 - 250 are informational

251 - 500 are warning

501 - 750 are error

751 - 999 are debug / trace (assuming you don't have a separate facility for that)

If you can use a letter indicator at the end of the message, then you could skip this severity subgrouping.  But not all event storage mechanisms allow for using a non-numeric character.

Another option would be to use the last digit of the message to indicate severity.  In other words, error numbers ending in 0,1,2 are Info, ... 8,9 are debug / sky-is-falling.

Obviously, cater the numbers and ranges based upon your needs, the above are just examples.

This is a similar, but different layout than HTTP error codes.

With the primary difference being that it is an application area driving the organization / assigning of error message numbers.  HTTP codes don't really have application areas to break things down by.

I'm not a big fan of just using sequential numbers or using skip counting.  First off, there is no logical structure to those schemes and merely gives a hint as to when the messages were created.  Knowing that 0010 was created as an error message long before message 750 is pretty much meaningless information.

I would put in a vote for logical organization even within the info / warning / error categories, but that can become very difficult or cumbersome to maintain.

Title: Is there a pattern or logical structure I can follow for Event Log Numbers?

Body:
What are some ideas or structure I can use when assigning  EventID to events that will be saved to the Windows Event Log?

Some options I've considered

Sequential  (0... int.Max)

Multiple of 10, where the "0" is replaced with how noisy the debugLevel is set.

xxx0 may represent exceptions, critical information, start, stop etc.

...?

What numbering approach gives you the most insight when a user describes the event in an email or phone?

What is the most useful to support staff?


问:
Why are side-effects considered evil in functional programming?
I feel that side effects are a natural phenomenon. But it is something like taboo in functional languages. What are the reasons?

My question is specific to functional programming style. Not all programming languages/paradigms.

答:
From an article about Functional programming:

In practice, applications need to have some side effects. Simon Peyton-Jones, a major contributor to the functional programming language Haskell, said the following: "In the end, any program must manipulate state. A program that has no side effects whatsoever is a kind of black box. All you can tell is that the box gets hotter." (http://oscon.blip.tv/file/324976) The key is to limit side effects, clearly identify them, and avoid scattering them throughout the code.

ContentLicense: CC BY-SA 2.5


问:
What is an “implementation plan”?
I was recently given the task of creating an implementation plan document. When I asked for an example of one that I could look at, I was told to look at the Project Plan that had already been created an use that as a base. I'm still a bit confused on what I should be creating.

Can anyone point me to a good example out there or to something that explains what this is and more importantly the details about what it should contain.

答:
This depends a lot on the size of your project, and what exactly you are implementing.  I've found that a lot of formal documents are overkill for most small projects.  I usually start by writing myself a list of things that need to happen before I implement. I ask myself questions like:

What actually will be implemented?

When do we want to do it, and what do we need to check before we do the implementation?

Do users have to be out of the systems when we do the implementation?

Is there a time-dependency (i.e. outside business hours, on the weekend, etc) for our implementation?

How many actual servers/workstations/databases are going to be updated?

Is this a brand-new application, or an upgrade to an existing system (the answer to this changes your implementation plan A LOT)?

What are the actual steps we will take to do the implementation?

How will we back up the existing system before we implement, in case we need to roll back?

How will we test the application after it is implemented?

How do we roll back to our backup?

Who needs to be notified about the implementation (before, during, after, statuses, etc.)?

Do we have documentation of what the changes are, and how the users can use the new changes?

Who's going to take support phone calls from users?

Once I have answers to these kinds of questions, I write up the plan, usually as a basic Word document, with different sections and a timeline.  I like to put in the detailed step by step parts, with paths to files, etc., logins, etc., so I will have all the sticky little detail in one place.

As a morning person who has to do installs when I'm normally sleeping, I like the comfort of a list of all the steps I need to take, so I don't forget something. I think it is worth writing down the communication steps you'll take, particularly if a group is doing the implementation, and some items are dependent on the others, or if you aren't all in the same place.  (ex.  I will email Fred when the database updates are complete, so that he can do the web server updates, Fred will email us all when he's done, so we can all do the testing)

Then, once you have one that works, it can become your template for future updates to the same system, or be a jumping off point.

Title: What is an “implementation plan”?


问:
Is this overkill? Using MDX queries and cubes instead of SQL stored procedures
I am new to Microsoft's SQL Server Analysis Services Cubes and MDX queries.  Where I work we have a daily sales table in SQL Server 2005 that already contains an aggregate of sale information per store per day. At this time it contains only 164,000+ rows. We have a sales cube dedicated to this table that about 15 reports are based off of. Now, I should also note that we generate reports based on our own fiscal year criteria: a 13 period year (1 month equals 28 days etc.).

Is this overkill? At what point is it justified to begin using SSAS Cubes/MDX over plain old SQL Server stored procedures? Since I have always been just using plain old SQL am I tragically late to the MDX party?

答: Generally people don't go the datawarehousing route until performance is suffering on the production server. With large reports and aggregations, reporting, especially with one or more years' worth of data, can be extremely slow in an ordinary relational database. It is especially true when a report that returned only 200 records when it was created returns 2 million records in December and has 20 or 30 calcuations that end up being processed row-by row through functions.  And at times running those huge reports ends up stopping eveyone else's work. So the work is moved to a data warehouse and the report people are happy becuase their reports run faster and the users are happy because they don't heve slowdowns once a month whe the reports run and the BI people are happy because they always have work to do and becasue they get paid better than someone who just writes t-sql code! </p>


问:
Can I do a git merge entirely remotely?
My team shares a "work" branch and a "stable" branch. Whenever a particular work branch is approved for further testing/release/etc, we merge it into stable. No code is ever checked directly into the stable branch.

Because of this, merge conflicts simply won't happen, and it seems silly to pull down the work branch and the stable branch, merge them, and then push the changes back. Is there a git command to ask a remote git server to commit a merge of two branches that it already knows about?

答:
It's kinda in the nature of a DVCS that the action happens on a local machine, and gets pushed back to the main repo.

If it's that onerous, script it.

```<code>#!/bin/bash

if [ ! -f ".git" ]
then
  echo "Not in a git repo!" >&2
  exit 1
else
  git checkout stable && \
  git pull origin stable && \
  git merge work && \
  git push origin stable
fi
</code>```

Title: Can I do a git merge entirely remotely?

Body:
It's kinda in the nature of a DVCS that the action happens on a local machine, and gets pushed back to the main repo.

If it's that onerous, script it.

#!/bin/bash

if [ ! -f ".git" ]
then
  echo "Not in a git repo!" >&2
  exit 1
else
  git checkout stable && \
  git pull origin stable && \
  git merge work && \
  git push origin stable
fi


答: Yes - by using SSH. Just SSH into the server containing the repo. If you have permissions to write to the repository and execute git, then just cd into the repository's directory and run the git merge command.</p>

Title: Can I do a git merge entirely remotely?

Body:
My team shares a "work" branch and a "stable" branch. Whenever a particular work branch is approved for further testing/release/etc, we merge it into stable. No code is ever checked directly into the stable branch.

Because of this, merge conflicts simply won't happen, and it seems silly to pull down the work branch and the stable branch, merge them, and then push the changes back. Is there a git command to ask a remote git server to commit a merge of two branches that it already knows about?


问:
Centrally managing 100+ websites without bankrupting a small company
I'm mainly interested in opinions on the trade-offs between having a single central server all the websites connect to as opposed to each website mirroring a subset of the master database with all the products in it. For example, will I run into severe performance issues (or even security issues, or restrictions) making queries to an offsite database? Will we hit scalability issues we can't handle early on from the sheer bandwidth required to maintain this? If we do go with something like a script that keeps smaller databases (each containing a subset of the central master data) in sync, what sorts of issues will we likely encounter there? I would really like the opinions of people far more knowledgeable than I am regarding the pros and cons of both setups and what headaches we are likely to encounter.

CLARIFICATION: This should not be viewed as a question about whether we should implement one database vs multiple databases. This question has been answered numerous times. The question is regarding the pros and cons for a deployment like this having the ability to manage all the websites centrally (one server) vs trying to keep them all in sync if they each have their own db (multiple servers).

REAL-WORLD EXAMPLE: We are a t-shirt company, and we have individual websites for our different kinds of t-shirts, but we're looking at a central order management integrated with our single shopping cart (which is ColdFusion + MySQL). Now, let's say we have a t-shirt that's on 10 of our websites and we change an image for it. Ideally we would change that in one place and the change would propagate, but how would we set this up?

答:
The answer is for each Web app you need a different database because of the security reasons. Simply do not put all your eggs in one basket!. If somebody attach your DB then you lost everything.

There is no cost difference between 1 database or 100 databases!. Most of the hosting companies get a certain rate (something like <40$) so you will have unlimited data storage and the ability to create unlimited number of DBs.


问:
The cost of longer delay between development and QA
At my current position, QA has become a bottleneck.  We have had the unfortunate occurence of features being held out of the current build so that QA could finish testing.  This means features that are done being developed may not get tested for 2-3 weeks after the developer has already moved on.  With dev moving faster thean QA, this time gap is only going to get bigger.

I keep flipping through my copy of Code Complete, looking for a "Hard Data" snippet that shows the cost of fixing defects grows exponentially the longer it exists.  Can someone point me to some studies that back up this concept?  I am trying to convince the powers that be that the QA bottleneck is a lot more costly than they think.

答:
You don't need any references, IMHO. Here's what you could (rather should) do:

Quantify the Cost of Delay! Let's assume that it takes 1 week to test the feature(s). A 2-3 week delay implies that the feature won't be available till at least the 4th week. And that too assuming 100% success. Add a fixing time of another week so that's about 5 weeks of delay.

Now, if possible get access to the expected deadline of the project/feature. By when does the client expect it? Will it slip? If not, will others slip as a consequence? So by how much will the 'release' be delayed as a result?

What is the 'cost to company' for that release i.e. how much does the client expect to profit from that release? If they expect $5200/yr of profit from that release then every week slipped costs them $100 in lost revenue. That's the client view. You may or may not have access to this data but it's worth taking into consideration and stating how the delay can impact the relationship.

Now, what's the loss to the developers? Once the developer moves on to other features, you ask him/her to break their cycle and 'fix' the previous feature. What's the time/effort loss? Convert it to cost to company by using the salary as a multiple for every hour wasted as a result. You can use that to say the amount of "profit/revenue" which the waste is "eating into".

What you've stumbled on can be conveniently quantified using "Cost of Delay" - advocated by Don Reinerstein in Principles of Product Development flow and also by Dean Leffingwell in Agile Software Requirements. You should be able to back every such claim by economic factors to convince the 'higher powers' whose primary language is $$ - you must speak their language to convince them :)

Beast of luck! (pun intended :)


答:
It sounds like what you are asking about is database replication.  You'd set that up with your MySQL servers to replicate changes made to, say, a master product table over to product tables in the various databases for the individual sites.  Such replication can be done between databases on either the same physical server or different ones.

That said, doing so seems needlessly complex when you can just use one shared db for all the stores and just have the individual stores filter on those products it can display.  A master inventory control panel could be made to assign products to sites.  If traffic then becomes an issue, you can replicate the single master database to other database servers, and point read-only queries over to the replicated copy of the database (read from many, but only write to the master db).

Title: Centrally managing 100+ websites without bankrupting a small company

Body:
I'm mainly interested in opinions on the trade-offs between having a single central server all the websites connect to as opposed to each website mirroring a subset of the master database with all the products in it. For example, will I run into severe performance issues (or even security issues, or restrictions) making queries to an offsite database? Will we hit scalability issues we can't handle early on from the sheer bandwidth required to maintain this? If we do go with something like a script that keeps smaller databases (each containing a subset of the central master data) in sync, what sorts of issues will we likely encounter there? I would really like the opinions of people far more knowledgeable than I am regarding the pros and cons of both setups and what headaches we are likely to encounter.

CLARIFICATION: This should not be viewed as a question about whether we should implement one database vs multiple databases. This question has been answered numerous times. The question is regarding the pros and cons for a deployment like this having the ability to manage all the websites centrally (one server) vs trying to keep them all in sync if they each have their own db (multiple servers).

REAL-WORLD EXAMPLE: We are a t-shirt company, and we have individual websites for our different kinds of t-shirts, but we're looking at a central order management integrated with our single shopping cart (which is ColdFusion + MySQL). Now, let's say we have a t-shirt that's on 10 of our websites and we change an image for it. Ideally we would change that in one place and the change would propagate, but how would we set this up?


答:
Evil is a bit over the top.. it all depends on the context of the usage of the language.

Another consideration to those already mentioned is that it makes proofs of correctness of a program much simpler if there are no functional side effects.

Title: Why are side-effects considered evil in functional programming?

Body:
I feel that side effects are a natural phenomenon. But it is something like taboo in functional languages. What are the reasons?

My question is specific to functional programming style. Not all programming languages/paradigms.


问:
Gerrit, git and reviewing whole branch
I'm now learning Gerrit (which is the first code review tool I use). Gerrit requires a reviewed change to consist of a single commit. My feature branch has about 10 commits.

The gerrit-prefered way is to squash those 10 commits into a single one. However this way if the commit will be merged into the target branch, the internal history of that feature branch will be lost. For example, I won't be able to use git-bisect to bisect into those commits. Am I right?

I am a little bit worried about this state of things. What is the rationale for this choice? Is there any way of doing this in Gerrit without losing history?

答:
Code review has the best impact when it is a pre-commit (pre-push in case of git) hook. If an error in encountered in 5th of your ten commits, how would you fix it (preserving history)? Sure, you can create another topic branch, fix that commit, cherry-pick the remaining 5 commits and resend the diffs for review, but this is very complex (albeit you can write a script for it).

Changes made to a single repo should ideally preserve its state (e.g. not break the build, tests, etc.) So if your changes are done this way, they can be reviewed separately, otherwise, squashing them would be better, than leaving the repo inconsistent.

You can create a bug in the bug tracker, and put a reference in every commit, so that the reviewers and future readers would know, what you were trying to achieve in whole.

Title: Gerrit, git and reviewing whole branch


问:
Git, auto updating, security and tampering?
I was thinking about hosting my private project on my server (i may use 'gitolite') and have a copy on my local machine as backup (git clone then automated git fetch every few minute). I want to know what happens if there is a bug gitolite or somewhere else on my server and the source code and git repository has been tampered with? Will my backup also be corrupted? will i easily be able to revert the source using the history?</p>

答:
Backup the folder that the project is in (its 'root') which includes the .git directory tree of files that are the contents of git.

Backing up 'outside' of git is a good idea - although be aware that after any add or change it's out of date, as in the nature of daily backups.


答:
Is that overkill? Based on the information you have provided, I would say probably yes. Given the table is relatively small and it seems the users are mostly interested in a limited number of "canned" reports, it might have been simpler just to deliver the reports using SSRS and stored procedures running directly on the table.

In my experience cubes are more valuable when you have a large number of users who want to create their own reports, drill down, slice the data in different ways etc. With very large data sets there can also sometimes be performance advantages with cubes. Also, some types of queries are more easily expressed using MDX.

On the other hand sometimes there is so clear right or wrong way to do something, so I wouldn't lose any sleep over it.

Title: Is this overkill? Using MDX queries and cubes instead of SQL stored procedures

Body:
I am new to Microsoft's SQL Server Analysis Services Cubes and MDX queries.  Where I work we have a daily sales table in SQL Server 2005 that already contains an aggregate of sale information per store per day. At this time it contains only 164,000+ rows. We have a sales cube dedicated to this table that about 15 reports are based off of. Now, I should also note that we generate reports based on our own fiscal year criteria: a 13 period year (1 month equals 28 days etc.).

Is this overkill? At what point is it justified to begin using SSAS Cubes/MDX over plain old SQL Server stored procedures? Since I have always been just using plain old SQL am I tragically late to the MDX party?


答:
Any side-effect introduces extra input/output parameters which must be taken in account when testing.

This make code validation much more complex as the environment cannot be limited to just the code being validated, but must bring in some or all of the surrounding environment (the global that is updated lives in that code over there, which in turn depends on that code, which in turn depends on living inside a full Java EE server....)

By trying to avoid side-effects you limit the amount of externalism needed to run the code.


问:
Should I add an "Abstract" prefix to my abstract classes?
Suppose I have an abstract class named Task.

Is there a standard or convention that would suggest I should name it AbstractTask instead?

答:
In my opinion, an entity's name shouldn't convey information about its type structure, but about its semantics. So it doesn't make sense to define your class as "AbstractSomething" if the abstraction is not part of its runtime goal. That it is a base abstract class is visible for the programmer, and doesn't need to be reflected in the name.

However, if makes perfect to call an implementation of an abstract factory an AbstractFactory, because that does relate to the class's intent.

In general, favor naming convention that help to convey the most information about the goal of your class.

Similarly, stay clear from SomethingImpl. We don't care that it's an implementation and not a base class. If your class hierarchy is designed properly for inheritance, then someone could inherit from it. Surely there would be no value in them adding more "Impl" suffixes or other artifacts. There's also no value in adding an "Interface" suffix or "I" prefix.

Consider:

```<code>IVehicle <-- IMotoredVehicle <-- AbstractCar <-- CarImpl
</code>```

As opposed to:

```<code>Vehicle <-- MotoredVehicle <-- Car <-- DefaultCar
                                   <-- Ferrari
                                   <-- Trabi
</code>```

I prefer the latter by far.

This, in some respect, similar to the blatant misuse of the Hungarian Notation that latter gave it its bad rep, as people wrongly started to interpret it as requiring developers to prefix their variables with an indicator of the variable's type. While this can sometimes have its uses (mostly if you are lazy to look up the type's definition), it's mostly useless. Simonyi's original idea with the Hungarian Notation was to use it as a mnemonic to remind the developer of the entity's capabilities, not of its type.

Body:
In my opinion, an entity's name shouldn't convey information about its type structure, but about its semantics. So it doesn't make sense to define your class as "AbstractSomething" if the abstraction is not part of its runtime goal. That it is a base abstract class is visible for the programmer, and doesn't need to be reflected in the name.

However, if makes perfect to call an implementation of an abstract factory an AbstractFactory, because that does relate to the class's intent.

In general, favor naming convention that help to convey the most information about the goal of your class.

Similarly, stay clear from SomethingImpl. We don't care that it's an implementation and not a base class. If your class hierarchy is designed properly for inheritance, then someone could inherit from it. Surely there would be no value in them adding more "Impl" suffixes or other artifacts. There's also no value in adding an "Interface" suffix or "I" prefix.

Consider:

IVehicle <-- IMotoredVehicle <-- AbstractCar <-- CarImpl

As opposed to:

Vehicle <-- MotoredVehicle <-- Car <-- DefaultCar
                                   <-- Ferrari
                                   <-- Trabi

I prefer the latter by far.

This, in some respect, similar to the blatant misuse of the Hungarian Notation that latter gave it its bad rep, as people wrongly started to interpret it as requiring developers to prefix their variables with an indicator of the variable's type. While this can sometimes have its uses (mostly if you are lazy to look up the type's definition), it's mostly useless. Simonyi's original idea with the Hungarian Notation was to use it as a mnemonic to remind the developer of the entity's capabilities, not of its type.


问:
What is a dotted pair's analogy in other Lisp implementations?
What is Scheme's dotted pair construct analogous to in other Lisp implementations? I can make a vector or list quite easily, and understand those in Clojure, even though the syntax is a little different, like Clojure's vectors use square brackets [].

However, seeing a dotted pair for the first time threw me. It almost looks like it is an implementation of of map.

I'm not looking for a discussion, but more for use or the dotted pair equivalent in other Lisp dialects, like Clojure, or even Python.

答:
Common Lisp (implementation: SBCL)

```<code>* (cons 1 2)

(1 . 2)
* (car '(1 . 2))

1
* (cdr '(1 . 2))

2
</code>```

I'm pretty sure that's standard Common Lisp.

Here's some Clojure:

```<code>Clojure 1.3.0
user=> (cons 1 2)
IllegalArgumentException Don't know how to create ISeq from: java.lang.Long  clojure.lang.RT.seqFrom (RT.java:487)
user=> (car '(1 . 2))
CompilerException java.lang.RuntimeException: Unable to resolve symbol: car in this context, compiling:(NO_SOURCE_PATH:2)
user=> (cdr '(1 . 2))
CompilerException java.lang.RuntimeException: Unable to resolve symbol: cdr in this context, compiling:(NO_SOURCE_PATH:3)
user=> '(1 . 2)
(1 . 2)
user=> (first '(1 . 2))
1
user=> (rest '(1 . 2))
(. 2)
</code>```

I'm really not a Clojure expert (or a Common Lisp expert), but I'm not sure Clojure has anything that supports an improper list (like '(a b . c)) built in.

Body:
Common Lisp (implementation: SBCL)

* (cons 1 2)

(1 . 2)
* (car '(1 . 2))

1
* (cdr '(1 . 2))

2

I'm pretty sure that's standard Common Lisp.

Here's some Clojure:

Clojure 1.3.0
user=> (cons 1 2)
IllegalArgumentException Don't know how to create ISeq from: java.lang.Long  clojure.lang.RT.seqFrom (RT.java:487)
user=> (car '(1 . 2))
CompilerException java.lang.RuntimeException: Unable to resolve symbol: car in this context, compiling:(NO_SOURCE_PATH:2)
user=> (cdr '(1 . 2))
CompilerException java.lang.RuntimeException: Unable to resolve symbol: cdr in this context, compiling:(NO_SOURCE_PATH:3)
user=> '(1 . 2)
(1 . 2)
user=> (first '(1 . 2))
1
user=> (rest '(1 . 2))
(. 2)

I'm really not a Clojure expert (or a Common Lisp expert), but I'm not sure Clojure has anything that supports an improper list (like '(a b . c)) built in.


答:
Pages 29 and 30 may have the data you are looking for, although a follow up might be required.

I would look into the research mentioned in this sentence on page 30:

Dozens of companies have found that simply focusing on correcting defects earlier rather than later in a project can cut development costs and schedules by factors of two or more (McConnell 2004).

BTW, it was your question that made me pick the book up again to refresh it :-)

Title: The cost of longer delay between development and QA

Body:
At my current position, QA has become a bottleneck.  We have had the unfortunate occurence of features being held out of the current build so that QA could finish testing.  This means features that are done being developed may not get tested for 2-3 weeks after the developer has already moved on.  With dev moving faster thean QA, this time gap is only going to get bigger.

I keep flipping through my copy of Code Complete, looking for a "Hard Data" snippet that shows the cost of fixing defects grows exponentially the longer it exists.  Can someone point me to some studies that back up this concept?  I am trying to convince the powers that be that the QA bottleneck is a lot more costly than they think.


问:
For what problems is object oriented programming not a good choice?
Somewhat inspired by this question: For what common problems is functional programming not a good fit? - but nevertheless a question which I always wanted, but was too afraid to ask.

I've been in ... well, let's call it engineering software development practically all my life, and in all that time, although OO had always been there (well, most of that time) I've never had the need to use "its ways", nor to learn that paradigm. We've always used rather simple program structures, routines/functions/modules and although it is opposite to today's best practices managing those programs (programs up to roughly 300k LOC, nothing too big) never proved to be difficult, let alone impossible.

So I wanted to ask you, what would be the sorta problems for which object oriented paradigm would not be a good choice? In comparison to procedural programming ?

答:
The PURE object oriented languages are not suitable for many cases. Because there are some criteria to be fulfilled for being pure object oriented language. See-

https://stackoverflow.com/questions/250062/what-is-meant-by-the-term-true-object-orientation/250098#250098

But most widely-used programming languages are multi-paradigm. They incorporate many non-OO features to encounter various types of programming and development issues. C++, C#, Java or Ruby all have non-OO functionalities. So, they can face issues that pure-OO is not good at.


问:
What Is The Formula for the 3 of 9 Bar Code Alphabet?
Background:
3 of 9 Barcode Alphabet

A simple syntax for 3 of 9 bar codes

What is the formula behind the alphabet and digits in a 3 of 9 bar code?

For example, ASCII has a relatively clear arrangement. Numbers start at 33, capitals at 65, lowercase at 97. From these starting points you can infer the ASCII code for any number or letter. The start point for each range is also a multiple of 32 + 1.

Bar codes seem random and lacking sequence. If we use the syntax from the second link, this is the first six characters in 3 of 9:

```<code>A 100-01
B 010-01
C 110-00
D 001-01
E 101-00
F 011-00
</code>```

I see no pattern here; what is it? I'm as much interested in the designer's intended pattern behind these as I am in someone devising an algorithm of their own that can give you the above code for a given character based on its sequence.

I struggled with where to put this question; is it history, computer science, information science? I chose Programmers because a StackExchange search had the most barcode hits here, and because I wanted to specifically relate it to ASCII to explain what sort of formula/explanation I'm looking for.

Update

For the curious, here's the full list of all basic characters in Code 39: http://jsfiddle.net/b9chris/LnX2e/2/

(the source lines are taken from my C# barcode lib)

You'll notice that the simplified syntax proposed can confuse the issue a bit, because it might imply that every character is a 5-bit number with a dash position. The final 4 characters have numerous dashes (wide gaps). Really, these codes are best thought of as 9-bit numbers that happen to have most odd bits set to 0 for the majority of symbols. Here they are as 9-bit numbers: http://jsfiddle.net/b9chris/LnX2e/1/

答: I don't know if this is the correct explanation, but based on what you posted: The first 3 bits are 1 to 6 in reverse binary.  The last digit is 1 when there are an odd number of 1s in the first 3(4?) bits, so this is probably a parity bit.</p>


问:
Where does Microsoft currently stand on dynamic languages?
With languages Python and Ruby still having a good foothold in the market what is Microsoft's current stance on dynamic languages?

Does Microsoft have any plans to incorporate or invent it's own dynamic language?

答: Microsoft used to have IronRuby, but that was discontinued around 2010. IronPython also exists and is still being developed (though not by Microsoft). Both of these languages run on the .NET framework.</p>


问:
Relationship between Repository and Unit of Work
I am going to implement a repository, and I would like to use the UOW pattern since the consumer of the repository could do several operations, and I want to commit them at once.

After read several articles about the matter, I still don't get how to relate this two elements, depending on the article it is being done in a way u other.

Sometimes the UOW is something internal to the repository:

public class Repository
{
    UnitOfWork _uow;

    public Repository()
    {
       _uow = IoC.Get<UnitOfWork>();
    }

    public void Save(Entity e)
    {
        _uow.Track(e);
    }

    public void SubmittChanges()
    {
        SaveInStorage(_uow.GetChanges());
    }
}
```

<p>And sometimes it is external:</p>

<pre class="lang-cs prettyprint-override"><code>public class Repository
{
    public void Save(Entity e, UnitOfWork uow)
    {
        uow.Track(e);
    }

    public void SubmittChanges(UnitOfWork uow)
    {
        SaveInStorage(uow.GetChanges());
    }
}
</code>```

Other times, is the UOW whom references the Repository

public class UnitOfWork
{
    Repository _repository;

    public UnitOfWork(Repository repository)
    {
       _repository = repository;
    }

    public void Save(Entity e)
    {
        this.Track(e);
    }

    public void SubmittChanges()
    {
       _repository.Save(this.GetChanges());
    }
}
```

How are these two elements related? UOW tracks the elements that needs be changed, and repository contains the logic to persist those changes, but... who call who? Does the last make more sense?

Also, who manages the connection? If several operations have to be done in the repository, I think using the same connection and even transaction is more sound, so maybe put the connection object inside the UOW and this one inside the repository makes sense as well.

Cheers

答:
Re: "UOW tracks the elements that needs be changed, and repository contains the logic to persist those changes, but... who call who?"

You understand the basic responsibilities of these classes. You say that each of the articles, that you've read, connects them together in different ways. This implies that the decision about "who calls who" is up to you.

I'd try to sketch out the problem in terms of 'layers' whilst being guided by basic principals of good software design such as Cohesion, Decoupling, Reusability, Unit-Testability etc.

To quote Eric Evans Domain Driven Design, (2004) Addison Wesley,  pg 69:

The essential principal [of Layered Archituctures] is that any element
  of a layer depends only on other elements in the same layer or on
  elements of the layers "beneath" it.

In my opinion, both the UOW and Repo are two very different classes that have clear, independent, responsibilities. To start with, I wouldn't make either invoke the other.

I think you need some third client class (i.e. either a controller or service class) that really knows 'when and what to get' from the repo and 'when' to save the transaction. This client sits relatively high in the architecture (so can know about more classes) and can do some orchestration between the two.

```<code>--------------------------------

         [Client]
           /   \
----------/---- \---------------
         /       \
        V         V
[Unit Of Work]  [Repo]

--------------------------------
</code>```

Body:
Re: "UOW tracks the elements that needs be changed, and repository contains the logic to persist those changes, but... who call who?"

You understand the basic responsibilities of these classes. You say that each of the articles, that you've read, connects them together in different ways. This implies that the decision about "who calls who" is up to you.

I'd try to sketch out the problem in terms of 'layers' whilst being guided by basic principals of good software design such as Cohesion, Decoupling, Reusability, Unit-Testability etc.

To quote Eric Evans Domain Driven Design, (2004) Addison Wesley,  pg 69:

The essential principal [of Layered Archituctures] is that any element
  of a layer depends only on other elements in the same layer or on
  elements of the layers "beneath" it.

In my opinion, both the UOW and Repo are two very different classes that have clear, independent, responsibilities. To start with, I wouldn't make either invoke the other.

I think you need some third client class (i.e. either a controller or service class) that really knows 'when and what to get' from the repo and 'when' to save the transaction. This client sits relatively high in the architecture (so can know about more classes) and can do some orchestration between the two.

--------------------------------

         [Client]
           /   \
----------/---- \---------------
         /       \
        V         V
[Unit Of Work]  [Repo]

--------------------------------


问:
How to access functions in extended classes efficiently?
In PHP I have classes as below

```<code>class Animal {
    //some vars
    public function printname(){
        echo $this->name;
    }
}

class AnimalMySql extends Animal {
    static public function getTableFields(){
        return array();
    }
}

class AnimalPostgreSql extends Animal {
    static public function getTableFields(){
        return array();
    }
}
</code>```

Now I have an object $lion = new Animal(); and I want to do

```<code>if($store == mysql)
    //getTableFields from class AnimalMySql
else
    //getTableFields form class AnimalPostgreSql
</code>```

I am new to OOP and not sure what is the best way to call the method from the specific class
P.S. Please leave a note with the answer to explain the efficiency of the approach

答:
To call the correct function based on the type data store will look as follow:

```<code>if($store == mysql)
{
  $lion = new AnimalMySql(); //extends the Animal class
  $array = $lion ->getTableFields();
  //Alternatively - $array = $lion::getTableFields();

}
else
{
  $lion = new AnimalPostgreSql(); //extends the Animal class
  $array = $lion ->getTableFields();
  //Alternatively - $array = $lion::getTableFields();

}
</code>```

To make it more effecient, put the getTableFields method in the Animal class seeing that it's function is exactly the same for both sub classes. When you define a subclass to extend to the Animal class the method will be exposed instantly. this is standard method to call classes in PHP. Striving to write fewer lines of code is always a good idea to keep code manageable and more efficient.

Body:
To call the correct function based on the type data store will look as follow:

if($store == mysql)
{
  $lion = new AnimalMySql(); //extends the Animal class
  $array = $lion ->getTableFields();
  //Alternatively - $array = $lion::getTableFields();

}
else
{
  $lion = new AnimalPostgreSql(); //extends the Animal class
  $array = $lion ->getTableFields();
  //Alternatively - $array = $lion::getTableFields();

}

To make it more effecient, put the getTableFields method in the Animal class seeing that it's function is exactly the same for both sub classes. When you define a subclass to extend to the Animal class the method will be exposed instantly. this is standard method to call classes in PHP. Striving to write fewer lines of code is always a good idea to keep code manageable and more efficient.


问:
Using a back-end mechanism to copy files to DB and notify the application
This Scenario: User copies large files to a local folder. I want to watch that folder and when a new file is dropped then go and copy it to Database, so later when coping is done I can actually use it in my application. ( A C# WinForms App). It would be awesome to also find a way to somehow get notified in the Application that hey copying the file to DB is finished and ready for use...

I am using C#.net, Windows... What solutions/architecture do you suggest for this?
For example having a windows service running all the time watching that folder, when something copied goes and write it to DB ... then how about getting notified? MSMQ is something I can use? don't know much about it yet.

Thanks.

答:
You can do it in two ways: -

If copying of files is being done through your application then you can write a piece of   code that will send you an email for notification.

If the user is not using the application for uploading the files then you can write a script that will be executed after every 30 minuts and read the folder in which the users are uploading the files and if a new file is found then either send you the notification or perform the required action on the file and notify you and the user.

Hope this helps.


答:
If you are talking about notifying the application, not user, two ways of doing that comes onto my mind:

Create and setup instance of System.IO.FileSystemWatcher, have your application working all the time (i.e. in system tray) and react as you only want to when files in directory change;

Create a service that will be listening the directory and will do all the copying and communicate with the main application through pipes.

Title: Using a back-end mechanism to copy files to DB and notify the application

Body:
This Scenario: User copies large files to a local folder. I want to watch that folder and when a new file is dropped then go and copy it to Database, so later when coping is done I can actually use it in my application. ( A C# WinForms App). It would be awesome to also find a way to somehow get notified in the Application that hey copying the file to DB is finished and ready for use...

I am using C#.net, Windows... What solutions/architecture do you suggest for this?
For example having a windows service running all the time watching that folder, when something copied goes and write it to DB ... then how about getting notified? MSMQ is something I can use? don't know much about it yet.

Thanks.


答:
The right pattern to think how this encoding works is that 1) you find a set of "safe bit sequences", then 2) map your characters to these sequences.

End result feels like a random order, but each of these steps is quite logical per se.

"Safe" bit sequences are such that if you invert a single bit in any of it, result will be "outside" of your set. This is a form of error checking - basically a major "selling point" of Code 39.

Say, if you want to "encode" that way two characters, you'll need two bits at least. 00 and 11 make a set of two safe bit sequences - break (invert) one bit in any of these and you will get invalid code. Note that set of 01 and 10 is safe, too.

To encode three characters, one needs more than two bits.

Example of safe set for three characters is 000, 110 and 011.

Now, you need to encode 39 characters.

First, find how much bits you need for that, then find a set of "safe bit sequences".

And only after that, map your characters, like first char -> first safe bit sequence, second char -> second sequence etc.

You see, it's easier to think in terms of "steps" here, not in terms of "formula".

Algorithm to find safe bit sequences for given number of bits N could be about as follows,

allocate boolean array of length 2 power N, initialize its elements with true

start with 0 - its boolean representation is N bits, each zero

do N times: invert one of the bits in 0 - that will be "unsafe bit sequence",

mark array element at resulting index false

array[1000], array[0100], array[0010], etc

find next after 0index in array where element is true,

for bit representation of that index, repeat same loop as above:

invert one of the bits and mark respective ("unsafe") element of array false

find next true index and so on and so on until array ends

In the end, elements of array marked true will represent "safe bit sequences".

To transform these sequences to bar code, one would just map pairs of bits appropriately, like 00 - narrow black, 01 - narrow white, 10 - wide black, 11 - wide white.

Title: What Is The Formula for the 3 of 9 Bar Code Alphabet?

Body:
Background:
3 of 9 Barcode Alphabet

A simple syntax for 3 of 9 bar codes

What is the formula behind the alphabet and digits in a 3 of 9 bar code?

For example, ASCII has a relatively clear arrangement. Numbers start at 33, capitals at 65, lowercase at 97. From these starting points you can infer the ASCII code for any number or letter. The start point for each range is also a multiple of 32 + 1.

Bar codes seem random and lacking sequence. If we use the syntax from the second link, this is the first six characters in 3 of 9:

```<code>A 100-01
B 010-01
C 110-00
D 001-01
E 101-00
F 011-00
</code>```

I see no pattern here; what is it? I'm as much interested in the designer's intended pattern behind these as I am in someone devising an algorithm of their own that can give you the above code for a given character based on its sequence.

I struggled with where to put this question; is it history, computer science, information science? I chose Programmers because a StackExchange search had the most barcode hits here, and because I wanted to specifically relate it to ASCII to explain what sort of formula/explanation I'm looking for.

Update

For the curious, here's the full list of all basic characters in Code 39: http://jsfiddle.net/b9chris/LnX2e/2/

(the source lines are taken from my C# barcode lib)

You'll notice that the simplified syntax proposed can confuse the issue a bit, because it might imply that every character is a 5-bit number with a dash position. The final 4 characters have numerous dashes (wide gaps). Really, these codes are best thought of as 9-bit numbers that happen to have most odd bits set to 0 for the majority of symbols. Here they are as 9-bit numbers: http://jsfiddle.net/b9chris/LnX2e/1/


问:
Best approach to learning web programming
I come from a scientific and embedded programming background, and I have had minimal experience with web programming.  What would be the best approach to take to get up to speed with web programming?  Tools and framework suggestions?

One approach would be to dive into learning a framework, such as Rails. I started doing this with rails tutorial, but I find that the framework abstracts so many important concepts that I should be learning.

To sum up, experienced programmer wants to learn web-app programming.

答:
From experience, the best way has to be get in too deep. Get making stuff, make mistakes, make lot's of mistakes. Learn from them.

With so many alternate paths, it's a really subjective thing to say you should take any one of them.


答:
Microsoft has a fine Javascript engine. Within WinRT Javascript will be a first-class citizen next to C++ and .NET.

And then there also is PowerShell which is a new dynamic language at a central position within Windows.

Title: Where does Microsoft currently stand on dynamic languages?

Body:
With languages Python and Ruby still having a good foothold in the market what is Microsoft's current stance on dynamic languages?

Does Microsoft have any plans to incorporate or invent it's own dynamic language?


答: Microsoft has the power of .NET . But there are more better languages then this (according to me) like python, ruby. The .NET has a great demand in the market as it is easy to hide the code. Further, it also provides good licenses that can earn you a lot of money. But the other languages like python or ruby are originally meant for open-source development.</p>


答:
Difficult to say for sure; even if a Microsoft team was behind IronRuby, Ruby was not necessarily a direct target. Microsoft has been known to throw money at experimental languages (M, Axum), even if they were only a (very) tentative part of their strategy.

When they integrated the DLR into the framework, they chose to immediately have the core languages (C# and VB.NET) leverage a lot of what the DLR can do, which took a big bite out of the market where the Iron* dynamic languages would have been - there was a lot of competition there anyway. On top of that, 3rd party dynamic languages (like Cobra) started to show up, to crowd the scripting gap even more. Since it's relatively easy to build a new compiler from some language to CIL, this area is really volatile.

There is speculation about a "DLR2" in a future version of .NET, supporting compiler-as-a-service and better scripting hosts, which means they're probably aiming to have even better integration between scripted code and host code.

All these lead me to believe that pure dynamic languages will remain 2nd class citizens on the .NET framework for a while. They will give you a better C#, and the option to glue whatever crazy language you can fit inside an assembly to your solution, plus out-of-the-box support for JS, Ruby and Python in Silverlight and Windows Runtime, but I think that's about it, there's little reason to back a dynamic language completely with so much action and volatility in this area.

Another interesting tidbit is the whole Java/Groovy thing. Someone asked here if there's an equivalent to C# for Groovy, and the answerers somehow missed the point with IronPython, Boo and IronRuby, because Groovy is (almost) a superset of Java (while these may at most generate clean C#). What Microsoft plans to do here is a good question for me (bring C# near Groovy? Create a C# superset?). Whatever they will do, I don't think it will be very soon or very enthusiastic though, because Groovy/Grails showed modest adoption rates with the more conservative Java community - even though a superset has better footing with the community than a new language.


问:
How to store multiple requirements with OR and AND?
Well I'm working on a personal project that needs to check if a user has met certain requirements, and they come in a form of

Requirement: [c1 OR c2] AND [d1 OR d2]

Requirement: [c1 AND c2] OR [d1 AND d2]

Requirement: c1 AND any dn(n can be any integer)

I'm just not sure how to store these sorts of requirements, I'm thinking of using another object to hold c1,c2,d1,d2....dn and OR, but that seems like a roundabout way of doing things. Is there a better method?

答:
You can use Reverse Polish Notation for storing and evaluating your requirements. For your first requirement the sequence is basically:

c1 c2 OR d1 d2 OR AND

As you see you don't need brackets so the storage format is simple. The evaluation is also very easy to implement, you just need a stack object to push parameter values and binary results to the stack, and to pop and evaluate parameters when an operator is met.


答:
Typically, expressions are represented by abstract syntax trees.</p>

```<code>public interface Expression {};
public class AND implements Expression {
    public Expression lhs;
    public Expression rhs;
}
public class OR implements Expression {
    public Expression lhs;
    public Expression rhs;
}
public class Requirement implements Expression {
    ...
}
</code>```

Title: How to store multiple requirements with OR and AND?

Body:
Well I'm working on a personal project that needs to check if a user has met certain requirements, and they come in a form of

Requirement: [c1 OR c2] AND [d1 OR d2]

Requirement: [c1 AND c2] OR [d1 AND d2]

Requirement: c1 AND any dn(n can be any integer)

I'm just not sure how to store these sorts of requirements, I'm thinking of using another object to hold c1,c2,d1,d2....dn and OR, but that seems like a roundabout way of doing things. Is there a better method?

Body:
Typically, expressions are represented by abstract syntax trees.

public interface Expression {};
public class AND implements Expression {
    public Expression lhs;
    public Expression rhs;
}
public class OR implements Expression {
    public Expression lhs;
    public Expression rhs;
}
public class Requirement implements Expression {
    ...
}


答:
You have two seperate problems :

monitoring and copying data

notifying clients

Monitoring: and copying the data to the database is a process that you would want to have running in the background so you can start and stop it when needed independent of your application. I would suggest making that a windows service that uses the filesystem watcher. Mind the location of the files, the uploading application and the service both need access to that location.

An older article on this can be found here http://www.codeproject.com/Articles/18521/How-to-implement-a-simple-filewatcher-Windows-serv (things have changed since 2007)

notifying your application, does it need to be real time ? When the application starts does it need to know there are new files waiting ?

If the application needs to check when starting you could simple make a table where the service keeps track on the files it has processed and that your windows app can query to see if files are waiting. If the notification does not need to be real time you could trigger the check based on a timer and you would have a pretty simple solution.

If the notification needs to be real time you need other options.

SignalR mostly is used in web apps but I have seen it work in console apps and it is pretty simple to set up and easy to use. If you download signalR https://github.com/SignalR/SignalR in the samples there is a self hosted example that might get you up to speed. Make your service the messagehub and let client applications connect on startup. SignalR is pretty new and I have not seen a lot of people use it outside of a web app so it might be a risk trying this, but it should be fun :)

If you don't want signalR and stil need real time notifications you could look at:

have a status folder in your data folder, your service writes status files in this folder and you application watches this status folder via the fileSystem watcher, I like this because your app and the service are using the same technologies and it is always a good idea to keep the number of technologies and the number of different solutions as low as possibel.

let the service write to a message queue and have your app monitor that (overkill in my mind)

make your service and windows app like chat application using WCF broadcast messages. A sample to get you started : http://www.codeproject.com/Articles/19752/WCF-WPF-Chat-Application (way to much work in my mind)


答:
IOFileFilter and its subclasses (for example, AndFileFilter, NotFileFilter and OrFileFilter)
 in Apache Commons IO could be a good example.


答:
Start with raw HTML.

Then get used to CSS

Learn server side programming with any easy-to-use scripting languages like python or php.

Learn Javascript.

Then go for the various web frameworks like MVC for learning web application management. Use the framework that suits you like Ruby-On-Rails or ASP.net MVC. If you switch to any framework depending on a language not learnt in 3rd step like C#(ASP.net) or JAVA(J2EE), then you have to learn that language also.

Go for JQuery.

Title: Best approach to learning web programming

Body:
I come from a scientific and embedded programming background, and I have had minimal experience with web programming.  What would be the best approach to take to get up to speed with web programming?  Tools and framework suggestions?

One approach would be to dive into learning a framework, such as Rails. I started doing this with rails tutorial, but I find that the framework abstracts so many important concepts that I should be learning.

To sum up, experienced programmer wants to learn web-app programming.


问:
How to start embedded development for developing a handheld game console?
I work as a iPhone app developer now, so I know a bit of c, c++ and objective c. Also have fiddled with Java and many other. All of them have been just high level application/games development.

My final goal is to make a handheld game console. More like a home made NES/SNES handheld console or even an Atari. I have found out about RaspberryPI and Arduino. But I need more information about how to approach this.

How Do I learn to pick the best board/cpu/controller/GPU/LCD screen/LCD controller etc?

Will learning to make a NES emulator first help me understand this field? If so are there any tutorials?

答:
My suggestion is buy one of the arduino kits related to this goal. A few examples:

Fuzebox

Hackvision

Video Game Shield Kit

How Do I learn to pick the best board/cpu/controller/GPU/LCD screen/LCD controller etc?

Firstly you need know in depth a real machine. The arduinos are a very good option for this because are 100% open source and include documentation. Don't buy a RaspberryPI or others ARM boards because the most use closed drivers for the GPU and other pieces. If you finally decide buy a traditional ARM board (not a arduino with ARM processor), search a board with the GPU "mali".

Will learning to make a NES emulator first help me understand this field? If so are there any tutorials?

No. You will only learn a lot of assembler code :) . Probably, enhance your C skills are a better idea.

Don't be too ambitious at the beginning or your project will die. Step by step. My advice is:

Buy a Kit.

Read all the documentation.

Program a simple game.

Program a complex game.

Enhance your game internally. Try different ideas for enhance the performance.

Now you know well the platform.

Read the code of your system. Kernel and low level libs.

I'm sure that your system has bugs. Search and fix these.

The code of your system is inefficient. Enhance the code.

At this moment you know all your system with a very big depth.

Now you can create anything. Congratulations :)


问:
Rails solution for mobile-specific content filter?
To note, I'm not interested in simply 'hiding' content for mobile devices, I want to filter out that content completely. I'm also not trying to address the issue by building a mobile specific interface (mob.example.com).

There was another question regarding something similar:

How do I prevent useless content load on the page in responsive design?

The solution, in that post, was to set a session during the initial request, and then use the session to filter content on subsequent requests.

I primarily develop in Rails, and I'm wondering if there are any gems or ruby-specific solutions to this problem?

答:
by 'fiter out completely' do you mean that you just don't want to pass the content to client and hide them using CSS? if so, in your rails views why don't you take output decision based on the device? for example,

```<code>#application_helper.rb
def mobile_device?
  true #put your device detection logic here
end

#view file (in haml)
- if mobile_device?
  Mobile content
- else
  General content
</code>```

instead of using your device detection logic, you can also use useragent gem

you can also render completely different view/partial depending on the browser/device.

Body:
by 'fiter out completely' do you mean that you just don't want to pass the content to client and hide them using CSS? if so, in your rails views why don't you take output decision based on the device? for example,

#application_helper.rb
def mobile_device?
  true #put your device detection logic here
end

#view file (in haml)
- if mobile_device?
  Mobile content
- else
  General content

instead of using your device detection logic, you can also use useragent gem

you can also render completely different view/partial depending on the browser/device.


问:
How many juniors should a senior mentor?
Our shop's size increases dynamically, so we are planning to hire a few new junior developers but we would not like to overwhelm the seniors with too much mentoring and training. How many (usually fresh out of college) junior developers could (and should) a senior developer mentor while the senior is still being able to do his or her tasks effectively?</p>

答:
As many as they can while still being able to get their own work done on time.

The answer, therefore, depends on how effective the senior is as both a developer and as a teacher.


答:
Anywhere from 0 to 5 or 7 (or so).

Arguments for the low side:

Not everyone is set out to be a mentor.  I have worked with some developers who were so gruff that they would have scared someone into a new career.

If you expect the senior devs to maintain the same level of output, then keep the number low.

Arguments for a higher amount:

Some devs have the ability to be just as productive by guiding others' work.  Pair-programming would be an example.  If you have those magical types of senior devs, then go ahead and give them more.

If you're willing to lower the expected output from the senior dev, then you can assign more junior devs to them.

If you have a dev that is really good at teaching they why's of governance, then you may explicitly want to take a hit in that senior dev's productivity and give them more junior devs.  The idea here is a short term cost (loss of production) for a long term gain / investment (better conformance to team's development standards).

I would encourage having a conversation with the senior devs and see what they are comfortable with.  Not everyone wants to mentor.  Also remember to use the "full bookshelf" analogy:  Their workloads are currently full.  If you are going to add to their workload by having them mentor, then you need to take something else off of the shelf to make room.

Title: How many juniors should a senior mentor?

Body: Our shop's size increases dynamically, so we are planning to hire a few new junior developers but we would not like to overwhelm the seniors with too much mentoring and training. How many (usually fresh out of college) junior developers could (and should) a senior developer mentor while the senior is still being able to do his or her tasks effectively?</p>


问:
Actor library / framework for C++
In the C++ project I am working on, we have an application consisting of
several processes deployed on different machines. This network of
processes is dynamic since processes (clients or background services)
can be started and terminated during the application's lifetime.

We have already a module that allows to transport arbitrary data over
the network through RPC, and we are using it to exchange information
(such as status information, progress information, error codes, etc)
between the processes. We would like to have a more abstract layer
to handle asynchronous communication (currently, the RPC is executed
synchronously), and to allow processes to be started and terminated
dynamically and still find each other.

We recently looked for a solution and we think we can use something
like Scala actors and remote actors (see e.g. this tutorial).
Another language using the actor model that has been around longer
than Scala is Erlang (see also this question).

Actors are objects that have a behaviour and a mailbox, share no data.
Actors are executed concurrently, and communicate through asynchronous
message exchange. As part of their behaviour, actors can create other actors.
Messages are also represented as objects.

The simplest case is that actors live in the same process.
In this case they can address each other using
a handle (reference, pointer, unique identifier). The actor implementation
hides the underlying threads and any other details.
When actors live in different processes (and possibly on different
machines in a network) they are identified by an IP address, a port and
a name. In this case we speak of remote actors
(see the short example at the top of this page).

In our case, we would have one actor on each process, taking care of
all the communication, i.e. we need some kind of remote actors.

On wikipedia I have found some links to actor libraries for C++ and
I have started to look at Theron. Theron seems a very well-written
and documented library but, to my understanding, it does not support
remote actors: all actors must live within the same process. It is possible
to create several actor pools (frameworks), but all these pools must
live in the same process.

So I wanted to ask if someone knows other C++ libraries
that support the remote actor concept as sketched above.

EDIT

This question has been edited wrt the original question, following
indications from programmers-meta discussion.

UPDATE

Other frameworks I have looked at are libcppa (should support
remote actors, but it is still under development, currently version 0.1),
actor-cpp (also under development), and libactor, which is
in C (the web site says it "is usable, although it may not be ready for production").

答:
Microsoft's latest "cloud-based client-server communication in native code using a modern asynchronous C++ API design", Casablanca is designed for this.

Actors

Another aspect of Casablanca is its implementation of the actor
  programming model, which has proven itself useful in building reliable
  and scalable systems. The C++ implementation stays close to the Erlang
  model; it’s obviously difficult to exactly mimic the model of a pure
  functional language in library built with an imperative language that
  has pointers, but we’ve gotten pretty close.

Its very new, Microsoft has only recently figured C++ is a good fit for cloud and scalable systems, but they're listening to feedback - they invited me to talk to them for an hour about it, go download it tick the "welcome feedback" box and they'll send you an email. Although its new, that doesn't mean much - MS is committed to Azure as their next big money-spinner, so this isn't going away.

Title: Actor library / framework for C++


答: No more than two per senior developer if you are hiring people straight out of college.  The recent college grads I've had to deal with in the past have a good understanding of the basics, but they had no idea what it was like to program in the business world.  You will you have to spend time teaching them how to program professionally, it is quite a shock when they realize that they will have to support the code they write for as long as they are with the company, no more turning assignments and moving on.  But you will also have to spend time teaching them your business (and all it's rules), teach them how to code your architecture, reviewing their code, teaching them how to test, and answering question after question after question.  Both times I was asked to mentor a junior I spent at least half my time at their desk for the first couple of months.   </p>


问:
What is the benefit of writing to a temp location, And then copying it to the intended destination?
I am writing an application that works with satellite images, and my boss asked me to look at some of the commercial applications, and see how they behave. I found a strange behavior and then as I was looking, I found it in other standard applications as well.

These programs first write to the temp folder, and then copy it to the intended destination.

Example: 7zip first extracts to the temp folder, and then copies the extracted data to the location that you had asked it to extract the data to.

I see several problems with this approach:

The temp folder might not have enough space, while the intended
location might have that much space.

If it is a large file, it can take a non-negligible amount of time
for the copy operation.

I thought about it a lot, but I couldn't see one single positive point to doing this.
Am I missing something, or is there a real benefit to doing this?

答:
This seems to be an issue in Windows, more specifically related to how the drag-drop is managed.

The developers of the WINSCP client have developed their own shell extension, which overrides this drag-drop behavior and allows dropping the file to the right folder immediately. They explain the trick in their documentation and, more interesting, what is the problem and how they solved it.

Here is the interesting part:

Windows drag&drop mechanics does not allow source application of
  drag&drop operation to find out easily, where the files are dropped.
  It is up to target application (Windows Explorer usually) to transfer
  files to destination. It is rather reasonable, because source
  application can hardly transfer files to all possible destinations.
  Keep in mind that you can drop files not only to a directory, but even
  to ZIP file (or any other archive), remote directory (via FTP, SFTP,
  SCP, …), trash, …

Obviously even Windows Explorer (or any other target application, like
  WinZip) cannot download files from any possible source (particularly
  it does not know SFTP/SCP).

Also, specifically for 7Zip: user ray023 answers this question in the SuperUser Stack Q&A: https://superuser.com/a/422463

Basically, if instead of drag-dropping your file you use the "extract here" method available in bith 7-ZIP and Winrar, the files are directly extractly to the right directory.


答:
A few reasons I can think of:

On most platforms, file moves are atomic, but file writes are not (especially if you can't write all the data in one go). So if you have the typical producer/consumer pattern (one process produces files, the other watches a directory and picks up everything it finds), writing to a temp folder first and only then moving to the real location means the consumer can never see an unfinished file.

If the process that writes the file dies halfway through, you have a broken file on your disk. If it's in a real location, you have to take care of cleaning it up yourself, but if it's in a temp location, the OS will take care of it.

If the file happens to be created while a backup job is running, the job may pick up an incomplete file; temp directories are generally excluded from backups, so the file will only be included once moved to the final destination.

The temp directory may be on a fast-but-volatile filesystem (e.g. a ramdisk), which can be beneficial for things like downloading several chunks of the same file in parallel, or doing in-place processing on the file with lots of seeks. Also, temp directories tend to cause more fragmentation than directories with less frequent reads, writes, and deletes, and keeping the temp directory on a separate partition can help keep fragmentation of the other partitions down.

TL;DR - it mostly boils down to atomicity, that is, you want to make it so that (at the final location) the file is either complete or not there at all at any given time.

Title: What is the benefit of writing to a temp location, And then copying it to the intended destination?

Body:
I am writing an application that works with satellite images, and my boss asked me to look at some of the commercial applications, and see how they behave. I found a strange behavior and then as I was looking, I found it in other standard applications as well.

These programs first write to the temp folder, and then copy it to the intended destination.

Example: 7zip first extracts to the temp folder, and then copies the extracted data to the location that you had asked it to extract the data to.

I see several problems with this approach:

The temp folder might not have enough space, while the intended
location might have that much space.

If it is a large file, it can take a non-negligible amount of time
for the copy operation.

I thought about it a lot, but I couldn't see one single positive point to doing this.
Am I missing something, or is there a real benefit to doing this?


答:
The way I went about it was:

Create a personal website, with only static content (only HTML)

Extend the website with dynamic content (using PHP)

Reform everything into a framework, to get better separation of presentation and business logic.

The biggest hurdle I had to wrap my mind about is that the server-side part of a web-application will not do anything without a preceding trigger from the client.


答:
You don't mention the type of project work which in my experience has a HUGE impact on where that ratio should be.

On a scale of cookie-cutter repetition that could almost be automated to experimental things the developer isn't even sure will work you need to make sure you keep the jr devs to the left unless you are at a really low ratio and even more strictly to the left if the sr devs are trying to do something they consider to the experimental end of the spectrum because they aren't usually going to be as effective riding herd on a team of jr devs if they are pushing themselves hard at the same time.

It depends on the work as much as the people in my opinion.


问:
I'm doing 90% maintenance and 10% development, is this normal?
I have just recently started my career as a web developer for a medium sized company. As soon as I started I got the task of expanding an existing application (badly coded, developed by multiple programmers over the years, handles the same tasks in different ways, zero structure).

So after I had successfully extended this application with the requested functionality, they gave me the task to fully maintain the application. This was of course not a problem, or so I thought. But then I got to hear I wasn't allowed to improve the existing code and to only focus on bug fixes when a bug gets reported.

From then on I have had three more projects just like the above, that I now also have to maintain. And I got four projects where I was allowed to create the application from scratch, and I have to maintain those as well.

At this moment I'm slightly beginning to get crazy from the daily mails of users (read managers) for each application I have to maintain. They expect me to handle these mails directly while also working on two other new projects (and there are already five more projects lined up after those). The sad thing is I have yet to receive a bug report on anything that I have coded myself. For that I have only received the occasional let's-do-things-180-degrees-different change requests.

Anyway, is this normal? In my opinion I'm doing the work equivalent of a whole team of developers.

Was I an idiot when I initially expected things to be different?

I guess this post has turned into a big rant, but please tell me that this is not the same for every developer.

P.S. My salary is almost equal if not lower than that of a cashier at a supermarket.

答:
This is business as usual. You will be exploited as long as you keep working there it seems. It's in the company's best interest to continue going with this model rather than to make you feel happy in what you are doing. When it comes down to it, they don't really care. It's about creating reliable code for them and if you are a one-man-band, they are certainly making bank of you. Why would they change?

The good news in all this is you are a VIP to them even if they don't know it. What I suggest to do is to line up some more opportunities before jumping ship then grab them by the balls and demand a higher salary. If not move to a better opportunity. In my opinion, you should be finding some more exciting work soon. Aim as high as you can. Once you get to a developer shop, you will be much happier like Google or some fun startup where there is a collaborative developer culture where you will truly feel happy.

What I did personally was to use a head hunter contractor organization and quickly got many great experiences under my belt, moving from one to another while still maintaining a steady employment from my contractor. It keeps you from getting bored and challenges you. Eventually, in my spare time I built up some small business which blossomed into actual business, and then I jumped ship from doing contract work.


答:
If you have a lot of juniors coming in, let's say >30, it might be worth it to dedicate a senior developer to mentoring them full time. At my first job they hired about that many of us fresh out of college and had a dedicated team member helping us learn the ropes for the first 6 months. It made the transition a lot easier and he taught us a lot.

Not only is it more efficient to have one person handling the job, there may be a single person in your office that you know would be a perfect mentor. A good programmer isn't necessarily a good teacher.


问:
The cost of longer delay between development and QA
At my current position, QA has become a bottleneck.  We have had the unfortunate occurence of features being held out of the current build so that QA could finish testing.  This means features that are done being developed may not get tested for 2-3 weeks after the developer has already moved on.  With dev moving faster thean QA, this time gap is only going to get bigger.

I keep flipping through my copy of Code Complete, looking for a "Hard Data" snippet that shows the cost of fixing defects grows exponentially the longer it exists.  Can someone point me to some studies that back up this concept?  I am trying to convince the powers that be that the QA bottleneck is a lot more costly than they think.

答:
What you are describing is a bottleneck in a process. Lean theory states that there will always be a bottleneck in a process, but its severity can vary widely. If QA hired one extra, then development might become the bottleneck.

To understand the cost, imagine the following situation. You picked one of the developers. His work would never be Quality Assured, but always get queued indefinitely. Imagine that, this would mean that the QA could Quality Assure the work of the rest of the developers in a timely fashion and there would be no cost of delay.

In that scenario, the cost of the delay is the cost of the salary of the developer, because his work would be wasted.

The reason why I argue in terms of cost and not the value created by the process, is simply because it is harder to document the value of a process, even though it is far better.


问:
Factors to be Considered for Software Risk Management
What are the risk factors that we need to consider while planning for a software project.</p>

答:
Is your team adequately trained?

Is your team large enough?

Do you have contingency in case
someone leaves the project, and how
would it affect the schedule?

Is your team too large?

Do they have the resources they need?

Might a competitor bring a product to
market before your project completes?

Can you deal with changed
requirements?

Can you deal with the
project becoming irrelevant?

Do you have buy-in from senior
management?

Do you have any reliances on
suppliers or contractors?

Are you
doing anything in-house that your
team isn't competent enough at?

Do you have budget big enough to meet
the estimated project cost?

Can you meet unforeseen project
costs?

And anything that's specific to your
circumstances :-)


问:
HTML, JS, CSS Engines
I am just messing around, trying to figure out how stuff works and right now I have a couple questions about HTML, JS and CSS engines.

I know there are two major JavaScript engines out there - V8 and JavaScriptCore (WebKit's JS engine as far as I know). Is that correct? And what are the main HTML + CSS renderers out there? Let's say I want to build a web browser using V8 (I saw it has some documentation and stuff + I like the way it works), what are the best options for me?

Partially another question. Is there any bare browser that uses V8 and runs on Ubuntu at least?

P.S. I am a Ubuntu user and prefer C++.

答:
Have you checked out Node.js? I only mention it because it fits your tech-trifecta: 1. JS, HTML, CSS  2. V8 3. and C++.

Not sure about building browsers, or rendering in particular.... Wikipedia gives a great history of the browser wars of 2010, as far as V8 goes. Names get crazy like SpiderMonkey, Rhino, and IE... may be an interesting history .

Title: HTML, JS, CSS Engines


问:
What syntax element do you hate most in a programming language you use frequently?
No matter how much you love a programming language, there are always a few details in it that aren’t quite as nice as they could be.

In this question, I would like to specifically focus on syntax elements. In a programming language that you use frequently (perhaps your favourite programming language, or perhaps the one you are forced to use at work), which syntax element do you find most unreadable, unclear, inconvenient or unpleasant?

答:
Scala multi-line code in brackets

For instance:

```<code>class Foo(
         val bar: String,
         val baz: Int,
         val bing: String,
         val bong: Boolean
 ) extends Model {
   // body here
 }
</code>```

What you actually get from it is terrific. It generates the constructor and the getters and setters for you. But it sure is ugly and breaks all my mental models of how to indent code and basically leaves me feeling like I'm in a sort of bizarre sandwich with Java on one side and Lisp on the other. (Oh, wait... that is rather the point of Scala.)

Body:
Scala multi-line code in brackets

For instance:

class Foo(
         val bar: String,
         val baz: Int,
         val bing: String,
         val bong: Boolean
 ) extends Model {
   // body here
 }

What you actually get from it is terrific. It generates the constructor and the getters and setters for you. But it sure is ugly and breaks all my mental models of how to indent code and basically leaves me feeling like I'm in a sort of bizarre sandwich with Java on one side and Lisp on the other. (Oh, wait... that is rather the point of Scala.)


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

What's your strongest opinion against functional programming?

答:
Some have a learning curve quite steep, taking a long time (especially if you come from OOP; you'll beak your head a few times before getting the paradigm shift).

Even though i started getting functional programming (coming from Java and going to Clojure) i still find it quite difficult. The community does not seem to write code as expressive as Java.

Seems like there is a small loss in expressiveness and a small increase in complexity.


问:
How to render RSS feed in a desktop RSS reader?
Consider one feed like this: http://feeds.feedburner.com/codinghorror

It has the entire content inside the description tag of the feed, so you don't need to access the website to read the post.

Now I have the problem of creating an interface for a feed like this on a desktop client. What's the best way to render the text in a pleasant way to the user? My first thought was to parse the entire HTML as if I was a web browser, but that looks really hard to do in a satisfying way. Are there any better (faster) alternatives?

Rephrasing: how a desktop rss client such as feeddamon parses the input to display it nicely? Does it have a web browser inside it?

答:
What you are looking for is a web-browser engine:
http://en.wikipedia.org/wiki/Web_browser_engine

That is what renders the HTML "as if it was a web-browser". For example, Firefox uses Gecko, and Google and iOS use WebKit.  According to the FeedDemon google group, FeedDemon uses the engine of the Internet Explorer that is installed on your Windows system.

If you want to create a desktop client that renders a feed into HTML, you first parse out the HTML from the XML. Then, you can use a web-browser engine that matches your programming language (here is a list of comparisons from Wikipedia).


问:
Converting a bounded knapsack problem to 0/1 knapsack problem
I ran across a problem where goal was to use dynamic programming (instead of other approaches). There is a distance to be spanned, and a set of cables of different lengths. What is the minimum number of cables needed to span the distance exactly?

To me this looked like a knapsack problem, but since there could be multiples of a particular length, it was a bounded knapsack problem, rather than a 0/1 knapsack problem. (Treat the value of each item to be its weight.) Taking the naive approach (and not caring about the expansion of the search space), the method I used to convert the bounded knapsack problem into a 0/1 knapsack problem, was simply break up the multiples into singles and apply the well-known dynamic programming algorithm. Unfortunately, this leads to sub-optimal results.

For example, given cables:

1 x 10ft,

1 x 7ft,

1 x 6ft,

5 x 3ft,

6 x 2ft,

7 x 1ft

If the target span is 13ft, the DP algorithm picks 7+6 to span the distance. A greedy algorithm would have picked 10+3, but it's a tie for minimum number of cables. The problem arises, when trying to span 15ft. The DP algorithm ended up picking 6+3+3+3 to get 4 cables, while the greedy algorithm correctly picks 10+3+2 for only 3 cables.

Anyway, doing some light scanning of converting bounded to 0/1, it seems like the well-known approach to convert multiple items to { p, 2p, 4p ... }. My question is how does this conversion work if p+2p+4p does not add up to the number of multiple items. For example: I have 5 3ft cables. I can't very well add { 3, 2x3, 4x3 } because 3+2x3+4x3 > 5x3. Should I add { 3, 4x3 } instead?

[I'm currently trying to grok the "Oregon Trail Knapsack Problem" paper, but it currently looks like the approach used there is not dynamic programming.]

答:
It might be some mistake in your code. I wrote the DP program as mentioned by Naryshkin. For the target span 13, it reports 6+7, and for 15, it reports 2+6+7.

```<code># weight: cable length
# total weight: target span
# value: 1 for each cable
# want minimum number of cables, i.e. minimum total value

def knapsack_01_exact_min(weights, values, W):
    # 0-1 knapsack, exact total weight W, minimizing total value
    n = len(weights)
    values = [0] + values
    weights = [0] + weights
    K = [[0 for i in range(W+1)] for j in range(n+1)]
    choice = [[0 for i in range(W+1)] for j in range(n+1)]
    for i in range(1, n+1):
        for w in range(1, W+1):
            K[i][w] = K[i-1][w]
            choice[i][w] = '|'
            if w >= weights[i]:
                t = K[i-1][w-weights[i]]
                if (w==weights[i] or t) and (K[i][w]==0 or t+values[i] < K[i][w]):
                    choice[i][w] = '\\'
                    K[i][w] = t+values[i]
    return K[n][W], choice

def print_choice(choice, weights):
    i = len(choice)-1
    j = len(choice[0])-1
    weights = [0] + weights
    while i > 0 and j > 0:
        if choice[i][j]=='\\':
            print weights[i],
            j -= weights[i]
        i -= 1
    print

lens = [10, 7, 6] + 5*[3] + 6*[2] + 7*[1]
values = (3+5+6+7)*[1]
span = 13
v, choice = knapsack_01_exact_min(lens, values, span)
print "need %d cables to span %d:" % (v,span),
print_choice(choice, lens)

span = 15
v, choice = knapsack_01_exact_min(lens, values, span)
print "need %d cables to span %d:" % (v,span),
print_choice(choice, lens)
</code>```

If you adjust the order of the input lengths, it can give other optimal solutions. For example, lens = 5*[3] + 6*[2] + 7*[1] + [10, 7, 6] will give 15=10+2+3.

Body:
It might be some mistake in your code. I wrote the DP program as mentioned by Naryshkin. For the target span 13, it reports 6+7, and for 15, it reports 2+6+7.

# weight: cable length
# total weight: target span
# value: 1 for each cable
# want minimum number of cables, i.e. minimum total value

def knapsack_01_exact_min(weights, values, W):
    # 0-1 knapsack, exact total weight W, minimizing total value
    n = len(weights)
    values = [0] + values
    weights = [0] + weights
    K = [[0 for i in range(W+1)] for j in range(n+1)]
    choice = [[0 for i in range(W+1)] for j in range(n+1)]
    for i in range(1, n+1):
        for w in range(1, W+1):
            K[i][w] = K[i-1][w]
            choice[i][w] = '|'
            if w >= weights[i]:
                t = K[i-1][w-weights[i]]
                if (w==weights[i] or t) and (K[i][w]==0 or t+values[i] < K[i][w]):
                    choice[i][w] = '\\'
                    K[i][w] = t+values[i]
    return K[n][W], choice

def print_choice(choice, weights):
    i = len(choice)-1
    j = len(choice[0])-1
    weights = [0] + weights
    while i > 0 and j > 0:
        if choice[i][j]=='\\':
            print weights[i],
            j -= weights[i]
        i -= 1
    print

lens = [10, 7, 6] + 5*[3] + 6*[2] + 7*[1]
values = (3+5+6+7)*[1]
span = 13
v, choice = knapsack_01_exact_min(lens, values, span)
print "need %d cables to span %d:" % (v,span),
print_choice(choice, lens)

span = 15
v, choice = knapsack_01_exact_min(lens, values, span)
print "need %d cables to span %d:" % (v,span),
print_choice(choice, lens)

If you adjust the order of the input lengths, it can give other optimal solutions. For example, lens = 5*[3] + 6*[2] + 7*[1] + [10, 7, 6] will give 15=10+2+3.


问:
CamelCase issue (PList or Plist)
Ok, I understand what CamelCase is. This question is relating to how to CamelCase the shortened version of Property List (PList). I am asking this because I am working on a PList parser in C# and knowing how everything in .NET is CamelCase, I am wondering, should it be PList or Plist (also why)?

答:
The camel case convention suggests that each distinct word joined into an identifier should have its first character capitalized.  So for public .NET identifiers, I would go with PList.

(the convention in .NET for private identifiers is to start with a lower case character though, so for class or routine variables it would be pList).

Title: CamelCase issue (PList or Plist)


答:
In the case of OS X property lists they are usually referred to as ".plist" or "Property List." I would recommend not using the shortened version because that is not the actual name of the file type, but the extension.

.NET is not actually CamelCase, but Pascal Casing; camel casing traditionally has the first letter be lowercase and further letters uppercase, while Pascal case has the first letter be uppercase. You may remove the rest of a word and retain the uppercase (as in "PList") but you shouldn't do that anyway, because its less descriptive. Additionally, .NET casing style requires that any acronym that is three or more letters be lowercased after the first letter, such that "Graphics Display Interface Tool" would be "GdiTool", NOT "GDITool".

Title: CamelCase issue (PList or Plist)

Body: Ok, I understand what CamelCase is. This question is relating to how to CamelCase the shortened version of Property List (PList). I am asking this because I am working on a PList parser in C# and knowing how everything in .NET is CamelCase, I am wondering, should it be PList or Plist (also why)?


答:
Your probelm is not with QA, in fact, if your QA is doing Testing, the delays are pretty much the least of your worries. Please let me expalin (again, as it's common misconception in the Programming industry)... QA Assures the quality of the product by overseeing the entire SDLC, from Requirements (maybe earlier), through development, verification, release and support. Testing ensures that no obvious defects exist in the code. There is a very large and important difference. If you had true QA, they would be all over the Test/ V&V department asking why they were costing the business time (and therefore money) delaying releases, or all over project managment ensusring they were managing project scheduling properly, or all over managment making sure there were enough testers for the code being produced etc...

So assumeing by QA you really mean Test, back to the orginal question. Code Complete got it right - the cost of a defect is the time taken from insertion to correction. Early detection is only useful if you also correct it early, but most peoples interpretation is wrong.

(Note : I am playing Devils advocate here, don't take any of this to literally as I know nothing of you situation)
The delay cause by your Test department is a cost, absolutely, however, I have to ask, if you are waiting for them to find your defects, what are you doing - should you not be finding you own defects? Perhaps if they had less work (through higher quality input with less defects from you), the delay would not be as significant and the cost less - as a manager I would ask you how you plan to reduce the defects in the code you deliver to test, as (based on your argument) those defects cost more if found by test then yourself.

Also as you manager, I might state that is not Tests job  find your defects, Their job is to find there are no defects - if you are expecting them to find defects, maybe you have not done your job well enough.

Be careful how you approach this. If you dont have a solution to the problem, you are likely to come off second best.