答:
The text that the question refers to is based on a thorough confusion, rooted in the vagueness (or semantic obscurity!) of the slogan “semantic markup.”

On one hand, “semantic markup” is markup that someone chooses to call “semantic”, and this may mean anything that is not directly defined in terms of rendering. (The HTML5 drafts even try to make  semantic by redefining it.) Typically, this nowadays means favoring novelties like ,
,
.

On the other hand, there is metadata attached to elements using markup like microdata or microformats, i.e. using reserved class names or some new attributes tailored specifically for the purpose. Such metadata is recognized by some major search engines – it was more or less designed by them – under conditions that they do not disclose (but which appear to be currently restricted to major commercial sites and most popular social media or other community sites).

No factual evidence has been given about search engines actually paying the least attention to “semantic markup” in the first sense, which is far more commonly used.

Body:
The text that the question refers to is based on a thorough confusion, rooted in the vagueness (or semantic obscurity!) of the slogan “semantic markup.”

On one hand, “semantic markup” is markup that someone chooses to call “semantic”, and this may mean anything that is not directly defined in terms of rendering. (The HTML5 drafts even try to make <i> semantic by redefining it.) Typically, this nowadays means favoring novelties like <nav>, <section>, <figure>.

On the other hand, there is metadata attached to elements using markup like microdata or microformats, i.e. using reserved class names or some new attributes tailored specifically for the purpose. Such metadata is recognized by some major search engines – it was more or less designed by them – under conditions that they do not disclose (but which appear to be currently restricted to major commercial sites and most popular social media or other community sites).

No factual evidence has been given about search engines actually paying the least attention to “semantic markup” in the first sense, which is far more commonly used.


问:
Make audible Ding! sound, or growl notification, when `rake test` finishes!
I lose a ton of productivity by getting distracted while waiting for my tests to run.

Usually, I'll start to look at something while they're loading --- and 15-20 minutes later I realize my tests are long done, and I've spent 10 minutes reading online.

Make a small change... rerun tests ... another 10-15 minutes wasted!

How can I make my computer make some kind of alert (Sound or growl notification) when my tests finish, so I can snap back to what I was doing??

答:
You have.a good idea to a real issue, with the notifications, and @tylerl suggestion is good.

I would like to recommend a parallel approach: try as much as possible not to lose your focus (reading blogs, surfing around...) during the tests. During the (I assume, few) minutes that they take up, try not to "get distracted". Productivity is lost more on the context switching, pulling out of the mindset and getting back into it, than simply by the clock moving on.

It is not easy and it depends also on how and how long your test take.

I try, not always succeeding, to continue working, even simply thinking about the results and trying to anticipate and analyze them in my mind, or thinking about alternative solutions...

In this way you should (could?) Be able to remain productive while coding, and you can devote a more structured time to blogs, updating your skills, asking and answering questions here :) or relaxing in general.

ContentLicense: CC BY-SA 3.0


问:
What are the boundaries between the responsibilities of a web designer and a web developer?
I have been hired to do functional development for several web site redesigns.  The company I work for has a relatively low technical level, and the previous development of the web sites were completed by a graphic designer who is self taught as far as web development is concerned.

My responsibilities have extended beyond basic development, as I have been also tasked with creating the development environment, and migrating hosting from external CMS hosting to internal servers incorporating scripting languages (I opted for PHP/MySQL).

I am working with the graphic designer, and he is responsible for the creative design of the web.  We are running into a bit of friction over confusion between the boundaries of our respective tasks.

For example, we had some differences of opinion on navigation.  I was primarily concerned with ease-of-use (the majority of our userbase are not particularly web-savvy), as well as meeting W3 WAI standards (many of our users are older, and we have a higher than average proportion of users with visual impairment).  His sole concern was what looked best for the website, and I felt that the direction he was pushing for caused some functional problems.

I feel color choices, images, fonts, etc. are clearly his responsibility, and my expectation was that he would simply provide me with the CSS pages and style classes and IDs to use, but some elements of page layout also seem to fall more under the realm of "usability", which to me translates as near-synonymous with "functionality".

I've been tasked with selecting the tools we'll use, which include frameworks, scripting languages, database design, and some open source applications (Moodle for example, and quite probably Drupal in the future).  While these tools are quite customizable, working directly with some of the interfaces is beyond his familiarity with CSS, HTML, and PHP.  This limits how much direct control he has over the appearance, which has lead to some discussion about the tool choices.

Is there a generally accepted dividing line between the roles of a web designer and a web developer?  Does his relatively inexperienced background in web technologies influence that dividing line?

答:
In a broad sense the difference is the development between the technical and artistic part of developing a website. Web developers have the technical part of writing code (php, Ruby, Pyhon) and testing while web designers have the purpose of designing how the web site should look (CSS, Photoshop) and how the users will perceive it.

This is somehow misleading because in normal software development the designer has the purpose to provide a technical high-level design of a software application; a more common name for a software designer is software architect.


答:
Graphic Designer = visual design only

UX designer = analyse and wireframe design

Web designer = prototype design creation

UI designer = HTML design with css, javascript, ajax and cross browser compatibility

Programmer = program using php. .net, jsp

Developer = who invent new widgets, frameworks like that above programming in regular work

Title: What are the boundaries between the responsibilities of a web designer and a web developer?

Body:
I have been hired to do functional development for several web site redesigns.  The company I work for has a relatively low technical level, and the previous development of the web sites were completed by a graphic designer who is self taught as far as web development is concerned.

My responsibilities have extended beyond basic development, as I have been also tasked with creating the development environment, and migrating hosting from external CMS hosting to internal servers incorporating scripting languages (I opted for PHP/MySQL).

I am working with the graphic designer, and he is responsible for the creative design of the web.  We are running into a bit of friction over confusion between the boundaries of our respective tasks.

For example, we had some differences of opinion on navigation.  I was primarily concerned with ease-of-use (the majority of our userbase are not particularly web-savvy), as well as meeting W3 WAI standards (many of our users are older, and we have a higher than average proportion of users with visual impairment).  His sole concern was what looked best for the website, and I felt that the direction he was pushing for caused some functional problems.

I feel color choices, images, fonts, etc. are clearly his responsibility, and my expectation was that he would simply provide me with the CSS pages and style classes and IDs to use, but some elements of page layout also seem to fall more under the realm of "usability", which to me translates as near-synonymous with "functionality".

I've been tasked with selecting the tools we'll use, which include frameworks, scripting languages, database design, and some open source applications (Moodle for example, and quite probably Drupal in the future).  While these tools are quite customizable, working directly with some of the interfaces is beyond his familiarity with CSS, HTML, and PHP.  This limits how much direct control he has over the appearance, which has lead to some discussion about the tool choices.

Is there a generally accepted dividing line between the roles of a web designer and a web developer?  Does his relatively inexperienced background in web technologies influence that dividing line?


问:
Why is semantic markup given more weight for search engines?
This question follows directly from the part of an  answer of this question - Why would one bother marking up properly and semantically? .

I would like to understand why SEO techniques gives more weight to semantically correct mark up?

答:
What does the semantic markup offer? A way for the machines to understand the data. What's a search engine? A machine.

Back in the days, the search engines just looked for the words in a page and showed the page when you search the keywords. However, this led to farm websites with thousands of keywords just to rank higher than anything else, but this wasn't a quality website.

So the search engines evolved, adding more and more to their algorithm in order to provide relevant results to the end-user.

And then, search engines added a new way for websites to tell what they are: semantic markup. When a spider sees a specific tag, it knows what it means. The word "meaning" has a lot of importance there.

Lately, SEO is not only about how to rank the highest. Sure, it's quite important, but it can be reached only through great content, internal links, backlinks, and a lot of work overall (semantic markup is also  a plus there, but it's not so much according to my experience).

There are other ways to be seen though: using semantic markup. Because Google can now link your result to a picture of your face, because it can also show a map of where your hotel is, because it can see your post is relevant to this date, etc. The point is not to be the highest ranked; it is about the visibility. Semantic markup is what allows your website to be visible on search engines.

Just try it: Google some hotel's name around your place: you'll get the phone number and a Google Maps with its location, although it might not be the first result. That's visiblity.


问:
Is it bad practice for a module to contain more information than it needs?
I just wanted to ask for your opinion on a situation that occurs sometimes and which I don't know what would be the most elegant way to solve it.

Here it goes:

We have module A which reads an entry from a database and sends a request to module B containing ONLY the information from the entry module B would need to accomplish it's job (to keep modularity I just give it the information it needs -> module B has nothing to do with the rest of the information from the read DB entry). Now after finishing it's job, module B has to reply to a module C if it succeeded or failed. To do this module B replies with the information it has gotten from module A and some variable meaning success or fail. Now here comes the problem: module C needs to find that entry again BUT the information it has gotten from module B is not enough to uniquely find the exact same entry again.

I don't think that module A giving more information to module B which it doesn't need to do it's job but which it could then give back to module C would be a good practice because this would mean giving some module information it doesn't really need.

What do you think?

答:
module A giving more information to module B which it doesn't need to do it's job

Word "need" may be confusing unless one clearly specifies the needs. It is true that module B doesn't need this information to get the processing result, but it is also true that without this information, its results are useless for module C. In that sense, additional information serves a different kind of need - an integration need.

POSA 2 book presents a pattern intended to serve similar need - Asynchronous Completion Token:

This design pattern allows an application to demultiplex and process efficiently the responses of asynchronous operations it invokes on services. (quoted from POSA 2 patterns abstracts page)

