问:
How should I start with Lisp?
I've been programming for years now, working my way through various iterations of Blub (BASIC, Assembler, C, C++, Visual Basic, Java, Ruby in no particular order of "Blub-ness") and I'd like to learn Lisp. However, I have a lot of intertia what with limited time (family, full time job etc) and a comfortable happiness with my current Blub (Java).

So my question is this, given that I'm someone who would really like to learn Lisp, what would be the initial steps to get a good result that demonstrates the superiority of Lisp in web development? Maybe I'm missing the point, but that's how I would initially see the application of my Lisp knowledge.

I'm thinking "use dialect A, use IDE B, follow instructions on page C, question your sanity after monads using counsellor D". I'd just like to know what people here consider to be an optimal set of values for A, B, C and perhaps D. Also some discussion on the relative merit of learning such a powerful language as opposed to, say, becoming a Rails expert.

Just to add some more detail, I'll be developing on MacOS (or a Linux VM) - no Windows based approaches will be necessary, thanks.

Notes for those just browsing by

I'm going to keep this question open for a while so that I can offer feedback on the suggestions after I've been able to explore them. If you happen to be browsing by and feel you have something to add, please do. I would really welcome your feedback.

Interesting links

Assuming you're coming at Lisp from a Java background, this set of links will get you started quickly.

Using Intellij's La Clojure plugin to integrate Lisp (videocast)

Lisp for the Web

Online version of Practical Common Lisp (c/o Frank Shearar)

Land of Lisp a (+ (+ very quirky) game based) way in but makes it all so straightforward

Install Clojure and Sublime 2 on MacOS an excellent getting started guide

Look at the Clojure in Action book. Worked for me.

答:
If you'll be developing on a Mac, you may want to try Clozure CL. It comes with an IDE that has Emacs-compatible keystrokes, and there's a bridge to Objective C so you can write Cocoa applications.

Also, I've read Practical Common Lisp, but found Successful Lisp to be helpful as well.

Finally, some patience on your part will be rewarded. Productivity and minor victories will come pretty quickly, but the big win may take a while.

Title: How should I start with Lisp?


问:
When to use REST to handle requests vs using AJAX to handle requests
On my web page, if I wish to display dynamic dropdowns (e.g city names based on country selected), I can do it using AJAX. But I can also do it using a REST call. So which should I use?

My problem is I really don't get the difference between REST and any other HTTP browser request.(a.k.a a form submit). I have looked at the formal definitions of REST and it seems identical to a HTTP request. So how is REST inherently different from AJAX?

答:
I can do it using AJAX. But I can also do it using a REST call.

Um, no. Those two are completely orthogonal. If you want to update your page with data you have to get from a server, you will do it using AJAX. There is no other way. And that AJAX call can use REST, or something else.

My problem is i really dont get the difference between REST and an HTTP browser request.(a.k.a a form submit). I have looked at formal definitions of REST and it seems like a HTTP request.

A REST call is an HTTP request, always. Though it can be used to handle regular browser calls (like form submits) and return full HTML pages, it's usually used to handle API calls that return only data (usually in JSON format).

So why it has a separate name?

Because REST is a specific style of using HTTP, arguably using it as it was originally meant to be used, but which most people didn't "get" and was thus rarely used for almost 2 decades.

Specifically, REST means encoding which entity you want to retrieve or manipulate in the URL itself (usually via an ID) and encoding what action you want to perform on it in the HTTP method used (GET for retrieving, POST for changing, PUT for creating, DELETE for deleting).

ContentLicense: CC BY-SA 3.0


答:
Well I think you first need to understand that AJAX and REST are not really to alternatives for your use case. AJAX stands for asynchronous javascript and XML so if you are using javascript to load data after the browser request has finished you are doing AJAX.

REST on the other hand stands for Representational State Transfer which as Stefan Billet pointed out uses HTTP requests to transfer data. So REST is actually one way to do AJAX with. SOAP would be another one but this is offtopic for your question. So your question should rather be: "Which technology is best for my use case?"

In this case I would recommend thinking about the amount of data used in your dropdowns. If you have only few elements you could have them all in your page and just use javascript to show the appropiate ones.
A second option could be using a REST call with JSON as respresentation because it's easy to use with javascript and very lightweight which of course would also mean doing AJAX.

Title: When to use REST to handle requests vs using AJAX to handle requests

Body:
On my web page, if I wish to display dynamic dropdowns (e.g city names based on country selected), I can do it using AJAX. But I can also do it using a REST call. So which should I use?

My problem is I really don't get the difference between REST and any other HTTP browser request.(a.k.a a form submit). I have looked at the formal definitions of REST and it seems identical to a HTTP request. So how is REST inherently different from AJAX?


问:
Can a webservice that uses JSON over POST be classified as RESTful?
Recently I have started using a new(to me) paradigm for web services. I use the controller to accept JSON strings sent over POST, process it and return JSON strings. GET, PUT, DELETE and other methods throw HTTP 405.

This pattern is proving to be very efficient from the point of view of asynchronous web frameworks (vert.x and play to be particular), as well as from development effort point of view.

What I am confused about is that this neither seems to be SOAP nor REST. I don't think it is even JSON-RPC, since I am using my own headers like:

Request:

```<code>{
  'requestId':<generated req Id>,
  'token':<previously authenticated token>,
  'action':<controller defined action>,
  'parameters':[
    <array of parameters>
  ]

}
</code>```

Response:

```<code>{
  'result':'success/fail',
  'payload':{
     <payload>
   }
}
</code>```

EDIT: There is only one endpoint URL, something like https://my.domain.com/api

Can anyone give any ideas about what this paradigm can be classified as?

答:
REST has absolutely nothing to do with using standard HTTP methods. It is a design concept that might equally apply to any network protocol. What defines REST is the set of operations that only limit to getting state and setting new state, creation and deletion are special cases of which. Object is created by setting state of object with not yet used id (which must therefore be client-generated or prepared by separate query), deleting by setting object state to empty. Important property is that all the operations are idempotent, i.e. doing them twice in a row is exactly equivalent to doing them just once.

The question itself thus does not give enough information to decide whether the service is REST or not. But the comment at bye's answer mentions methods "COPY" and "MOVE" and these don't fit in REST (the only way to copy in rest is to get the state and upload it to new resource and the only way to move is to copy and than delete the original). That does not mean it's wrong. Nobody said REST is appropriate for all situations.


问:
Does a group of Select Statements count as a valid model?
I'm making a facebook app and I'm trying to follow MVC properly. But I was wondering if I had a class that was a bunch of fql queries (getting data from facebook) should I have keep these in a controller or a model?

According to Codeigniter's user guide "Models are PHP classes that are designed to work with information in your database". Since fql interacts with facebook's databases and not my own, would having a class full of what is basically just SQL Select statements count as valid model?

答:
If you want to be orthodox about MVC:

The Model implements the entire domain logic, and nothing but the domain logic. For a game, this would include:

The current state of the players, units, world, etc.

Persistence of such state

The rules of the game (e.g., how units can move, what happens when unit X shoots unit Y, etc.)

The View is about presenting output to the user. In a web application context, this means templates; depending on how powerful your template system is, you may need some presentation logic outside of the templates, and you'll need some boilerplate to bootstrap the template engine. These, too, are part of the view.

The Controller part is about processing user input. For web applications, this means parsing requests, routing to sub-controllers, validating inputs, and dispatching them into the Model.

There is one more part to it for which I haven't seen a clean solution in a web application yet: you need to glue those three together. In strict MVC, the three components are mostly independent; the only connections are between controller and model (controller pushes requests for state changes to the model) and between the model and the view (view reacts to state changes in the model). In a web application, however, the controller typically needs at least some control over the view: the incoming request determines which view to use, and this information has absolutely nothing to do with the domain logic, so typically, the controller is allowed to select a view. Quite often, the controller even takes care of getting data from the model and passing it to the view.

So far the theory.

In modern-day web programming practice, MVC is usually taken to mean something quite different, along the lines of:

Models are classes that map to database entities. They usually derive from a generic base class, which implements standard CRUD operations, and extend it to implement methods that are specific to the particular entity they represent.

Views are classes that execute some presentation logic such as filtering, formatting, and sometimes even translation, and load and apply a template.

Controllers are classes that do pretty much everything else: getting input data from the request, performing domain logic on the models, reading data back from the model, instantiating and executing a suitable view, and sometimes even things like redirecting.


问:
Maintaining SVN history for a file when merge is done from the dev branch to trunk?
In my org, we use SVN for version control  So for each build (done periodically), we merge the code to trunk from the development branch (all the developers checks in to this branch). So when we want a new branch say for a new release, we create from the trunk doing a svn copy.

Now in the new branch we have the history only from the trunk and not from the previous development branches.

Is there any way to maintain the history when merge is done from the dev branch to trunk?

Update :

By history I meant revision History of each and every file . Who created it and who edit it.

Unfortunately we are using svn 1.6 right now

答:
Unfortunately this is not supported directly by Subversion prior to Subversion 1.8. The files in the branch and the files in trunk are copies and Subversion keeps track with svn log only for specific files, not across branches.

So the only option is to filter your SVN log. The major downside to this is that in case you filter for file name, files being moved or copied to another name are not matched.

Subversion 1.7 and lower

To keep it practical I would get the history of the file you are interested in for your trunk

```<code>svn log http://www.your.org/svn/repo/trunk/path/to/file.txt -g
</code>```

This includes the mergeinfo for your file like this:

```<code>Commit message
Merged via: r6504, r6493, r6451, r6429
</code>```

Now you can see where the file comes from and then look up those revisions on your repository root with

```<code>svn log http://www.your.org/svn/repo -r 6504
</code>```

Subversion 1.8 and higher

