问:
Developing an iOS app for a single device - licensing issue
I'm developing an iOS app for a museum as a freelancer. It's a very simple video player, to be installed on a single iPad that will be part of a permanent exhibition, basically acting as a kiosk. It turns out the iPad is the ideal device for that if you're looking for a small and affordable touchscreen.

The problem is: as far as I can tell, none of the Apple Developer Program options available will allow me to distribute an app like that. The relevant options are (from the link above):

iOS Developer Program ($99/year)
Select this program if you would like to distribute apps on the App Store as an individual, sole proprietor, company, organization, government entity or educational institution.

iOS Developer Enterprise Program ($299/year)
Select this program if you would like to develop proprietary apps for internal distribution within your company, organization, government entity or educational institution.

The regular program requires distribution through the App Store. The Enterprise version is for internal distribution within my own organization. Neither is the case here! It seems like I'm doomed to violate Apple's terms of service (and I can think of at least two ways of doing that: jailbreaking, or changing the iPad's date so it won't know the provisioning profile expired).

Is that really so, or did I get the descriptions wrong? Has anyone here been in a similar situation?

答: You should investigate the VPP program from Apple.  It allows you release an App to a virtual private iTunes Store for each customer.  Once the customer and you are registered they will be able to download the app from their private store.  Once they have done so you can lock the app to prevent additional downloads to that one customer.  The same setup can be replicated for possible future customers as well.  A bit spendy but then you are providing a one off for their use.  With luck some other curator will see it and want it for their exhibit! :-)  Good luck.</p>


问:
Pure Java web browser, is it practical?
I know that a Java web browser is possible, but is it practical? I've seen the Lobo project and must admit I am impressed, but from what I've gathered it seems that development stopped in 2009. Would a browser coded in pure Java (no WebKit java bindings of any type) be able to compete with those among the ranks of Chrome or Firefox, or would it be inherently slower, hindering the user?</p>

答:
The current top answer is excellent. I'll add, though, that one doesn't need to totally recode something into Java. There are tools that convert native source to Java bytecodes with varying degrees of interoperability. They often create an interpreter of sorts or use a JVM-like representation such as MIPS as a stepping stone. One might break a Java browser development into many steps by converting key native libraries into Java bytecode, integrate them with pure Java browser source, and gradually implementing more library code as pure Java source. </p>

<p>This allows you to contain everything within the safer JVM. However, it will be a pain in the butt ensuring efficiency. There's some precedent in gradually refactoring large, pre-Agile/OOP legacy applications. Plus, some of the components already have good Java implementations and those could be used too to reduce labor. </p>

ContentLicense: CC BY-SA 3.0

Title: Pure Java web browser, is it practical?

Body:
The current top answer is excellent. I'll add, though, that one doesn't need to totally recode something into Java. There are tools that convert native source to Java bytecodes with varying degrees of interoperability. They often create an interpreter of sorts or use a JVM-like representation such as MIPS as a stepping stone. One might break a Java browser development into many steps by converting key native libraries into Java bytecode, integrate them with pure Java browser source, and gradually implementing more library code as pure Java source.

This allows you to contain everything within the safer JVM. However, it will be a pain in the butt ensuring efficiency. There's some precedent in gradually refactoring large, pre-Agile/OOP legacy applications. Plus, some of the components already have good Java implementations and those could be used too to reduce labor.


问:
Submit code during interview
I'm interviewing for a position at an internet startup. The position relates to doing data mining on their very large database of user information. As part of the (long-distance) interview procedure which involves examining a subset of their database, they requested that I submit the code I used for analysis.

My main concern is that this code is "proprietary", for lack of a better word. I have no problems giving them all my code if I end up working for them, but considering that they could potentially take the code, not hire me, and use it on their larger database to generate revenue, I'm hesitant. Am I being just being paranoid? Is this a legitimate concern?

答:
Yeah, imma chime in 2 years later in case someone stumbles upon this in a Google search like I did.

I would just submit it.  What kind of IT shop does their programming by tricking interviewees into doing their work for them?  That's just backwards.  If your code is good enough for them to use, they'll probably hire you to write more of it.  That's why they're interviewing you... to find out if your code is good enough for their application.  It isn't like you're submitting source code for something proprietary you wrote for someone else... you don't own their database or their products, so what's it to you?  Even if they do steal your code, that isn't gonna hurt you.  You really have nothing to lose but your time, which... you're gonna lose that anyways.  If you don't plan on giving them the code, I would just walk away from the prospect altogether.  If that's their process that's their process.  You're not going to gain anything by not giving them the code.

Title: Submit code during interview


答:
Am I being just being paranoid? Is this a legitimate concern?

I think you probably being paranoid.  Or mercenary.  Or both.

You are worrying about something that is highly unlikely to have any significant inherent value1.

You commented thus:

Does that really matter? The inherent value is the same if it's four minutes or four days.

Erm ... this is not a realistic.  A 2 line "hello world" program is not the same as something you spent days, weeks, months working on.  But either way, the real value of this code (i.e. the potential for making money) to YOU is most likely zero.  If you make a fuss about the IP issues, a prospective employer is likely take this as a sign of things to come.

And on the ethics side, of course they have a legitimate need to see how you implemented the code.  How else are they going to assess the quality of your work?  They also have a moral obligation to treat your code as your property.  But you don't need legal agreements and stuff for something like this.  It is simply a waste of everyone's time for a trivial amount of effort.

Footnote 1 - The exception would be is that if your solution to the "interview homework" problem included a large body of private code that you spent months / years developing, and that you have realistic plans to make money out of it.  If that is the case you should not be using it in "interview homework" questions.

No employer wants to employ a programmer only to get into fights about who owns the IP rights for critical code that may-or-may-not have been written by said programmer outside of work hours.  And if your effectiveness as a programmer depends on your use of a bunch of your own private code, then your employer will have major problems if / when you "move on".

Title: Submit code during interview

Body:
I'm interviewing for a position at an internet startup. The position relates to doing data mining on their very large database of user information. As part of the (long-distance) interview procedure which involves examining a subset of their database, they requested that I submit the code I used for analysis.

My main concern is that this code is "proprietary", for lack of a better word. I have no problems giving them all my code if I end up working for them, but considering that they could potentially take the code, not hire me, and use it on their larger database to generate revenue, I'm hesitant. Am I being just being paranoid? Is this a legitimate concern?


问:
When are RPC-ish approaches more appropriate than REST?
After watching this talk on REST, Reuse and Serendipity by Steve Vinoski, I wonder if there are business cases in greenfield projects for (XML-)RPC-ish setups, that REST could not solve in a better way.

A few RPC-Problems he mentions:

Focus on language (fit the distributed system to the language, not the other way around)

"Make it look local" (and cope with failure and latency as exceptions rather than the rule)

intended to be language-independent, but still has "function calls"  across languages as main ingredient

IDL boilerplate

Illusion of type safety

and a few more ...

Just to dramatize it a bit, some Google Instant results for RPC vs REST:

答: You actually can have both. Plugins like RestRPC for Grails provides annotations that will intercept calls to your methods and handle them restfully while allowing you to have as many as you want (which would be very RPC-like).</p>


问:
Program license : Open-Source and commercial?
Currently programming a new software, I'm searching for information about protecting my concept and my source-code. I precise I'm quite new in licensing.

As I'm feeling very concerned by Open-source and sharing with the community, I'm puzzled on the other hand because I want to make some profit of my work (around 1 year of free-time, you can imagine the amount of missed beers in pub!). So I'm looking for a double license, that is compatible, and allows software source-code distributing, but force companies to get a commercial license, or to negotiate directly with me. But I think it is totally contradictory with GPL like licenses.

What are you thinking about that?