Book presents a real life example to help understand the pattern: FedEx inventory tracking

...An intriguing real-life example of the Asynchronous Completion Token pattern is implemented by the inventory tracking mechanism used by the US Federal Express postal services. A FedEx Airbill contains a section labeled: 'Your Internal Billing Reference Information (Optional: First 24 characters will appear on invoice).' The sender of a package uses this field as an ACT. This ACT is returned by FedEx (the service) to you (the initiator) with the invoice that notifies the sender that the transaction has completed. FedEx deliberately defines this field very loosely: it is a maximum of 24 characters, which are otherwise 'untyped.' Therefore, senders can use the field in a variety of ways. For example, a sender can populate this field with the index of a record for an internal database or with a name of a file containing a 'to-do list' to be performed after the acknowledgment of the FedEx package delivery has been received.

You see, above example is quite close to what you describe. Guys "in the middle of FedEx chain" may say they don't really need billing reference, all they need to know is delivery address. But sender may use it when they need to be notified about transaction completion. That's an integration kind need.

For the sake of completeness note, there's an approach avoiding need to pass the "identification" info to module B. Module B could return its results to module A from synchronous blocking call. Upon return, module A could "enrich" obtained results with whatever additional info and pass it further to module C.

This way is not necessarily better than yours - for example, it loads module A with additional burden of knowing about module C, which isn't the case in your approach. That's why above answer doesn't dive into what approach to choose and when and instead, simply assumes that passing control from A to B then to C has been preferred for whatever reasons.

OwnerDisplayName: gekod


问:
Avoiding "double" subscriptions
I am working on a website that requires a bit of marketing; let me explain.

This website is offering a single, say, iTunes 50$ voucher to a lucky winner.

To be entered in the draw, you need to invite (and has to join) at least one friend to the website. Pretty straightforward.

Now, of course it would be easy for anyone to just create a fake account and invite that account so, I was thinking of some other way to somehow find out of possible cheating.

I was thinking of an IP check on the newly subscribed (invited) user, and if there is the same IP logged in the last 24 hours, and if that's the case, investigate more about it.

But I was thinking that maybe there is a more clever way around this issue. Has anyone ever though about this? What other solutions did you try?

Thanks in advance.

答: You have to link it to something that's hard to replicate freely.  Cash is good.  A cellphone text message is also good (one reg code per cell phone number).  Of course, you'll scare away a large percentage of your potential subscribers.  Or outsouce the problem to a bigger web site - use facebook login and let facebook decide who is real.</p>

Title: Avoiding "double" subscriptions


答:
A Web developer is the one who actually develops web projects like websites, web-services and all.

A Web designer is a sub-part of web developer. A web-designer is developer who only concentrates on creating the presentation logic that is the user interface.


问:
How to organize unit/integration test in BDD
So finally after reading a lot, I have understood that the difference between BDD and TDD is between T & B. But coming from basic TDD background, what I used to was,

first write unittest for database models

write test for views (at this point start with integration test as well, along with unittests)

write more integration tests for testing UI stuff.

What would be a correct way to approach BDD. Say I have a simple blog application.

Given : When a user logs in.
He should be shown list of all his posts.
```

But for this, I need a model with a row user, another row blog posts.

So how do we go about writing tests?

when do we create fixtures? When do we write integration (selenium) tests?

答:
The prerequisites are the "Given" part of the equation. This should preferably access the database directly and create the objects you need. So for your case:

```<code>Given user "whatf" exists
And user "whatf" has 3 blog posts
When "whatf" logs in
Then he should be shown a list of all his posts
</code>```

Now, step user "whatf" exists creates a user in the database (we name the user so that we can have a specific definition of the user behind-the-scenes, such that you don't have to say user exists with admin rights and pink theme and password "s3cret" ... over and over).

Step user "whatf" has 3 blog posts creates three blog posts in the database, against that new user. You can be more or less specific here, if you choose. More specific gives you flexibility, less specific gives you more reusable steps.

Step "whatf" logs in should be the first time you use Selenium, to launch the browser and log the user in.

Then, in the confirmation step, you also use Selenium to check that the user is shown a list of all his posts in the response.

Also note that the difference between TDD and BDD is really dictionary. BDD encourages a more behaviour-driven language for your tests. But those tests can still be unit tests. Or they can be acceptance tests (ATDD).

But the difference between what we call a unit-test framework (eg. xUnit) and what we call a BDD framework (eg. Cucumber) is much bigger. A BDD framework is much more accurately called an acceptance-test framework, if we're to compare it to a unit-test framework. There are also unit-test frameworks that are designed with BDD in mind -- we call them context/specification test frameworks (as opposed to arrange/act/assert).

Body:
The prerequisites are the "Given" part of the equation. This should preferably access the database directly and create the objects you need. So for your case:

Given user "whatf" exists
And user "whatf" has 3 blog posts
When "whatf" logs in
Then he should be shown a list of all his posts

Now, step user "whatf" exists creates a user in the database (we name the user so that we can have a specific definition of the user behind-the-scenes, such that you don't have to say user exists with admin rights and pink theme and password "s3cret" ... over and over).

Step user "whatf" has 3 blog posts creates three blog posts in the database, against that new user. You can be more or less specific here, if you choose. More specific gives you flexibility, less specific gives you more reusable steps.

Step "whatf" logs in should be the first time you use Selenium, to launch the browser and log the user in.

Then, in the confirmation step, you also use Selenium to check that the user is shown a list of all his posts in the response.

Also note that the difference between TDD and BDD is really dictionary. BDD encourages a more behaviour-driven language for your tests. But those tests can still be unit tests. Or they can be acceptance tests (ATDD).

But the difference between what we call a unit-test framework (eg. xUnit) and what we call a BDD framework (eg. Cucumber) is much bigger. A BDD framework is much more accurately called an acceptance-test framework, if we're to compare it to a unit-test framework. There are also unit-test frameworks that are designed with BDD in mind -- we call them context/specification test frameworks (as opposed to arrange/act/assert).


答:
In software development you usually start with a specification which, ideally, comes from the customer. In that specification, among other things, you will find user stories that define the behavior of the application. The example that you gave is an example of such user story. This is where BDD kicks in. It gives you the language (Gherkin) and tools (Cucumber, SpecFlow, JBehave) that enable you, the developer, to translate these user stories into features and scenarios that are easy to understand by a non-technical person (eg. customers, stakeholders etc.) This gives you the option of training a person to write these specifications, leaving you (or a tester) the job of implementing the tests.

To continue on your example, you start by defining a feature and a scenario (or more), using what is called the GWT (Given-When-Then) syntax:

```<code>Feature: Read blog
    In order to read the blog
    As a registered user
    I want to see a list of blog entries

Scenario: Access the blog
    Given: I am logged in (I am logged in as, if you plan on testing specific users)
    When: I navigate to the blog
    Then: I see a list of blog entries
</code>```

In this case, Cucumber will generate tests for each step in your scenario. In the tests you will write automation code (Selenium) that will make your browser act on the behavior specified in the scenario. This is extremely useful when you want to do acceptance testing or regression testing.

Title: How to organize unit/integration test in BDD

Body:
So finally after reading a lot, I have understood that the difference between BDD and TDD is between T & B. But coming from basic TDD background, what I used to was,

first write unittest for database models

write test for views (at this point start with integration test as well, along with unittests)

write more integration tests for testing UI stuff.

What would be a correct way to approach BDD. Say I have a simple blog application.

Given : When a user logs in.
He should be shown list of all his posts.
```

But for this, I need a model with a row user, another row blog posts.

So how do we go about writing tests?

when do we create fixtures? When do we write integration (selenium) tests?

Body:
In software development you usually start with a specification which, ideally, comes from the customer. In that specification, among other things, you will find user stories that define the behavior of the application. The example that you gave is an example of such user story. This is where BDD kicks in. It gives you the language (Gherkin) and tools (Cucumber, SpecFlow, JBehave) that enable you, the developer, to translate these user stories into features and scenarios that are easy to understand by a non-technical person (eg. customers, stakeholders etc.) This gives you the option of training a person to write these specifications, leaving you (or a tester) the job of implementing the tests.

To continue on your example, you start by defining a feature and a scenario (or more), using what is called the GWT (Given-When-Then) syntax:

Feature: Read blog
    In order to read the blog
    As a registered user
    I want to see a list of blog entries

Scenario: Access the blog
    Given: I am logged in (I am logged in as, if you plan on testing specific users)
    When: I navigate to the blog
    Then: I see a list of blog entries

In this case, Cucumber will generate tests for each step in your scenario. In the tests you will write automation code (Selenium) that will make your browser act on the behavior specified in the scenario. This is extremely useful when you want to do acceptance testing or regression testing.


问:
Best Practice - XML To Excel
I've to read a big XML file with a lot of information. Afterwards I extract the needed information (~20 Points(columns) / ~80 relevant Data (rows, some of them with subdatasets) and write them out in a Excel File.

My Question is how to handle the extraction (of unused Data) part,

should I copy the whole file and delete the unused parts, and then write it to excel

or is it a good approach to create Objects for each column?

should I write the whole xml to excel and start to delete rows in excel?

What would be performant and a acceptable solution?

答:
I'd say do the filtering as part of the processing. Programming in Excel is significantly more painful and limited than any server-side technology you could possibly be using.