The Subversion 1.8 release contains a couple of improvements to the command line client that make the above easier. To find all log entries for a specific file you can simply search for it directly:

```<code> svn log -v --search "src/foo.c" http://svn.example.com/svn/
</code>```

Body:
Unfortunately this is not supported directly by Subversion prior to Subversion 1.8. The files in the branch and the files in trunk are copies and Subversion keeps track with svn log only for specific files, not across branches.

So the only option is to filter your SVN log. The major downside to this is that in case you filter for file name, files being moved or copied to another name are not matched.

Subversion 1.7 and lower

To keep it practical I would get the history of the file you are interested in for your trunk

svn log http://www.your.org/svn/repo/trunk/path/to/file.txt -g

This includes the mergeinfo for your file like this:

Commit message
Merged via: r6504, r6493, r6451, r6429

Now you can see where the file comes from and then look up those revisions on your repository root with

svn log http://www.your.org/svn/repo -r 6504

Subversion 1.8 and higher

The Subversion 1.8 release contains a couple of improvements to the command line client that make the above easier. To find all log entries for a specific file you can simply search for it directly:

 svn log -v --search "src/foo.c" http://svn.example.com/svn/


问:
What is the difference between a Program Manager and a Project Manager?
Is a Program Manager a person who manages mutiple projects (under a single program) which are in turn managed by Project Managers?

Or is a Program Manager a person as defined by Joel Spolsky here.

NOTE: I am not referring to this.

答:
Michael Lopp wrote an article recently with a comparison I quite liked.

First, some definition. Project manager, product manager, and program manager. Let’s clear that up. A project manager is responsible for shipping a product, whereas a product manager is responsible for making sure the right product is shipped. A program manager is an uber-mutated combination of both that usually shows up to handle multiple interrelated projects like, say, an operating system. Different companies use the names differently, but for this article, project = ship the product, product = ship the right product, and program = ship many interrelated products, usually at the same time. Got it?

ContentLicense: CC BY-SA 2.5


答:
In case of SVN 1.8

>svn log -v REPO-ROOT --search FILENAME

Title: Maintaining SVN history for a file when merge is done from the dev branch to trunk?

Body:
In my org, we use SVN for version control  So for each build (done periodically), we merge the code to trunk from the development branch (all the developers checks in to this branch). So when we want a new branch say for a new release, we create from the trunk doing a svn copy.

Now in the new branch we have the history only from the trunk and not from the previous development branches.

Is there any way to maintain the history when merge is done from the dev branch to trunk?

Update :

By history I meant revision History of each and every file . Who created it and who edit it.

Unfortunately we are using svn 1.6 right now


问:
What methods are available to show colleagues the advantages of a database+application solution over Excel?
I work in a company where there are Excel spreadsheets everywhere. As my colleagues are non-programmers, I'm sure they haven't contemplated that there might be a better/easier/more productive way of managing their data. Naturally, I advocate an application of sorts that can leverage the features you find in relational databases and interactive front ends, tailored to the needs of the various workflows currently distributed over disparate spreadsheets.

The problem I have is that I have tried to explain the merits of such systems to various parties, but short of actually writing them from scratch I'm having a hard time convincing them, or even just exposing them to the greener grass. People in general understand Excel (even if they aren't power users) but perhaps go all fuzzy when the word 'database' pops up or you start talking about 'code'.

Can anyone suggest a method, with evidence of how a workflow was improved by switching from spreadsheets to an actual application?

答:
The problem we had was that of different excel sheets with different purposes but with same contacts. Then when a contact changed their adress it would be hard to synchronize all excel and while their adress was changed in excel sheet 1, he would still get mail because excel sheet 2 wasn't updated.

We solved this with a central database of clients.


问:
Notify players every x seconds in a multiplayer game
I'm working on a realtime multiplayer game using Django and gevent-socketio, I'm facing some issues:

I need to send an update of the game state to connected players every X seconds (~4 seconds), so basically I need to execute a function every x seconds which does some calculations and sends the connected players the new game state. What is the easiest way to achieve this? is using cron a good choice here or should I look for other tools like celery or ...?

Also, the function needs to operate on some data. querying the database every time the function is executed does not seems to be a good idea, where can I store the game data (which is updated frequently during the game)?

答:
What i would recommend you to use PUSH Technology .. for example 'long polling' connections. What happens in these connections that the client give a request with always keep alive and server receives it.

Now client keeps waiting for the response and on server side , server waits for any actions , as soon as server receives actions , it responds to the client request and as soon as client receives response from server , it again request the server as this goes in a loop .

So in this technique you dont have to send request on some particular time and there will be no lagging also.

Use frameworks like : Twisted


问:
Use TFS to track bugs from Production Support
I have just moved to a new company and they are using TFS 2010 (2012 in a couple of months) as their version control system and recently started to use it as a work tracking system for the developers.

However, there doesn't seem to be a bug tracking system for use by people outside development & test.  Production support are getting reports of issues, fixing them on the fly and reporting back to their users at the moment.  This needs to be changed but I don't really want to have a sperate system for tracking bugs and tracking dev work.

Is there a way that I can create a very light weight way of entering bugs into TFS similar to the way that FogBugz does?  Logging into TFS to fill out a bug report seems to be a lot heavier and you have to associate it with a particular application.  Support may be able to do this but I want to be able to triage the item and potentially change the association to something other than an application.

I have used FogBugz in the past and when adding a bug, you can add a much/little as you want to the item so it is at least recorded and later you can bounce it back to get more information when you come to triage the ticket.

答:
No, that's right - Microsoft's premier ALM isn't really useful outside of Visual Studio and the dev teams.

You can access the work items using the Team Explorer (which is a very cut down version of VS) or access it via the TFS web site. Neither are particularly good options as the bug fields are reminiscent of ancient 'enterprise' bug trackers I had the misfortune to use in the past.

There's no real distinction between bugs in TFS - there's only the single tracker that you filter using a field in the item itself, so use a category field and then create a report that only shows a particular type of category. I think that's your only realistic option with TFS.

If you want external issue tracking, then I think TFS is a poor choice, you're better off using something like Jira or Redmine and using that to manage bugs - their interfaces are much, much nicer and easier to use than TFS. I particularly liked the way you can send an email to Redmine and it creates a new issue for you, that was an ideal usability feature for off-site workers.


问:
JOIN vs. INNER JOIN and FULL OUTER JOIN
I know there is a difference between INNER JOIN and FULL OUTER JOIN, I can see it, but, what is the difference between the two following: JOIN ... ON... and INNER JOIN...ON... and still yet JOIN...ON... vs FULL OUTER JOIN...ON...

Reason being is I think maybe just using JOIN is messing up a query I am working on that is posted on SO, link to question HERE.

So basically what is the syntactical difference between the actual set operations themselves?

Thank You,

答:
JOIN and INNER JOIN are the same, the inner keyword is optional as all joins are considered to be inner joins unless otherwise specified. The difference between JOIN and FULL OUTER JOIN is the same as the difference between INNER JOIN and FULL OUTER JOIN.

An INNER JOIN will only return matched rows if a row in table A matches many rows in table B the table A row will be repeated with each table B row and vice versa.

A FULL OUTER JOIN will return everything an inner join does and return all unmatched rows from each table.

Title: JOIN vs. INNER JOIN and FULL OUTER JOIN

ContentLicense: CC BY-SA 4.0


问:
Will high reputation in Stack Overflow help to get a good job?
In a post, Joel Spolsky mentioned that 5 digit Stack Overflow reputation can help you to earn a job paying $100k+. How much of that is real?

Would anyone like to share their success in getting a high paid job by virtue of their reputations on Stack Exchange sites?

I read somewhere that, a person got an interview offer from Google because a recruiter found his Stack Overflow reputation to be impressive. Anyone else with similar stories?

答:
Yes…ish

I’ve got (for want of a better term) job “invitations” via email which explicitly mention my Stack Overflow profile, from companies that boast a 12/12 score on the Joel Test and which honestly seem like extremely cool work environments.

And I know that the same has happened to several other people.

But …

I don’t believe for a second that I (or any of the other people) would score a job without an interview. Like most others here, I think that Stack Overflow may help you to get exposure on the web. But that’s all. It merely gets your name out. It shows that you’re active and motivated but not whether you’re qualified.


答:
When people manage data, there are three fundamentally different ways they can add value:

Computing

Storage and Retrieval

Forwarding and Sharing.

For computing at the level of simple arithmetic, you can't beat Excel.  Even if you are an experienced programmer, you can build a spreadsheet in a fraction of the time you'll take to write and debug a  computer program.  You can even group data into tables and use lookup functions to gain some of the advantages you get with queries.  The pivot table and the graphing features make summarizing data simple and easy.

For storage and retrieval at the file/document level Excel is about as useful as MS Word or MS Access.  For retrieval at the level of SQL queries, MS Access works a lot better than Excel, although Access is severely limited as you will know if you've ever compared Access with an industrial strength DBMS.

For data sharing, Excel is extremely primitive.  Most shops that adopt Excel by contagion run into trouble at this point.  Your question suggests that this is the case at your shop.

There are several problems in introducing databases in a place that is not ready for databases.  One is political.  The people who jockey their spreadsheets may recognize the system wide problem, but they are extremely pleased with the control they have over their own little piece of the data.  You can expect resistance if you try to substitute central management and control for the decentralized solution you have now.  Some of that resistance is justified.

Another is the cost of databases.  As has already been stated in another response, the disadvantages of database may outweigh the advantages.

Another is the credibility of databases.  People who put data into databases usually do so because it's their job or maybe to gain something for themselves, like placing an order on a website.  They don't do it out of community spirit.  At least, not much.  Without good inputs, the database never gains credibility.