答:
This is pretty common.  Plenty of companies offer to dual license their products, with an open-source license and a commercial license.  Companies who wish to modify the source code without distributing the source themselves will pay for the commercial license, since open source prohibit this (thought there's a web app loophole in some open source licenses).  Also, some companies will pay for the license because their legal department doesn't like dealing with open source software.

Just make sure you don't accept code contributions that aren't licensed back to you (and if someone forks due to this limitation, don't look at it).

For example, I suggest examining the old licensing strategy of YAF.Net (archive.org), a GPL forum application.

A common additional revenue source is paid support (include some free support with a paid license).

Disclaimer: I'm not a lawyer and this is not legal advice.  Consult a lawyer.  Even if this information is accurate in my jurisdiction, it might be inaccurate in yours.


问:
Creating an expandable, cross-platform compatible program "core"
Basically the brief is relatively simple. We need to create a program core. An engine that will power all sorts of programs with a large number of distinct potential applications and deployments.

The core will be an analytics and algorithmic processor which will essentially take user-specific input and output scenarios based on the information it gets, whilst recording this information for reporting.

It needs to be cross platform compatible. Something that can have platform specific layers put on top which can interface with the core.

It also needs to be able to be expandable, for instance, modular with developers being able to write "add-ons" or "extensions" which can alter the function of the end program and can use the core to its full extent.

(For instance, a good example of what I'm looking to create is a browser. It has its main core, the web-kit engine, for instance, and then on top of this is has a platform-specific GUI and can also have add-ons and extensions which can change the behavior of the program.)

Our problem is that the extensions need to interface directly with the main core and expand/alter that functionality rather than the platform specific "layer".

So, given that I have no experience in this whatsoever (I have a PHP background and recently objective-c), where should I start, and is there any knowledge/wisdom you can impart on me please?

Thanks for all the help and advice you can give me. :) If you need any more explanation just ask. At the moment its in the very early stages of development, so we're just researching all possible routes of development.

Thanks a lot

答:
Ive done it.
http://members.dodo.com.au/~bpc01/index.html
Has linked lists of each data type in the main class (can have as much or as little data as a class needs)
Expandable using shared memory segments so that each .dll can add its own classes to the main list that classes are cloned from in the main program. Multicore enabled so that lists of classes can be run parallel. Ive added Lua as a scripting language so it can be expanded using compiled code (.dll's) or scripts. I am going to add graphics, sounds, networking and a database for more functionality</p>

ContentLicense: CC BY-SA 2.5


问:
What makes for "good style" in Java?
I had asked this question on Stackoverflow, and before it got booed off, I received the helpful suggestion from Péter Török that this might be a better place to post it.

I've been programming in Java for a few years. I've often discussed design decisions with colleagues on the basis of what constitutes 'good style'. Indeed, there are a number of StackOverflow questions/answers that discuss a design on the basis of whether something is 'good style'.

But what makes 'good style'? Like many things, I know it when I see it... but I wanted to have better idea than just my conscience saying that this design doesn't feel right.

What are the things you think about in order to produce good, well designed code?

(I acknowledge that this is somewhat subjective, as what is 'good style' will depend on the task at hand). (Also, I should add that I'm not interested in team styles - e.g. "we use indents of 2 spaces rather than 4"..., and I'm not interested in the Java code conventions.)

Edit: thanks for all the good answers/comments so far. I'm especially keen for answers that would help codify those things that make a programmer's conscience (and possibly stomach) wrench?

答: Read the String and ArrayList class for excellent examples of proper Java programming. But they are highly concise, almost C style, which isn't necessarily best for maintainable code w/ minimal java docs. The common practice at my shop is no comments, so I try to comment by code by using verbose camelCase var names and excessive use of newlines to delimit one line of thought from another. I still debate using tabs to separate vars from their values. Tabs can enhance readability, IMO, but only when done minimally and it's very subjective. I find it's really about the audience. There's no best answer here.</p>

Title: What makes for "good style" in Java?


问:
Inserting HTML code with jquery
One of our web applications is a page that takes in a serial number and various information is returned and displayed to the user. The serial is passed via AJAX, and based on the response, one of the following can happen -

An error message is shown

A new form replaces the previous form

Now, the way I am handling this is to use jQuery to destroy (using $.remove()) the table that displayed the initial serial form, then I'm appending another html table that contains another form. Right now I am including that additional form as part of the html source, and just setting it to display:none, then using jQuery to show it when appropriate. However, I don't like this approach because if someone views source on the page, they can see that table html code that is not being displayed.

My next thought would be to use AJAX to read in another HTML file, and append it that way. However, I am trying to keep down the number of files this project uses, and since most pages in our project will use AJAX, I could see a case where there are multiple files containing HTML snippets - and that feels sloppy to me.

What is the best way to handle a case where multiple html elements are being shown and removed with jQuery?

答:
I've done something like this by sending the new HTML with the response in a JSON object. Something like this question.

```<code>echo '{"html": "<p>I\'m the markup</p>"}';
</code>```

Then replacing the HTML like this:

```<code>$.ajax({
    url: "foo.php",
    type: "post",
    data: values,
    success: function(data){
        $("#myDiv").html(data.html);
    }
});
</code>```

Title: Inserting HTML code with jquery

Body:
I've done something like this by sending the new HTML with the response in a JSON object. Something like this question.

echo '{"html": "<p>I\'m the markup</p>"}';

Then replacing the HTML like this:

$.ajax({
    url: "foo.php",
    type: "post",
    data: values,
    success: function(data){
        $("#myDiv").html(data.html);
    }
});


问:
Is big-O really that relevant when working in industry?
In every interview I have been in, I have been quizzed on mathematical analysis of complexity, including big-O notation.

How relevant is big-O analysis to development in industry? How often do you really use it, and how necessary is it to have a honed mindset for the problem?

答:
Well, maybe a little story enlightens you why it DEFINITELY IS necessary:

In a project I've been working at, there was a program responsible for printing all kind of documents (labels, picking lists etc.) This program consisted of two parts, one reading all the necessary data from the database and writing it into a .ini-style file, and another part that read those files and filled it into the templates. This worked reasonably well for labels and small lists (with only a few fields) but it ran for almost 10 minutes when it had to print a "large" list of ~20 pages. Because accessing these ini-files resulted in O(n²) access times, n being the number of fields to print.

Had the original programmers of this program understood O-notation, they would never have made it that way. Replacing that stupidity with a hashtable made it soooooooo much faster.


问:
Are certain problems solved more elegantly with AOP?
I've come across the idea of Aspect Oriented Programming, and I have some concerns with it.

The basic idea seems to be that we want to take cross-cutting concerns which aren't well modularized using object and modularize them. That is all very fine and well.

But the implementation of AOP seems to be that of modifying code from outside of the module. So, for example, an aspect could be written that changes what happens when a particular object is passed as a parameter in a function. This seems to go directly against the idea of modules. I should not be able to modify a module's behavior from outside of that module, otherwise the whole point of modules are overturned. But aspects seem to be doing exactly that!

Basically, aspects seems to be a form of code patching. It may useful for some quick hacks; but, as a general principle perhaps its not something you want to do. Aspect Oriented Programming seems to me taking a bad practice and raising to a general design principle.

Is AOP a good practice?  Are certain programming problems solved more elegantly with AOP?

答:
Coming in late to the game, but I provide this for later developers who might stumble across this question.

I would strongly advise against AOP if your application depends on it to operate correctly. Aspects work like this:

Advice (additional behavior) is applied to

Join points (places where the extra code can be attached, such a method start or end, or when a given event triggers)

... where pointcut (a pattern that detects whether a given join point matches) patterns match

For anyone who's been doing computers for a long time, the fact that patterns are used might be something to look at closely. So to here's an example of a pointcut that matches any method named set regardless of the arguments:

```<code>call(* set(..))
</code>```

So that's a fairly sweeping pointcut and it should be clear that handling this with care is advised (no pun intended) because you're applying advice to many things.

Or heck, let's apply advice to everything, regardless of name or signature!

```<code>execution(* *(..))
</code>```

So clearly we should be careful because there's a lot of power here, but this is not an argument against aspects — it's an argument for caution because there's a lot of power here and pattern matching can easily go awry (just hit your favorite search engine for aop bugs and have fun).

So here's what looks like a relatively safe pointcut:

```<code>pointcut setter(): target(Point) &&
                   ( call(void setX(int)) ||
                     call(void setY(int)) );
</code>```

That explicitly provides advice if methods named setX or setY on a Point object are found. The methods can only receive ints and they must be void. Looks pretty safe, right? Well, that's safe if those methods exist and you've applied the correct advice. If not, too bad; it silently fails.

To give an example, a friend was trying to debug a Java application where everyone once in a great while, it would return incorrect data. It was an infrequent failure and didn't appear to be correlated with any particular event or data in particular. It was a threading bug, something that is notoriously difficult to test or detect. As it turns out, they were using aspects to lock methods and make them "thread safe", but a programmer renamed a method and a pointcut failed to match it, thus causing a silent breakage of the application.

Thus, I tell people that if they must use AOP, to treat aspects like exceptions: in a well-designed system and if nothing goes wrong, they can be removed and the software still functions correctly. However, if the functionality of the program depends on AOP, you introduce a fragility to your program that is unwarranted.

Thus, logging, debugging and tracing are great examples of behaviors that are perfect for aspects, but security? Nope. Thread safety? Nope.

For a robust alternative to AOP, see traits. Rather than being bolted onto the language, they are integrated into it directly, don't need a "trait aware" IDE (though it can help) and have compile-time failures if the methods you require are not present. Traits do a much cleaner job of handling separation of concerns because the problem was better defined from the start. I use them extensively and they're fantastic.

Body:
Coming in late to the game, but I provide this for later developers who might stumble across this question.

I would strongly advise against AOP if your application depends on it to operate correctly. Aspects work like this:

Advice (additional behavior) is applied to

Join points (places where the extra code can be attached, such a method start or end, or when a given event triggers)

... where pointcut (a pattern that detects whether a given join point matches) patterns match

For anyone who's been doing computers for a long time, the fact that patterns are used might be something to look at closely. So to here's an example of a pointcut that matches any method named set regardless of the arguments:

call(* set(..))

So that's a fairly sweeping pointcut and it should be clear that handling this with care is advised (no pun intended) because you're applying advice to many things.

Or heck, let's apply advice to everything, regardless of name or signature!

execution(* *(..))

So clearly we should be careful because there's a lot of power here, but this is not an argument against aspects — it's an argument for caution because there's a lot of power here and pattern matching can easily go awry (just hit your favorite search engine for aop bugs and have fun).

So here's what looks like a relatively safe pointcut:

pointcut setter(): target(Point) &&
                   ( call(void setX(int)) ||
                     call(void setY(int)) );

That explicitly provides advice if methods named setX or setY on a Point object are found. The methods can only receive ints and they must be void. Looks pretty safe, right? Well, that's safe if those methods exist and you've applied the correct advice. If not, too bad; it silently fails.

To give an example, a friend was trying to debug a Java application where everyone once in a great while, it would return incorrect data. It was an infrequent failure and didn't appear to be correlated with any particular event or data in particular. It was a threading bug, something that is notoriously difficult to test or detect. As it turns out, they were using aspects to lock methods and make them "thread safe", but a programmer renamed a method and a pointcut failed to match it, thus causing a silent breakage of the application.

Thus, I tell people that if they must use AOP, to treat aspects like exceptions: in a well-designed system and if nothing goes wrong, they can be removed and the software still functions correctly. However, if the functionality of the program depends on AOP, you introduce a fragility to your program that is unwarranted.

Thus, logging, debugging and tracing are great examples of behaviors that are perfect for aspects, but security? Nope. Thread safety? Nope.

For a robust alternative to AOP, see traits. Rather than being bolted onto the language, they are integrated into it directly, don't need a "trait aware" IDE (though it can help) and have compile-time failures if the methods you require are not present. Traits do a much cleaner job of handling separation of concerns because the problem was better defined from the start. I use them extensively and they're fantastic.


问:
Do you keep your project code names the same in the source tree?
Sometimes when I start working on a project, I just can't think of a good name, or think of a good name that isn't already taken. As a result, I'll end up picking some sort of code name for the project.

My question is, how do you handle name changes in your source code once you find a real name for your project? Should you continue to refer to the code name in your source tree, namespaces, binaries, etc?

答:
In my experience, it is extremely common that the name used to market a product is completely different from the name used internally for that product by the developers. Most often, because marketing has not decided on a name yet when development starts.

Whenever a project or product name is used in the internal documentation, file hierarchy, etc., it has been the practice to keep using the internal code-name, even after marketing has decided on the official product name. Only in documentation that is meant for the end-users is the product referred to with its official marketing name.
Usually, there is significant cost and no benefit in renaming everything.


问:
What software is used to write functional and non-functional requirements?
Is there any software which can be used to write functional and non-functional requirements?

When writing those, it is essential to:

Store the document in text format to be able to make diffs and minimize the impact on the version control,

Apply extensive formatting when creating diagrams would be an overkill,

Use diagrams, preferably stored in text format as well,

Cross-link the requirements or the appendixes.

Currently, I can only think about three editors which may be used, but which are not truly suitable:

A Markdown editor.

Benefits: text only; easy to add formatting.

Disadvantage: not powerful enough: one can add images, but not diagrams; formatting is rather limited; no cross-linking (unless adding much HTML markup).

An HTML editor.

Benefits: text only; ability to add diagrams with HTML 5. Advanced formatting is possible.

Disadvantages: markup difficult to change by hand, or if WYSIWYG editor is used, markup is often too verbose and low quality; cross-linking limited to manual only.

A document editor such as OpenOffice or Microsoft Word.

Benefits: ability to apply some advanced formatting; excellent automated cross-linking.

Disadvantages: binary format, which means no diff and wasted space in version control.

What are my other choices?

What is actually used in the industry?

答:
Have you thought about these

Docx - MS Word format based on XML

Latex

a Wiki eg Confluence


问:
What mistakes do your users make, and how can you update your application to handle them?
In fact this question is about cautions to be taken to enhance quality user experience and reduce avoidable support calls.</p>

答:
User don't make mistakes. The mistakes lie with the programmer who failed to create a usable interface.

So do usability tests with each release!


问:
Python 3, replace in strings
I need to transliterate a Hebrew text. So wrote a little Python script, which reads-in the Hebrew text from a text file, globally replaces the Hebrew letters with Latin ones. Now I need to do some fine tuning (replace certain things in some position but not in other, so a global replace won't do). The trouble is the following: The read-in text is a string so I cannot replace individual string elements. So, what would be the best way to do it?</p>

答:
If you are needing to pull the ";" out of "Hebrew W;rd" rather than writing a list and iterating through it, just find the replacing character and replace it.

If the conversion from Hebrew to Latin leaves ";" where "x" should be, loop through and replace the characters.

```<code>while ";" in converted_string:
     converted_string = converted_string.replace(";","x")
</code>```

If some ";" are legit within the string, than just require conditions before executing the code to narrow down what bad characters to replace.

```<code>while ";" in converted_string:
      if converted_string[converted_string.find(";")-1] != "z": # sample condition
           converted_string = converted_string.replace(";","x")
</code>```

The real trick is not whether to use lists or strings, but writing the conditions well enough that parsing the code will be accurate.

Title: Python 3, replace in strings

Body:
If you are needing to pull the ";" out of "Hebrew W;rd" rather than writing a list and iterating through it, just find the replacing character and replace it.

If the conversion from Hebrew to Latin leaves ";" where "x" should be, loop through and replace the characters.

while ";" in converted_string:
     converted_string = converted_string.replace(";","x")

If some ";" are legit within the string, than just require conditions before executing the code to narrow down what bad characters to replace.

while ";" in converted_string:
      if converted_string[converted_string.find(";")-1] != "z": # sample condition
           converted_string = converted_string.replace(";","x")

The real trick is not whether to use lists or strings, but writing the conditions well enough that parsing the code will be accurate.


问:
In embedded, is there any difference between a device driver and a library?
Assuming a platform with no kernel mode, such as Atmel AVR, is there any difference between a device driver and a library, given that everything is user mode anyway?

I ask because I'm thinking about how I want to layer my code. It's like this:

```<code>+----------------+
| Business logic |
+----------------+
|   CAN library  |
+----------------+
| MCP2515 driver |
+----------------+
|   SPI driver   |
+----------------+
</code>```

The SPI "driver" has an interrupt handler, and it talks directly to the microcontroller's SPI peripheral, which sounds like a driver, but other than that, I don't see how it's any different to, say, the CAN library, which has high-level functions like "send this message".

答:
The main difference between a device driver and a library is that the purpose of a device driver is to control some hardware component.

Device drivers can either directly control I/O pins of the processor (like the SPI driver in your example is likely doing), or they can use the services of a lower-layer device driver to communicate over a communication channel with their device (like the MCP2515 driver).

What sets the latter kind of device driver apart from a library that implements a communication protocol is that the communication partner is a hardware chip that can only perform some dedicated function and that the communication protocol is very low level.


答: DOORS (Dynamic Object-Oriented Requirements management System) is an object-oriented database system and application code specifically for managing requirements.  It is heavily used in the industry by the serious players.</p>

Title: What software is used to write functional and non-functional requirements?

Body:
Is there any software which can be used to write functional and non-functional requirements?

When writing those, it is essential to:

Store the document in text format to be able to make diffs and minimize the impact on the version control,

Apply extensive formatting when creating diagrams would be an overkill,

Use diagrams, preferably stored in text format as well,

Cross-link the requirements or the appendixes.

Currently, I can only think about three editors which may be used, but which are not truly suitable:

A Markdown editor.

Benefits: text only; easy to add formatting.

Disadvantage: not powerful enough: one can add images, but not diagrams; formatting is rather limited; no cross-linking (unless adding much HTML markup).

An HTML editor.

Benefits: text only; ability to add diagrams with HTML 5. Advanced formatting is possible.

Disadvantages: markup difficult to change by hand, or if WYSIWYG editor is used, markup is often too verbose and low quality; cross-linking limited to manual only.

A document editor such as OpenOffice or Microsoft Word.

Benefits: ability to apply some advanced formatting; excellent automated cross-linking.

Disadvantages: binary format, which means no diff and wasted space in version control.

What are my other choices?

What is actually used in the industry?


问:
Best way to test a reimplemented web service
In my team, we are about to start the reimplement of a service. One of the important steps to do to accomplish this is how do we ensure that we are doing it in the right way and  we are not introducing new bugs.

So, what we have in mind is create a bunch of test to verify the following:

The behavior. Both services should behave the same way (store data in the same places, send same, notificacions, etc...)

Results. Object returned by the service's calls should be exactly the same.

So, the things that we have thought is to do the following:

Create a set of test that verifies the behavior and results of old service.

Create the new service adding unit test, and whitebox integration test for the new service

Create some kind of "Mirror test" that checks if the new service is working as the old one. Is there a way to do this?

Thanks for any help.

Note: None of the code of the previous version is reusable. There is no test for the older version of the service

[Edited]replaced original word "migrate" with "reimplement"

答:
you can write approvaltests that are available for .net and java.

the idea you implement a test-client that calls the old service with typical inputvalues and record the corresponding output from the service.

then you execute the test-client against the new service: The approval-test-tool complains if the output is different from the previosly recorded output.


问:
Java vs C#: What should a junior programmer (just finished degree) consider when entering the programming world?
I just want to hear some pro and con's - it's obvious that there is no right answer

So would Java be a better choice for a long term career? Or should I opt for .Net since it could be the platform having all the latest advances?

I just want to hear others point of view, so please don't close this question just because it's being subjective

答: Choose programming, not a language. If I were still in school, java and C# would be the last things on my list. Look at the crazy academic stuff while you can, like Haskell and Lisp. Then come back to the mundane code you will spend 95% of your professional career slinging.</p>

OwnerDisplayName: oneWhoNeedGuidenss


答:
Two ideas:

docbook may suit your needs (not specifically for requirements, you can use this for any kind of formatted docs). Text format, cross linking capabilities, images. How you get diagrams into your documents depends a little bit on your workflow (for example, in the past my team set up a workflow where we can use Inkscape for diagramming, with an automatic conversion from SVG to PNG images).

any kind of issue tracking system. See requirements just as "missing features" (or issues), starting from a "Hello World" program.


问:
Do sigils make source code easier to read?
In most programming languages, variables do not have identifying characters like they do in PHP. In PHP you must prefix a variable with the $ character.

Example;

```<code> var $foo = "something";
 echo $foo;
</code>```

I'm developing a new scripting language for a business application, and my target users do not have a programming background. Do these characters make code easier to read and use?

One reason PHP uses the $ is because without it PHP can't tell if a name is a function reference or variable reference. This is because the language allows strange references to functions. So the $ symbol helps the parser separate the namespace.

I don't have this problem in my parser. So my question is purely on readability and ease of use. I have coded for so many years in PHP that when I see $foo it's easy for me to identify this as a variable. Am I just giving a bias preference to this identifier?

答:
I not agree that PHP uses $ to differ vars from funcs. At least because PHP have C-like syntax, and funcs() have parens after the name.

Read this post on stack overflow about why $ is in PHP.

Many popular languages, such as C, C++, C#, Java do not use $ and we can differ easy var from function.

In PHP $ helps, for example, when you write:
  echo "var = $var"

Without $ such trick will be impossible.


答:
Big-O performance is important, but it's been largely internalized.

The Big-O performance of sorting and searching doesn't matter, because people generally use the system-supplied ones, and those will be as good as they can be (given that they need to be generally useful).  There are data structures that are more efficient for different things, but those can usually be selected on general principles (and are typically built into modern languages).  There is some sense of algorithms that do or do not scale.

The result is that the formal issues rarely come up in practice, but practice is built on the same principles.

Title: Is big-O really that relevant when working in industry?

Body:
In every interview I have been in, I have been quizzed on mathematical analysis of complexity, including big-O notation.

How relevant is big-O analysis to development in industry? How often do you really use it, and how necessary is it to have a honed mindset for the problem?


问:
Efficient way of evaluating an array of strings then add to an array in Ruby
I am looking for an efficient way of evaluating an array of strings against a series of rules and then adding them to another array.

For example I have an array of strings:

something

a

1234

#gohere

I want to iterate through all the items in the array and evaluate them based on a series of rules. For example:

Strings greater that 1 in length

Strings that don't start with the # character

I was thinking of either:

Nested loop of if statements evaluating the string for each rule and if they all pass then add to another array

Evaluating the string against rule 1 then adding to the array then performing another evaluation - I have discounted this since it requires lots of array read/write operations to evaluate the complete ruleset.

Please note that I have kept the number of rules to two for brevity however I could be needing up to 10 rules. Additionally, I do not control the original array since the function I am calling returns an array of strings.

I know I may have answered my own question with the nested loop however I wondered if anyone had any ideas for optimizing this type of situation.

Also, I know I asked this question in the reference of Ruby but any pseudo-code would suffice.

答: I would use Array#select and pass it a block that &&s together all the tests.  If the tests get unwieldy you can abstract them into a method or series of methods.</p>


答:
Sigils actually make a lot more sense in perl, where they provide a certain amount of type checking.  In php they don't help much outside of templating.  You can get a sense of their usefulness and readability by looking around at different languages.  Hardly any use them.

In an end user targeted language I'm working on, I even go further, making identifiers case insensitive and allowing spaces and apostrophes.  That lets me make variable names like Karl's height that are much closer to natural languages.

Title: Do sigils make source code easier to read?

Body:
In most programming languages, variables do not have identifying characters like they do in PHP. In PHP you must prefix a variable with the $ character.

Example;

```<code> var $foo = "something";
 echo $foo;
</code>```

I'm developing a new scripting language for a business application, and my target users do not have a programming background. Do these characters make code easier to read and use?

One reason PHP uses the $ is because without it PHP can't tell if a name is a function reference or variable reference. This is because the language allows strange references to functions. So the $ symbol helps the parser separate the namespace.

I don't have this problem in my parser. So my question is purely on readability and ease of use. I have coded for so many years in PHP that when I see $foo it's easy for me to identify this as a variable. Am I just giving a bias preference to this identifier?


问:
What's the best way to scale and split an agile team building a web app?
I've recently joined a company where I'm working as the scrum master on an agile development project building a web app.

The team is just about to be the maximum size for an agile team (expecting 9 next week).  We have talked about potentially splitting the team into two teams, not so much to shorten standups (which aren't excessive at the moment) but to stop people from being completely bored in sprint planning sessions (which again aren't excessively long).

There are two very distinct layers to the project - high technical backend dev (like seriously complex), and UI design/build/integration.  It seems that when the backend guys are talking technical the UI guys zone out, and vice versa.  It seems like the logical way to split the team if only to be more time efficient, but I have one massive reservation in that all I might really be doing is reducing collaboration and knowledge sharing.  The two teams just won't really have a good idea about what the rest of the team are building.

Does anyone have any experience in dealing with something like this?

答:
Like others, I would definitely suggest going with vertical slices.  These are sometimes referred to as "Feature Teams".  I would recommend reading on the pros/cons over at the Scaled Agile Framework site: http://scaledagileframework.com/scaled-agile-framework/team/features-components/

At first, when you split, your Product Owner and SDF Master may be able to handle the Release Backlog for both teams as well as individual backlogs for each feature team.  As you grow, however, you will likely need to implement a product features backlog which is then fed into multiple agile teams release backlogs.  Once you scale to that level, you will likely need a separate team managing the features backlog and then bringing the features down to the individual teams for implementation.  In that structure, you may have something like this:

Agile Team 1:  SM, PO, Cross-functional team.  Has own team backlog for their stories.

Agile Team 2:  SM, PO, Cross-functional team.  Has own team backlog for their stories.

Program Management Team: Product Manager, Release Managers, Enterprise Architects.  Has own program backlog of higher level epics and features that will be organized, analyzed, and then fed down into the teams.

The SAFe website has a lot of cool stuff for organizing larger teams, and some might be helpful for you as you move to a larger scale of teams-of-teams.


问:
Backlog item with preparation for future sprint Scrum
I'm currently at the beginning of a build. We are requiring a lot of back end functionality around Clients/Users/Groups/Roles.

However, these aren't required for Sprint 1 which is acting as a MVP release. But I want to ensure we are preparing for this enhanced back-end in the future.

This is easiest by defining an interface to the User Management system without actually building all of it yet. How would you organise this in a Scrum project environment?

Obviously, in order to decide how the interface needs to look. We need to decide on it's functionality. But in doing so, we'll be getting very close to speccing the entire thing out. Which isn't required for several months!

(This is a Team Foundation Scrum 3.0 workflow for those interested)

答:
I assume that since you want to prepare for the work you believe that the back-end functionality is bigger than could fit into a sprint?  (i.e you could not build it in the sprint where the functionality is required)

If that is the case, then I would suggest taking the overall back-end functionality and breaking it down into multiple independent pieces that are small enough to be completed inside of a sprint.  Take each of these pieces as a story, and build out the back-end functionality for each piece sequentially across multiple sprints, evolving the back-end architecture and user management UI as you go.

For example,  you may just start with something as simple as a Login story, which requires the back-end to have the concept of usernames and passwords.  You don't need to worry about all the roles and groups yet, just start with something.

There will be refactoring along the way, you don't need to spec it all out up front.  That doesn't mean you shouldn't think about the architecture and your eventual goal, but you can drill down to the details as needed.  Perhaps on user story 5 you realize something in user story 2 was done wrong.  When you estimate story 5, make sure to include the effort to rework what was done in story 2.

One of the easiest ways to support this in a demo is to think about what the high-level user goals are for managing the users.  In your demo, show a user accomplishing one of the goals.  The goals may be something like this:

Login

Edit My Profile

View other users in the system

Assign roles to other users

Manage groups

Secure group management

Secure user management

Those 7 goals might become your stories (or you may group some together depending on their size and your own personal preferences).  You can then tackle them incrementally across your sprints, planning so that all of them are in place by the time you reach the sprint where all the functionality is needed.


问:
Is there a name for this kind of database constraint? "Functional foreign key"? And is it a good idea?
Say we want to enforce that a table represents a tree. I have found this method for doing so:

```<code>create table tree (
  id integer[] primary key,
  parent integer[] references tree (id),
  item text not null,
  constraint tree_parent check (
       (id = array[]::integer[] and parent is null)
    or parent = id[1:array_length(id,1)-1])
);
</code>```

A node in the tree is identified by its path from the root node. As such, the foreign key parent is just that path with one element dropped off the end. The combination of foreign key and check guarantees the tree structure.

First question: is this a good idea? Are there better approaches? In Oracle at least, I'm able to define parent as a virtual column, which is elegant.

Second question: is there a name for this approach? I like to think of this as a "functional foreign key": tree.id references tree.id, but via a function that drops the last element in the path. I think this concept has more general use than the tree example above.

答:
1) Can you explain better your check constraint. What exactly you want to check? Circles?

If you going to check the whole path for item on INSERT this can cost good time ... each jump means indexes search of a key.

2) I do not see how you can make 'parent' to be a virtual column, i.e. calculated column ... It will be calculated from where?

I think the 'parent' column is required to save on disk link to a parent item.


答:
I would suspect that a for loop or a select are equal in terms of efficiency. You can always implement both options and benchmark them.

What you can optimise is the body of the iteration. If you have multiple rules and you join those together using and ruby will do short-circuit evaluation and return after it found the first false value. Hence the order of those rules is important.

Now you need to find out:

Which rule is most likely to return false

Which rule will evaluate quickest

Order the rules from fastest to slowest and/or most likely to fail to least likely to fail. Without a specific problem however I can't give you a more specific answer. And as with everything in optimisation, always measure first.

Totally contrived example

```<code>require 'benchmark'
def slow_and_false
  sleep 0.1
  false
end

def fast_and_false
  sleep 0.005
  false
end

Benchmark.bm do |x|
  x.report("slow first") do
    100.times do
      slow_and_false and fast_and_false
    end
  end
  x.report("fast first") do
    100.times do
      fast_and_false and slow_and_false
    end
  end
end
</code>```

The result of this:

```<code>            user     system      total        real
slow first  0.000000   0.000000   0.000000 ( 10.086344)
fast first  0.010000   0.010000   0.020000 (  0.560307)
</code>```

Title: Efficient way of evaluating an array of strings then add to an array in Ruby

Body:
I am looking for an efficient way of evaluating an array of strings against a series of rules and then adding them to another array.

For example I have an array of strings:

something

a

1234

#gohere

I want to iterate through all the items in the array and evaluate them based on a series of rules. For example:

Strings greater that 1 in length

Strings that don't start with the # character

I was thinking of either:

Nested loop of if statements evaluating the string for each rule and if they all pass then add to another array

Evaluating the string against rule 1 then adding to the array then performing another evaluation - I have discounted this since it requires lots of array read/write operations to evaluate the complete ruleset.

Please note that I have kept the number of rules to two for brevity however I could be needing up to 10 rules. Additionally, I do not control the original array since the function I am calling returns an array of strings.

I know I may have answered my own question with the nested loop however I wondered if anyone had any ideas for optimizing this type of situation.

Also, I know I asked this question in the reference of Ruby but any pseudo-code would suffice.

Body:
I would suspect that a for loop or a select are equal in terms of efficiency. You can always implement both options and benchmark them.

What you can optimise is the body of the iteration. If you have multiple rules and you join those together using and ruby will do short-circuit evaluation and return after it found the first false value. Hence the order of those rules is important.

Now you need to find out:

Which rule is most likely to return false

Which rule will evaluate quickest

Order the rules from fastest to slowest and/or most likely to fail to least likely to fail. Without a specific problem however I can't give you a more specific answer. And as with everything in optimisation, always measure first.

Totally contrived example

require 'benchmark'
def slow_and_false
  sleep 0.1
  false
end

def fast_and_false
  sleep 0.005
  false
end

Benchmark.bm do |x|
  x.report("slow first") do
    100.times do
      slow_and_false and fast_and_false
    end
  end
  x.report("fast first") do
    100.times do
      fast_and_false and slow_and_false
    end
  end
end

The result of this:

            user     system      total        real
slow first  0.000000   0.000000   0.000000 ( 10.086344)
fast first  0.010000   0.010000   0.020000 (  0.560307)


答:
The actual technical possibilites and limitations are nothing of the sort as are suggested throughout this thread. Let's clear out those first.

Here's what $ is making possible in PHP:

Variable variables

Variables with keyword name e.g. $return or being able to use same name for a variable and a functon/constant e.g. $__FILE__

Limitations or features that are unrelated to the $ prefix:

The implementation otherwise being unable to tell difference between functions and variables

PHP string interpolation or template syntax

Required variable declaration

That means there is no technical reason you couldn't have

```<code>foo = "something";
echo foo;
</code>```

or

```<code>foo = "something";
echo "foo = $foo";
//would print
//foo = something
</code>```

However you cannot have (assuming return is a keyword)

```<code>return = "something";
</code>```

Without serious complications. If you used a prefix like $, then it would not
have been any problem.

It's an opinion but I believe a sigil would be worth it for non programmers since it enables them to use keywords
as variable names, to them it would otherwise look like arbitrary limitation :P

Body:
The actual technical possibilites and limitations are nothing of the sort as are suggested throughout this thread. Let's clear out those first.

Here's what $ is making possible in PHP:

Variable variables

Variables with keyword name e.g. $return or being able to use same name for a variable and a functon/constant e.g. $__FILE__

Limitations or features that are unrelated to the $ prefix:

The implementation otherwise being unable to tell difference between functions and variables

PHP string interpolation or template syntax

Required variable declaration

That means there is no technical reason you couldn't have

foo = "something";
echo foo;

or

foo = "something";
echo "foo = $foo";
//would print
//foo = something

However you cannot have (assuming return is a keyword)

return = "something";

Without serious complications. If you used a prefix like $, then it would not
have been any problem.

It's an opinion but I believe a sigil would be worth it for non programmers since it enables them to use keywords
as variable names, to them it would otherwise look like arbitrary limitation :P


问:
"Everything is a Map", am I doing this right?
I watched Stuart Sierra's talk "Thinking In Data" and took one of the ideas from it as a design principle in this game I'm making. The difference is he's working in Clojure and I'm working in JavaScript.  I see some major differences between our languages in that:

Clojure is idiomatically functional programming

Most state is immutable

I took the idea from the slide "Everything is a Map" (From 11 minutes, 6 seconds to > 29 minutes in).  Some things he says are:

Whenever you see a function that takes 2-3 arguments, you can make a case for turning it into a map and just passing a map in.  There are a lot of advantages to that:

You don't have to worry about argument order

You don't have to worry about any additional information.  If there are extra keys, that's not really our concern.  They just flow through, they don't interfere.

You don't have to define a schema

As opposed to passing in an Object there's no data hiding.  But, he makes the case that data hiding can cause problems and is overrated:

Performance

Ease of implementation

As soon as you communicate over the network or across processes, you have to have both sides agree on the data representation anyway.  That's extra work you can skip if you just work on data.

Most relevant to my question. This is 29 minutes in: "Make your functions composable". Here's the code sample he uses to explain the concept:

```<code>;; Bad
(defn complex-process []
  (let [a (get-component @global-state)
        b (subprocess-one a)
        c (subprocess-two a b)
        d (subprocess-three a b c)]
    (reset! global-state d)))

;; Good
(defn complex-process [state]
  (-> state
    subprocess-one
    subprocess-two
    subprocess-three))
</code>```

I understand the majority of programmers aren't familiar with Clojure, so I'll rewrite this in imperative style:

```<code>;; Good
def complex-process(State state)
  state = subprocess-one(state)
  state = subprocess-two(state)
  state = subprocess-three(state)
  return state
</code>```

Here are the advantages:

Easy to test

Easy to look at those functions in isolation

Easy to comment out one line of this and see what the outcome is by removing a single step

Each subprocess could add more information on to the state.  If subprocess one needs to communicate something to subprocess three, it's as simple as adding a key/value.

No boilerplate to extract the data you need out of the state just so that you can save it back in.  Just pass in the whole state and let the subprocess assign what it needs.

Now, back to my situation:  I took this lesson and applied it to my game.  That is, almost all of my high level functions take and return a gameState object.  This object contains all the data of the game.  EG: A list of badGuys, a list of menus, the loot on the ground, etc.  Here's an example of my update function:

```<code>update(gameState)
  ...
  gameState = handleUnitCollision(gameState)
  ...
  gameState = handleLoot(gameState)
  ...
</code>```

What I'm here to ask about is, have I created some abomination that perverted an idea that is only practical in a functional programming language?  JavaScript isn't idiomatically functional (though it can be written that way) and it's really challenging to write immutable data structures.  One thing that concerns me is he assumes that each of those subprocesses are pure. Why does that assumption need to be made?  It's rare that any of my functions are pure (by that, I mean they often modify the gameState.  I don't have any other complicated side effects other than that).  Do these ideas fall apart if you don't have immutable data?

I'm worried that one day I'll wake up and realize this whole design is a sham and I've really just been implementing the Big Ball Of Mud anti-pattern.

Honestly, I've been working on this code for months and it's been great.  I feel like I'm getting all the advantages he's claimed.  My code is super easy for me to reason about.  But I'm a one man team so I have the curse of knowledge.

Update

I've been coding 6+ months with this pattern. Usually by this time I forget what I've done and that's where "did I write this in a clean way?" comes into play. If I haven't, I'd really struggle. So far, I'm not struggling at all.

I understand how another set of eyes would be necessary to validate its maintainability. All I can say is I care about maintainability first and foremost. I'm always the loudest evangelist for clean code no matter where I work.

I want to reply directly to those that already have a bad personal experience with this way of coding.  I didn't know it then, but I think we're really talking about two different ways of writing code.  The way I've done it appears to be more structured than what others have experienced.  When someone has a bad personal experience with "Everything is a map" they talk about how hard it is to maintain because:

You never know the structure of the map that the function requires

Any function can mutate the input in ways you'd never expect.  You have to look all over the code base to find out how a particular key got into the map or why it disappeared.

For those with such an experience, perhaps the code base was, "Everything takes 1 of N types of maps." Mine is, "Everything takes 1 of 1 type of map". If you know the structure of that 1 type, you know the structure of everything.  Of course, that structure usually grows over time.  That's why...

There's one place to look for the reference implementation (ie: the schema). This reference implementation is code the game uses so it can't get out of date.

As for the second point, I don't add/remove keys to the map outside of the reference implementation, I just mutate what's already there. I also have a large suite of automated tests.

If this architecture eventually collapses under its own weight, I'll add a second update.  Otherwise, assume everything is going well :)

答:
So, there seems to be a lot of discussion between the effectiveness of this approach in Clojure. I think it might be useful to look at Rich Hickey's philosophy as to why he created Clojure to support data abstractions in this way:

Fogus: So once incidental complexities have been reduced, how can
Clojure help solve the problem at hand? For example, the idealized
object-oriented paradigm is meant to foster reuse, but Clojure is not
classically object-oriented—how can we structure our code for reuse?

Hickey: I would argue about OO and reuse, but certainly, being able to
reuse things makes the problem at hand simpler, as you are not
reinventing wheels instead of building cars. And Clojure being on the
JVM makes a lot of wheels—libraries—available. What makes a library
reusable? It should do one or a few things well, be relatively
self-sufficient, and make few demands on client code. None of that
falls out of OO, and not all Java libraries meet this criteria, but many do.

When we drop down to the algorithm level, I think OO can
seriously thwart reuse. In particular, the use of objects to represent
simple informational data is almost criminal in its generation of
per-piece-of-information micro-languages, i.e. the class methods,
versus far more powerful, declarative, and generic methods like
relational algebra. Inventing a class with its own interface to hold a
piece of information is like inventing a new language to write every
short story. This is anti-reuse, and, I think, results in an explosion
of code in typical OO applications. Clojure eschews this and instead
advocates a simple associative model for information. With it, one can
write algorithms that can be reused across information types.

This
associative model is but one of several abstractions supplied with
Clojure, and these are the true underpinnings of its approach to
reuse: functions on abstractions. Having an open, and large, set of
functions operate upon an open, and small, set of extensible
abstractions is the key to algorithmic reuse and library
interoperability. The vast majority of Clojure functions are defined
in terms of these abstractions, and library authors design their input
and output formats in terms of them as well, realizing tremendous
interoperability between independently developed libraries. This is in
stark contrast to the DOMs and other such things you see in OO. Of
course, you can do similar abstraction in OO with interfaces, for
instance, the java.util collections, but you can just as easily not,
as in java.io.

Fogus reiterates these points in his book Functional Javascript:

Throughout this book, I’ll take the approach of using minimal data
types to represent abstractions, from sets to trees to tables. In
JavaScript, however, although its object types are extremely powerful,
the tools provided to work with them are not entirely functional.
Instead, the larger usage pattern associated with JavaScript objects
is to attach methods for the purposes of polymorphic dispatch.
Thankfully, you can also view an unnamed (not built via a constructor
function) JavaScript object as simply an associative data store.

If the only operations that we can perform on a Book object or an
instance of an Employee type are setTitle or getSSN, then we’ve locked
our data up into per-piece-of- information micro-languages (Hickey
2011). A more flexible approach to modeling data is an associative
data technique. JavaScript objects, even minus the prototype
machinery, are ideal vehicles for associative data modeling, where
named values can be structured to form higher-level data models,
accessed in uniform ways.

Although the tools for manipulating and accessing JavaScript objects
as data maps are sparse within JavaScript itself, thankfully
Underscore provides a bevy of useful opera‐ tions. Among the simplest
functions to grasp are _.keys, _.values, and _.pluck. Both _.keys and
_.values are named according to their functionality, which is to take an object and return an array of its keys or values...


问:
ASP.Net or WPF(C#)?
Our team is divided on this and I wanted to get some third-party opinions.

We are building an application and cannot decide if we want to use .Net WPF Desktop Application with a WCF server, or ASP.Net web app using jQuery. I thought I'd ask the question here, with some specs, and see what the pros/cons of using either side would be. I have my own favorite and feel I am biased.

Ideally we want to build the initial release of the software as fast as we can, then slow down and take time to build in the additional features/components we want later on. Above all we want the software to be fast. Users go through records all day long and delays in loading records or refreshing screens kills their productivity.

Application Details:

I'm estimating around 100 different screens for initial version, with plans for a lot of additional screens being added on later after the initial release.

We are looking to use two-way communication for reminder and event systems

Currently has to support around 100 users, although we've been told to allow for growth up to 500 users

We have multiple locations

Items to consider (maybe not initially in some cases but in future releases):

Room for additional components to be added after initial release (there are a lot of of these... perhaps work here than the initial application)

Keyboard navigation

Performance is a must

Production Speed to initial version

Low maintenance overhead

Future support

Softphone/Scanner integration

Our Developers:

We have 1 programmer who has been learning WPF the past few months and was the one who suggested we use WPF for this.

We have a 2nd programmer who is familiar with ASP.Net and who may help with the project in the future, although he will not be working on it much up until the initial release since his time is spent maintaining our current software.

There is me, who has worked with both and am comfortable in either

We have an outside company doing the project management, and they are an ASP.Net company.

We plan on hiring 1-2 others, however we need to know what direction we are going in first

Environment:

General users are on Windows 2003 server with Terminal Services. They connect using WYSE thin-clients over an RDP connection. Admin staff has their own PCs with XP or higher. Users are allowed to specify their own resolution although they are limited to using IE as the web browser.

Other locations connects to our network over a MPLS connection

Based on that, what would you choose and why?

答: Lunatic fringe answer: both. Get the service layer right, it is easy to have a thick client that does everything (WPF) and a quick web client to do most common things (ASP.NET). Leaves door open to mobile client, etc., down the road.</p>

Title: ASP.Net or WPF(C#)?


答:
Years ago, I learned Applesoft Basic.  Strings were always suffixed with $ and arrays had a suffix of %.  Thats just how the language worked.  You looked at something, you knew what it was.  I never did delve too far into the interpreter to understand why this was the case or the design decisions that made it so.

The sigil in php comes from its perl influence (which was influenced by awk and sh).  The sigil in perl is quite a bit more than just $ as it can identify many different types:

$ scalar

@ list

% hash

& codeblock

* typeglob

The sigil identifies what part of the symbol table structure you are looking at.  Behind the scenes, the symbol table entry for foo (accessed via *foo - the typeglob) has everything that may be a foo.  There is $foo, @foo, %foo, the format foo, &foo, the filehandle foo, etc...

This also allows making an alias of one variable to another:

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

$foo = "foo";
@qux = (1,2);
*bar = \$foo;
*bar = \@qux;

print "$bar @bar\n";
</code>```

This prints foo 1 2 - in perl, this is what the sigils are really for, not that you should do this but rather that there is this behind the scenes thing that they do.

The sigils aren't there so much for readability, but rather so that one can have $foo and @foo without having a collision in the namespace (compare other languages where one cannot have both int foo; int[] foo;)

Sigils for readability are something that is learned as part of any language - reading the syntax.  You could, hypothetically, enforce the type itself (as hungarian notation) to be part of the identifier.

Something in lex along the lines of:

```<code>typeChar  [is]
capLetter [A-Z]
letter    [a-z]
digit     [0-9]
%%
{typeChar}{capLetter}(letter}|{digit})* { prientif("iddentifier");}
%%
</code>```

And then you could have code like

```<code>iFoo = 42;
sFoo = "a string";
iBar = iFoo * 2;
</code>```

I'm not saying this is a good idea, but rather that someone who is accustom to the language will be able to read this natively and think that it enhances readability while someone who isn't familiar with the language may think that it just adds a bunch of noise to the language.

However, after working with a language defined this way, I could probably read it without trouble.

Some people like them, some people don't.  There are great holy wars in various forums debating this and it really boils down to how much you've used them.

One could design a new language for non-programmers that uses sigils and anyone who has never programed before will never complain one bit about them.  On the other hand, you could not have them as part of the language and then have ruby or perl programers complain that they're missing out on some key information.

It really doesn't matter.  What does matter is how sigils would fit into the language if you use them or not.  Do you want to be able to do "123 $foo 456" or must you do "123 " + foo + " 456"?  This is where the decision should be made.

Body:
Years ago, I learned Applesoft Basic.  Strings were always suffixed with $ and arrays had a suffix of %.  Thats just how the language worked.  You looked at something, you knew what it was.  I never did delve too far into the interpreter to understand why this was the case or the design decisions that made it so.

The sigil in php comes from its perl influence (which was influenced by awk and sh).  The sigil in perl is quite a bit more than just $ as it can identify many different types:

$ scalar

@ list

% hash

& codeblock

* typeglob

The sigil identifies what part of the symbol table structure you are looking at.  Behind the scenes, the symbol table entry for foo (accessed via *foo - the typeglob) has everything that may be a foo.  There is $foo, @foo, %foo, the format foo, &foo, the filehandle foo, etc...

This also allows making an alias of one variable to another:

#!/usr/bin/perl

$foo = "foo";
@qux = (1,2);
*bar = \$foo;
*bar = \@qux;

print "$bar @bar\n";

This prints foo 1 2 - in perl, this is what the sigils are really for, not that you should do this but rather that there is this behind the scenes thing that they do.

The sigils aren't there so much for readability, but rather so that one can have $foo and @foo without having a collision in the namespace (compare other languages where one cannot have both int foo; int[] foo;)

Sigils for readability are something that is learned as part of any language - reading the syntax.  You could, hypothetically, enforce the type itself (as hungarian notation) to be part of the identifier.

Something in lex along the lines of:

typeChar  [is]
capLetter [A-Z]
letter    [a-z]
digit     [0-9]
%%
{typeChar}{capLetter}(letter}|{digit})* { prientif("iddentifier");}
%%

And then you could have code like

iFoo = 42;
sFoo = "a string";
iBar = iFoo * 2;

I'm not saying this is a good idea, but rather that someone who is accustom to the language will be able to read this natively and think that it enhances readability while someone who isn't familiar with the language may think that it just adds a bunch of noise to the language.

However, after working with a language defined this way, I could probably read it without trouble.

Some people like them, some people don't.  There are great holy wars in various forums debating this and it really boils down to how much you've used them.

One could design a new language for non-programmers that uses sigils and anyone who has never programed before will never complain one bit about them.  On the other hand, you could not have them as part of the language and then have ruby or perl programers complain that they're missing out on some key information.

It really doesn't matter.  What does matter is how sigils would fit into the language if you use them or not.  Do you want to be able to do "123 $foo 456" or must you do "123 " + foo + " 456"?  This is where the decision should be made.


答:
I just sorta faced this topic earlier today while playing with a new project. I'm working in Clojure to make a Poker game. I represented face-values and suits as keywords, and decided to represent a card as a map like

```<code>{ :face :queen :suit :hearts }
</code>```

I could just as well have made them lists or vectors of the two keyword elements. I don't know if it makes a memory/performance difference so I'm just going with maps for now.

In case I change my mind later though, I decided that most parts of my program should go through an "interface" to access the pieces of a card, so that the implementation detail is controlled and hidden. I've got functions

```<code>(defn face [card] (card :face))
(defn suit [card] (card :suit))
</code>```

that the rest of the program uses. Cards get passed around to functions as maps, but the functions use an agreed-upon interface to access the maps and thus shouldn't be able to mess up.

In my program, a card will probably only ever be a 2-valued map. In the question, entire game state is passed around as a map. Game state will be a lot more complicated than a single card, but I don't think there is fault to raise about using a map. In an object-imperative language I could just as well have a single big GameState object and call its methods, and have the same problem:

```<code>class State
  def complex-process()
    state = clone(this) ; or just use 'this' below if mutation is fine
    state.subprocess-one()
    state.subprocess-two()
    state.subprocess-three()
    return state
</code>```

Now it's object-oriented. Is there anything particularly wrong with it? I don't think so, you're just delegating work to functions which know how to handle a State object. And whether you're working with maps or objects, you should be wary of when to split it up into smaller pieces. So I say using maps is perfectly fine, as long as you use the same care you would use with objects.

Title: "Everything is a Map", am I doing this right?

Body:
I watched Stuart Sierra's talk "Thinking In Data" and took one of the ideas from it as a design principle in this game I'm making. The difference is he's working in Clojure and I'm working in JavaScript.  I see some major differences between our languages in that:

Clojure is idiomatically functional programming

Most state is immutable

I took the idea from the slide "Everything is a Map" (From 11 minutes, 6 seconds to > 29 minutes in).  Some things he says are:

Whenever you see a function that takes 2-3 arguments, you can make a case for turning it into a map and just passing a map in.  There are a lot of advantages to that:

You don't have to worry about argument order

You don't have to worry about any additional information.  If there are extra keys, that's not really our concern.  They just flow through, they don't interfere.

You don't have to define a schema

As opposed to passing in an Object there's no data hiding.  But, he makes the case that data hiding can cause problems and is overrated:

Performance

Ease of implementation

As soon as you communicate over the network or across processes, you have to have both sides agree on the data representation anyway.  That's extra work you can skip if you just work on data.

Most relevant to my question. This is 29 minutes in: "Make your functions composable". Here's the code sample he uses to explain the concept:

```<code>;; Bad
(defn complex-process []
  (let [a (get-component @global-state)
        b (subprocess-one a)
        c (subprocess-two a b)
        d (subprocess-three a b c)]
    (reset! global-state d)))

;; Good
(defn complex-process [state]
  (-> state
    subprocess-one
    subprocess-two
    subprocess-three))
</code>```

I understand the majority of programmers aren't familiar with Clojure, so I'll rewrite this in imperative style:

```<code>;; Good
def complex-process(State state)
  state = subprocess-one(state)
  state = subprocess-two(state)
  state = subprocess-three(state)
  return state
</code>```

Here are the advantages:

Easy to test

Easy to look at those functions in isolation

Easy to comment out one line of this and see what the outcome is by removing a single step

Each subprocess could add more information on to the state.  If subprocess one needs to communicate something to subprocess three, it's as simple as adding a key/value.

No boilerplate to extract the data you need out of the state just so that you can save it back in.  Just pass in the whole state and let the subprocess assign what it needs.

Now, back to my situation:  I took this lesson and applied it to my game.  That is, almost all of my high level functions take and return a gameState object.  This object contains all the data of the game.  EG: A list of badGuys, a list of menus, the loot on the ground, etc.  Here's an example of my update function:

```<code>update(gameState)
  ...
  gameState = handleUnitCollision(gameState)
  ...
  gameState = handleLoot(gameState)
  ...
</code>```

What I'm here to ask about is, have I created some abomination that perverted an idea that is only practical in a functional programming language?  JavaScript isn't idiomatically functional (though it can be written that way) and it's really challenging to write immutable data structures.  One thing that concerns me is he assumes that each of those subprocesses are pure. Why does that assumption need to be made?  It's rare that any of my functions are pure (by that, I mean they often modify the gameState.  I don't have any other complicated side effects other than that).  Do these ideas fall apart if you don't have immutable data?

I'm worried that one day I'll wake up and realize this whole design is a sham and I've really just been implementing the Big Ball Of Mud anti-pattern.

Honestly, I've been working on this code for months and it's been great.  I feel like I'm getting all the advantages he's claimed.  My code is super easy for me to reason about.  But I'm a one man team so I have the curse of knowledge.

Update

I've been coding 6+ months with this pattern. Usually by this time I forget what I've done and that's where "did I write this in a clean way?" comes into play. If I haven't, I'd really struggle. So far, I'm not struggling at all.

I understand how another set of eyes would be necessary to validate its maintainability. All I can say is I care about maintainability first and foremost. I'm always the loudest evangelist for clean code no matter where I work.

I want to reply directly to those that already have a bad personal experience with this way of coding.  I didn't know it then, but I think we're really talking about two different ways of writing code.  The way I've done it appears to be more structured than what others have experienced.  When someone has a bad personal experience with "Everything is a map" they talk about how hard it is to maintain because:

You never know the structure of the map that the function requires

Any function can mutate the input in ways you'd never expect.  You have to look all over the code base to find out how a particular key got into the map or why it disappeared.

For those with such an experience, perhaps the code base was, "Everything takes 1 of N types of maps." Mine is, "Everything takes 1 of 1 type of map". If you know the structure of that 1 type, you know the structure of everything.  Of course, that structure usually grows over time.  That's why...

There's one place to look for the reference implementation (ie: the schema). This reference implementation is code the game uses so it can't get out of date.

As for the second point, I don't add/remove keys to the map outside of the reference implementation, I just mutate what's already there. I also have a large suite of automated tests.

If this architecture eventually collapses under its own weight, I'll add a second update.  Otherwise, assume everything is going well :)

Body:
I just sorta faced this topic earlier today while playing with a new project. I'm working in Clojure to make a Poker game. I represented face-values and suits as keywords, and decided to represent a card as a map like

{ :face :queen :suit :hearts }

I could just as well have made them lists or vectors of the two keyword elements. I don't know if it makes a memory/performance difference so I'm just going with maps for now.

In case I change my mind later though, I decided that most parts of my program should go through an "interface" to access the pieces of a card, so that the implementation detail is controlled and hidden. I've got functions

(defn face [card] (card :face))
(defn suit [card] (card :suit))

that the rest of the program uses. Cards get passed around to functions as maps, but the functions use an agreed-upon interface to access the maps and thus shouldn't be able to mess up.

In my program, a card will probably only ever be a 2-valued map. In the question, entire game state is passed around as a map. Game state will be a lot more complicated than a single card, but I don't think there is fault to raise about using a map. In an object-imperative language I could just as well have a single big GameState object and call its methods, and have the same problem:

class State
  def complex-process()
    state = clone(this) ; or just use 'this' below if mutation is fine
    state.subprocess-one()
    state.subprocess-two()
    state.subprocess-three()
    return state

Now it's object-oriented. Is there anything particularly wrong with it? I don't think so, you're just delegating work to functions which know how to handle a State object. And whether you're working with maps or objects, you should be wary of when to split it up into smaller pieces. So I say using maps is perfectly fine, as long as you use the same care you would use with objects.


问:
Web Development on Windows but on Linux Environment
I do PHP Development on WAMP but sometime it don't work properly when I upload the files to a Linux server, its involve a lot of testing and annoying.

I am looking for a solution to do PHP Development on Windows but the files will be sync with Linux Server. I do not want to use SFTP/SSH clients like WinSCP to view or edit files.

I was told to look at vagrant, is there any other solution?

答: I recommend using VirtualBox to run a Linux instance within your Windows environment. Install Linux on VirtualBox and you'll be able to share a directory between the two, meaning you can edit your files locally within Windows and they're immediately available on your web server running within the Linux instance. Install the same Linux distro and version as your live server for accurate testing.</p>


答:
Php is meant to be cross-platform, but if you hard code windows specific things in your php code (Like Paths) or making assumptions about directory/file permissions things might not work the cross-platfrom way.

Try this article for portable paths : Write file manipulation cross-platform PHP code

Use htaccess files for specifying permissions on project specific files.

Like @Matt S suggested use a Virtualized Linux environement to test your code in target environement (Automated tests are preferred by the way)

Title: Web Development on Windows but on Linux Environment

Body:
I do PHP Development on WAMP but sometime it don't work properly when I upload the files to a Linux server, its involve a lot of testing and annoying.

I am looking for a solution to do PHP Development on Windows but the files will be sync with Linux Server. I do not want to use SFTP/SSH clients like WinSCP to view or edit files.

I was told to look at vagrant, is there any other solution?


答:
...a sigil allows to:

Better distinguish variables from non-variables. People that are still learning basic concepts might have trouble figuring out which words are variables and which don't. They often start by reading examples or other people's code with no adequate background.

Use reserved keywords or function names as variable names. At times I found some of those names to be the right ones for a variable (i.e. $count while there was a count() function defined) and thanked sigils for allowing me to use them.

Also I happen to do that function name reusing frequently, for holding a function's result in a throwaway variable, e.g.:

$isdir=isdir($dir);

if(/* complex condition implying $isdir */) {

     /* etc */

     }


答:
If there's no test for the old service, and I assume you don't want to spend time creating one... then you have to create one, but one that will still work with the new service.

I'd recommend selenium and/or cucumber (or equivalent) as you're reimplementing it, these drive the overall website from an external PoV and record the results you get back. This kind of integration test is much less complicated than adding unit tests to existing code, and will provide you with a set of requirements for the new service. Once you've get some tests for the website, you can repeat it, then you can replace it and see if it still works.

Title: Best way to test a reimplemented web service

Body:
In my team, we are about to start the reimplement of a service. One of the important steps to do to accomplish this is how do we ensure that we are doing it in the right way and  we are not introducing new bugs.

So, what we have in mind is create a bunch of test to verify the following:

The behavior. Both services should behave the same way (store data in the same places, send same, notificacions, etc...)

Results. Object returned by the service's calls should be exactly the same.

So, the things that we have thought is to do the following:

Create a set of test that verifies the behavior and results of old service.

Create the new service adding unit test, and whitebox integration test for the new service

Create some kind of "Mirror test" that checks if the new service is working as the old one. Is there a way to do this?

Thanks for any help.

Note: None of the code of the previous version is reusable. There is no test for the older version of the service

[Edited]replaced original word "migrate" with "reimplement"


答:
I think the obvious answer is to set up a standalone local linux box.  It doesnt have to be a heavy duty machine - just enough to run Apache & MySQL.  You dont even need a GUI on it.  Then set up Samba on it so you can have Windows shares.  After that you'll be able to open and save files like you would on a normal networked Windows PC.  </p>

<p>Another thing to consider is if you are using standalone FTP clients to transfer files now, look at switching to an editor that supports remote file loading & saving natively.  For example, w/ Eclipse & the Remote Systems plugin, you can open & save remote files via ssh very easily. </p>

Body:
I think the obvious answer is to set up a standalone local linux box.  It doesnt have to be a heavy duty machine - just enough to run Apache & MySQL.  You dont even need a GUI on it.  Then set up Samba on it so you can have Windows shares.  After that you'll be able to open and save files like you would on a normal networked Windows PC.

Another thing to consider is if you are using standalone FTP clients to transfer files now, look at switching to an editor that supports remote file loading & saving natively.  For example, w/ Eclipse & the Remote Systems plugin, you can open & save remote files via ssh very easily.


问:
What are some algorithms that can assist with reservation time scheduling?
Here's the gist of the problem: There are multiple service providers who each have their own schedules of availability. There are multiple customers who seek their services. Customers need to be able to book a reservation time for the service but they should only be able to book times in which some service provider is available (ie they don't really care which particular provider they get so long as they get a provider). Unfortunately, service providers may change schedules between when the customer registers and when the service is provided, meaning that even with the reservation safeguards in place there could still end up being too many reservations for a given time.

I would like to know what work has already been done on this sort of problem, and additionally:

Should providers actually be "assigned" to customers in a persistent way even though providers are interchangeable?

Depending on the answer to the previous question, how might I determine the provider's "next assignment" based on the current time, other providers' schedules, and scheduled reservations?

I've thought a lot about this problem but I am stumped and left with unsatisfying solutions. As someone with no CS background I would appreciate some insight and/or a better way to think about the problem.

答:
You don't have to bind a reservation to a specific service provider.  You already know how to tell if a time slot is fully booked, there is the same number of reservations as service providers scheduled during that slot.  So if you're fully booked for a slot and a provider wants to no longer be scheduled during that slot, you either deny the schedule change or cancel one of the reservations.

If that isn't feasible (in which case it's not really a "reservation", is it?), then you just sort the customers by earliest reservation time first, and go down the list.


问:
Accurate calculation of a raster image's boundary length
I have a rasterized image that contains two colors: white and black.  The black portion is entirely connected and looks like a big blob.  Is there a good way to estimate the length of the boundary between the regions?

One method I have considered is to simply count how many "edges" of the rasterized grid have a different color on each side.  However, for e.g. a purely diagonal line, this will overestimate the distance of the boundary by a factor of sqrt(2).  Is there a better method for estimating the boundary length which does not have this problem?

答: As rwong wrote, you can use findContours to get the countours, if you don't already have them. Then you can use arcLength to compute the length of the contour.


问:
How do you call the discipline which consist of making the right choice of language/paradigm/class diagrams?
As a physicist, I've learnt programming on my own. But I would like to know the name of the discipline (like algorithmics is the discipline of designing algorithms) which consists of :

making the right choice of language/paradigm

designing a class diagram

organizing the different parts of a code and how they will interact between each other

答:
I believe the term you are looking for is Software Architect.

Here's Wikipedia's definition of Software Architect

And here's SEI's definition of Software Architect

However, the criteria you provided are a bit nebulous.

making the right choice of language/paradigm

It's pretty rare that a project is able to swap out its existing language or overall architecture.  Those choices can and do occur with green field projects (aka brand new ones), but it's generally considered a catastrophic change for an existing project.

However, an architect will guide the project in adopting new technologies into the existing stack.  That may mean a new framework or development approach, but it's generally an incremental type change.  Also keep in mind that the list of potential candidates will be limited by existing language choice and code structure.

designing a class diagram

At the broadest level, this is done by the architect(s) and other team leads / lead developers.  It's rare for a single individual to understand all of an application, so major design changes requiring a class diagram would be handled by a team.

Conversely, projects that are small enough that a single individual could understand all of the application generally don't have a dedicated architect.  They usually have a lone developer (or two) that knows the product and makes changes as necessary.

organizing the different parts of a code and how they will interact between each other

Your criterion here implies that these things change all the time on an active project.  They don't.  An approach is laid out, the team sticks with it, and it only changes when sufficient pain causes the need for that change.  Structural changes tend to be quite painful and expensive, so they're only done when absolutely necessary.

Even in the rare case of a green field project destined to be "something big", the design team (aka the architects and team leads) will lay out broad areas and start laying out contracts for interactions between the layers.  If there's enough work to justify such structural definitions like this, then there needs to be a team that lays out how they are going to interact.

So with all of that explained, let's look at the pertinent quotes from Wikipedia and SEI.

From Wikipedia:

The role of software architect generally has certain common traits:

  * Architect makes high-level design choices much more often than low-level choices. In addition, the architect may sometimes dictate technical standards, including coding standards, tools, or platforms.

  * Software architects may also be engaged in the design of the architecture of the hardware environment, or may focus entirely on the design methodology of the code.

  * Architects can use various software architectural models that specialize in communicating architecture.

From SEI:

Crafting the right architecture to solve the problem at hand is only part of architects' responsibilities. They must also

  * define, document, and communicate it

  * make sure the right modeling is being done, to know that qualities like performance are going to be met

  * give input as needed to issues like tool and environment selection

  * understand and plan for evolutionary paths

  * plan for new technology insertion

One final thought -

Many of the primary roles of a Software Architect are a bit nebulous and the feedback cycle in identifying good decisions can get quite extended.  There can be a lot of business risk without associated benefit in having dedicated architects who aren't developers.  So pure Software Architects are kind of rare in the industry.  It's really only the ultra-large projects that can afford to have dedicated architects who work in a team over the major areas of their project.

Many of the criteria you mentioned are handled by team leads and senior developers on most other projects.  Often times that's simply because the decision is best made by someone who intimately knows the code that will be impacted.  Some development methodologies (such as Agile) naturally preclude having a dedicated architect on the team.  There are certainly exceptions to that statement, but Agile focuses on developers driving those decisions based upon business needs.

This blog / article goes into a few more specifics beyond what I touched upon.  And SEI's definition of Architecture may be of interest.


问:
Should I let my "beginnerishness" hold me back? (not rhetorical)
My situation is that I've been programming for about three years and have learned a lot but still have a long long way to go.

I have an idea for an app that I believe would take off, but I'm afraid to build it because it involves architecting a back-end with databases and authenticated payment transactions and user accounts and I've never done any of that.

I'm afraid that if I hacked it together, people would use it and things would go wrong-- security flaws, data loss, somehow I accidentally drop_table and lose everyone's payment history, etc, because I'm not sufficiently experienced with industry practices in terms of data management, versioning, hosting transitions, and plain old coding.

But I really want to build this.

Has anyone every been in a similar situation, and do you have any advice?

答:
Don't let it stop you, but don't build it for yourself either. There are very difficult and extreme restrictions on PCI compliance, which is the technical hoop you have to jump through to store credit card information.

Do yourself a big favor and use a service like Authorize.net or Stripe that lets you store all of that sensitive data on their servers and access it with authentication tokens. It reduces your risk significantly yet allows you to build what you want to.

Assuming you are willing to learn on the job, you'll figure out either the easy way or the hard way how to do data management, versioning, deployment, server admin, etc, if you're the only guy on the job. But, you're not the only person in the world; you may consider bringing someone else in that has some other skills to complement yours.