CSV as an output format is much easier to work with than Excel proper, and virtually every programming language can easily output CSV without requiring any libraries (even writing your own CSV writer should be doable in about an hour or so); as long as you're only interested in the plain data, no formulae, multi-sheet workbooks or layout, CSV should be fine.

Now, depending on the size of the XML input, I'd either:

a) Read the entire XML file into memory, parse it into a DOM tree, and use XPath to extract the information you want. If the transformation is nontrivial, consider using XSLT (you'll need a tiny bit of post-processing, because generating valid CSV with XSLT is unnecessarily complicated). Because the DOM tree needs to fit into RAM in its entirety, this is only doable for smaller XML files (say, up to the tens-of-megabytes range).

For larger documents:

b) Use a SAX parser to walk the document, outputting the relevant nodes as you go. This is a bit harder to write, because you'll be doing input and output intertwined, but it has the advantage that memory requirements are linear with the depth of the tree rather than its total size (that is, the SAX parser only keeps the path from the document root up to the current node in memory, not the entire DOM).

Title: Best Practice - XML To Excel


答:
It only works if the account is hard-tied to something valuable and verifyable which uniquely identifies its owner.

Things that don't work:

IP addresses

These are neither unique (think corporate firewalls, internet cafes, reused dynamic IPs on mobile networks, proxies, etc.), nor constant (many internet connections have dynamic IPs, especially mobile). An IP check is also easy to circumvent: most people these days have at least two internet connections available to them (mobile and home, or home and work, etc.), and if you don't, finding a suitable proxy service isn't hard at all. Those still on dialup can just close and re-open their connection, which usually gives them a different IP address. If all else fails, Tor provides a steady stream of ever-changing IP addresses to use.

Cookies

These are ridiculously easy to circumvent - just clear your cookies, and you're good for another fake account.

User agent strings

While user agent strings are interesting bits of information these days, and close to unique, they are just as easy to spoof as cookies and similar information.

Other schemes that rely on the absence of something

All the above have in common that they verify that something does not yet exist, which is easy to bypass by simply removing or changing the thing you're checking against. Whatever you come up with yourself, if it checks that the user does not have something, it will not work. It's like trying to restrict access to a theater by giving everyone who has already been a ticket, and then refusing access to everyone who can produce a valid ticket.

Other services

You could use an account at another service (e.g., OpenID, Facebook, Twitter, etc.), but then you're just shifting the problem - if people can create fake accounts at your site, they can do so at another. E-mail doesn't work either: setting up fake e-mail accounts is just as easy as setting up fake twitter accounts, if not easier, and the world is full of throwaway-email providers.

Things that might work

Paid accounts.

The safest way is to turn your thing into a paid service; if people have to pay for their accounts, they can't just open dummy accounts. But most likely, you don't want that.

Real-world identification.

Tie accounts to real-world objects. Cellphones work well, as these cost money and can be verified by sending text messages. Credit cards work, too, but they increase the trust threshold - people won't just give you their credit card data as willingly as their cellphone number or e-mail address. You'll also be subject to more restrictive requirements on your end. Passport numbers and social security numbers would be great if only you could verify them; but most likely, you can't. Snail mail would theoretically work, but it would make for a cumbersome registration process, and I'd expect it to scare more people away than what you'd win through the promotion.

Valuable accounts.

If your site has some sort of 'karma' feature (like reputation on Stackexchange, or karma points on reddit), you can limit the promotion to accounts that have collected a minimum amount of karma points, both on the person spreading it and the new account - for example, a new account may only count after collection 100 points, and only existing accounts with 1000 points or more would be eligible. This way, building a large number of harvesting accounts would take a lot of effort, and if your karma system actually works, exploiting the promotion only makes your site better. Similar mechanisms can be used for sites that involve content (e.g. a minimum number of uploaded pictures, etc.), but you have to be careful - people can just upload anything, so just the fact that there is content is not enough to make it valuable.

Title: Avoiding "double" subscriptions

Body:
I am working on a website that requires a bit of marketing; let me explain.

This website is offering a single, say, iTunes 50$ voucher to a lucky winner.

To be entered in the draw, you need to invite (and has to join) at least one friend to the website. Pretty straightforward.

Now, of course it would be easy for anyone to just create a fake account and invite that account so, I was thinking of some other way to somehow find out of possible cheating.

I was thinking of an IP check on the newly subscribed (invited) user, and if there is the same IP logged in the last 24 hours, and if that's the case, investigate more about it.

But I was thinking that maybe there is a more clever way around this issue. Has anyone ever though about this? What other solutions did you try?

Thanks in advance.


问:
Java heap space
In Java/JVM, why do we call the memory place where Java creates objects as "Heap"?

Does it use the Heap Data Structure to create/remove/maintain the objects?

As I read in the documentation of Heap data structure, the algorithm compares the objects with existing nodes and places them in such a way that Parent object is "greater" than the children. ( Or "lesser" in case of min heap). So in JVM, how are the objects compared against each other before placing them in the heap?

答: The heap in JVM is not related to the data structure, it is more like a space, where objects created by "new" operator are allotted memory at run time. Memory management on heap is done more by de referencing of objects that are no longer in use. As of now,not sure of what algorithm is used, but we have the garbage collector program that determines which objects are no longer referenced by a program, and they are removed from the heap.</p>

Title: Java heap space


问:
Is there a way to publish IOS app from windows/Linux?
I have been using Linux (especially, Ubuntu) and Windows 7 for a long time.  I want to publish iOS apps, but I don't have a Mac or an iPhone.  I don't have anyone near me who will lend me a Mac, and I don't actually want to buy them either.

So my question is: how do I publish my iOS app from Windows or Linux? I am not referring to publishing programs for jailbroken iPhones, I want to publish through the Apple Store.

My search results indicate that there is no fool-proof way of publishing an iOS app from Windows or Linux. I also want to make it a paid app, and not give it away for free.

Does anyone know of a way to publish iOS apps from Windows or Linux?

答:
Basically, Apple's policy is that in order to develop for iOS, you need a Mac.

They have all sorts of reasons for doing it that way: increased sales on the desktop market (which isn't exactly Apple's cash cow), controlling the development platform, better brand exposure, you name it.

Now, there may be tools to develop iOS apps without a Mac, but these will never be officially supported, and as such, they may break any time - Apple controls both the target platform and the development tools, and one of the reasons to do this is so that they can change both in tandem more quickly and without having to watch out for compatibility with third-party tools.

Apart from the political issues, if you develop for any platform, you absolutely need a real specimen of the device you're going to deploy to, if only for testing purposes. If you don't, you will miss edge cases, usability no-no's, and you are at risk of hitting cases where the emulation is not accurate.

Bottom line, you want to develop for an Apple platform, you need a Mac - consider a used mac mini, or if you're daring, a hackintosh. Or decide to not develop for iOS.


答:
For companies like Google information is money and the better their information is the more value it has. Pages with semantically correct mark up contain more and better information then pages without.

So if Google wants to promote page-makers to use semantic markup, the easiest way to do that is to rank pages with semantic markup higher.

Title: Why is semantic markup given more weight for search engines?

Body:
This question follows directly from the part of an  answer of this question - Why would one bother marking up properly and semantically? .

I would like to understand why SEO techniques gives more weight to semantically correct mark up?


问:
How to convince a non-technical client that their application spec needs to be simplified?
Often times I am faced with the situation where a new client comes to me with an application that has literally 100s of unnecessary features and it is quite clear that things need to be drastically simplified for the project to have any chance of succeeding. How do you convince the client to take a more Minimum Viable Product (MVP) approach and simplify?

edit:

So the current top answer is to provide the client with a time/cost estimate for the huge application. I'm not too fond of this answer because it doesn't address the real problem with this situation. And that is - it's a bad practice to spec out a massive application and then try and build it from the get go. I feel much more comfortable initially building a small, simple MVP foundation. And then adding small features to that foundation one by one. So how do I convince the client to approach building software in this way?

答:
The core cause of your frustration with the situation is probably one of perception and misleading/wrong terms used by the customer.  The customer does not usually come to you with a list of requirements, but a wish-list of every single thing they could think of that might be useful to them.  Those are not all requirements because the customer hasn't spent the time yet to really think if each feature is truly required.

This is not necessarily always a problem

If your customer has the money for all those features and is willing to part with it, and you don't really care about solving the actual, real issues that the customer has, then this could be a very lucrative project.  It happens, just very, very rarely, and for most developers it's soul-killing work because you can feel in advance that the project will not be successful for the customer in the end (even if it's financially successful for you as a developer).  It's also high-risk because  you're likely to end up with a fixed-cost project with a lot of uncertainty, and it's really issue to misjudge risk on large projects.

What if it is a problem?

Lets assume you're not in that rare situation.  In this case you will want to address the two main shortcomings of the wish-list as given:

It's unlikely that the customer has a correct idea of the costs of developing such a large list of requirements, so you're unlikely to get the contract for the amount of money you actually need to do it.

It's unlikely that this wish-list accurately and succinctly describes the real problem that the customer has and wants to solve.

In my experience you need to address 2 to fix 1.  Drilling down to the actual problem  means that you, the developer, now have the necessary input to make creative leaps in solving the problem in ways that the customer themselves never even thought of.  These solutions are likely to be much cheaper and quicker than the implementation of the full wish-list.

How do you fix that?

Like Matthew Flynn says in his answer - start by making the customer prioritize the requirements.  This is not always easy, but force them to do it.  If necessary use the phrase "If someone held a gun to your head, which single requirement would you keep?".
You will often find during this process that the customer really doesn't have a very clear idea of what the individual requirements mean.  In that case do what Peter Rowell suggests and get the customer to work through User Stories.  You and the customer will start to understand the problem and requirements much better, and then you can back to prioritization.  Repeat those steps as often as you need to until you feel comfortable that you know enough to solve the customer's problem.

How does that answer the question of developing a solution?
Once you have a prioritized list of requirements, you have the input you need to suggest an incremental development process to your customer.
You don't have to call it Agile, but you can suggest to break down the contract into smaller pieces for each requirement (or indivisible set of requirements) and deliver them one by one with validation by the customer.
Or you can go all-out and use the many resources available online and offline to convince the customer that it's in their best interest to cooperate in one of the Agile styles of development.
In any case, you can provide your contract/project proposal in a form that clearly suggests these building blocks of requirements in priority order, each with their own cost and conclusion.  Hold that carrot in front of the customer, and they may even think it was their own idea to decide whether to continue after increment :).