A solution I am working on now at a site where spreadsheets are just catching on is building a prototype database in MS Access.  There is a distinct downside to this:  people may learn the wrong thing about databases, something they will have to unlearn at a later stage of evolution.  I also think that the reporting features of Access are sorely lacking.  and if you are thinking of concurrent users, you have to think beyond Access although Access is making progress inthat regard.

I like three things about Access:  it's simple, quick, and cheap to produce primitive prototypes.  There is almost no learning curve, especially if you already understand data analysis and table composition.

Second, it's less intimidating than a big centralized DBMS.  When users are shown how to open an Access table in table view, by just clicking on it, they lose their fear of tables.  And the fact that a single file stores the data, the data definitions, and the application keeps things simple for people who don't think in terms of systems.

Third, it plays well with Excel and Word.  copying a table or query into an Excel spreadsheet is as simple as clicking on a button.

Before I could get to this point, I had to overcome a somewhat snobby attitude I had about Access.   It's not SQL Server or Oracle.  But it does have it's uses, as long as you understand the limitations

Having said all this, you will still be faced with a monumental task when it comes time to move your shop from a lot of little Access databases into a single large scale integrated database, with professional management and shared resources.

Title: What methods are available to show colleagues the advantages of a database+application solution over Excel?

Body:
I work in a company where there are Excel spreadsheets everywhere. As my colleagues are non-programmers, I'm sure they haven't contemplated that there might be a better/easier/more productive way of managing their data. Naturally, I advocate an application of sorts that can leverage the features you find in relational databases and interactive front ends, tailored to the needs of the various workflows currently distributed over disparate spreadsheets.

The problem I have is that I have tried to explain the merits of such systems to various parties, but short of actually writing them from scratch I'm having a hard time convincing them, or even just exposing them to the greener grass. People in general understand Excel (even if they aren't power users) but perhaps go all fuzzy when the word 'database' pops up or you start talking about 'code'.

Can anyone suggest a method, with evidence of how a workflow was improved by switching from spreadsheets to an actual application?


答:
Non developer users can access the TFS work item tracking system by using a web browser to go to the Team Project Portal.  To find the URL, go to Team->Show Project Portal in Visual Studio.  From there, anyone with permissions can browse, create, or modify work items.  They can also generate all kinds of reports to look at the status of things.

The types of work items available and the fields in the work items vary depending on how TFS is configured (primarily by which process templates were chosen).

The information required to enter a bug is also dependent on how you have TFS configured.  In our case, we require a title, steps to reproduce, and the build that it was found in.  The TFS work item tracking system is very powerful and flexible.  It can be as complicated or as simple as you want it to be - it all comes down to how you have it set up.

Title: Use TFS to track bugs from Production Support

Body:
I have just moved to a new company and they are using TFS 2010 (2012 in a couple of months) as their version control system and recently started to use it as a work tracking system for the developers.

However, there doesn't seem to be a bug tracking system for use by people outside development & test.  Production support are getting reports of issues, fixing them on the fly and reporting back to their users at the moment.  This needs to be changed but I don't really want to have a sperate system for tracking bugs and tracking dev work.

Is there a way that I can create a very light weight way of entering bugs into TFS similar to the way that FogBugz does?  Logging into TFS to fill out a bug report seems to be a lot heavier and you have to associate it with a particular application.  Support may be able to do this but I want to be able to triage the item and potentially change the association to something other than an application.

I have used FogBugz in the past and when adding a bug, you can add a much/little as you want to the item so it is at least recorded and later you can bounce it back to get more information when you come to triage the ticket.


问:
SMS verification in web application
This is my first project related to SMS verification.

How to implement SMS verification in online ordering web application? For example:- when we try to reset the password in amazon's website, it sends an sms verification code and after entering the code it proceeds with changing the password. I want to implement the same function in my application, where users will place order, but before the final step it will send an sms verification code to the users mobile and verify the same.

The main requirement is SMS Gateway(Transactional Quality).

But as I'm completely new in this, so any idea how to proceed, or how can I implement it.

答:
There are a number of cloud hosted SMS gateways, with a very simple api that you can implement your solution using. Twilio is the first that comes to mind, but there are others as well if you do a quick search for SMS Cloud API.

What's cool about twilio is that it also has a voice API with Text to Speech capabilities. So you can send an SMS or initiate a phone call with just a little change in code.

Title: SMS verification in web application


答:
Consider what it takes to get a good Stack Overflow rating...

intelligence

knowledge

experience

good language skills

immense amounts of "free" time

Now take the last point there, people who have very high reputations here take a great deal of time to answer the questions of the masses.  Now whilst hugely thankful for such benevolent people, this implies one of the following.

They are unemployed

They are self-employed and have a
lot of "free" time

They are employed and spend all
their personal time sitting at a
screen (for example, "in want of a life")

They are employed and waste working
hours answering non-business
questions.

All but number three are reasons for a prospective employer not to take you on, and the third makes you wonder if they are ideal for spending all day with.

Anyhow, my boss is watching my screen a bit so I had better stop this post, before I have to use my Stack Overflow reputation to get me a new job...

Title: Will high reputation in Stack Overflow help to get a good job?

Body:
In a post, Joel Spolsky mentioned that 5 digit Stack Overflow reputation can help you to earn a job paying $100k+. How much of that is real?

Would anyone like to share their success in getting a high paid job by virtue of their reputations on Stack Exchange sites?

I read somewhere that, a person got an interview offer from Google because a recruiter found his Stack Overflow reputation to be impressive. Anyone else with similar stories?


问:
General way for getting graphics for open source project
I'm in process of making an open source application for Windows. In the end I would require an icons for my app and its gui. I'm huge fan of Tango styled icons, but its pack doesn't provide all icons I need. Gnome project seems to provide ones for more mature projects that run on linux.

What is the general way, procedure for getting help in graphic assets for open source project?

答:
I think the general way -- if there is such a thing -- is to do a google search for "free icons".

The most commonly used set of free icons that I know about are the silk icons.


答:
I use both SVN (dictated by business) and Mercurial (local repo only).

Netbeans handles this situation fine - not sure how it would integrate with other IDEs.

This provides me with many benefits. An update from SVN often makes changes I am not aware of but Mercurial immediately picks them up. I can take a new Clone and copy the old .hg folder in and instantly see all the changes.

Best of all, Mercurial works much easier with Diff patches and Quilt.


问:
Is a Factory class still a Factory class if the objects it returns already exist?
I can't decide what to name my class. So far I've labelled it up as a Factory, but I am not sure.

Here is the class. As you can see, it exists to return a concrete type of an Interface (ResolveRegistrationIssue) based on the argument supplied to the getter method (ResolutionFamilyEnum):

```<code>@SuppressWarnings("serial")
@ManagedBean(name = "resolveIssuesFactory")
@ViewScoped
public class ResolveIssuesFactory implements Serializable {

    @ManagedProperty(value = "#{resolvePrimaryIssuesFactory}")
    private ResolvePrimaryIssuesBean resolvePrimaryIssuesBean;

    @ManagedProperty(value = "#{resolveSecondaryIssuesBean }")
    private ResolveSecondaryIssuesBean resolveSecondaryIssuesBean ;

    @ManagedProperty(value = "#{resolveTertaryIssuesBean }")
    private ResolveTertaryIssuesBean resolveTertaryIssuesBean ;

    public ResolveRegistrationIssue getResolutionBean(
            ResolutionFamilyEnum familyEnum) {

        //null safety
        if(null ==familyEnum) {
            throw new IllegalArgumentException("The family which determines the Resolution Bean to be used may not be null.");
        }

        if (familyEnum.equals(ResolutionFamilyEnum .PRIMARY)) {
            return resolvePrimaryIssuesBean;
        } else if (familyEnum.equals(ResolutionFamilyEnum .SECONDARY)) {
            return resolveSecondaryIssuesBean;
        } else if (familyEnum.equals(ResolutionFamilyEnum .TERTERY)) {
            return resolveTertaryIssuesBean;
                    } else {
            throw new IllegalArgumentException("Could not determine the correct Resolution Issue bean for the provided family.");
        }
    }
</code>```

Now, I understand that a Factory class accepts arguments which define the entity to be developed and then delivered (returned).

However in my case, my entities are already developed, as they are EJB references. Thus this method only delivers them.

So is this still a Factory?

答:
This looks to be more related to the Service Locator pattern.

While you are not using JNDI as the registry, your class is acting as one. This is not a flyweight pattern though. It doesn't look like this implementation is meant to save memory. It is meant to look-up instances to "services" based on an Enumeration.


问:
random unique pair numbers from two range
I want to write a function that return random unique pair numbers every time call it from a range until resetting it.
Something like this:

```<code>function randomUniquePairs($ranges, $reset = false){
   if ($reset === false){
      // some code for reseting
   }
   /*
     some code for creating random unique pair numbers
   */
   return $result;
}

randomUniquePairs(range(1,10), range(1,20));
/*
  this function returns for example:
   array(2,9)
*/
randomUniquePairs(range(1,10), range(1,20));
/*
  this function returns for example:
   array(5,19)
*/

randomUniquePairs(range(1,10), range(1,20));
/*
  this function returns for example:
   array(5,9)
*/
 //this function returns random unique pairs until we pass reset paramer true
</code>```

I tried two approaches:

Approach 1

My first attempt was to make an array of all of possible pairs then select from them randomly, but it is very inefficient, because if ranges are so wide, it consumes a lot of memory.
the code:

```<code>  class a {
    private $asqar;

    function __construct() ($range) {

        // cycle for ranges
        foreach ($range[0] as  $v1) {
            foreach ($range[1] as $v2) {
                $asqar[] =  array(
                    $v1,
                    $v2,
                );
            }
        }
    }

    function randomUniquePairs($reset = false){

        if ($reset === true){
           $this->asgar = array();
        }

        $rndKey = array_rand($this->asgar);
        $result = $this->asqar[$rndkey];
        unset($this->asqar[$rndkey]);
        return $result;
    }
}

$c = new a(range(1,10), range(1,20));
$c->randomUniquePairs();
</code>```

Approach 2

My second attempt was to write a function that produce a pair from these ranges, then store it in a variable, every time that function calls after producing a pair , it checks if this pair produced before call function recursively, it continues until it produce a unique pair.
Here's the code:

```<code>class a{

    private $__uniqueVariables = array();

    public function randomUniquePairs($range, $reset = false) {

        if ($reset === true){
       $this->__uniqueVariables = array();
    }

    // cycle for each value
    foreach ($range as $value) {

        // shuffle
        shuffle($value);

        // selected id
        $selectedId[] = $value[0];
    }

    // check for selected variable
    if (in_array($rndUnqNum, $this->__uniqueVariables)) {

        // return for try again
        return $this->uniqueVariable($range);
    }

    // added to current unique variables
    $this->__uniqueVariables[] = $rndUnqNum;

    // return
    return $rndUnqNum;
}

}
</code>```

but this second approach has an issue that sometimes throw Fatal error: Maximum function nesting level of '100' reached.

I'm looking for a better approach to my algorithm.

答:
Something you need to determine is how 'fair' you want this to be and the performance as the unused space becomes exhausted.

In essence, you want a random box from a N dimensional array.  Its not the box itself that is important, but the location of the box that is important.

Under the covers, a 10x20 array is often represented as a 1x200 array with some math behind it to access the right spot.  If you were to access [5][13], you are actually accessing location [5*20 + 13].  You can use the same approach to go from a number back to the position.  Location 113 goes to the integer devision by 20 and remainder giving 5 r13.

So now, you don't need to actually store 200 pairs (though that isn't a lot), you just need a bitfield of 200 bits long.  Generate a random number within the proper range and mark it as used in the bitfield.

Now, the question of how do you handle it when you've got a collision?  This goes to the various hash collision techniques used in hash tables.  Some won't work for this application, but its a good read nonetheless.

A simple approach would be once you have one collision, just start incrementing where you are looking at until you find one that wasn't used.  The increment could be 1, or any number that is relativity prime to the size of the space.

Ok, I'm at a place I can sit down and write something.  Its perl.  Shouldn't be too far off of php and is rather straight forward.

```<code>#!/usr/bin/perl

my $x = shift @ARGV;
my $y = shift @ARGV;
my $f = shift @ARGV; # fill factor
my $t = $x * $y;    # total space
my $v = '';

foreach (1 .. int($t * $f)) {
    my $r = int(rand($t));  # random number from 0 .. $t-1
    my $yp = int($r / $x); # y' (y prime)
    my $xp = int($r % $x); # x' (x prime)

    print "Trying $r: $xp $yp...\n";
    while(vec($vec, $r, 1)) {
        $yp = int($r / $x);
        $xp = int($r % $x);
        print "\tcollision at $r: $xp $yp\n";
        $r += 1;
        $r %= $t;   # scale $r to within $t
    }
    $yp = int($r / $x);
    $xp = int($r % $x);
    vec($vec, $r, 1) = 1; # set the $r th bit
    print "\tsettled at $r: $xp $yp\n";
}
</code>```

Ultimately, the 'settled' values are the ones that you want.

You read two numbers from the command line and assign them to x and y.  The total search space is t - this is how big all the possible numbers are.  Additionally, read a fill factor as $f, this should be a value less than 1 and is used to limit the list iteration.  Setting a value greater than 1 will present an infinite loop.

I'm filling up the space to the specified value (the foreach (1 .. ($t * $f))). No, there isn't any error checking on $f to make sure it is less than or equal to 1, but there should be.

So pick a random number from 0 to $t - 1.  The spot that this represents is $yp and $xp - y prime and x prime.

There is some perlish things here, vec works with a bit vector of arbitrary size.  There are a number of ways of doing this in a given language, its just rather easy with perl.  With Java, one could use a BitSet (this is big enough to hold maxint bits, which could represent a pair of 46340 numbers).

You then test the bit at the $rth location to see if it has been used.  If it has, increment $r and roll it over if it becomes larger than the total space (so if you have a 10 and 20 (0 .. 199) and you hit 200, it becomes 0).

Once you find an unused bit, set it and output your values.

This is what the output looks like though:

```<code>Trying 96: 6 9...
        settled at 96: 6 9
Trying 117: 7 11...
        collision at 117: 7 11
        settled at 118: 8 11
Trying 115: 5 11...
        settled at 115: 5 11
Trying 153: 3 15...
        settled at 153: 3 15
Trying 90: 0 9...
        settled at 90: 0 9
Trying 140: 0 14...
        collision at 140: 0 14
        collision at 141: 1 14
        collision at 142: 2 14
        settled at 143: 3 14
Trying 73: 3 7...
        settled at 73: 3 7
</code>```

This is tested on a unix system thus:

```<code>% rndpair.pl 10 20 0.5 | grep settled | sort | uniq | wc -l
     100
</code>```

This shows that with 100 numbers there are 100 unique pairs printed out (just look at the 'settled' lines).

There's a fair bit of debugging information in there (you don't really need to keep resetting the value of $yp and $xp until the end.

And then there's the question of how fast is it?  This is to generate 50% of the available pairs for the available space.  Realize that there is some time tied up in the sort and uniq (of possibly some not small bits of text):

```<code>% time ./rndpair.pl 500 500 0.5 | grep settled | sort| uniq | wc -l
  125000

real    0m3.528s
user    0m3.901s
sys     0m0.045s
</code>```

Lets kick it up a notch and remove the other applications from the chain.

```<code>% time ./rndpair.pl 5000 5000 0.5 > /dev/null

real    0m34.668s
user    0m34.482s
sys     0m0.180s
</code>```

How much room did that 5k x 5k storage space take?  25,000,000 bits, or about 3 megabytes.

Note that the performance of this drops as the fill factor goes up. For a search space of 6, 80610 (a previous comment if I read it right) this runs quite quickly (note the increasing times as the fill factor goes up):

```<code>% time ./rndpair.pl 6 80610 0.5 | grep settled | wc -l
  241830

real    0m0.827s
user    0m1.562s
sys     0m0.029s
% time ./rndpair.pl 6 80610 0.75 | grep settled | wc -l
  362745

real    0m1.721s
user    0m3.151s
sys     0m0.043s
% time ./rndpair.pl 6 80610 0.9 | grep settled | wc -l
  435294

real    0m3.993s
user    0m7.031s
sys     0m0.079s
</code>```

Body:
Something you need to determine is how 'fair' you want this to be and the performance as the unused space becomes exhausted.

In essence, you want a random box from a N dimensional array.  Its not the box itself that is important, but the location of the box that is important.

Under the covers, a 10x20 array is often represented as a 1x200 array with some math behind it to access the right spot.  If you were to access [5][13], you are actually accessing location [5*20 + 13].  You can use the same approach to go from a number back to the position.  Location 113 goes to the integer devision by 20 and remainder giving 5 r13.

So now, you don't need to actually store 200 pairs (though that isn't a lot), you just need a bitfield of 200 bits long.  Generate a random number within the proper range and mark it as used in the bitfield.

Now, the question of how do you handle it when you've got a collision?  This goes to the various hash collision techniques used in hash tables.  Some won't work for this application, but its a good read nonetheless.

A simple approach would be once you have one collision, just start incrementing where you are looking at until you find one that wasn't used.  The increment could be 1, or any number that is relativity prime to the size of the space.

Ok, I'm at a place I can sit down and write something.  Its perl.  Shouldn't be too far off of php and is rather straight forward.

#!/usr/bin/perl

my $x = shift @ARGV;
my $y = shift @ARGV;
my $f = shift @ARGV; # fill factor
my $t = $x * $y;    # total space
my $v = '';

foreach (1 .. int($t * $f)) {
    my $r = int(rand($t));  # random number from 0 .. $t-1
    my $yp = int($r / $x); # y' (y prime)
    my $xp = int($r % $x); # x' (x prime)

    print "Trying $r: $xp $yp...\n";
    while(vec($vec, $r, 1)) {
        $yp = int($r / $x);
        $xp = int($r % $x);
        print "\tcollision at $r: $xp $yp\n";
        $r += 1;
        $r %= $t;   # scale $r to within $t
    }
    $yp = int($r / $x);
    $xp = int($r % $x);
    vec($vec, $r, 1) = 1; # set the $r th bit
    print "\tsettled at $r: $xp $yp\n";
}

Ultimately, the 'settled' values are the ones that you want.

You read two numbers from the command line and assign them to x and y.  The total search space is t - this is how big all the possible numbers are.  Additionally, read a fill factor as $f, this should be a value less than 1 and is used to limit the list iteration.  Setting a value greater than 1 will present an infinite loop.

I'm filling up the space to the specified value (the foreach (1 .. ($t * $f))). No, there isn't any error checking on $f to make sure it is less than or equal to 1, but there should be.

So pick a random number from 0 to $t - 1.  The spot that this represents is $yp and $xp - y prime and x prime.

There is some perlish things here, vec works with a bit vector of arbitrary size.  There are a number of ways of doing this in a given language, its just rather easy with perl.  With Java, one could use a BitSet (this is big enough to hold maxint bits, which could represent a pair of 46340 numbers).

You then test the bit at the $rth location to see if it has been used.  If it has, increment $r and roll it over if it becomes larger than the total space (so if you have a 10 and 20 (0 .. 199) and you hit 200, it becomes 0).

Once you find an unused bit, set it and output your values.

This is what the output looks like though:

Trying 96: 6 9...
        settled at 96: 6 9
Trying 117: 7 11...
        collision at 117: 7 11
        settled at 118: 8 11
Trying 115: 5 11...
        settled at 115: 5 11
Trying 153: 3 15...
        settled at 153: 3 15
Trying 90: 0 9...
        settled at 90: 0 9
Trying 140: 0 14...
        collision at 140: 0 14
        collision at 141: 1 14
        collision at 142: 2 14
        settled at 143: 3 14
Trying 73: 3 7...
        settled at 73: 3 7

This is tested on a unix system thus:

% rndpair.pl 10 20 0.5 | grep settled | sort | uniq | wc -l
     100

This shows that with 100 numbers there are 100 unique pairs printed out (just look at the 'settled' lines).

There's a fair bit of debugging information in there (you don't really need to keep resetting the value of $yp and $xp until the end.

And then there's the question of how fast is it?  This is to generate 50% of the available pairs for the available space.  Realize that there is some time tied up in the sort and uniq (of possibly some not small bits of text):

% time ./rndpair.pl 500 500 0.5 | grep settled | sort| uniq | wc -l
  125000

real    0m3.528s
user    0m3.901s
sys     0m0.045s

Lets kick it up a notch and remove the other applications from the chain.

% time ./rndpair.pl 5000 5000 0.5 > /dev/null

real    0m34.668s
user    0m34.482s
sys     0m0.180s

How much room did that 5k x 5k storage space take?  25,000,000 bits, or about 3 megabytes.

Note that the performance of this drops as the fill factor goes up. For a search space of 6, 80610 (a previous comment if I read it right) this runs quite quickly (note the increasing times as the fill factor goes up):

% time ./rndpair.pl 6 80610 0.5 | grep settled | wc -l
  241830

real    0m0.827s
user    0m1.562s
sys     0m0.029s
% time ./rndpair.pl 6 80610 0.75 | grep settled | wc -l
  362745

real    0m1.721s
user    0m3.151s
sys     0m0.043s
% time ./rndpair.pl 6 80610 0.9 | grep settled | wc -l
  435294

real    0m3.993s
user    0m7.031s
sys     0m0.079s


答:
The following is a re-write to use for instead of foreach.

```<code><?php

function unique_arrays($first, $second) {
    $arrays = array();
    for ($i = $first[0]; $i <= $second[0]; $i++)
        for ($j = $first[1]; $j <= $second[1]; $j++)
            $arrays[] = array($i, $j);

    return $arrays;
}

print_r(unique_arrays(array(1,6), array(3,8)));

?>
</code>```

Here is an iterator-inspired class that should keep the memory down.

```<code><?php

class XYStepper {
    protected $first;
    protected $second;
    protected $current = null;

    public function __construct($first, $second) {
        $this->first = $first;
        $this->second = $second;
    }

    public function next() {
        if ($this->current == null)
            $this->current = $this->first;

        else {
            if ($this->current[0] < $this->second[0]) {
                if ($this->current[1] < $this->second[1])
                    $this->current[1]++;
                else {
                    $this->current[0]++;
                    $this->current[1] = $this->first[1];
                }
            }

            else {
                if ($this->current[1] < $this->second[1])
                    $this->current[1]++;
                else
                    return null;
            }
        }

        return $this->current;
    }
}

$xy = new XYStepper(array(1,6), array(3,8));
while (($next = $xy->next()) != null)
    print_r($next);

?>
</code>```

Adding the ability to step down, or have negative increments is left as an exercise to the reader.

Title: random unique pair numbers from two range

Body:
I want to write a function that return random unique pair numbers every time call it from a range until resetting it.
Something like this:

```<code>function randomUniquePairs($ranges, $reset = false){
   if ($reset === false){
      // some code for reseting
   }
   /*
     some code for creating random unique pair numbers
   */
   return $result;
}

randomUniquePairs(range(1,10), range(1,20));
/*
  this function returns for example:
   array(2,9)
*/
randomUniquePairs(range(1,10), range(1,20));
/*
  this function returns for example:
   array(5,19)
*/

randomUniquePairs(range(1,10), range(1,20));
/*
  this function returns for example:
   array(5,9)
*/
 //this function returns random unique pairs until we pass reset paramer true
</code>```

I tried two approaches:

Approach 1

My first attempt was to make an array of all of possible pairs then select from them randomly, but it is very inefficient, because if ranges are so wide, it consumes a lot of memory.
the code:

```<code>  class a {
    private $asqar;

    function __construct() ($range) {

        // cycle for ranges
        foreach ($range[0] as  $v1) {
            foreach ($range[1] as $v2) {
                $asqar[] =  array(
                    $v1,
                    $v2,
                );
            }
        }
    }

    function randomUniquePairs($reset = false){

        if ($reset === true){
           $this->asgar = array();
        }

        $rndKey = array_rand($this->asgar);
        $result = $this->asqar[$rndkey];
        unset($this->asqar[$rndkey]);
        return $result;
    }
}

$c = new a(range(1,10), range(1,20));
$c->randomUniquePairs();
</code>```

Approach 2

My second attempt was to write a function that produce a pair from these ranges, then store it in a variable, every time that function calls after producing a pair , it checks if this pair produced before call function recursively, it continues until it produce a unique pair.
Here's the code:

```<code>class a{

    private $__uniqueVariables = array();

    public function randomUniquePairs($range, $reset = false) {

        if ($reset === true){
       $this->__uniqueVariables = array();
    }

    // cycle for each value
    foreach ($range as $value) {

        // shuffle
        shuffle($value);

        // selected id
        $selectedId[] = $value[0];
    }

    // check for selected variable
    if (in_array($rndUnqNum, $this->__uniqueVariables)) {

        // return for try again
        return $this->uniqueVariable($range);
    }

    // added to current unique variables
    $this->__uniqueVariables[] = $rndUnqNum;

    // return
    return $rndUnqNum;
}

}
</code>```

but this second approach has an issue that sometimes throw Fatal error: Maximum function nesting level of '100' reached.

I'm looking for a better approach to my algorithm.

Body:
The following is a re-write to use for instead of foreach.

<?php

function unique_arrays($first, $second) {
    $arrays = array();
    for ($i = $first[0]; $i <= $second[0]; $i++)
        for ($j = $first[1]; $j <= $second[1]; $j++)
            $arrays[] = array($i, $j);

    return $arrays;
}

print_r(unique_arrays(array(1,6), array(3,8)));

?>

Here is an iterator-inspired class that should keep the memory down.

<?php

class XYStepper {
    protected $first;
    protected $second;
    protected $current = null;

    public function __construct($first, $second) {
        $this->first = $first;
        $this->second = $second;
    }

    public function next() {
        if ($this->current == null)
            $this->current = $this->first;

        else {
            if ($this->current[0] < $this->second[0]) {
                if ($this->current[1] < $this->second[1])
                    $this->current[1]++;
                else {
                    $this->current[0]++;
                    $this->current[1] = $this->first[1];
                }
            }

            else {
                if ($this->current[1] < $this->second[1])
                    $this->current[1]++;
                else
                    return null;
            }
        }

        return $this->current;
    }
}

$xy = new XYStepper(array(1,6), array(3,8));
while (($next = $xy->next()) != null)
    print_r($next);

?>

Adding the ability to step down, or have negative increments is left as an exercise to the reader.


问:
What does "(say)" mean in this Java method in Hadoop The Definitive Guide?
What does "(say)" mean in this Java method?

Since Mapper and Reducer are separate classes, the type parameters have different scopes, and the actual type argument of KEYIN (say) in the Mapper may be different from the type of the type parameter of the same name (KEYIN) in the Reducer.  For instance, in the maximum temperature example from earlier chapters, KEYIN in replaced by longWritaeble for the Mapper and by Text for the Reducer.

From Hadoop The Definitive Guide, by Tom White, page 224 (scanned version of the page at 223 and 224).

答: There's no doubt that it is just the usage of the english word 'say' and I don't think it has anything to do with Java.</p>


问:
Which things instantly ring alarm bells when looking at code?
I attended a software craftsmanship event a couple of weeks ago and one of the comments made was "I'm sure we all recognize bad code when we see it" and everyone nodded sagely without further discussion.

This sort of thing always worries me as there's that truism that everyone thinks they're an above average driver. Although I think I can recognize bad code I'd love to learn more about what other people consider to be code smells as it's rarely discussed in detail on people's blogs and only in a handful of books. In particular I think it'd be interesting to hear about anything that's a code smell in one language but not another.

I'll start off with an easy one:

Code in source control that has a high proportion of commented out
  code - why is it there? was it meant
  to be deleted? is it a half finished
  piece of work? maybe it shouldn't have
  been commented out and was only done
  when someone was testing something
  out? Personally I find this sort of
  thing really annoying even if it's just the odd line here and there, but when you see large blocks interspersed with the rest of the code it's totally unacceptable. It's
  also usually an indication that the rest of
  the code is likely to be of dubious
  quality as well.

答:
Catching general exceptions:

try {

 ...

} catch {
}
```

<p>or </p>

<pre class="lang-java prettyprint-override"><code>try {

 ...

} catch (Exception ex) {
}
</code>```

Region overuse

Typically, using too many regions indicates to me that your classes are too big. It's a warning flag that signals that I should investigate more into that bit of code.

Body:
Catching general exceptions:

try {

 ...

} catch {
}

or

try {

 ...

} catch (Exception ex) {
}

Region overuse

Typically, using too many regions indicates to me that your classes are too big. It's a warning flag that signals that I should investigate more into that bit of code.


答:
You don't need AJAX or anything other than using POST commands over a secure channel.

At a very high level these are the steps:

Step 1 - The signup page.