答:
Officially you must have an Apple computer (iMac, Macbook, etc), and boot it in Apple OS X in order to develop for the iPhone. Unofficially, you can get a running OS X in a virtual machine that you can run on any computer under any OS. There's also the possibility to acquire an OS X image that can be installed on a non Apple (but still x86) computer. I've seen this working, but it's not great. Apparently you have a hard time connecting your IOS device to such a setup in order to deploy your app. Also, since the IOS SDK is tightly bonded to the OS X version, and thus you need the latest OS X in order to use the latest SDK, it's far simpler to just buy the Apple software and hardware.

I think it's important to the discussion to note that there are cross-platform SDKs that can be installed and tried on various platforms, but which still require Apple hardware and software to deploy to IOS. However these allow you to try them on non-Apple stuff (or at least preview them) before deciding weather to invest in that SDK's OS X license. An example of this is Unity 3D which can be installed on Windows as well as OS X (and Linux I think is coming up in the next version). You can easily see some of its basic capabilities even without having an Apple computer, then you can opt to buy its OSX/IOS license and install it on a Macbook in order to deploy whatever you make with it on an IOS device.

Title: Is there a way to publish IOS app from windows/Linux?

Body:
I have been using Linux (especially, Ubuntu) and Windows 7 for a long time.  I want to publish iOS apps, but I don't have a Mac or an iPhone.  I don't have anyone near me who will lend me a Mac, and I don't actually want to buy them either.

So my question is: how do I publish my iOS app from Windows or Linux? I am not referring to publishing programs for jailbroken iPhones, I want to publish through the Apple Store.

My search results indicate that there is no fool-proof way of publishing an iOS app from Windows or Linux. I also want to make it a paid app, and not give it away for free.

Does anyone know of a way to publish iOS apps from Windows or Linux?


问:
Refactoring code to separate concerns
While programming an object that represent a GUI, the class is a mix of code of following sections:

Overrides of super GUI, for behavior customization

Implementations of interface contracts, to talk/listen to other GUI objects

Local event handling methods

Local data crunching methods

Code to query/update a remote database and a global object provider

Assuming all this is crammed into one class file, how would you split it into separate files or parent-child classes so that you can delegate these to different developers with minimum dependency on each other?

答:
Check out the Model-View-Presenter or Presentation Model patterns, or indeed any of the many UI design patterns whose express purpose is to separate the display from the logic.

The basic concept is that the View, being the page or screen of form or whatever, handles only the UI itself - fields and buttons and so forth. There's a Presenter that does the number crunching, DB access and so forth, and any UI action (button click, for instance) is mapped on the View to a call to an action on the Presenter, which does the logic. This means the UI can be developed independently, facing a mock/basic Presenter. Meanwhile, the Presenter can be developed abstractly, since it just exposes Commands, rather than expecting button clicks.

Title: Refactoring code to separate concerns


答:
As other answers state, prioritization is very important. A handy way of doing this is through the MoSCoW-method. But you might want to start with dividing the whole list up, otherwise the feature list itself will give you (or your customer) comprehension problems :)

Next to this, you have the problem of looking at the problem as a whole. You can probably solve this by sitting with your customer and go through the following steps:

Go globally through the features and distill categories from them

Prioritize (using MoSCoW) the categories, and maybe define a hierarchy (one basic category with default features, categories for major subjects, categories for specific variations of the major subjects). This might alter the categories you defined in the previous step (thanks to new insights).

Go through each feature one by one, and assign them to a category

Prioritize (using MoSCoW) the items in the top-x categories.

This will give a nice and condense top-down view of your requested features, and will give you handlebars to define different iterations to start with a base and extend it with other features.

Title: How to convince a non-technical client that their application spec needs to be simplified?

Body:
Often times I am faced with the situation where a new client comes to me with an application that has literally 100s of unnecessary features and it is quite clear that things need to be drastically simplified for the project to have any chance of succeeding. How do you convince the client to take a more Minimum Viable Product (MVP) approach and simplify?

edit:

So the current top answer is to provide the client with a time/cost estimate for the huge application. I'm not too fond of this answer because it doesn't address the real problem with this situation. And that is - it's a bad practice to spec out a massive application and then try and build it from the get go. I feel much more comfortable initially building a small, simple MVP foundation. And then adding small features to that foundation one by one. So how do I convince the client to approach building software in this way?


问:
So, "Are Design Patterns Missing Language Features"?
I saw, here on Programmers, the answer to this question: How does thinking on design patterns and OOP practices change in dynamic and weakly-typed languages? There I found a link to an article with an outspoken title: Are Design Patterns Missing Language Features. But where I found snippets that to me seemed very catchy and that can be probably verified against experience given there is an incentive for that , like:

PaulGraham said "Peter Norvig found that 16 of the 23 patterns in
  Design Patterns were 'invisible or simpler' in Lisp."

or another sentence that confirms what I recently seen with people trying to simulate classes in JavaScript:

Of course, nobody ever speaks of the "function" pattern, or the
  "class" pattern, or numerous other things that we take for granted
  because most languages provide them as built-in features. OTOH,
  programmers in a purely PrototypeOrientedLanguage? might well find it
  convenient to simulate classes with prototypes...

I am also taking into consideration that design patterns are a communcation tool. Because even with my limited experience participating in building applications I can see as an anti-pattern(ineffective and/or counterproductive)
for example, forcing a small PHP team to learn GoF patterns for small to medium intranet App. I am aware that scale, scope and purpose can determine what is effective and/or productive, but still I didn't managed to find an technical overview about that.

I saw small commercial applications that mixed functional with OOP and still be maintainable, and I don't know if many would need for example in python to write a singleton   , but for me a simple module does the same thing.

So are there studies, exhaustive articles or other form of exposition that takes into consideration design patterns vs. workarounds vs. simpler ways to do it, or replacements by language features ?

答:
I'm not aware of any in-depth discussion or study which takes into account all of those things.

That said, the whole argument of "design patterns are just patching missing features in OO languages" is a bit thin, in my opinion.  Yes, some design patterns are exactly that, they fill some common gap doesn't even exist in some other language X.  These are typically your low-level, simpler design patterns, like some / many of the original ones in the GoF book.

But design patterns go far beyond those simple ones, and calling them missing language features stretches the imagination.  Glance over Fowler's catalogue of enterprise application patterns, and think about what it would be like if those were all part of the core definition of a language.  I guess you'd end up with domain-specific language (DSL) for enterprise applications (and a very complex one, at that).

So this is the thing, really - design patterns are way to come up with reusable solutions for particular problems (which are often applied in a generic, all-purpose language).  This is where communication also comes in.  If you tell me "we use Active Records", I already know quite a lot about your application, without spending minutes discussing what the various approaches are.  So yes, design patterns do patch holes in the language spec.  Is that all that they do?  No - not by a long shot.

Edit:

In a way, what I am saying is that patterns allow OO practitioners to think on a higher level, and almost construct a type of DSL for their environment, while staying within their language's syntax.  And yes, I've seen what happens when you apply them everywhere (see: AbstractSingletonProxyFactoryBean, yes, it exists), or think they are some kind of silver bullet.  The point is that while they take a long time to get truly comfortable with, they are supposed to actually lower complexity by making things predictable / understandable at a high level.  This is very different to being a patch-kit for the failings of your language.

Edit 2 - added the AbstractSingletonProxyFactoryBean counter-example to poke some fun at patterns.  To be completely fair, when viewed from an AOP light, even this counter-example is defensible.


问:
Build/deployment tools for a small (1) development effort
What build or deployment tools are available for a 1 person development effort, in the .NET space, that are capable of producing project outputs?

I'm not looking necessarily looking for a CI server (though I can't think of anything else that does what I'm looking for) but I am looking for it to:

produce and publish documentation from xml comments

produce and publish the project (web and/or clickonce app)

handle basic versioning (automatic build number incrementing)

work from a sln file

be easy to setup (< 8-16 hrs for someone who knows little to nothing about the tool(s))

do this at the push of a button (after configuration obviously)

Things I don't need:

source control integration : I can point it to a sln if need be. Not a huge deal.

unit testing : I run test suite before commits

static analysis : again, I also run these before commits

I know that msbuild is capable of most or all of this, and I do have my msbuild book(s) with me, but I'm still very new to it and I don't have the time at the moment to learn it well enough to do what I want.

答:
TeamCity is a CI server that does what you need (and a few other things too). Automatic assembly versioning requires some tricks (I can go into more details here if needed), but it will version build artifacts that it produces.

Setting it up is very easy and there is a free version that supports up to 20 build configurations, which should be sufficient for a single developer.

Edit: come to think of it, I'm not sure about setting up XML doc generation with TeamCity. But if it's something that can run as part of an MSBuild project, TeamCity will run it, I'm pretty sure.

ContentLicense: CC BY-SA 2.5


问:
Rules and advice for logging?
In my organization we've put together some rules / guildelines about logging that I would like to know if you can add to or comment.

We use Java but you may comment in general about loggin - rules and advice

Use the correct logging level

ERROR: Something has gone very wrong and need fixing immediately

WARNING: The process can continue without fixing. The application should tolerate this level but the warning should always get investigated.

INFO: Information that an important process is finished

DEBUG. Is only used during development

Make sure that you know what you're logging.

Avoid that the logging influences the behavior of the application

The function of the logging should be to write messages in the log.

Log messages should be descriptive, clear, short and concise.

There is not much use of a nonsense message when troubleshooting.

Put the right properties in log4j

Put in that the right method and class is written automatically.

Example:

Datedfile -web

```<code>log4j.rootLogger=ERROR, DATEDFILE
log4j.logger.org.springframework=INFO
log4j.logger.waffle=ERROR
log4j.logger.se.prv=INFO
log4j.logger.se.prv.common.mvc=INFO
log4j.logger.se.prv.omklassning=DEBUG

log4j.appender.DATEDFILE=biz.minaret.log4j.DatedFileAppender
log4j.appender.DATEDFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.DATEDFILE.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%C{1}.%M] - %m%n

log4j.appender.DATEDFILE.Prefix=omklassning.
log4j.appender.DATEDFILE.Suffix=.log
log4j.appender.DATEDFILE.Directory=//localhost/WebSphereLog/omklassning/
</code>```

Log value.

Please log values from the application.

Log prefix.

State which part of the application it is that the logging is written from, preferably with something for the project agreed prefix e.g. PANDORA_DB

The amount of text.

Be careful so that there is not too much logging text. It can influence the performance of the app.

Loggning format:

-There are several variants and methods to use with log4j but we would like a uniform use of the following format, when we log at exceptions:

logger.error("PANDORA_DB2: Fel vid hämtning av frist i
TP210_RAPPORTFRIST", e);

In the example above it is assumed that we have set log4j properties so that it automatically write the class and the method.

Always use logger and not the following:

System.out.println(), System.err.println(), e.printStackTrace()

If the web app uses our framework you can get very detailed error information from EJB, if using try-catch in the handler and logging according to the model above:

In our project we use this conversion pattern with which method and class names are written out automatically . Here we use two different pattents for console and for datedfileappender:

```<code>log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

log4j.appender.DATEDFILE.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
</code>```

In both the examples above method and class wioll be written out. In the console row number will also be written our.

toString()

Please have a toString() for every object.
EX:

```<code>@Override
public String toString() {
  StringBuilder sb = new StringBuilder();
  sb.append(" DwfInformation [ ");
  sb.append("cc: ").append(cc);
  sb.append("pn: ").append(pn);
  sb.append("kc: ").append(kc);
  sb.append("numberOfPages: ").append(numberOfPages);
  sb.append("publicationDate: ").append(publicationDate);
  sb.append("version: ").append(version);
  sb.append(" ]");
  return sb.toString();
}
</code>```

instead of special method which make these outputs

```<code>public void printAll()
{
    logger.info("inbet: " + getInbetInput());
    logger.info("betdat: " + betdat);
    logger.info("betid: " + betid);
    logger.info("send: " + send);
    logger.info("appr: " + appr);
    logger.info("rereg: " + rereg);
    logger.info("NY: " + ny);
    logger.info("CNT: " + cnt);
}
</code>```

So is there anything you can add, comment or find questionable with these ways of using the logging? Feel free to answer or comment even if it is not related to Java, Java and log4j is just an implementation of how this is reasoned.

答:
I do not find anything questionable in what you have added here Nick. This is how I have been doing it for some time . The post that you have  provided is very detailed and probably can be used as a kind of a tutorial for logging. However, i do want to add one thing here, which is : In many places, i have been seeing chaps using conditional logging, for e.g. :

```<code>     if(env_local)
     {
     write_to_local();
     }
     else if(env_IT)
     {
     write_to_IT();
     }
     else if(env_PROD)
     {
     write_to_prod();
     }
     else
     dosomething();
</code>```

I do think this kind of conditional tracing or debugging is not the best way to go .

Title: Rules and advice for logging?

Body:
I do not find anything questionable in what you have added here Nick. This is how I have been doing it for some time . The post that you have  provided is very detailed and probably can be used as a kind of a tutorial for logging. However, i do want to add one thing here, which is : In many places, i have been seeing chaps using conditional logging, for e.g. :

     if(env_local)
     {
     write_to_local();
     }
     else if(env_IT)
     {
     write_to_IT();
     }
     else if(env_PROD)
     {
     write_to_prod();
     }
     else
     dosomething();

I do think this kind of conditional tracing or debugging is not the best way to go .


答:
Short Answer: web-developers usually DO NOT implement real-functional development (server side code, services, database operations, CRUD, etc.) in web application.

In another words, nothing is wrong with being a web designer. The problem lies with those people who say they are that which they aren’t. I am talking about people claiming to be web developers who don’t know any backend (server side) programming languages and have never had to deal with modifying a database in their careers. These are the people who drive down the pay the real web developers can expect for their work.

Thus, there substantial difference in nature of work that web developer and web designer do, and mixing them isn't good.


问:
C# Open Source software that is useful for learning Design Patterns
In college I took a class in Expert Systems.  The language the book taught (CLIPS) was esoteric - Expert Systems: Principles and Programming, Fourth Edition.  I remember having a tough time with it.  So, after almost failing the class, I needed to create the most awesome Expert System for my final presentation.  I chose to create an expert system that would calculate risk analysis for a person's retirement portfolio.  In short, the system would provide the services normally performed by one's financial adviser. In other words, based on personality, age, state of the macro economy, and other factors, should one's portfolio be conservative, moderate, or aggressive?

In the appendix of the book (or on the CD-ROM), there was this in-depth example program for something unrelated to my presentation.  Over my break, I read and re-read every line of that program until I understood it to the letter.  Even though it was unrelated, I learned more than I ever could by reading all of the chapters.  My presentation turned out to be pretty damn good and I received praises from my professor and classmates.

So, the moral of the story is..., by understanding other people's code, you can gain greater insight into a language/paradigm than by reading canonical examples.  Still, to this day, I am having trouble with everyday design patterns such as the Factory Pattern.  I would like to know if anyone could recommend open source software that would help me understand the Gang of Four design patterns, at the very least.  I have read the books, but I'm having trouble writing code for the concepts in the real world.  Perhaps, by studying code used in today's real world applications, it might just "click".

I realize a piece of software may only implement one kind of design pattern.  But, if the pattern is an implementation you think is good for learning, and you know what pattern to look for within the source, I'm hoping you can tell me about it.

For example, the System.Linq.Expressions namespace has a good example of the Visitor Pattern.  The client calls Expression.Accept(new ExpressionVisitor()), which calls ExpressionVisitor (VisitExtension), which calls back to Expression (VisitChildren), which then calls Expression (Accept) again - wooah, kinda convoluted.  The point to note here is that VisitChildren is a virtual method.  Both Expression and those classes derived from Expression can implement the VisitChildren method any way they want.  This means that one type of Expression can run code that is completely different from another type of derived Expression, even though the ExpressionVisitor class is the same in the Accept method.  (As a side note Expression.Accept is also virtual).  In the end, the code provides a real world example that you won't get in any book because it's kinda confusing.

To summarize, If you know of any open source software that uses a design pattern implementation you were impressed by, please list it here.  I'm sure it will help many others besides just me.

```<code>public class VisitorPatternTest
{

    public void Main()
    {
        Expression normalExpr = new Expression();
        normalExpr.Accept(new ExpressionVisitor());
        Expression binExpr = new BinaryExpression();
        binExpr.Accept(new ExpressionVisitor());
    }
}

public class Expression
{
    protected internal virtual Expression Accept(ExpressionVisitor visitor)
    {
        return visitor.VisitExtension(this);
    }

    protected internal virtual Expression VisitChildren(ExpressionVisitor visitor)
    {
        if (!this.CanReduce)
        {
            throw Error.MustBeReducible();
        }
        return visitor.Visit(this.ReduceAndCheck());
    }

    public virtual Expression Visit(Expression node)
    {
        if (node != null)
        {
            return node.Accept(this);
        }
        return null;
    }

    public Expression ReduceAndCheck()
    {
        if (!this.CanReduce)
        {
            throw Error.MustBeReducible();
        }
        Expression expression = this.Reduce();
        if ((expression == null) || (expression == this))
        {
            throw Error.MustReduceToDifferent();
        }
        if (!TypeUtils.AreReferenceAssignable(this.Type, expression.Type))
        {
            throw Error.ReducedNotCompatible();
        }
        return expression;
    }

}

public class BinaryExpression : Expression
{
    protected internal override Expression Accept(ExpressionVisitor visitor)
    {
        return visitor.VisitBinary(this);
    }

    protected internal override Expression VisitChildren(ExpressionVisitor visitor)
    {
        return CreateDummyExpression();
    }

    protected internal Expression CreateDummyExpression()
    {
        Expression dummy = new Expression();
        return dummy;
    }
}

public class ExpressionVisitor
{
    public virtual Expression Visit(Expression node)
    {
        if (node != null)
        {
            return node.Accept(this);
        }
        return null;
    }

    protected internal virtual Expression VisitExtension(Expression node)
    {
        return node.VisitChildren(this);
    }

    protected internal virtual Expression VisitBinary(BinaryExpression node)
    {
        return ValidateBinary(node, node.Update(this.Visit(node.Left), this.VisitAndConvert<LambdaExpression>(node.Conversion, "VisitBinary"), this.Visit(node.Right)));
    }
}
</code>```

答:
You got it upside down, like many students/people fresh out of school, design patterns shine as a way to become a great developer.

You couldn't be more wrong, this leads to over-engineering real fast, and that's bad programming.

You don't start by thinking which design pattern should be used for this or that, you start writing code, and as you refactor, patterns emerge. May it be reusing some components, components having similar behavior, you name it.

Then as you gain experience, you'll be able to forsee that a particular pattern is going to emerge, and can plan ahead by using a design pattern from day one.

Design patterns themselves, as of GoF's definition at least, are a way for programmers to be able to talk and share about experience by using words that everyone understands (i.e: Factory pattern).

However, they are not an international way of handling a particular problem, and they should not be blindly used.

My advice, is that you should get your hands dirty, get some experience, and reflect on it: "how could I have made this code better". And whenever you can/have the time/touch a poorly designed code, refactor!


答: The area used for dynamic allocation is traditionally called a heap because this is how the first dynamic allocators ordered the memory- in a heap, by block size. Of course, the JVM's memory management has got nothing whatsoever to do with a heap, and more modern memory allocators also have little in common with it. But that is where the term originates.</p>

Title: Java heap space

Body:
In Java/JVM, why do we call the memory place where Java creates objects as "Heap"?

Does it use the Heap Data Structure to create/remove/maintain the objects?

As I read in the documentation of Heap data structure, the algorithm compares the objects with existing nodes and places them in such a way that Parent object is "greater" than the children. ( Or "lesser" in case of min heap). So in JVM, how are the objects compared against each other before placing them in the heap?


答: The developers of SharpDevelop actually wrote a book about it, and it discusses the design patterns used: Dissecting a C# Application - Inside SharpDevelop</p>

Title: C# Open Source software that is useful for learning Design Patterns

Body:
In college I took a class in Expert Systems.  The language the book taught (CLIPS) was esoteric - Expert Systems: Principles and Programming, Fourth Edition.  I remember having a tough time with it.  So, after almost failing the class, I needed to create the most awesome Expert System for my final presentation.  I chose to create an expert system that would calculate risk analysis for a person's retirement portfolio.  In short, the system would provide the services normally performed by one's financial adviser. In other words, based on personality, age, state of the macro economy, and other factors, should one's portfolio be conservative, moderate, or aggressive?

In the appendix of the book (or on the CD-ROM), there was this in-depth example program for something unrelated to my presentation.  Over my break, I read and re-read every line of that program until I understood it to the letter.  Even though it was unrelated, I learned more than I ever could by reading all of the chapters.  My presentation turned out to be pretty damn good and I received praises from my professor and classmates.

So, the moral of the story is..., by understanding other people's code, you can gain greater insight into a language/paradigm than by reading canonical examples.  Still, to this day, I am having trouble with everyday design patterns such as the Factory Pattern.  I would like to know if anyone could recommend open source software that would help me understand the Gang of Four design patterns, at the very least.  I have read the books, but I'm having trouble writing code for the concepts in the real world.  Perhaps, by studying code used in today's real world applications, it might just "click".

I realize a piece of software may only implement one kind of design pattern.  But, if the pattern is an implementation you think is good for learning, and you know what pattern to look for within the source, I'm hoping you can tell me about it.

For example, the System.Linq.Expressions namespace has a good example of the Visitor Pattern.  The client calls Expression.Accept(new ExpressionVisitor()), which calls ExpressionVisitor (VisitExtension), which calls back to Expression (VisitChildren), which then calls Expression (Accept) again - wooah, kinda convoluted.  The point to note here is that VisitChildren is a virtual method.  Both Expression and those classes derived from Expression can implement the VisitChildren method any way they want.  This means that one type of Expression can run code that is completely different from another type of derived Expression, even though the ExpressionVisitor class is the same in the Accept method.  (As a side note Expression.Accept is also virtual).  In the end, the code provides a real world example that you won't get in any book because it's kinda confusing.

To summarize, If you know of any open source software that uses a design pattern implementation you were impressed by, please list it here.  I'm sure it will help many others besides just me.

```<code>public class VisitorPatternTest
{

    public void Main()
    {
        Expression normalExpr = new Expression();
        normalExpr.Accept(new ExpressionVisitor());
        Expression binExpr = new BinaryExpression();
        binExpr.Accept(new ExpressionVisitor());
    }
}

public class Expression
{
    protected internal virtual Expression Accept(ExpressionVisitor visitor)
    {
        return visitor.VisitExtension(this);
    }

    protected internal virtual Expression VisitChildren(ExpressionVisitor visitor)
    {
        if (!this.CanReduce)
        {
            throw Error.MustBeReducible();
        }
        return visitor.Visit(this.ReduceAndCheck());
    }

    public virtual Expression Visit(Expression node)
    {
        if (node != null)
        {
            return node.Accept(this);
        }
        return null;
    }

    public Expression ReduceAndCheck()
    {
        if (!this.CanReduce)
        {
            throw Error.MustBeReducible();
        }
        Expression expression = this.Reduce();
        if ((expression == null) || (expression == this))
        {
            throw Error.MustReduceToDifferent();
        }
        if (!TypeUtils.AreReferenceAssignable(this.Type, expression.Type))
        {
            throw Error.ReducedNotCompatible();
        }
        return expression;
    }

}

public class BinaryExpression : Expression
{
    protected internal override Expression Accept(ExpressionVisitor visitor)
    {
        return visitor.VisitBinary(this);
    }

    protected internal override Expression VisitChildren(ExpressionVisitor visitor)
    {
        return CreateDummyExpression();
    }

    protected internal Expression CreateDummyExpression()
    {
        Expression dummy = new Expression();
        return dummy;
    }
}

public class ExpressionVisitor
{
    public virtual Expression Visit(Expression node)
    {
        if (node != null)
        {
            return node.Accept(this);
        }
        return null;
    }

    protected internal virtual Expression VisitExtension(Expression node)
    {
        return node.VisitChildren(this);
    }

    protected internal virtual Expression VisitBinary(BinaryExpression node)
    {
        return ValidateBinary(node, node.Update(this.Visit(node.Left), this.VisitAndConvert<LambdaExpression>(node.Conversion, "VisitBinary"), this.Visit(node.Right)));
    }
}
</code>```


问:
How to translate formulas into form of natural language?
I am recently working on a project aiming at evaluating whether an android app crashes or not. The evaluation process is

```<code>  1.Collect the logs(which record the execution process of an app).
  2.Generate formulas to predict the result
    (formulas is generated by GP)
  3.Evaluate the logs by formulas
</code>```

Now I can produce formulas, but for convenience for users, I want to translate formulas into form of natural language and tell users why crash happened.(I think it looks like "inverse natural language processing".)

To explain the idea more clearly, imagine you got a formula like this:

```<code>  155 - count(onKeyDown) >= 148
</code>```

It's obvious that if count(onKeyDown) > 7, the result of "155 - count(onKeyDown) >= 148" is false, so the log contains more than 7 onKeyDown event would be predicted "Failed".

I want to show users that if onKeyDown event appears more than 7 times(155-148=7), this app will crash.

However, the real formula is much more complicated, such as:

```<code>  (< !( ( SUM( {Att[17]}, Event[5]) <= MAX( {Att[7]}, Att[0] >= Att[11]) OR SUM( {Att[17]}, Event[5]) > MIN( {Att[12]}, 734 > Att[19]) ) OR count(Event[5]) != 1 ) > (< count(Att[4] = Att[3]) >= count(702 != Att[8]) + 348 / SUM( {Att[13]}, 641 < Att[12]) mod 587 - SUM( {Att[13]}, Att[10] < Att[15]) mod MAX( {Att[13]}, Event[2]) + 384 > count(Event[10]) != 1))
</code>```

I tried to implement this function by C++, but it's quite difficult, here's the snippet of code I am working right now.

Does anyone knows how to implement this function quickly?(maybe by some tools or research findings?)Any idea is welcomed: )

Thanks in advance.

答:
I'm definitely not the best person to answer this, but I'll give it a go:

What you have, to some extent, is a DSL: a domain-specific language. All of the formulas that you generate have a specific syntax and grammar, which is what constitutes a language. It's a "domain-specific"  language because it specifically has to do with the domain of the formulas that you create.

Because the formulas you mention above have a specific grammar, they can assumedly be evaluated to create a "AST" or abstract syntax tree.

You could thus do the following:

Use lex/yacc or bison write a parser generator. I'd suggest antlr (java-based), but you're using c++.

Write your own C++ code that would then process the AST/structure that your generated parser provides.

The lex/yacc/flex/bison page above says the following:

A compiler or interpreter for a programming language is often
  decomposed into two parts:

Read the source program and discover its structure.

Process this structure, e.g. to generate the target program.

Lex and Yacc can generate program fragments that solve the first task.

The "source program" in this case is each formula that you evaluate. The "structure" is then the AST or similar structure that your (generated) parser will generate. You then write more code to process the structure.

Amazon (or your favorite book source) will have books on this, not to mention all the information on the internets.