Utilize https for any signup pages that include sensitive information. Because the user will be sending their e-mail address and phone number this must be https.

Post the account information including the phone number in which the
SMS should be sent to.

Create a random verification code

Store the verification code along with the new account sign up
information

Send the SMS message with only the verification code

Then redirect the user to the verification page. This page only needs to accept the verification code. Remember that all you are doing is ensuring that the person that has access to the phone is also the same person with the account information. You can't stop someone from being malicious if they have someone else's phone. The phone is called "Something you have" in security terms.

Step 2 - The verification page

Post the verification code. This assumes you are using any one of
the number technologies that tracks state through session ids.

Look up the account id in memory using the current session. This
information should already be readily available. Then confirm that
the verification code is the same one that is stored in the
database. This isn't a password so I don't see a reason to hash this
information. It's a one-user throw away code. It doesn't matter if
someone else gets it later.

If the verification code matches mark the user as verified. Now you
know that this account has access to a specific phone number.

I've included a rudimentary diagram for reference.

Title: SMS verification in web application

Body:
This is my first project related to SMS verification.

How to implement SMS verification in online ordering web application? For example:- when we try to reset the password in amazon's website, it sends an sms verification code and after entering the code it proceeds with changing the password. I want to implement the same function in my application, where users will place order, but before the final step it will send an sms verification code to the users mobile and verify the same.

The main requirement is SMS Gateway(Transactional Quality).

But as I'm completely new in this, so any idea how to proceed, or how can I implement it.


答:
I worked for an organization that had spreadsheets all over the place, largely because the IT resources were hopelessly overstretched.  They would have moved this to an application if it was possible - it simply wasn't possible.

One of the things I did after I left that organization was created a tool for generating C#/SQL Server table maintenance programs from Excel spreadsheets. It assumes the column header is the column name for purposes of table construction and field labeling.  However, this is a crude instrument. It ended up getting used for things having nothing to do with Excel.

The issues we had ran into several categories:

Validation: When the validation rules are complicated, people have to
keep the procedures in their head.  It's possible to design the
spreadsheet with 'if' statements all over the place, as long as
people understand how these work.

Sharing: as pointed out elsewhere, if one person has a network share
spreadsheet open for read/write other users can only read.  We were
not at the point where we could open a spreadsheet in a collaboration
mode.  That was another thing the IT people couldn't handle at the
time.

Schema consistency: In the situation I was in we had a spreadsheet
for each state: the format was common but the state by state data
traveled in separate files.  If someone made a creative use of a
column then everyone had to agree on this use, which was not always
assured.

The spreadsheets were always on a network share and the server was backed up every night, so none of this was an issue.  There was also the distinct possibility of one of them being accidentally emailed to a destination where it didn't belong.  While the likelihood of real harm was slight in this case, the organization was one where 'leading by example' was critical to it's credibility.  That kind of mess up would have been embarrassing.

I saw an ad on Craigslist where someone needed an "Excel Guru".  I passed this to a friend that was between jobs, and he found that the company had a construction contracting estimation system operating at sites all over the state.  Someone here had arbitrary doctored up the system to 'make it work more in they're style'.  Whatever that style was, it had caused a lot of damage.  He spent several days fixing it.  Hardly had he turned in his work and gotten paid they called him back to fix another one in another city.  Same story: someone arbitrarily 'fixed' it to do what they wanted.  This one was even worse.

Complicated systems like this need to be 'out of reach' of ad-hoc customization.


答:
When you are trying to persuade people about the advantages of using a different system you should avoid trying to persuade them.

I know that sounds very strange.

But what I mean is this:

People like using the current system.  It works for them.  It's easy to use and quick to make changes.
To persuade people to use another system, treat them like adults:

Lay out the pro's and con's of excel and of a database approach.  Explain the short and long term consequences of each.  If you can mention all the benefits of BOTH and still persuade folks to change then you have made a convincing enough argument.  The key is to let THEM make the decision that a database approach is better based on the facts and concepts that you've presented.


答:
I'd like to add some ideas/thoughts to @WalterMitty's nice answer.

He's right in that it really depends on the purpose of the Excel files. I would add however that if they contain complex rules AND data, you could think about leveraging the power of rules engines. Rules engines such as Drools, OpenRules or OpenL Tablets allow you to use Excel files for storing the business rules, and (at least for Drools that I know), to update these rules on-the-fly.

It's an excellent way for business-minded people to keep control of their ... business, and to properly separate the business from the datan which is your job, or at least the job of the IT departement. I think business people would agree that the storage, maintenance, and backup should be taken off their shoulders. You should frighten them a bit with the backup part in fact:

What would happen if the guy's hard drive suddenly dies ?

What would happen if the file gets corrupted, deleted, inadvertently reset ?

If we migrate to Excel 2013 from Excel 2007, will everything be alright ?