Learning to write a parser generator is unfortunately not easy -- I only vaguely remember some of the theory from my university days. However, it's really worth it, because there are lots of applications for it, even in your every day work. DSL's are increasingly popping up in many different situations, and being able to work with them (or invent them!) is a valuable skill. (In short, I wish I was better at it.. )


问:
How to manage/control software versions?
I'm facing a problem to create a version control outline for several already existing software parts for my company. Until now no one - expect for the developers - knows that there are different versions, which is the reason for the outline. In fact, I'm supposed to set up the future version control and communicate all this with our management...

So, the question is how to create such a outline. Are there principles to follow to make software versioning easier or even a good program to map all versions and there compatibility?

And are there generally good approaches to control software versions?

答:
I don't know a rule for this, but in many cases version is composed of 2-4 numbers.

A version like 1.2.3.4 can be interpreted as

1 - the major version, changing it will break compatibility

2 - minor version, new features

3 - bugfix version, only when a release contains bugfixes

4 - build number, the internal number of the build, usually decided by an automated build system or continuous integration system.

As I mentioned, this is just one of many common solutions, and it is the one I would prefer.


答:
Well, if you aren't doing it already, you really need to use Version Control Software.  I know that Fossil has nice built-in display of branching and merging.  Git and Mercurial are hot right now, but Subversion might still be the most popular because it's been around longer.  I bet there are plug-ins for Git that can make graphics out of the software history and perform analysis.

When you put the software into source control for the first time, you probably want to recreate the history of major releases.  Presumably (hopefully, as in, "Please God, Please") they have zip files of the source to each major release.  You unzip these and check the contained files into source control in chronological order.  Then you have a history of branches and merges and major functionality that you can use with a plug-in to Git or Mercurial to generate pretty graphics.

It may take a few tries to get the initial check-in really right.  I can't imagine you have more than one developer working on something without it being in source control.  What are you currently using?

Title: How to manage/control software versions?

Body:
I'm facing a problem to create a version control outline for several already existing software parts for my company. Until now no one - expect for the developers - knows that there are different versions, which is the reason for the outline. In fact, I'm supposed to set up the future version control and communicate all this with our management...

So, the question is how to create such a outline. Are there principles to follow to make software versioning easier or even a good program to map all versions and there compatibility?

And are there generally good approaches to control software versions?


答:
I'm not sure that C++ is the ideal tool for this project.  This sounds a lot like Logic Programming.  A friend of mine has been using Clojure's built in the core.logic library (I had previously mentioned Frenchy64, but that's someone using core.logic to add type-safety to clojure).

This looks like the kind of problem that Functional or Lisp-ish programming was made to solve - turning mathematical statements into code.  This is not a procedural problem (like making a to-do list).  You might have a look at Lisp, or any of its derivatives (Clojure, Haskell, Erlang, Scala, Scheme, etc.).

SICP is a great training resource for learning functional programming.  Martin Odersky is using it as a basis for his Functional Programming in Scala free online course which started this week.  I'm guessing though that Clojure is closest to your needs.  I'll see if I can get my friend to comment.

Title: How to translate formulas into form of natural language?

Body:
I am recently working on a project aiming at evaluating whether an android app crashes or not. The evaluation process is

```<code>  1.Collect the logs(which record the execution process of an app).
  2.Generate formulas to predict the result
    (formulas is generated by GP)
  3.Evaluate the logs by formulas
</code>```

Now I can produce formulas, but for convenience for users, I want to translate formulas into form of natural language and tell users why crash happened.(I think it looks like "inverse natural language processing".)

To explain the idea more clearly, imagine you got a formula like this:

```<code>  155 - count(onKeyDown) >= 148
</code>```

It's obvious that if count(onKeyDown) > 7, the result of "155 - count(onKeyDown) >= 148" is false, so the log contains more than 7 onKeyDown event would be predicted "Failed".

I want to show users that if onKeyDown event appears more than 7 times(155-148=7), this app will crash.

However, the real formula is much more complicated, such as:

```<code>  (< !( ( SUM( {Att[17]}, Event[5]) <= MAX( {Att[7]}, Att[0] >= Att[11]) OR SUM( {Att[17]}, Event[5]) > MIN( {Att[12]}, 734 > Att[19]) ) OR count(Event[5]) != 1 ) > (< count(Att[4] = Att[3]) >= count(702 != Att[8]) + 348 / SUM( {Att[13]}, 641 < Att[12]) mod 587 - SUM( {Att[13]}, Att[10] < Att[15]) mod MAX( {Att[13]}, Event[2]) + 384 > count(Event[10]) != 1))
</code>```

I tried to implement this function by C++, but it's quite difficult, here's the snippet of code I am working right now.

Does anyone knows how to implement this function quickly?(maybe by some tools or research findings?)Any idea is welcomed: )

Thanks in advance.


答:
Check out Semantic Versioning.

In the world of software management there exists a dread place called "dependency hell." The bigger your system grows and the more packages you integrate into your software, the more likely you are to find yourself, one day, in this pit of despair.

In systems with many dependencies, releasing new package versions can quickly become a nightmare. If the dependency specifications are too tight, you are in danger of version lock (the inability to upgrade a package without having to release new versions of every dependent package). If dependencies are specified too loosely, you will inevitably be bitten by version promiscuity (assuming compatibility with more future versions than is reasonable). Dependency hell is where you are when version lock and/or version promiscuity prevent you from easily and safely moving your project forward.

As a solution to this problem, I propose a simple set of rules and requirements that dictate how version numbers are assigned and incremented...

I call this system "Semantic Versioning." Under this scheme, version numbers and the way they change convey meaning about the underlying code and what has been modified from one version to the next.


问:
Thread safe GUI programming
I have been programming Java with swing for a couple of years now, and always accepted that GUI interactions had to happen on the Event Dispatch Thread. I recently started to use GTK+ for C applications and was unsurprised to find that GUI interactions had to be called on gtk_main. Similarly, I looked at SWT to see in what ways it was different to Swing and to see if it was worth using, and again found the UI thread idea, and I am sure that these 3 are not the only toolkits to use this model. I was wondering if there is a reason for this design i.e.  what is the reason for keeping UI modifications isolated to a single thread. I can see why some modifications may cause issues (like modifying a list while it is being drawn), but I do not see why these concerns pass on to the user of the API. Is there a limit imposed by an operating system? Is there a good reason these concerns are not 'hidden' (i.e. some form of synchronization that is invisible to the user)? Is there any (even purely conceptual) way of creating a thread safe graphics library, or is such a thing actually impossible?

I found this http://blogs.operationaldynamics.com/andrew/software/gnome-desktop/gtk-thread-awareness which seems to describe GTK differently to how I understood it (although my understanding was the same as many people's) How does this differ to other toolkits? Is it possible to implement this in Swing (as the EDT model does not actually prevent access from other threads, it just often leads to Exceptions)

答:
a single looper thread is easier to implement, understand and use compared to multiple threads, (like separate painter eventcallback threads)

because with multithreading in the GUI all access to a GUI component needs to be synchronized (only exception is immutable stuff), this would then become a major bottle neck especially in times where it was prohibitevly expensive to acquire a lock or in tightly coupled frameworks

then there's also that if the eventlisteners can be notified on any thread (whichever one happened to poll the event queue) you would require thread safety to be applied to the underlying model (this is hard to get right). Even the paint-eventcallback segregation example above would need read-write synchronization.

one thing to note is that most frameworks have the idea of a background thread to use for long calculations and IO (like SwingWorker) or atleast a way to add a event to call a certain function on the event thread (generally called invoke)

Title: Thread safe GUI programming


答:
If you 'just' are working on HTML Apps there is a new cloud solution from Adobe called https://build.phonegap.com/

You don't need to have a Mac or Xcode to deploy iOS Versions of your Phonegap App this way.

The application has to be a Phonegap application (html5/css/JavaScript based).


答:
In addition to logging the Class / Method that raised the error, it would be useful to also log the parameters passed into that method. Knowing where an error was raised isn't very useful if it only happens 1 time out of 1000; you also need to know what data caused the error to occur.

I've also found it useful to have a variable which defines the default level of logging for an application. That way you can have DEBUG and INFO code alongside WARNING and ERROR code. When running in production mode you default it to not output DEBUG info, but when a bug shows up you can update a flag and start writing DEBUG messages to the log as well.

Title: Rules and advice for logging?

Body:
In my organization we've put together some rules / guildelines about logging that I would like to know if you can add to or comment.

We use Java but you may comment in general about loggin - rules and advice

Use the correct logging level

ERROR: Something has gone very wrong and need fixing immediately

WARNING: The process can continue without fixing. The application should tolerate this level but the warning should always get investigated.

INFO: Information that an important process is finished

DEBUG. Is only used during development

Make sure that you know what you're logging.

Avoid that the logging influences the behavior of the application

The function of the logging should be to write messages in the log.

Log messages should be descriptive, clear, short and concise.

There is not much use of a nonsense message when troubleshooting.

Put the right properties in log4j

Put in that the right method and class is written automatically.

Example:

Datedfile -web

```<code>log4j.rootLogger=ERROR, DATEDFILE
log4j.logger.org.springframework=INFO
log4j.logger.waffle=ERROR
log4j.logger.se.prv=INFO
log4j.logger.se.prv.common.mvc=INFO
log4j.logger.se.prv.omklassning=DEBUG

log4j.appender.DATEDFILE=biz.minaret.log4j.DatedFileAppender
log4j.appender.DATEDFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.DATEDFILE.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%C{1}.%M] - %m%n

log4j.appender.DATEDFILE.Prefix=omklassning.
log4j.appender.DATEDFILE.Suffix=.log
log4j.appender.DATEDFILE.Directory=//localhost/WebSphereLog/omklassning/
</code>```

Log value.

Please log values from the application.

Log prefix.

State which part of the application it is that the logging is written from, preferably with something for the project agreed prefix e.g. PANDORA_DB

The amount of text.

Be careful so that there is not too much logging text. It can influence the performance of the app.

Loggning format:

-There are several variants and methods to use with log4j but we would like a uniform use of the following format, when we log at exceptions:

logger.error("PANDORA_DB2: Fel vid hämtning av frist i
TP210_RAPPORTFRIST", e);

In the example above it is assumed that we have set log4j properties so that it automatically write the class and the method.

Always use logger and not the following:

System.out.println(), System.err.println(), e.printStackTrace()

If the web app uses our framework you can get very detailed error information from EJB, if using try-catch in the handler and logging according to the model above:

In our project we use this conversion pattern with which method and class names are written out automatically . Here we use two different pattents for console and for datedfileappender:

```<code>log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

log4j.appender.DATEDFILE.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
</code>```

In both the examples above method and class wioll be written out. In the console row number will also be written our.

toString()

Please have a toString() for every object.
EX:

```<code>@Override
public String toString() {
  StringBuilder sb = new StringBuilder();
  sb.append(" DwfInformation [ ");
  sb.append("cc: ").append(cc);
  sb.append("pn: ").append(pn);
  sb.append("kc: ").append(kc);
  sb.append("numberOfPages: ").append(numberOfPages);
  sb.append("publicationDate: ").append(publicationDate);
  sb.append("version: ").append(version);
  sb.append(" ]");
  return sb.toString();
}
</code>```

instead of special method which make these outputs

```<code>public void printAll()
{
    logger.info("inbet: " + getInbetInput());
    logger.info("betdat: " + betdat);
    logger.info("betid: " + betid);
    logger.info("send: " + send);
    logger.info("appr: " + appr);
    logger.info("rereg: " + rereg);
    logger.info("NY: " + ny);
    logger.info("CNT: " + cnt);
}
</code>```

So is there anything you can add, comment or find questionable with these ways of using the logging? Feel free to answer or comment even if it is not related to Java, Java and log4j is just an implementation of how this is reasoned.


答:
As an extension of your rule of logging where in the application the log statement came from, you may want to add per module level logging flags.  Instead of logging everything, all the time, this allows you to selectively target sections of your application instead.  There is overhead in this, and you need to create a facility that allows you to enable / disable that logging.  Ideally, you would be able to enable / disable on-the-fly as the application is running.

I'm used to seeing a layer below debug which I term "Trace", but that's not necessarily a universal term.  "Trace" level logging tracks as much as you can possibly stand, including module entry / exit, timestamps with entry / exit, and bonus points for capturing passed values.  Obviously, that generates a LOT of data and it's not something you turn on willy-nilly.  But it has advantages with respect to debugging when you can't attach to the process or you don't have a core dump of the errant application.

I like to see file / module references and timestamps with my log information.  It can be handy when trying to hunt down race conditions between threads as well as coordinating the activities of multiple areas of the application.  To be fair, I know of some folk who think these details clutter the log file.  Adding in the timestamp is something to discuss with the team.  (Apologies if log4j already does that.)

If the logging isn't being taken care of by it's own thread / process, that's something to consider as well.  Instead of making the application thread wait for the logging to process, the log message gets passed off to the log handler and the application thread goes on its merry way.  Alternatively, creating some sort of buffer mechanism to handle the log messages is another way to speed up application responsiveness.

Having controls on the size and history of log files is another feature to consider.  You don't want the app blowing out all the disk space on the host system, nor do you necessarily want to keep all log files for all eternity.

Title: Rules and advice for logging?


问:
How do tight timelines and scheduling pressure affect TCO and delivery time?
A friend's father, who is a software engineering manager, said, emphatically, "The number one cause of scheduling overruns is scheduling pressure."

Where does the research stand? Is a moderate amount of scheduling pressure invigorating, or is the manager I mentioned right or wrong, or is it a matter of "the more scheduling pressure you have, the longer the delivery time and the more TCO?" Is it one of those things where ideally software engineering would work without scheduling pressure but practically we have to work with constraints of real-world situations?

Any links to software engineering literature would be appreciated.

答:
the more scheduling pressure you have, the longer the delivery time and the more TCO?

Well, any scheduling done by manager without discussing it with technical lead is prone to that. It is very obvious truth that Scheduling or estimations that are NOT based on facts are prone to failure.

In addition, managers who avoid Evidence-Based Scheduling are also moving toward next failure of their project. There are number of studies on this topic and  metrics based scheduling is the right way to follow.


答:
You don't need software engineering literature.  Conceptual probability and statistics, from undergrad, is all you need.

An estimate is just that, an estimate.  It is not precise, it is not guaranteed. For any estimate, there is some probability that you will underrun it, or hit it on the nose, and some probability that you will overrun it.

Probability 101: p(underrun or hit exactly) + p(overrun) = 100%.

A schedule based on an estimate has the exact same characteristics.

You cannot eliminate the uncertainty completely.  There will ALWAYS be some probability of overrun.  It might be small, the probability of Iran nuking your office building, but it is still there.  The best you can do is look at EVERYTHING, and reduce the uncertainty as much as you can.  Once you have done that, you will, if you are lucky, have a schedule with small uncertainty, and 50% probability on each side.

Now, think about it: If you pull the schedule in, the probability that you will underrun or exactly hit the schedule decreases.  The total still has to sum to 100%.  Where does that probability go?  Answer, it goes into the overrun probability.

General Dynamics / Fort Worth Division learned this one the hard way.  They did their initial estimate for F-16C/D development, and sent it up the food chain.  Somebody higher up arbitrarily cut a year out of it, and sent that to the Air Force.  As a direct result, GD/FW was a year late to flight test, and the Air Force was NOT happy.  (Note that "one year late" was according to the revised schedule, meaning that the original schedule was RIGHT ON TARGET.)

Title: How do tight timelines and scheduling pressure affect TCO and delivery time?

Body:
A friend's father, who is a software engineering manager, said, emphatically, "The number one cause of scheduling overruns is scheduling pressure."

Where does the research stand? Is a moderate amount of scheduling pressure invigorating, or is the manager I mentioned right or wrong, or is it a matter of "the more scheduling pressure you have, the longer the delivery time and the more TCO?" Is it one of those things where ideally software engineering would work without scheduling pressure but practically we have to work with constraints of real-world situations?

Any links to software engineering literature would be appreciated.


问:
Designing a system with different business rules for different customers
My company is rewriting our proprietary business application. The current architecture is poorly done and inflexible. It is coded more procedural oriented as opposed to object oriented. It has become difficult to maintain.

Our system is a web application written in .Net Webforms. I am considering ASP.Net MVC for the rewrite.

We intend to rewrite it with a good, solid architecture with the goal of maintainability and reusable classes for some of our other systems and services. We would also like the system to be customizable for different customers in the event that we market the system.

I am considering redesigning the system based on the layered architecture (Presentation, Business, Data Access layers) described in the Microsoft Patterns and Practices Application Architecture Guide. http://msdn.microsoft.com/en-us/library/ff650706.aspx

Hopefully this isn't too open ended, but how would you recommend allowing for different business logic/rules for different customers? I'm aware of Windows Workflow Foundation, but from what I've read about it, it seems many business rules could be too complicated to handle there.

Also, Can anyone point me to where I can download an example of a .net solution that is based on the Application Architecture Guide? I have already downloaded the Layered Architecture Solution Guidance and the Expense Sample on codeplex. I was looking for something a bit larger and more robust that I could step through the code and see how it works.

If you feel there are better architectures to base our redesign on please feel free to share.

I appreciate your help!

答:
I suggest you look into something like the Managed Extensibility Framework from .NET 4.  If you use that, you would define certain extension points in your software and then fulfill those extension points with DLLs that you drop into your application at run-time.

So, you might have an extension point for a UserListService that has a default implementation that uses an internal database, but if it finds another implementation in the directory, it would end up using CustomerXYZUserListService which goes and pulls in a user list from their ERP system.


问:
Removing an element not currently in a list: ValueError?
This is something that's bothered me for a while, and I can't figure out why anyone would ever want the language to act like this:

```<code>In [1]: foo = [1, 2, 3]

In [2]: foo.remove(2) ; foo  # okay
Out[2]: [1, 3]

In [3]: foo.remove(4) ; foo  # not okay?
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)

/home/izkata/<ipython console> in <module>()

ValueError: list.remove(x): x not in list
</code>```

If the value is already not in the list, then I'd expect a silent success.  Goal already achieved.  Is there any real reason this was done this way?  It forces awkward code that should be much shorter:

```<code>for item in items_to_remove:
   try:
      thingamabob.remove(item)
   except ValueError:
      pass
</code>```

Instead of simply:

```<code>for item in items_to_remove:
   thingamabob.remove(item)
</code>```

As an aside, no, I can't just use set(thingamabob).difference(items_to_remove) because I do have to retain both order and duplicates.

答:
From the Python philosophy:

Explicit is better than implicit

The .remove() method has raised an exception from the very first commit; trying to remove a value that is not there gives you explicit feedback instead of implicitly assuming that the value not being there was fine and what you wanted all along.