Now, if you go that way, also think about the fact that if you add databases, it will be your job to maintain their health and integrity. That is, you should conceive a way, or/and prepare your IT infrastructure for keeping data backups. Although not as sophisticated as Oracle's, or IBM's databases, Microsoft Access can produce backups (though I'm not sure this can be automated).

Last but not least, if they accept, don't forget that you would need someone to analyze the business data, conceive the database, prepare a migration plan, allow business people to submit evolution plans, etc. Depending on the amount of data, it may be an IT project of a certain size, and you will most likely be responsible for it. Brace yourself! :-)


问:
What are the deliverables to give to the client for a web application ?
I have completed a web application which is basically developed in PHP and is just another regular web application. Usually when I deliver the final production release I just handover the code documentation and the architecture information to the client. However, for this particular project the client insists on having the complete in and out data about the project. </p>

<p>So I'm just wondering... What are the mandatory technical and non technical docs that I can give my client apart from the code and architecture documentations ? </p>

<p>(Also it would be kinda cool to hit the client about various stats and data about the project so that he would actually know the amount of work involved and how cool the product actually is.) </p>

答:
Follow whichever documentation is applicable for your project from the following.You may already have some of them.

Technical documentation:

Details about PHP and information on how it is useful for the project

Details about the back end and information on how it is useful for the project

Information on Database connectivity along with suitable pictures depicting the flow of data

Information about other programming languages or applications involved in the project like XML,HTML etc.

FAQ Help file

Prepare documents with screenshots and highlight the relevant code (if necessary) for the following:

Information on the front end application like objects or controls,object properties etc.

Information on Database queries(if its not already present)

Information on Database properties like Primary Key,Foreign Key etc. and how they ensure data consistency and accuracy.

Detailed guide throughout the project by using screenshots of all possible kind of screen using both the front end as well as back end after running it with sample data,without repetition of similar kind of data or screen,in a logical order.

Input invalid data and show that is impossible to do so as you have done data validation at the front end and back end.

/* This step is not applicable if you have not used any object for getting direct input from the user like Text Field as it is obvious that you cannot get invalid data through indirect  input. */

Show that there is no error in the program or inconsistency in the data if there is a sudden failure in the server or client system by explaining the relevant code.

After giving sample data through the front end,you can include sample queries in the back end for direct retrieval of data from the server and also include sample DML queries which can help to prepare vital statistics of your data.

You should check these for yourself before documenting them so that if your client asks for a demo with sample data,you can show how the project actually works.Also,make sure that your front end code has appropriate comment lines.

Finally conclude with the statistics like total number of lines of code,total number of days spent towards the project,total number of times you have checked the project,a list of all applications used and other technical and non-technical information.

  Non-Technical documentation:

Licensing details of project,if applicable.

Commercial aspects of the project,if applicable.


答:
The use of "say" in the passage is another way of writing "for example" posing a hypothetical.

An example of this usage seen on English.SE - How to punctuate an example indicated by “say” which shows "parenthetical commas":

"If you have (say) a bucket..."

In the paragraph, "For instance" follows this sentence and an editor may find it wordy to use another clause construct that starts with "for".  It is easier to modify the one in the middle of a sentence to "say" rather than the one that starts a sentence.

An identical meaning of the text:

Since Mapper and Reducer are separate classes, the type parameters have different scopes, and the actual type argument of KEYIN, for example, in the Mapper may be different from the type of the type parameter of the same name (KEYIN) in the Reducer. For instance, in the maximum temperature example from earlier chapters, KEYIN in replaced by longWritaeble for the Mapper and by Text for the Reducer.

Title: What does "(say)" mean in this Java method in Hadoop The Definitive Guide?

Body:
What does "(say)" mean in this Java method?

Since Mapper and Reducer are separate classes, the type parameters have different scopes, and the actual type argument of KEYIN (say) in the Mapper may be different from the type of the type parameter of the same name (KEYIN) in the Reducer.  For instance, in the maximum temperature example from earlier chapters, KEYIN in replaced by longWritaeble for the Mapper and by Text for the Reducer.

From Hadoop The Definitive Guide, by Tom White, page 224 (scanned version of the page at 223 and 224).


问:
Find out whose turn it is to buy the croissants, accounting for possible absences
A team has decided that every morning someone should bring croissants for everybody. It shouldn't be the same person every time, so there should be a system to determine whose turn it is next. The purpose of this question is to determine an algorithm for deciding whose turn it will be to bring croissants tomorrow.

Constraints, assumptions and objectives:

Whose turn it is to bring croissants will be determined the previous afternoon.

On any given day, some people are absent. The algorithm must pick someone who will be present on that day. Assume that all absences are known a day in advance, so the croissant buyer can be determined on the previous afternoon.

Overall, most people are present on most days.

In the interest of fairness, everyone should buy croissants as many times as the others. (Basically, assume that every team member has the same amount of money to spend on croissants.)

It would be nice to have some element of randomness, or at least perceived randomness, in order to alleviate the boredom of a roster. This is not a hard constraint: it is more of an aesthetic judgement. However, the same person should not be picked twice in a row.

The person who brings the croissants should know in advance. So if person P is to bring croissants on day D, then this fact should be determined on some previous day where person P is present. For example, if the croissant bringer is always determined the day before, then it should be one of the persons who are present the day before.

The number of team members is small enough that storage and computing resources are effectively unlimited. For example the algorithm can rely on a complete history of who brought croissants when in the past. Up to a few minutes of computation on a fast PC every day would be OK.

This is a model of a real world problem, so you are free to challenge or refine the assumptions if you think that they model the scenario better.

Origin 1: Find out who's going to buy the croissants by Florian Margaine.

Origin 2: Find out who's going to buy the croissants by Gilles.

This question is the same version as Gilles', and has been re-posted on Programmers as an experiment to see how the different communities address a programming challenge.

答:
What I would do, if I had to pick this, is get a hat, and put everyone's names in the hat once on little pieces of paper.  Then each day, I'd draw someone's name from the hat at random, and that's the person who brings the croissants the next day.  That paper then gets tacked up on a board, under "BRINGING CROISSANTS TOMORROW".  The paper that's currently on the board gets thrown away.

I'd also have a box.  It starts out empty. Each day, before drawing the names, I'd dump the contents of the box into the hat, then go through the papers in the hat and remove everyone who's going to be absent tomorrow.  Their names go in the box.

If it's time to draw a name and the hat is empty, I'd tear up some more paper and add everyone's name once, then move the names of everyone who's going to be absent tomorrow to the box.

Because of these last two steps, it's possible for the same name to be in the hat multiple times at once. If the name I happen to draw is the same as the name that's on the board, I'd move that paper to the box, and then draw again.

It shouldn't be too difficult to translate this system to an algorithm in your language of choice.


答:
Algorithm, smalgorithm. Use a DB.

```<code>create table team_members
(
    id integer auto_increment,
    name varchar(255),
    purchase_count integer,
    last_purchase_date datetime,
    present integer,
    prefers_donuts integer default 0,
    primary key( id)
)
</code>```

Who buys?

```<code>select id from team_members where (present = 1) and (prefers_donuts = 0) order by purchase_count, last_purchase_date limit 1;
</code>```

After they buy:

```<code>update team_members set purchase_count = purchase_count + 1, last_purchase_date = now() where id = ?
</code>```

And then set:

```<code>insert into team_members (name, prefers_donuts) values ('GrandmasterB', 1);
</code>```

...because I'm old school.

It shouldn't be too difficult to add a little randomness by tweaking the first query - maybe by adding a random() instead of sorting by last_purchase date.

Title: Find out whose turn it is to buy the croissants, accounting for possible absences

Body:
A team has decided that every morning someone should bring croissants for everybody. It shouldn't be the same person every time, so there should be a system to determine whose turn it is next. The purpose of this question is to determine an algorithm for deciding whose turn it will be to bring croissants tomorrow.

Constraints, assumptions and objectives:

Whose turn it is to bring croissants will be determined the previous afternoon.

On any given day, some people are absent. The algorithm must pick someone who will be present on that day. Assume that all absences are known a day in advance, so the croissant buyer can be determined on the previous afternoon.

Overall, most people are present on most days.

In the interest of fairness, everyone should buy croissants as many times as the others. (Basically, assume that every team member has the same amount of money to spend on croissants.)

It would be nice to have some element of randomness, or at least perceived randomness, in order to alleviate the boredom of a roster. This is not a hard constraint: it is more of an aesthetic judgement. However, the same person should not be picked twice in a row.

The person who brings the croissants should know in advance. So if person P is to bring croissants on day D, then this fact should be determined on some previous day where person P is present. For example, if the croissant bringer is always determined the day before, then it should be one of the persons who are present the day before.

The number of team members is small enough that storage and computing resources are effectively unlimited. For example the algorithm can rely on a complete history of who brought croissants when in the past. Up to a few minutes of computation on a fast PC every day would be OK.

This is a model of a real world problem, so you are free to challenge or refine the assumptions if you think that they model the scenario better.

Origin 1: Find out who's going to buy the croissants by Florian Margaine.

Origin 2: Find out who's going to buy the croissants by Gilles.

This question is the same version as Gilles', and has been re-posted on Programmers as an experiment to see how the different communities address a programming challenge.

Body:
Algorithm, smalgorithm. Use a DB.

create table team_members
(
    id integer auto_increment,
    name varchar(255),
    purchase_count integer,
    last_purchase_date datetime,
    present integer,
    prefers_donuts integer default 0,
    primary key( id)
)

Who buys?

select id from team_members where (present = 1) and (prefers_donuts = 0) order by purchase_count, last_purchase_date limit 1;

After they buy:

update team_members set purchase_count = purchase_count + 1, last_purchase_date = now() where id = ?

And then set:

insert into team_members (name, prefers_donuts) values ('GrandmasterB', 1);

...because I'm old school.

It shouldn't be too difficult to add a little randomness by tweaking the first query - maybe by adding a random() instead of sorting by last_purchase date.


答:
I've actually had to solve this problem somewhat in the real world:

```<code>remember how many times people have gotten donuts
every day:
  var candidates = everyone
  toss out people who aren't here tomorrow
  toss out people who aren't here today
  toss out the person who got them today (unless they're the only one left)
  toss out everyone where "times they got donuts"/"times everyone has got donuts"
    is more than 1/number of people (unless that would eliminate everyone)

  pick someone at random from the candidates
</code>```

What happens is people who have bought donuts "too much" (due to bad luck, going to work when others are on vacation, etc) are excluded from the pool until enough acquisitions go by to put them back under the "right" percent of purchases.

This would need to be expanded to better handle hiring new people though...

Anyways, this design worked really well for changing variables (who is in, who is out) and when the schedule needs to be (practically) infinite. As an added bonus, it's easy to make deterministic by seeding your RNG.

Body:
I've actually had to solve this problem somewhat in the real world:

remember how many times people have gotten donuts
every day:
  var candidates = everyone
  toss out people who aren't here tomorrow
  toss out people who aren't here today
  toss out the person who got them today (unless they're the only one left)
  toss out everyone where "times they got donuts"/"times everyone has got donuts"
    is more than 1/number of people (unless that would eliminate everyone)

  pick someone at random from the candidates

What happens is people who have bought donuts "too much" (due to bad luck, going to work when others are on vacation, etc) are excluded from the pool until enough acquisitions go by to put them back under the "right" percent of purchases.

This would need to be expanded to better handle hiring new people though...

Anyways, this design worked really well for changing variables (who is in, who is out) and when the schedule needs to be (practically) infinite. As an added bonus, it's easy to make deterministic by seeding your RNG.


问:
Is Ruby on Rails a suitable framework for a desktop application?
I was wondering if there are obvious advantages and disadvantages to using Ruby on Rails to develop a desktop application.

RoR has great infrastructure for rapid development, proper implementation of specs and automated acceptance tests, an immense number of popular libraries and the promise of being actively developed and maintained in the future.

The downsides I can see are mostly about usability - installation of a Rails app as a local service and launching of a browser when it needs to be active may not come naturally to many users... or be technically easy to implement and support for different platforms.

答:
Rails is a web framework, I'd use it for that or if you really want to produce a desktop application then pick something else.  You might be able to get it working as a desktop platform now but that's clearly not how it's seen by the community so who's to say it won't be changed in the future to make your implementation harder or impossible?

I'd also suggest that if you're going to be constrained by a browser based UI, why not just host it on a server and get the benefits rather than having to deal with support of local installs?

The best desktop applications will be ones written in a language which is intended for that purpose and ideally which are native (or in the case of .NET native-ish) to the operating system so they can adopt all the usual UI components, metaphors and functionality users are used to seeing on that OS.


答:
I'd use a scoring algorithm.  Each person starts with a score of zero.  Each time they bring croissants, increment their score by 1.  The score of all team members who did not bring croissants is decremented by 1/N.  Thus a score of 0 means that a team member has neither over or under bought.

Without randomness, choose the person with the lowest score out of the list of those who will be present.

To add randomness, sort the list by score and choose at random out of the list of all team members with a negative score.  By restricting to negative scores, you ensure that no one will be too "lucky" over many weeks.

The advantage of this algorithm is that it has no reliance on keeping historical records and it easily allows the addition of new team members at any point in time.

It could be adapted to allow for absences being relatively common by decrementing the scores of only those present to enjoy the croissants.


答:
Not as good as some of the other answers already presented, but another way of looking at the problem:

Make a list of all participating employees

Duplicate the list a lot of times (say, 1,000)

Shuffle the list

Each afternoon, select the next available croissant-bringer.
Each morning, the croissant-bringer crosses his/her name off the top of the list.

Daily processing is pen & paper simple.

New Hires & Terminations Alumni would probably best be handled by making a new list.  If CPU cycles ever get expensive again (or you have 100M employees & only a 1st gen Arduino) then it'd be easy to salt the original list with an appropriate number of place holders.

More info (per request).

Using this approach with an arbitrarily long list, you get the benefit of transparency.

Not only do you know who will bring croissants tomorrow, you know who is scheduled to bring them in the day after, and so on.  Of course the further out in time you look the less accurate you'll be due to absences, etc.

Sneaky devs who figure out how to weight their slips of paper in a hat won't have as much opportunity to avoid their croissant-bringing duties.

Whining non-devs who claim the processed is rigged can easily review the data, come up with the wrong conclusion, and whine anyway.


答:
Non Random

Maintain a ordered list.  If a person is absent on the day they are supposed to buy, swap them with the next available person.  Eventually the person will be present and thus buy croissants.  So, the contents of the list remain the same, but persons may be moved or up down depending on absenses.

New people get inserted to the list after the current position.  People who quit or terminated get removed from the list.  The current position increments by 1 every day, when it reaches the end, it will go back to the start.

This assumes there are enough people in the list to account for the average absense time to promote fairness.

Random

We can't just select random people each day as there will be short term bias, for example flip a coin 10 times and you could come up heads 8 and tails 2, so heads would be screwed for the short term.  So, we need to create buckets of people to keep it fair.

The bucket is determined by the number of times people have bought crossiants in the past.  So, in this case, we would store a dictionary of people and crossiant buys.  On day 1 everyone is in bucket zero.  As people buy croissiants, they will be assigned to the next bucket up, i.e 1, 2, etc.  The random part is picking from the pool of available people in the bucket. The first available bucket is the one with the fewest buys.  If there are 10 people in the bucket, then pick a random number from 1 to 10 and that who buys croissants.  New people are assigned the lowest current bucket so they don't end up buying extra rounds of crossiants (although they will be in the buy pool right away).  If no one is available in the lowest bucket (they are all absent), then you go to the next highest bucket.  For example, let's say there is a list of 10 people.  On day 8, 8 people are in bucket 1 and 2 are in bucket 0.  The two people in bucket 0 are absent.  In this case, bucket 1 will be used and one person will end up in bucket 2.  But, people will always be within a few crossiant buys (buckets) within each other, because the person now in bucket 2 will most likely not be in the buy pool for a while.

Tweaks could be added to make sure the same person does not buy two days in a row and there are some edge cases to handle, but this would add an element of randomness as well as keeping it fair.  Also, one might want to keep actual croissant buys versus current bucket separated.  As people leave, there are removed from the bucket either by marking them permanately absent or deleting them altogether.


问:
Learning Multiple Languages Simultaneously
When learning new languages, is it better to commit yourself to one language 100% and wait until you've "mastered" it to move on to another, or to work on learning different languages at the same time?

If it matters, I'm currently learning C++ and I'd like to know Java and Python as well.

答:
I have been teaching programming for several years, so I can share my experience with you. I assume that C# is your first language, so my experience teaching programming to people that had never programmed before may be useful.

First of all, let me tell you that learning more than one language is something that every seasoned programmer should do. But this does not mean that you should learn several languages at the same time if you are just starting.

Over the years, students have shown that it takes about a year for a language to solidify in the mind (at least the first one), sometimes a little more, sometimes a little less. If you try to teach more than one language in one year students tend to mix them up and confuse concepts and languages. Although students make progress, they get into a lot of bad habits that is difficult to weed out later. If you are learning on your own, this risk is higher.

However, I have noticed that it helps if you teach two languages with a very different syntax. When two programming languages look really different it helps the mind to see them as really different entities without polluting each other. (When one programming language helps you understand difficult concepts in another language, that is good; when one language makes you write bad code in another language, that is bad).

Therefore, my recommendation would be to stick to one programming language for your first year. Alternatively, it may be a good idea to learn two languages at the same time as long as they are / look very different. If your first language is C#, I would stay away from C, C++, Objective C, and Java for sure; and probably Python, Ruby, and Javascript. I would recommend combining C# with a functional language like Haskell, Scheme, F#, Erlang, Clojure, or maybe Scala.


答:
Anything that violates principles that are important.  For instance, a few anti-patterns have been suggested (magic number -- see http://en.wikipedia.org/wiki/Anti-pattern).  Anti-patterns are called that because they cause problems (also already mentioned - fragility, maintenance nightmares, etc). Also, watch out for violation of SOLID principles - see http://en.wikipedia.org/wiki/Solid_(object-oriented_design)
Also, Code that doesn't consider separation of tiers (data access things inside the UI, etc).  Having coding standards and code reviews help to combat this.</p>

Title: Which things instantly ring alarm bells when looking at code?

Body:
I attended a software craftsmanship event a couple of weeks ago and one of the comments made was "I'm sure we all recognize bad code when we see it" and everyone nodded sagely without further discussion.

This sort of thing always worries me as there's that truism that everyone thinks they're an above average driver. Although I think I can recognize bad code I'd love to learn more about what other people consider to be code smells as it's rarely discussed in detail on people's blogs and only in a handful of books. In particular I think it'd be interesting to hear about anything that's a code smell in one language but not another.

I'll start off with an easy one:

Code in source control that has a high proportion of commented out
  code - why is it there? was it meant
  to be deleted? is it a half finished
  piece of work? maybe it shouldn't have
  been commented out and was only done
  when someone was testing something
  out? Personally I find this sort of
  thing really annoying even if it's just the odd line here and there, but when you see large blocks interspersed with the rest of the code it's totally unacceptable. It's
  also usually an indication that the rest of
  the code is likely to be of dubious
  quality as well.


问:
Will SQL Server autonumber reuse a value if a record is deleted?
The titled basically states it. If I have a bigint column with primary key and autonumber, and a record is deleted, will SQL Server ever reuse that now available value?

The underlying issue is that I have a multi-user environment, and if I retrieve a record from the database into memory, then another user makes changes (like deleting and/or re-adding), if I do updates or deletes based on that ID in memory, is there a chance that I could be editing a record that was added in the background that doesn't truly represent the record I should be editing?

I realize I could use Guids, but I'd really like to know if BigInt/Autonumber is "safe" in this scenario.

Thanks!

答: wouldn't it be simple just to try it out?  To answer your question, auto-increments typically use sequence generators to come up with numbers.  Once a sequence generator gives you a number, it will move on and will continue giving new numbers regardless of what happens to the existing tables.  So you should be safe.</p>


答:
There's no such thing as AUTONUMBER in SQL Server, that I'm aware of.  What there is, is the IDENTITY property, which allows for the automatic creation of new values, such as for primary keys.  And IDENTITY is just a generator: it starts at a starting value and counts upwards.

There are some advanced uses to make it loop, but you have to know what you're doing to invoke those.  So no, if you just use a normal IDENTITY 1, 1 on a column, and it's a BIGINT, for all intents and purposes it will never reuse a value.  (If you're able to exhaust the 64-bit range of numbers, that's a different problem...)

Title: Will SQL Server autonumber reuse a value if a record is deleted?

Body:
The titled basically states it. If I have a bigint column with primary key and autonumber, and a record is deleted, will SQL Server ever reuse that now available value?

The underlying issue is that I have a multi-user environment, and if I retrieve a record from the database into memory, then another user makes changes (like deleting and/or re-adding), if I do updates or deletes based on that ID in memory, is there a chance that I could be editing a record that was added in the background that doesn't truly represent the record I should be editing?

I realize I could use Guids, but I'd really like to know if BigInt/Autonumber is "safe" in this scenario.

Thanks!


问:
What's the career path for a developer who doesn't like management?
If you're developer (Senior or Lead Developer) and you'd rather stay with code/design than pursue a management career, what are the available career paths at your company, or any you've heard of? How far can you go?

Is it possible to continue being a geek until you bite the dust or is that too naive?

Are people like Uncle Bob for example still considered developers, as they claim?

答:
There are several paths I've seen taken:

Product Manager

Requirements Analyst

Architect

Team Lead

Configuration Manager

Technical Writer

Start-up Founder

Grant Writer


答:
Common sense, team play and people skills are as much important as technical skills. It's better to have a decent score overall.

Dealing with 'Hi Tech' bosses with low score in other skills is a nightmare.


问:
How to deal with requirements and use cases in this kind of situation?
Recently I've started to work with object oriented analysis and design and it seemed very interesting to me as a way to get work done better. But I'm still in doubt with one kind of situation. If this is not the correct site to ask about it, sorry for that.

Well, if I have to design a system that allows one user to register customers, sell products and so on, we have someone that will operate the system, in the sense that actor is kind of obvious for some of the use cases - the actor we will consider on the use case "Register New Customer" is simply the responsible for that action in the company of the customer that is purchasing the software.

Now, there are sometimes that this doesn't happen. I'll give an example: I've developed once a system to manage templates for websites in PHP. In that time, I didn't develop it within an object oriented context, but I was thinking on bring this system into object orientation to practice object oriented analysis and design. The point is that the system is very simple: "it takes some configurations written in a xml file, takes a URL and maps it to a file".

The point is that there's no interaction between the users of the websites and the system. The only thing that happens is that the user requests a URL and the system selects one html file that matches this URL in some way, and embed this html into a template specified in the xml. In cases like that, the only functional requirements I can think of are:

The system must allow the user to specify the folders of templates into an xml file;

The system must get the information of directories from the xml file;

The system must load one specific file corresponding to the requested url inside one template file;

The system must allow the replacement of placeholders into the template by values specified on code;

The problem is: for instance, although I thought of them as functional requirements, all of them has to do directly with how the code must be made. Only the third one really fits what I understood of functional requirement. Also the use cases are a little complicated, every action is took by the system itself. The only use case could be "Request Page" with actor being "Site Visitor" and this would imply that the scenario would be just "The user inputs the url into the browser window and the system loads the page."

So, in cases like that, when we are dealing with code will simply be reused into some other code (this is an example, it's just a bunch of code that a developer can use to load pages independent of a template), how should we deal with requirement analysis, use cases and so on?

As I've said, the PHP system I wrote is just an example, I'm really asking in general. Could someone give some hints or reference (some article, tutorial, something like that), that shows how to deal with this?

Thanks very much in advance!

答:
Use cases like Register New Customer belong to the business- or domain view and describe interactions between end-users and the system.

The purpose of use cases is to allow communication between the software developer and non-technical end users, stakeholders, managers.

Use cases describe what has to be done but not how is it implemented.

Your sentences The system must ...  describe how is it implemented which are important implementation details. In my opinion implementation details do not belong to use cases. End users are usually not interested in folders, xml, file, placeholder. In your system, end users want to register new customers and sell something to them.