答:
It would be just logical to hold a pointer to the Plane in the Pilot and a pointer to the Pilot in the Plane, accessible via getters and setters.

The pattern you are looking for is aggregation (here e.g. in Ruby):

```<code>class Plane
    attr_accessor :pilot
end

class Pilot
  attr_accessor :plane
end

plane1=Plane.new
pilot1=Pilot.new
plane1.pilot=pilot1
pilot1.plane=plane1
</code>```

Every time you want to know, who is pilot of plane1, you could ask the plane:

```<code>plane1.pilot
</code>```

This solution is simple, intuitive - but has a small drawback:

In order to cut the relation between both, you have to manipulate both instances.

Another problem occurs if you at a later point decide, that you need a JSON-Representation of your Planes and their pilots. Then you have a circular dependency: a plane has a pilot, which has a plane, which has a pilot ... you get it?

Of course there are ways around this problem (e.g. in Java you have @JsonManagedReferenc and @JsonBackReference when using JACKSON).

In the context of ORM this is a common solution: building a one-to-one-Relation via aggregation. The framework takes care of the relational mapping.

On the other hand: like @user144552 said in his answer, a solution in form of a Map might be the way to go. If you are working in-memory building a Map is the fastest solution, since you have O(1) with a Map.

But if you were working wih a DB, you would have to query the DB and let the DB doing the filtering

It depends on the usecase, what kind of implementation seems useful.

Body:
It would be just logical to hold a pointer to the Plane in the Pilot and a pointer to the Pilot in the Plane, accessible via getters and setters.

The pattern you are looking for is aggregation (here e.g. in Ruby):

class Plane
    attr_accessor :pilot
end

class Pilot
  attr_accessor :plane
end

plane1=Plane.new
pilot1=Pilot.new
plane1.pilot=pilot1
pilot1.plane=plane1

Every time you want to know, who is pilot of plane1, you could ask the plane:

plane1.pilot

This solution is simple, intuitive - but has a small drawback:

In order to cut the relation between both, you have to manipulate both instances.

Another problem occurs if you at a later point decide, that you need a JSON-Representation of your Planes and their pilots. Then you have a circular dependency: a plane has a pilot, which has a plane, which has a pilot ... you get it?

Of course there are ways around this problem (e.g. in Java you have @JsonManagedReferenc and @JsonBackReference when using JACKSON).

In the context of ORM this is a common solution: building a one-to-one-Relation via aggregation. The framework takes care of the relational mapping.

On the other hand: like @user144552 said in his answer, a solution in form of a Map might be the way to go. If you are working in-memory building a Map is the fastest solution, since you have O(1) with a Map.

But if you were working wih a DB, you would have to query the DB and let the DB doing the filtering

It depends on the usecase, what kind of implementation seems useful.


问:
When would you want two references to the same object?
In Java specifically, but likely in other languages as well: when would it be useful to have two references to the same object?

Example:

```<code>Dog a = new Dog();
Dob b = a;
</code>```

Is there a situation where this would be useful? Why would this be a preferred solution to using a whenever you want to interact with the object represented by a?

答:
That's actually a surprisingly profound question! Experience from modern C++ (and languages that take from modern C++, such as Rust) suggests that very often, you don't want that! For most data, you want a single or unique ("owning") reference. This idea is also the one main reason for linear type systems.

However, even then you typically want some short-lived "borrowed" references that are used to access the memory briefly but don't last for the a significant fraction of the time the data exists. Most commonly when you pass an object as argument to a different function (Parameters are variables too!):

```<code>void encounter(Dog a) {
  hissAt(a);
}

void hissAt(Dog b) {
  // ...
}
</code>```

A less common case when you use one of two objects depending on a condition, doing essentially the same thing regardless of which you choose:

```<code>Dog a, b;
Dog goodBoy = whoseAGoodBoy ? a : b;
feed(goodBoy);
walk(goodBoy);
pet(goodBoy);
</code>```

Going back to more common uses, but leaving local variables behind, we turn to fields: For example, widgets in GUI frameworks often have parent widgets, so your big frame containing ten buttons would have at least ten references pointing at it (plus some more from its parent and perhaps from event listeners and so on). Any kind of object graph, and some kinds of object trees (those with parent/sibling references), have multiple objects refer to each the same object. And virtually every data set is actually a graph ;-)

ContentLicense: CC BY-SA 3.0

Body:
That's actually a surprisingly profound question! Experience from modern C++ (and languages that take from modern C++, such as Rust) suggests that very often, you don't want that! For most data, you want a single or unique ("owning") reference. This idea is also the one main reason for linear type systems.

However, even then you typically want some short-lived "borrowed" references that are used to access the memory briefly but don't last for the a significant fraction of the time the data exists. Most commonly when you pass an object as argument to a different function (Parameters are variables too!):

void encounter(Dog a) {
  hissAt(a);
}

void hissAt(Dog b) {
  // ...
}

A less common case when you use one of two objects depending on a condition, doing essentially the same thing regardless of which you choose:

Dog a, b;
Dog goodBoy = whoseAGoodBoy ? a : b;
feed(goodBoy);
walk(goodBoy);
pet(goodBoy);

Going back to more common uses, but leaving local variables behind, we turn to fields: For example, widgets in GUI frameworks often have parent widgets, so your big frame containing ten buttons would have at least ten references pointing at it (plus some more from its parent and perhaps from event listeners and so on). Any kind of object graph, and some kinds of object trees (those with parent/sibling references), have multiple objects refer to each the same object. And virtually every data set is actually a graph ;-)


答:
An example is when you want to have the same object in two separate lists:

```<code>Dog myDog = new Dog();
List dogsWithRabies = new ArrayList();
List dogsThatCanPlayPiano = new ArrayList();

dogsWithRabies.add(myDog);
dogsThatCanPlayPiano.add(myDog);
// Now each List has a reference to the same dog
</code>```

Another use is when you have the same object playing several roles:

```<code>Person p = new Person("Bruce Wayne");
Person batman = p;
Person ceoOfWayneIndustries = p;
</code>```

Title: When would you want two references to the same object?

Body:
In Java specifically, but likely in other languages as well: when would it be useful to have two references to the same object?

Example:

```<code>Dog a = new Dog();
Dob b = a;
</code>```

Is there a situation where this would be useful? Why would this be a preferred solution to using a whenever you want to interact with the object represented by a?

Body:
An example is when you want to have the same object in two separate lists:

Dog myDog = new Dog();
List dogsWithRabies = new ArrayList();
List dogsThatCanPlayPiano = new ArrayList();

dogsWithRabies.add(myDog);
dogsThatCanPlayPiano.add(myDog);
// Now each List has a reference to the same dog

Another use is when you have the same object playing several roles:

Person p = new Person("Bruce Wayne");
Person batman = p;
Person ceoOfWayneIndustries = p;


答:
There are plenty of scenarios wherein b must be a reference to an unknown "a" in order to be useful. In particular:

Any time you don't know what b points to at compile-time.

Any time you need to iterate over a collection, whether known at compile time or not

Any time you have limited scope

For example:

Parameters

```<code>public void DoSomething(Thing &t) {
}
</code>```

t is a reference to a variable from an outside scope.

Return values and other conditional values

```<code>Thing a = Thing.Get("a");
Thing b = Thing.Get("b");
Thing biggerThing = Thing.max(a, b);
Thing z = a.IsMoreZThan(b) ? a : b;
</code>```

biggerThing and z are each references to either a or b. We don't know which at compile-time.

Lambdas and their return values

```<code>Thing t = someCollection.FirstOrDefault(x => x.whatever > 123);
</code>```

x is a parameter (example 1 above), and t is a return value (example 2 above)

Collections

```<code>indexByName.add(t.name, t);
process(indexByName["some name"]);
</code>```

index["some name"] is, to a large extent, a more sophisticated looking b. It's an alias to an object that was created and stuffed into the collection.

Loops

```<code>foreach (Thing t in things) {
 /* `t` is a reference to a thing in a collection */
}
</code>```

t is a reference to an item returned (example 2) by an iterator (previous example).

Body:
There are plenty of scenarios wherein b must be a reference to an unknown "a" in order to be useful. In particular:

Any time you don't know what b points to at compile-time.

Any time you need to iterate over a collection, whether known at compile time or not

Any time you have limited scope

For example:

Parameters

public void DoSomething(Thing &t) {
}

t is a reference to a variable from an outside scope.

Return values and other conditional values

Thing a = Thing.Get("a");
Thing b = Thing.Get("b");
Thing biggerThing = Thing.max(a, b);
Thing z = a.IsMoreZThan(b) ? a : b;

biggerThing and z are each references to either a or b. We don't know which at compile-time.

Lambdas and their return values

Thing t = someCollection.FirstOrDefault(x => x.whatever > 123);

x is a parameter (example 1 above), and t is a return value (example 2 above)

Collections

indexByName.add(t.name, t);
process(indexByName["some name"]);

index["some name"] is, to a large extent, a more sophisticated looking b. It's an alias to an object that was created and stuffed into the collection.

Loops

foreach (Thing t in things) {
 /* `t` is a reference to a thing in a collection */
}

t is a reference to an item returned (example 2) by an iterator (previous example).


问:
How do you guys feel about organization specific frameworks?
I know that there should be a kind of standard for developing software but in the organization where I work for (30,000+ employees), we have a very strict framework for Java development.

In my opinion such a framework is prehistoric as we are therefor running at least 10 years behind (Standard is Java 1.5 but with support 'til java 1.2).

Further the framework slows down performance, user satisfaction drops and I'm writing more boilerplate code than is good for my health :-).

Any suggestions on the advantages of such a framework? What are good practices for such a framework for not running behind the facts?

答:
What frameworks are meant to do is to simplify, or organize software development in some way that has benefit.  Unfortunately, unless the framework evolves with new advances in the language, those advantages it affords are probably overtaken by events.  For example, 10 years ago there were a few Java frameworks, but the one that has the widest acceptance is currently Spring.  Anecdotedly, I remember hearing about Spring and thinking to myself it'll never get anywhere.  I was wrong.

It's important to understand what problem(s) the framework was intended to address.  If your organization has to support 10 year old installs of Java for whatever reason, and the framework ensures that new code will run on old VMs--that's an important advantage to the company.  However, if there are no advantages whatsoever to the old (and possibly aging) framework, then you will probably need to take some statistics.

Nothing speaks to managers more than numbers.  When you show them how much of your work is due to feeding the framework vs. how much time it would take to do it another way.  Perhaps it would be much less political if you were to address a specific portion of the framework that if changed would buy you another x hours of productivity during the day.

Frameworks need to evolve over time just as all software does.  As new features come out in a language, the framework needs to be adapted to take advantage of them.  The Spring of today is hardly the Spring when it was originally introduced.

ContentLicense: CC BY-SA 2.5


问:
Filtering common starting/ending characters from array/list of strings
Ok so for example I have an array of strings with each string as below:

364VMS1029
364VMSH920
364VMSH192
364VMSU839
364VMN2382
364VMR223
364VMR2X3
364VMN829
364VMN8757
364VMN831
```

How can I dynamically get the program to recognise the common characters among all strings in the array, which in this case is 364VM and filter them out?
If there's no common character, then don't do anything.

答:
When you have a complicated problem that you can't solve, try breaking it down into simpler problems and solve those.

Your problem rephrased:

Remove the common prefix and suffix from a list of strings.

A simpler problem would be:

Find the common prefix for a pair of strings.

This should be much simpler to solve, for example like this:

```<code>string GetPrefix(string first, string second)
{
    int prefixLength = 0;

    for (int i = 0; i < Math.Min(first.Length, second.Length); i++)
    {
        if (first[i] != second[i])
            break;

        prefixLength++;
    }

    return first.Substring(0, prefixLength);
}
</code>```

Now that you have this, you can build back to the original problem:

Find the common prefix for a list of strings.

Here, it's very helpful to realize that the prefix of three strings is the same as the prefix of the prefix of the first two strings and the third string. (Hmm, that sounds confusing, maybe it will be clearer in a more formal notation: prefix(A, B, C) = prefix(prefix(A, B), C).)

This means that you can use the LINQ method Aggregate() on the GetPrefix() method above to get the prefix of a whole list of strings:

```<code>string GetPrefix(IEnumerable<string> strings)
{
    return strings.Aggregate(GetPrefix);
}
</code>```

The next step:

Remove the common prefix from a list of strings.

Now that we can find the common prefix, we can remove it using LINQ Select() and  Substring():

```<code>IEnumerable<string> RemovePrefix(IEnumerable<string> strings)
{
    var prefix = GetPrefix(strings);

    return strings.Select(s => s.Substring(prefix.Length, s.Length - prefix.Length));
}
</code>```

This assumes you want to get a new sequence containing the filtered strings. If you want to modify an existing collection, use a for loop instead of the Select().

One last step:

Remove the common prefix and suffix from a list of strings.

I'll leave this as an exercise for the reader. This answer contains simple code for reversing a string, which could be helpful. (I think you don't need the code from other answers to that question, since it looks like your strings are ASCII-only.)

Body:
When you have a complicated problem that you can't solve, try breaking it down into simpler problems and solve those.

Your problem rephrased:

Remove the common prefix and suffix from a list of strings.

A simpler problem would be:

Find the common prefix for a pair of strings.

This should be much simpler to solve, for example like this:

string GetPrefix(string first, string second)
{
    int prefixLength = 0;

    for (int i = 0; i < Math.Min(first.Length, second.Length); i++)
    {
        if (first[i] != second[i])
            break;

        prefixLength++;
    }

    return first.Substring(0, prefixLength);
}

Now that you have this, you can build back to the original problem:

Find the common prefix for a list of strings.

Here, it's very helpful to realize that the prefix of three strings is the same as the prefix of the prefix of the first two strings and the third string. (Hmm, that sounds confusing, maybe it will be clearer in a more formal notation: prefix(A, B, C) = prefix(prefix(A, B), C).)

This means that you can use the LINQ method Aggregate() on the GetPrefix() method above to get the prefix of a whole list of strings:

string GetPrefix(IEnumerable<string> strings)
{
    return strings.Aggregate(GetPrefix);
}

The next step:

Remove the common prefix from a list of strings.

Now that we can find the common prefix, we can remove it using LINQ Select() and  Substring():

IEnumerable<string> RemovePrefix(IEnumerable<string> strings)
{
    var prefix = GetPrefix(strings);

    return strings.Select(s => s.Substring(prefix.Length, s.Length - prefix.Length));
}

This assumes you want to get a new sequence containing the filtered strings. If you want to modify an existing collection, use a for loop instead of the Select().

One last step:

Remove the common prefix and suffix from a list of strings.

I'll leave this as an exercise for the reader. This answer contains simple code for reversing a string, which could be helpful. (I think you don't need the code from other answers to that question, since it looks like your strings are ASCII-only.)


问:
What's the difference between an API and an SDK?
I was looking through various APIs and SDKs, when I realized that I couldn't really tell the difference between something called an API and something called an SDK.

Both of them are, conceptually, a way for your program to interface with and control the resources provided by another piece of software, whether that other software is a web service, an end-user app, an OS service or daemon, or a kernel device driver.

So, what is the semantic difference between an SDK and an API?

答:
My two cents: I believe the term API is often used incorrectly.

An API is an Application Programming Interface.

Although kind of an awkward name, it means it's an interface. So an application might have an API to allow other applications to communicate with it. And a piece of software (e.g. a class in an OO system) might offer an API to allow other modules in the system to communicate with it.

However often the term API is used as a synonym of "library". I don't think that's a correct use of the word. Part of the library is an API to allow code to use it, but the library isn't an API.

And an SDK is a kind of library, so that's where the confusion might be.


问:
Copying and Selling Apache Licensed Software?
Questions in bold:

I've read the Apache Software License 2.0... What I gather is that all a person needs to do when redistributing the licensed software is include their name in all the parts they've modified(if any), include some notices and whatnot, and you're away. You don't even need to follow along with the license in all your additions/edits, because you can sub-license.

The thing I don't really get is, why would anyone want to use this kind of license, honestly? Am I missing something?

One more thing, does #include-ing(or similar) a licensed library mean that you are making a derivative of the licensed source, therefore binding you to the terms and conditions of the license?

答:
You say:

If I made free software, I'd want to know that it will stay free, and that no one will just copy and sell. Or slightly modify and sell. Am I missing something?

Yes.  When I make free software, I want to know that people will find what I do useful.  I don't care whether they make money out of it or not -- I know I'm not in a position to make that money anyway, so why does it matter to me?  I just want to make the world a better place, and as far as I'm concerned that means the more people use the software I write the better.  I prefer BSD-style licenses (which includes the Apache license) because they open up the largest possible audience.


问:
What's the worst question you were ever asked at interview?
It doesn't have to be programming or software development related, but just asked during an interview for an IT related job.

I know some "left field" questions are meant to see how the candidate copes with unexpected and novel situations, but here I'm looking for a question that appeared to be completely unrelated to the job they were interviewing you for, or something that made you think "what useful information could they possibly get from my answer to that question?".

答:
"Can you bring us the secrets of your past employers?"

Not exactly in these words, but that's the intention.


问:
What are the warning signs of impending doom to watch out for on a project?
Having worked on a failed project is one of the few things that most programmers have in common, regardless of language used, industry or experience.

These projects can be great learning experiences, soul-crushing disasters (or both!), and can occur for a multitude of reasons:

upper management change of heart

under-skilled / under-resourced team

emergence of superior competitor during dev cycle

over/under management

Once you've worked on a couple of such projects, is it possible to recognise at an early stage exactly when a project is doomed to fail?

For me, a big sign is having a hard & fast external deadline combined with feature creep. I've seen projects which were well planned out and proceeding right on schedule go horribly off the rails once the late feature requests started to roll in and get added to the final "deliverable". The proposers of these requests earned the nickname of Columbo, due to rarely leaving the room without asking for "just one more thing".

What are the warning signs you look out for that set off the alarm bells of impending doom in your head?

答:
The most obvious sign is a high staff turnover. When everybody is looking for a new job, you probably should, too.

The other highly obvious sign is lack of progress. If a year has passed, and it doesn't seem like you are any closer to the target, you're doomed. This happens especially when requirements change faster than you can implement them.


问:
Licencing GNU GPlv3 - sofware provides a service - not distributed
I have a couple questions with regard to the GNU GPLv3 license.
My application is closed-source and I do not intend to actually release it to the public. However, it does generate commercial items. The use of dlls licensed under the above license are used and linked to the software that generates these commercial products.

I would just like clarification, that because the software is not actually being distributed - only what the software generates. Therefore, no release of source etc would be required. The licensed dlls are not modified in any way.

Secondly, out of interest. When a GNU GPLv3 is used by commercial software (let's say this software is released). This time the licensed material is a EXE and not a .DLL and therefore not actually linked to the code of the software. Rather the software is executing the licensed software directly and sending it command line style arguments and using what the exe returns. Would the source code have to be released?

Thanks, I am new to the realms of these licenses and slightly confused.

答:
Regarding your first question (if I understand it correctly), see this excerpt taken from the GPL FAQ:

In what cases is the output of a GPL program covered by the GPL too?

Only when the program copies part of itself into the output.

Regarding your second question, see this excerpt from the GPL FAQ (emphasis mine):

Can I release a non-free program that's designed to load a GPL-covered plug-in?

It depends on how the program invokes its plug-ins. For instance, if
  the program uses only simple fork and exec to invoke and communicate
  with plug-ins, then the plug-ins are separate programs, so the license
  of the plug-in makes no requirements about the main program.

If the program dynamically links plug-ins, and they make function
  calls to each other and share data structures, we believe they form a
  single program, which must be treated as an extension of both the main
  program and the plug-ins. In order to use the GPL-covered plug-ins,
  the main program must be released under the GPL or a GPL-compatible
  free software license, and that the terms of the GPL must be followed
  when the main program is distributed for use with these plug-ins.

If the program dynamically links plug-ins, but the communication
  between them is limited to invoking the ‘main’ function of the plug-in
  with some options and waiting for it to return, that is a borderline
  case.

If you want to get a more detailed answer for your specific situation, you can contact the Free Software Foundation directly at licensing(at)fsf(dot)org explaining your exact use case.

I must point out that I am not a lawyer and only a lawyer can responsibly give you legal advice on any matter, including software development and distribution. You can use the information in this answer at your own risk in order to get a rough idea of what to expect, but any actions you take are your responsibility unless a lawyer has been consulted first.

OwnerDisplayName: John Nagg

OwnerDisplayName: Theodoros Chatzigiannakis


问:
Client-side coding: How to prevent malicious use?
Over the last few years, the trend for client-side (browser) applications has really taken off.

For my latest project, I have decided to try and move with the times and write a client-side application.

Part of this application involves sending transaction emails to users (for example, validate signup, password reset emails, etc.). I am using a third-party API to send the emails.

Normally I would have my application running on a server. I would call the third-party API from code on my server.

Running a client-side application means this now needs to happen on a user's browser. The third-party API provides the necessary JavaScript files to achieve this.

The first glaring issue I can see is I need to use an API key. This would normally be safely stored on my server, but now presumably I will need to provide this key to the client browser.

Assuming I can get round this problem, the next problem is what stops a tech-savvy user loading up the JavaScript developers tool on a browser and using the email API anyway they like, rather than say adhering to any rules I have set in the application.

I guess my general question is - how can we prevent malicious use of a client-side application?

答:
It's quite simple, really. Assume that the client computer and all software running on it is under complete control of a clever malicious hacker.

That means that any information that you send from the server to the client will be known to the malicious hacker, so you must make sure to send out no information to the client that could be used to attack your server or your business.

It also means that anything sent from the client to the server has been produced by the malicious hacker, so your server code must make sure that nothing the client could send would be capable of successfully attacking your server.

Admittedly, the implementation is a problem, but the important thing is the mental attitude, the assumption that the "client" you think your server is talking to isn't a client but an active attacker.

(You also need to assume that the user is a clever conman who will try to attack your business methods, but that has nothing to do with client-side programming).


问:
How would you approach errors notification?
Recently we had a discussion with my colleagues caused by my intentional attempt to generate user friendly message about occurred error (business logic) at the server side.

They insisted on putting all string localizable resources inside web client assembly and not server one. The argument is to let client decide how to generate and present messages to the user. I can't but agree with the requirement of such flexibility for public services, however we develop intranet back-office system and we develop client part as well (both thin and thick client). Frankly speaking the code I've seen so far does nothing more as generating the message (identical to the code I tried to put in BL). There is no particular controls highlighting, accurately positioned popups or something like that. But now the logic is duplicated: web client + win client.

My point is that It's better to adhere to DRY and YAGNI principles. Copy paste is evil.

The second argument is encapsulation. If error occurred inside Business Logic then it's BL who knows how to describe the error and what additional information should be collected and presented to the user without compromising security or revealing implementation details to the client part.

For example, in case of concurrent changes we return ConcurrenAccessError from the server and client then converts this to "bla bla bla, object was changed by someone else, edit once again, please." Now, to add user name and timestamp of the changes I need to extend ConcurrentAccessError class with additional properties and change code of message generation in two places. I would ask whether client should even know about concurrency as a special error type if it does nothing about it besides user notification. System is not designed for conflict resolving via merge. I believe that high granularity of errors is important only when such structured information allows system somehow help user to make corrections. (Highlighted and focused email input field is better than just a message below the form)

Well, eventually I did not manage to persuade my colleagues. I had to follow the conventions. Yet I need more pro and contra arguments to continue the discussion or agree with them.

I'd like to know which strategies of error notification you usually use and why. Where do you put the logic of constructing the message?

答:
Every error should ideally inform its immediate consumer of a problem it can "understand."

Report errors from web services that developers and their client code needs to interpret. That means business objects sitting behind a web service don't contain end-user errors. Business objects shouldn't even know what interface is ultimately invoking them.

Client code, or whatever code sits "nearest to" to user should interpret lower level errors for and provide instructions to the end-user as-needed. Some errors don't need to be reported unless they recur.

My gmail, for instance, doesn't give me an onslaught of timeout errors when my connection goes down, it unobtrusively places a tiny string of text on the screen letting me know the server couldn't be reached, that's it's about to try again.

And while a connectivity error is a bit different than what you're asking, I think it illustrates the point: the client needs to know how to interpret lower level technical errors and tell the user how to deal with our ignore the problem.


问:
How do scalable bloom filters work?
I was reading up on scalable bloom filters and could not understand how each time a constituent bloom filters fills up, a new bloom filter with larger size is added.

The elements that contributed to the set bits in the initially created filters cannot be looked up for presence. Perhaps I am wrong in my understanding of this?

I do understand basic bloom filters. However, I cannot wrap my head around dynamic bloom filters.

答:
An item is in the scalable bloom filter if any filter returns true. Hence, you can add filters without affecting membership queries for previous items.

To make sure you still have a worst-case false positive guarantee, new filters are added with false positive rates that decrease geometrically. For example, the first filter has false positive rate p, the second rp, the third r^2p, etc. The probability of a false positive over the scalable bloom filter is then bounded by the union bound: sum_{k>=0} r^k p = p/(1-r).

Title: How do scalable bloom filters work?

ContentLicense: CC BY-SA 4.0


答:
To supplement the other answers, you may also want to traverse a data structure differently, starting from the same place. For example, if you had a BinaryTree a = new BinaryTree(...); BinaryTree b = a, you could traverse down the tree's leftmost path with a and its rightmost path with b, using something like:

```<code>while (!a.equals(null) && !b.equals(null)) {
    a = a.left();
    b = b.right();
}
</code>```

It's been a while since I've written Java, so that code may not be correct or sensible. Take it more as pseudocode.

Body:
To supplement the other answers, you may also want to traverse a data structure differently, starting from the same place. For example, if you had a BinaryTree a = new BinaryTree(...); BinaryTree b = a, you could traverse down the tree's leftmost path with a and its rightmost path with b, using something like:

while (!a.equals(null) && !b.equals(null)) {
    a = a.left();
    b = b.right();
}

It's been a while since I've written Java, so that code may not be correct or sensible. Take it more as pseudocode.


问:
selling closed source commercial product in a virtualbox (GPL)
Can I sell a closed source commercial product inside a virtualbox VM?

This is extremely useful when you want to deliver server side software to users, and not mess in with different OS's (windows/osx).

By reading some of the answers here in programmers, I get that it should not be a problem since my software does not link a GPL library, and that's practically the biggest concern of GPL FOSS.

So, if I use GPL software just bundled with Closed source software that's fine?

答:
What you're asking is if you can make a VM appliance/image that includes proprietary software. I don't see why not, after all, most people using GNU/Linux and Ubuntu will install the proprietary Flash plugin. People also include proprietary data within their images when they distribute them.

Check out the VirtualBox Licensing FAQ

Of course, this is all IANAL (I Am Not A Lawyer) and the recommended advice to hire a lawyer to deal with licensing issues is a very good idea, especially if your company can afford it (I'm sure they can since they stand to make a profit off of making an appliance VM image).


问:
Properly licensing FOSS: text location
I have a few FOSS projects that I want to release under the BSD license, since I only wish to maintain the intellectual property of the code, that others will know I've been writing it.

I suppose all I need to do is:

Have a file called LICENSE only in the main folder of the software.

Write at the top of each source file the following text:

This software is released under the BSD License.

  Full text of the
  license can be found in the file named 'LICENSE' at the main folder of
  the software.

  Copyright (c) 2013, Dor.

Am I correct? Is there anything to add/remove/change?

Should I include my full name,

or may I just use the first name and first letter of last name (e.g. Dor K.)?

The BSD license text that's contained in the file LICENSE is:

```------------------------------------------------------------------------
This software is released under the BSD License
------------------------------------------------------------------------
Copyright (c) 2013, Dor K.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------```

答: You can also call the file COPYING. If you have contributors and depending on your license, you will also need to list their name for the copyright or get them to assign their copyright to you.</p>

Title: Properly licensing FOSS: text location


问:
How modularized should my interfaces be?
I stumbled upon a specific instance where it seems that modularity and simplicity are at conflict with each other. Usually that's not the case, so I was really unsure how to resolve it.

Suppose I would like to make a queue interface:

```<code>template<typename T>
class queue {
 public:
  virtual ~queue() {}
  virtual void enqueue(const T& t) = 0;
  virtual void enqueue(T&& t) = 0;
  virtual T dequeue() = 0;
};
</code>```

As I was making a couple implementations (some of which are atomic), I noticed that I could really save time by having an "abstract class" which called on empty() or full() methods to help implement condition variables. That way any synchronized class I implement could also just extend that "abstract class." The abstract class, in turn, implemented an extended interface:

```<code>template<typename T>
class bounded_queue : public queue<T> {
public:
  virtual ~bounded_queue() {}
  virtual bool full() = 0;
  virtual bool empty() = 0;
};
</code>```

But wouldn't it be simpler if I just shoved those methods into queue, perhaps returning false by default? The answer to this question is not immediately obvious to me. If it is, then consider the other end of the spectrum.

I'm not even sure the above design (in the link) works as expected! How do I decide on something simple, yet modular?

答:
They should be in the same interface. Bounded vs unbounded does not change this. The simple solution is to provide default implementations of isfull() and isempty() which a subclass can override. [My answer is much the same as comments by @tp1.]

If you do not provide empty(), how can a caller determine whether to request a dequeue or not?

You should also consider including a peek(). Once you implement isempty() then both dequeue() and peek() can block or raise an exception if called on an empty queue.

The general alternative is to provide several different types of queue. In this case a blocking queue might well be a different class, but with the same interface. However the same does not apply to an infinite queue, in which isfull() is never true.


问:
What's the name of this category of variables (NEW, OLD, etc) available inside triggers?
I need to do some very specific web search, but in order to do that I need to know what's the technical name of the category/type of variables like NEW, OLD, USER ( the could be more ) that you can accessed inside a trigger in a RDBMS without having to declare them.

The question I want to post is "does <RDBMS> support <xxxx> variables in triggers ?" but I don't know what to put in the <xxxx> placeholder.

For example, variables like this :var in a query are called bind variables.

答:
I hope you were looking for a total lack of standardization!

PostgreSQL calls them "special variables".

IBM DB2 calls them "transitional variables".

Oracle calls them both "correlation names" and "pseudorecords".

Microsoft SQL server calls them "inserted and deleted tables".

SQLite does not appear to have a name for them.

I would suggest looking at the "CREATE TRIGGER" manual page for the databases you are interested in, and see if it supports the functionality that you're looking for. You may also need to look at the "CREATE [FUNCTION|PROCEDURE]" page, as some special variables that you're interested in (those other than NEW and OLD) may actually be among those available to all functions/procedures, and so might not appear on the trigger/procedure page.


答: Re the second part of the question, including a library means merging and merging always creates a derived work. You can only merge code if you comply with the licence and you can only distribute the merged product if you comply with the distribution part of the licence.</p>

Title: Copying and Selling Apache Licensed Software?

Body:
Questions in bold:

I've read the Apache Software License 2.0... What I gather is that all a person needs to do when redistributing the licensed software is include their name in all the parts they've modified(if any), include some notices and whatnot, and you're away. You don't even need to follow along with the license in all your additions/edits, because you can sub-license.

The thing I don't really get is, why would anyone want to use this kind of license, honestly? Am I missing something?

One more thing, does #include-ing(or similar) a licensed library mean that you are making a derivative of the licensed source, therefore binding you to the terms and conditions of the license?


问:
What is meant by Scope of a variable?
I think of the scope of a variable as -

"The scope of a particular variable is the range within a program's source code in which that variable is recognized by the compiler".

That statement is from "Scope and Lifetime of Variables in C++", which I read many months ago.

Recently I came across this in LeMoyne-Owen College courses:

What exactly is the difference between the scope of variables in C# and (C99, C++, Java) when

However a variable still must be declared before it can be used

答:
In C++ and Java the following code is legal, but in C# it would cause this conflict: "local variable 'logging' cannot be declared in this scope because it would give a different meaning to 'logging', which is already used in a child scope".</p>

```<code>// Statically check script.
{
    Boolean logging = false;
    MyClass.check(script, logging);
}

// Translate code.
Boolean logging = true;
MyClass.translate(script, logging);
</code>```

Title: What is meant by Scope of a variable?

Body:
In C++ and Java the following code is legal, but in C# it would cause this conflict: "local variable 'logging' cannot be declared in this scope because it would give a different meaning to 'logging', which is already used in a child scope".

// Statically check script.
{
    Boolean logging = false;
    MyClass.check(script, logging);
}

// Translate code.
Boolean logging = true;
MyClass.translate(script, logging);


问:
Processor architectures for testing C/C++ portability
Currently I'm working on a C/C++ code-base which is fairly portable, it can compile on most Unix like systems as well as MS-Windows (MSVC), using various popular compilers.

Previously I've found testing on different OS's and architectures can help find obscure bugs or bad assumptions.

I worry with the dominance of x86/amd64 our code-base may unknowingly become less portable.

Besides testing on a big-endian system (to find obvious errors with big/little endian), are there some architectures which have characteristics making them better for stress-testing software portability?

Examples of possible differences.

different endian.

different behavior when threading.

behavior of stack memory.

size of primitive types (char, short, int, long, float... etc).

alignment/padding of structs (which might hide errors).

difference in optimizations made by the compiler.

Are there some architectures which have more significant differences to x86/amd64, making them better candidates for exposing code portability issues? (and have C/C++ compilers and libraries - libc, libstdc++).

Asking because its a sizable time-investment to setup a new system, even if its emulated.

in case its not clear what I mean by processor-architectures, eg (x86, amd64, ia64, mips, risc, arm, m68k, ppc, itanium)

Note, I'm not proposing this as a primary way to discover bugs, we run multiple static analysis tools and tests, but in the past we have found errors in code because of differences in less common platforms (SGI, SPARC, Solaris, BSD's etc. However some of these systems are fading out of use)

答:
You are right that using different setups for your tests can increase the chance of accidentally stumbling on some bugs. However, you should consider whether setting up a another testing rig makes sense from a business perspective of things – I suspect you want to sell or distribute useful code, rather than crafting The Perfect Code in your ivory tower.

I worry with the dominance of X86/AMD64 our code-base may unknowingly become less portable.

If your code only ever runs on x86 or AMD64 architectures, then there is little use for testing on other architectures – YAGNI applies here. You'd be better off by expanding your test suite to guarantee all documented behaviour, and by purging the code base of dubious constructs with the help of linters. Using multiple different compilers on different settings is also a low-cost, high-impact strategy for discovering bugs (e.g. GCC and Clang).

If however you explicitly support certain combinations of architectures and operating systems, you should also test those combinations.

If you nevertheless do want to test some more alien setups that are still used fairly commonly, I would recommend:

Architecture: SPARC. OSes: Solaris family, Linux, BSD family. Endianness: big, possibly bi. Comments: massive parallelism.

Architecture: ARM. OSes: Linux, BSD family, OpenSolaris. Endianness: little, possibly bi. Comments: used in embedded devices, mobile phones.

The features you listed can be tested by varying the following components in the setup:

Endianess: architecture.

Threading: OS, kernel settings, threading libraries, number of processors.

Stack: ?

Primitive sizes: preprocessor directives, compiler settings.

Struct alignment: compilers.

Optimizations: compiler settings.

Other: compile using different libc implementations.

My primary exposure to cross-platform programming is reading through the source of the Perl interpreter. Here portability issues are adressed by:

… detecting features provided by the used libc implementation, possibly substituting custom functions. This information is then recorded as a set of preprocessor definitions before compilation.

… pervasively using macros for numeric types. The sizes can be set during compilation.

… making threading optional, as the unthreaded version performs better. In the code, some sections are executed only when compiled with threading support.

… mostly ignoring endianess, as this tends to sort itself out. Endianness only becomes relevant when doing something like interpreting a given bit pattern as a 16-bit BE number on a LE system.

… explicitly listing supported platforms and also documenting portability issues or differing behaviour on these platforms.

… running a huge test suite incl. a ton of regression tests that are executed on a network of CI boxes.


答:
Quite often organisational frameworks pop up because external frameworks "weren't invented here" and equally as often "There's nothing that current meets our needs" (which was quite common in the early days of J2EE).

The wise organisation has plans to move parts of their own internal frameworks onto industry standards (e.g.  JPA)

And/Or

The wise organisation has plans to improved their own internal frameworks to increase developer productivity yet maintain what ever special support that is required

And/Or

A truly brave/enlightened organisation might open source parts or all of their framework in order to keep it up to date, relevant etc.

Most organisations don't do this and ammoQ's comment:

It's no surprise that some
  organisations manage to implement the
  worst of both worlds: an outdated
  in-house framework for some projects,
  several other tools for the other
  projects.

Is very apt :)

Title: How do you guys feel about organization specific frameworks?

Body:
I know that there should be a kind of standard for developing software but in the organization where I work for (30,000+ employees), we have a very strict framework for Java development.

In my opinion such a framework is prehistoric as we are therefor running at least 10 years behind (Standard is Java 1.5 but with support 'til java 1.2).

Further the framework slows down performance, user satisfaction drops and I'm writing more boilerplate code than is good for my health :-).

Any suggestions on the advantages of such a framework? What are good practices for such a framework for not running behind the facts?


问:
Should a parent CSS class be added to the markup or @extended?
Reading SASS basic features on their website, I stumbled upon the @extend feature.

The example they give is the following:

```<code>.message {
    border: 1px solid #ccc;
    padding: 10px;
    color: #333;
}

.success {
    @extend .message;
    border-color: green;
}

.error {
    @extend .message;
    border-color: red;
}

.warning {
    @extend .message;
    border-color: yellow;
}
</code>```

That compiles to

```<code>.message, .success, .error, .warning {
    border: 1px solid #cccccc;
    padding: 10px;
    color: #333;
}

.success {
    border-color: green;
}

.error {
    border-color: red;
}

.warning {
    border-color: yellow;
}
</code>```

Thus with this snippet of HTML

```<code><div class="success">hello world</div>
</code>```

you style your element with properties of .message and .success. However I feel this way of writing HTML (and CSS) very poor, in terms of semantic (you don't explicitly see from the markup above that the element has also the styling of .message).

Shouldn't the snippet above be

```<code><div class="message success">hello world</div>
</code>```

?

I feel it to be more descriptive, and more easily reusable. For example I could assign the .success class (as written in the above CSS but without the @extend) to other elements which are not messages, and so using the class as a modifier, in a BEM-fashion.

So my question is, is the SASS example approach more desiderable than mine?

答:
Both approaches are valuable and semantically, they are not very different. Remember that you also can use both in Sass.

I believe that what makes you think that yours is more descriptive is their choice of class names: success class is not descriptive enough: how would anyone guess that success refers to a message, and not, say, a small green check icon on the side of an item showing whether a unit test passed? If we chose a (meaningless) example with better names, things become clearer:

```<code>.animal { ... }
.cat { @extend .animal; ... }
.dog { @extend .animal; ... }
</code>```

Would you rather write:

```<code><div class="animal cat">...</div>
</code>```

or:

```<code><div class="cat">...</div>
</code>```

Probably the second variant, since it avoids redundancy and makes your HTML more readable.

If you know object oriented programming, think of:

Their approach as inheritance: Cat class inherits Animal, and can have only zero or one base classes.

Your approach as interfaces: ISuccessful interface can be implemented by both Message class and TestResult; at the same time, Message can implement at the same time ISuccessful, IImportant and IMandatory.

Body:
Both approaches are valuable and semantically, they are not very different. Remember that you also can use both in Sass.

I believe that what makes you think that yours is more descriptive is their choice of class names: success class is not descriptive enough: how would anyone guess that success refers to a message, and not, say, a small green check icon on the side of an item showing whether a unit test passed? If we chose a (meaningless) example with better names, things become clearer:

.animal { ... }
.cat { @extend .animal; ... }
.dog { @extend .animal; ... }

Would you rather write:

<div class="animal cat">...</div>

or:

<div class="cat">...</div>

Probably the second variant, since it avoids redundancy and makes your HTML more readable.

If you know object oriented programming, think of:

Their approach as inheritance: Cat class inherits Animal, and can have only zero or one base classes.

Your approach as interfaces: ISuccessful interface can be implemented by both Message class and TestResult; at the same time, Message can implement at the same time ISuccessful, IImportant and IMandatory.


问:
SQL scripts in TFS without putting them into solutions?
I am working on adding existing SQL scripts to version control. I have Team Foundation Server 2012 set up with Visual Studio 2008 and SQL Server Management Studio 2008 R2 with the MSSCCI. I am fairly new to TFS so I do not know if I am missing an easier way of doing things.

Managing SSIS projects and even SSRS projects makes perfect sense with TFS, as a project is needed to use or modify it in Visual Studio/BIDS. You add the project to source control then check in much like saving a solution/project normally on your local machine.

SQL scripts seem a little more cumbersome to use with TFS. It seems like I have to create SQL Server solutions to add any sort of sql script to my source control from SQL Server Management Studio (the add to source control functionality). While I can create new solutions in SSMS and add them to source control quite easily, it is a little annoying to have to add all of my existing scripts, which are simply .sql files, to new solutions.

Ideally I would like some way to just add the scripts to source control, be able to modify them in SSMS, then check them back in somewhat easily. If this were subversion, I could just commit and check in the single file in Windows Explorer and be done with it, managing and modifying the file however I want. Is there an equivalent in TFS to this?

答:
With TFS Power Tools, you can access your repository (do commits, add files to the repository, etc.) directly from Windows Explorer, just like you do with TortoiseSVN.

Then, you can add any file you want to TFS without adding it to the solution.


问:
When would you want two references to the same object?
In Java specifically, but likely in other languages as well: when would it be useful to have two references to the same object?

Example:

```<code>Dog a = new Dog();
Dob b = a;
</code>```

Is there a situation where this would be useful? Why would this be a preferred solution to using a whenever you want to interact with the object represented by a?

答:
In web applications, Object Relational Mappers can use lazy loading so that all references to the same database object (at least within the same thread) point to the same thing.

For instance, if you had two tables:

Dogs:

id | owner_id | name

1 | 1 | Bark Kent

Owners:

id | name

1 | me

2 | you

There are several approaches that your ORM can do if the following calls are made:

```<code>dog = Dog.find(1)  // fetch1
owner = Owner.find(1) // fetch2
superdog = owner.dogs.first() // fetch3
superdog.name = "Superdog"
superdog.save! // write1
owner = dog.owner // fetch4
owner.name = "Mark"
owner.save! // write2
dog.owner = Owner.find(2)
dog.save! // write3
</code>```

In the naive strategy, all calls to the models and the related references retrieve separate objects. Dog.find(), Owner.find(), owner.dogs, and dog.owner result in a database hit the first time around, after which they are saved to memory. And so:

database is fetched from at least 4 times

dog.owner is not the same as superdog.owner (fetched separately)

dog.name is not the same as superdog.name

dog and superdog both attempt to write to the same row and will overwrite each other's results: write3 will undo the name change in write1.

Without a reference, you have more fetches, use more memory, and introduce the possibility of overwriting earlier updates.

Suppose that your ORM knows that all references to row 1 of the dogs table should point to the same thing. Then:

fetch4 can be eliminated as there is an object in memory corresponding to Owner.find(1). fetch3 will still result in at least an index scan, as there might be other dogs owned by owner, but won't trigger a row retrieval.

dog and superdog point to the same object.

dog.name and superdog.name point to the same object.

dog.owner and superdog.owner point to the same object.

write3 does not overwrite the change in write1.

In other words, using references helps codify the principle of a single point of truth (at least within that thread) being the row in the database.

Body:
In web applications, Object Relational Mappers can use lazy loading so that all references to the same database object (at least within the same thread) point to the same thing.

For instance, if you had two tables:

Dogs:

id | owner_id | name

1 | 1 | Bark Kent

Owners:

id | name

1 | me

2 | you

There are several approaches that your ORM can do if the following calls are made:

dog = Dog.find(1)  // fetch1
owner = Owner.find(1) // fetch2
superdog = owner.dogs.first() // fetch3
superdog.name = "Superdog"
superdog.save! // write1
owner = dog.owner // fetch4
owner.name = "Mark"
owner.save! // write2
dog.owner = Owner.find(2)
dog.save! // write3

In the naive strategy, all calls to the models and the related references retrieve separate objects. Dog.find(), Owner.find(), owner.dogs, and dog.owner result in a database hit the first time around, after which they are saved to memory. And so:

database is fetched from at least 4 times

dog.owner is not the same as superdog.owner (fetched separately)

dog.name is not the same as superdog.name

dog and superdog both attempt to write to the same row and will overwrite each other's results: write3 will undo the name change in write1.

Without a reference, you have more fetches, use more memory, and introduce the possibility of overwriting earlier updates.

Suppose that your ORM knows that all references to row 1 of the dogs table should point to the same thing. Then:

fetch4 can be eliminated as there is an object in memory corresponding to Owner.find(1). fetch3 will still result in at least an index scan, as there might be other dogs owned by owner, but won't trigger a row retrieval.

dog and superdog point to the same object.

dog.name and superdog.name point to the same object.

dog.owner and superdog.owner point to the same object.

write3 does not overwrite the change in write1.

In other words, using references helps codify the principle of a single point of truth (at least within that thread) being the row in the database.


问:
Should an Animal be abstract or allow for instantiation to represent a "general" instance?
After a short discussion in the comments here I have come to wonder whether or not a baseclass like Animal in the traditional OOP example should be marked as abstract or not.

Personally I believe it should: there is no such thing as an "animal", it is merely a term that groups certain subtypes based on what they are. Any instance of an "animal" should be a subtype, a concrete example.

The comment that followed on this was

There most certainly is such a thing as an Animal. Or would you insist that Dog be broken down into Affenpinscher, IrishWolfhound, SiberianHusky, EnglishSetter, and 600 other breeds?

which is a fair remark but that is different from the original situation where the hierarchy was

And there are no subclasses of Dog in the first place. Should there have been then yes, Dog should be abstract because the tree includes more specific leafs for that specific type.

I can only assume that the reason you wouldn't make it a specific subtype is when you simply don't know it. I would instead add a "default" implementation of a dog to account for this so I can keep the Dog class itself abstract so there wouldn't be any ambiguity possible: you are forced to either create a specific dog or indicate that you don't know the type.

Furthermore it also allows you to create abstract methods that every dog should implement for themselves because they are dogtype-specific. By using a non-abstract class you can't do this and you'll have to remember to override each method in the subclasses.

In the above tree I would make Dog, Mammal and Animal abstract and allow the others to be instantiated.

The question boils down to this: should you be able to instantiate a class that exists to indicate a subspecies or should you defer the creation of such a "general" object to a subtype?

答:
Think about the scope of your business logic. If your application records sounds made by your pets, you may want to make a difference between dogs and cats; otherwise, when you call myCat.Bark, something may go wrong. On the other hand, an Irish wolfhound barks, and a Siberian husky barks as well, making this distinction irrelevant.

In this case, Dog and Cat would be actual classes, and Animal will be abstract.

On the other hand, if your application handles different breeds of dogs and cats, the difference between a Siberian husky and an English setter becomes relevant.

Now, Affenpinscher and IrishWolfhound will be actual classes, while Animal or Dog would be abstract.

The comment:

There most certainly is such a thing as an Animal. Or would you insist that Dog be broken down into Affenpinscher, IrishWolfhound, SiberianHusky, EnglishSetter, and 600 other breeds?

doesn't take scope in account. When all I want is to record the sounds of cats and dogs, business-wise, there is no such a thing as an instance of the Animal class: it's either a dog or a cat. If it's a dog, his breed doesn't matter; it may be a property of Dog class, but certainly not a part of the class hierarchy.


问:
Reading assembly useful for insights when writing C/C++?
While in most cases its not necessarily, recently I have taken to reading the generated assembly of my C code every so often, when I'm curious as to the kinds of optimizations my compiler is making. Especially for low level code or functions which are called many times.

Examples include:

Checking if a change to the C code has any impact on the generated code.

Checking if the same expression used twice is optimized into one, or if assigning a variable makes a difference.

Check for changes which may bloat-generated code-size.

Now this is not a perfect method by any means, its possible that some difference in the generated output is a red-herring, because of all sorts of internal logic & thresholds within the compiler, but its still interesting at times.

At this point while looking at the assembly I can lookup each command, but not really read the assembly (amd64 as it happens).

So my question is, has anyone found it useful to learn a certain amount of assembly to write better C code? (or at least get more insights into their code).

If so, how much is useful to know?

What kinds of issues did it help you resolve?

Note, the danger here is that one writes C code targeting the assembly which is very specific to the developers own system - any advantage may be lost on a different compiler or architecture, taking that into account, Im still interested in other developers experience

答:
It is not always useful (but sometimes it can help) to read the generated assembly code. Small tip when compiling with GCC, compile with

```<code> g++ -Wall -fverbose-asm -O2 -S somesourcefile.cc
</code>```

(the -fverbose-asm  gives more readable assembly code)

You may also look at intermediate representations. With g++  try passing -fdump-tree-all  (with your optimization flags). Beware, it gives hundreds of dump file.

BTw, you might find useful my GCC MELT plugin

At last, be aware that generally speaking compilers optimize better than human programmers do.

Body:
It is not always useful (but sometimes it can help) to read the generated assembly code. Small tip when compiling with GCC, compile with

 g++ -Wall -fverbose-asm -O2 -S somesourcefile.cc

(the -fverbose-asm  gives more readable assembly code)

You may also look at intermediate representations. With g++  try passing -fdump-tree-all  (with your optimization flags). Beware, it gives hundreds of dump file.

BTw, you might find useful my GCC MELT plugin

At last, be aware that generally speaking compilers optimize better than human programmers do.


答:
Sometimes you need to be able to read some assembly. For example when optimizing code through compiler instrumentation (see for example here). One needs to know what the costs of type casting, data alignment and so on, have for performance.

Also, there are some issues like different function call conventions (pascal vs stdcall) and other system specific issues which are of relevance. Again, it is useful to understand what the compiler does, what the different technologies provide (SSE, AVX,...) and debug some weird problems.

Once you are aware of such problems, you write better code:

data type awareness (do I need double/long, or does it suffice with float/int)

avoiding unnecessary casts

Usually one avoids such problems by defining its own types and sticking to conventions. You help the compiler do a better job, and it is also easier to understand/maintain.

Title: Reading assembly useful for insights when writing C/C++?

Body:
While in most cases its not necessarily, recently I have taken to reading the generated assembly of my C code every so often, when I'm curious as to the kinds of optimizations my compiler is making. Especially for low level code or functions which are called many times.

Examples include:

Checking if a change to the C code has any impact on the generated code.

Checking if the same expression used twice is optimized into one, or if assigning a variable makes a difference.

Check for changes which may bloat-generated code-size.

Now this is not a perfect method by any means, its possible that some difference in the generated output is a red-herring, because of all sorts of internal logic & thresholds within the compiler, but its still interesting at times.

At this point while looking at the assembly I can lookup each command, but not really read the assembly (amd64 as it happens).

So my question is, has anyone found it useful to learn a certain amount of assembly to write better C code? (or at least get more insights into their code).

If so, how much is useful to know?

What kinds of issues did it help you resolve?

Note, the danger here is that one writes C code targeting the assembly which is very specific to the developers own system - any advantage may be lost on a different compiler or architecture, taking that into account, Im still interested in other developers experience


问:
UI Applications and operations in background threads
I am not really sure about what is the best way to deal with operations executed in background threads in an application I am writing.

I am writing it in C# and I am following the MVVM design pattern. Some user actions are expensive and I'd like to run them in a background thread, which is a quite straightforward approach.

The worker thread then modifies my model, which notifies the ViewModel that something changed and finally the change gets propagated to the View.

My problem is that the chain of events triggered would cause the modification of the View from the background thread, when it is only allowed in the UI thread.

I know I can use the UI thread dispatcher but I am not really sure where (could the view-model be the right place?) so I'd like to know if you follow any design pattern to address this situation.

答:
In WinForms, I used InvokeIfRequired to solve this. I haven't worked much with WPF, but this guy writes about WPF equivalent of InvokeIfRequired:
http://blog.somecreativity.com/2008/01/10/wpf-equivalent-of-invokerequired/

Not much of an answer, but better than nothing, I hope :)


问:
What is the reasoning behind these design choices?
In ReactJS tutorial you are guided in the building of a commenting system. It's a very useful tutorial to understand ReactJS library, but there are some design choices I can't fully understand.

So let's start from the initial setup:

The system is composed of three components: CommentBox, CommentList, Comment and CommentForm.
The hierarchy is the following

```<code>CommentBox
    CommentList
        Comment
    CommentForm
</code>```

The tutorial then implements all the data-fetching logic in the CommentBox component, which then pass this data to CommentList that renders it in the DOM.

Q1: Why? Is an arbitrary choice or there is some reasoning behind?

Then, when the tutorial come to the logic of new comments submission, it states:

When a user submits a comment, we will need to refresh the list of comments to include the new one. It makes sense to do all of this logic in CommentBox since CommentBox owns the state that represents the list of comments.

Q2: Why CommentBox represents a list of comments when there is another component representing it (CommentList, as the name seems to suggest)?

Further, implementing the submission logic, the code handling the comment POST to the server is part of the CommentBox component, wrapped in a method which is passed to CommentForm as a callback. So when the CommentForm form is submitted, it calls this CommentBox function to perform the server request, while the rest of the logic is implemented in CommentForm's functions.

Q3: Why isn't all submission logic implemented in CommentForm?

EDIT: as I stated in a comment, " I already understood the application architecture and the concept of box. I'm arguing about the "individual implementation" details and why some choices are preferable than others"

答:
The way the hierarchy works is this:

Comment Box holds instances of a Comment List which holds and lists Comments and a Comment Form which is used to submit additional comments.

You thus have a container on a web page, a "box" in standard web jargon. This box then has two subcomponents, a List and a Form. The list holds elements that have been submitted and are being displayed while the form deals with items in the process of being entered for display.

How that display and submission works is a matter of individual implementation. You could remove the form and the box would still operate correctly. The box exists so that the list and the form are treated uniformly for display purposes.


答:
The CommentBox component owns the business logic. CommentList, Comment and CommentForm are visible representations of data (also known as views). The latter is more of a collection bucket for user inserted data.

When CommentBox owns all the actual logic it is easy to maintain since you won't have your logic scattered across multiple areas/objects. Instead it's packed into one.

Title: What is the reasoning behind these design choices?

Body:
In ReactJS tutorial you are guided in the building of a commenting system. It's a very useful tutorial to understand ReactJS library, but there are some design choices I can't fully understand.

So let's start from the initial setup:

The system is composed of three components: CommentBox, CommentList, Comment and CommentForm.
The hierarchy is the following

```<code>CommentBox
    CommentList
        Comment
    CommentForm
</code>```

The tutorial then implements all the data-fetching logic in the CommentBox component, which then pass this data to CommentList that renders it in the DOM.

Q1: Why? Is an arbitrary choice or there is some reasoning behind?

Then, when the tutorial come to the logic of new comments submission, it states:

When a user submits a comment, we will need to refresh the list of comments to include the new one. It makes sense to do all of this logic in CommentBox since CommentBox owns the state that represents the list of comments.

Q2: Why CommentBox represents a list of comments when there is another component representing it (CommentList, as the name seems to suggest)?

Further, implementing the submission logic, the code handling the comment POST to the server is part of the CommentBox component, wrapped in a method which is passed to CommentForm as a callback. So when the CommentForm form is submitted, it calls this CommentBox function to perform the server request, while the rest of the logic is implemented in CommentForm's functions.

Q3: Why isn't all submission logic implemented in CommentForm?

EDIT: as I stated in a comment, " I already understood the application architecture and the concept of box. I'm arguing about the "individual implementation" details and why some choices are preferable than others"


问:
What is this boolean law?
A friend of mine has shown sometime ago the name of the below boolean technique/law but I forget that name unfortunately. Does someone know what it's called?

example in C language:

```<code>!(a || b)
</code>```

It's a short to:

```<code>!a && !b
</code>```

答:
That's not a law - in fact it's quite wrong!

You want !a && !b. Then its one of De Morgan's laws.

Title: What is this boolean law?


答:
It is a crucial point, but IMHO is worth understanding.

All OO languages always make copies of references, and never copy an object 'invisibly'. It would be much harder to write programs if OO languages worked any other way. For example, functions, and methods, could never update an object. Java, and most OO languages would be almost impossible to use without significant added complexity.

An object in a program is supposed to have some meaning. For example it represents something specific in the real physical world. It usually makes sense to have many references to the same thing. For example, my home address can be given to many people and organisations, and that address always refers to the same physical location. So the first point is, objects often represent something which is specific, real, or concrete; and so being able to have many references to the same thing is extremely useful. Otherwise it would be harder to write programs.

Every time you pass a as an argument/parameter to another function e.g. calling

foo(Dog aDoggy);

or apply a method to a, the underlying program code makes a copy of the reference, to produce a second reference to the same object.

Further, if code with a copied reference is in a different thread, then both can be used concurrently to access the same object.

So in most useful programs, there will be multiple references to the same object, because that is the semantics of most OO programming languages.

Now, if we think about it, because passing by reference is the only mechanism available in many OO languages (C++ supports both), we might expect it to be the 'right' default behaviour.

IMHO, using references is the right default, for a couple of reasons:

It guarantees that the value of an object used in two different places is the same. Imagine putting an object into two different data structures (arrays, lists etc.), and doing some operations on an object that changes it. That could be a nightmare to debug. More importantly, it is the same object in both data structures, or the program has a bug.

You can happily refactor code into several functions, or merge the code from several functions into one, and the semantics do not change. If the language did not provide reference semantics, it would be even more complex to modify code.

There is also an efficiency argument; making copies of entire objects is less efficient than copying a reference. However, I think that misses the point. Multiple references to the same object make more sense, and are easier to use, because they match the semantics of the real physical world.

So, IMHO, it usually makes sense to have multiple references to the same object. In the unusual cases where that doesn't make sense in the context of an algorithm, most languages provide the ability to make a 'clone' or deep copy. However that is not the default.

I think people who argue that this should not be the default are using a language which does not provide automatic garbage collection. For example, old fashioned C++. The issue there is that they need to find a way to collect 'dead' objects and not reclaim objects that may still be required; having multiple references to the same object makes that hard.

I think, if C++ had sufficiently low-cost garbage collection, so that all referenced objects are garbage collected, then much of the objection goes away. There will still be some cases where reference semantics is not what is needed. However, in my experience, the people who can identify those situations are also usually capable of choosing the appropriate semantics anyway.

I believe there is some evidence that a large amount of the code in a C++ program is there to handle or mitigate garbage collection. However, writing, and maintaining that sort of 'infrastructural' code adds cost; it is there to make the language easier to use, or more robust. So, for example the Go language is designed with a focus on remediating some of the weaknesses of C++, and it has no choice except garbage collection.

This is of course irrelevant in the context of Java. It too was designed to be easy to use, and so has garbage collection. Hence having multiple references is the default semantics, and is relatively safe in the sense that objects aren't reclaimed while there is a reference to them. Of course they might be held onto by a data structure because the program doesn't properly tidy-up when it has really finished with an object.

So, circling back around to your question (with a bit of generalisation), when would you want more than one references to the same object? Pretty much in every situation I can think of. They are the default semantics of most languages parameter passing mechanism. I suggest that is because the default semantics of handling objects which exists in the real world pretty much has to be by reference ('cos the actual objects are out there).

Any other semantics would be harder to handle.

```<code>Dog a = new Dog("rover");  // initialise with name
DogList dl = new DogList()
dl.add(a)
...
a.setOwner("Mr Been")
</code>```

I suggest that the "rover" in dl should be the one effected by setOwner or programs get hard to write, understand, debug or modify. I think most programmers would be puzzled or dismayed otherwise.

later, the dog is sold:

```<code>soldDog = dl.lookupOwner("rover", "Mr Been")
soldDog.setOwner("Mr Mcgoo")
</code>```

This sort of processing is common and normal. So reference semantics are the default because it usually makes most sense.

Summary: It always makes sense to have multiple references to the same object.

Body:
It is a crucial point, but IMHO is worth understanding.

All OO languages always make copies of references, and never copy an object 'invisibly'. It would be much harder to write programs if OO languages worked any other way. For example, functions, and methods, could never update an object. Java, and most OO languages would be almost impossible to use without significant added complexity.

An object in a program is supposed to have some meaning. For example it represents something specific in the real physical world. It usually makes sense to have many references to the same thing. For example, my home address can be given to many people and organisations, and that address always refers to the same physical location. So the first point is, objects often represent something which is specific, real, or concrete; and so being able to have many references to the same thing is extremely useful. Otherwise it would be harder to write programs.

Every time you pass a as an argument/parameter to another function e.g. calling

foo(Dog aDoggy);

or apply a method to a, the underlying program code makes a copy of the reference, to produce a second reference to the same object.

Further, if code with a copied reference is in a different thread, then both can be used concurrently to access the same object.

So in most useful programs, there will be multiple references to the same object, because that is the semantics of most OO programming languages.

Now, if we think about it, because passing by reference is the only mechanism available in many OO languages (C++ supports both), we might expect it to be the 'right' default behaviour.

IMHO, using references is the right default, for a couple of reasons:

It guarantees that the value of an object used in two different places is the same. Imagine putting an object into two different data structures (arrays, lists etc.), and doing some operations on an object that changes it. That could be a nightmare to debug. More importantly, it is the same object in both data structures, or the program has a bug.

You can happily refactor code into several functions, or merge the code from several functions into one, and the semantics do not change. If the language did not provide reference semantics, it would be even more complex to modify code.

There is also an efficiency argument; making copies of entire objects is less efficient than copying a reference. However, I think that misses the point. Multiple references to the same object make more sense, and are easier to use, because they match the semantics of the real physical world.

So, IMHO, it usually makes sense to have multiple references to the same object. In the unusual cases where that doesn't make sense in the context of an algorithm, most languages provide the ability to make a 'clone' or deep copy. However that is not the default.

I think people who argue that this should not be the default are using a language which does not provide automatic garbage collection. For example, old fashioned C++. The issue there is that they need to find a way to collect 'dead' objects and not reclaim objects that may still be required; having multiple references to the same object makes that hard.

I think, if C++ had sufficiently low-cost garbage collection, so that all referenced objects are garbage collected, then much of the objection goes away. There will still be some cases where reference semantics is not what is needed. However, in my experience, the people who can identify those situations are also usually capable of choosing the appropriate semantics anyway.

I believe there is some evidence that a large amount of the code in a C++ program is there to handle or mitigate garbage collection. However, writing, and maintaining that sort of 'infrastructural' code adds cost; it is there to make the language easier to use, or more robust. So, for example the Go language is designed with a focus on remediating some of the weaknesses of C++, and it has no choice except garbage collection.

This is of course irrelevant in the context of Java. It too was designed to be easy to use, and so has garbage collection. Hence having multiple references is the default semantics, and is relatively safe in the sense that objects aren't reclaimed while there is a reference to them. Of course they might be held onto by a data structure because the program doesn't properly tidy-up when it has really finished with an object.

So, circling back around to your question (with a bit of generalisation), when would you want more than one references to the same object? Pretty much in every situation I can think of. They are the default semantics of most languages parameter passing mechanism. I suggest that is because the default semantics of handling objects which exists in the real world pretty much has to be by reference ('cos the actual objects are out there).

Any other semantics would be harder to handle.

Dog a = new Dog("rover");  // initialise with name
DogList dl = new DogList()
dl.add(a)
...
a.setOwner("Mr Been")

I suggest that the "rover" in dl should be the one effected by setOwner or programs get hard to write, understand, debug or modify. I think most programmers would be puzzled or dismayed otherwise.

later, the dog is sold:

soldDog = dl.lookupOwner("rover", "Mr Been")
soldDog.setOwner("Mr Mcgoo")

This sort of processing is common and normal. So reference semantics are the default because it usually makes most sense.

Summary: It always makes sense to have multiple references to the same object.


问:
Is Lambda Still Supported In Python?
Only one or two years ago, I remember reading Python constructs that would be removed from Python -- reduce was one of them -- and other constructs that would be emphasized like comprehensions and generators. I saw a very nice description of how Python could be made more functional here, and I was wondering on which list lambda appeared, supported or soon-not-to-be supported. </p>

答:
lambda is not deprecated, and will continue to be part of the language. Attempts have been made to find an alternative, but nothing fruitful ever came from that.

Quoting a post by Guido van Rossum in 2006:

After so many attempts to come up with an alternative for lambda,
  perhaps we should admit defeat. I've not had the time to follow the
  most recent rounds, but I propose that we keep lambda, so as to stop
  wasting everybody's talent and time on an impossible quest.

reduce() was moved to the functools module, so out of the built-in namespace, because its use in Python has always remained obscure. map() is still there though, as it was shown to be very useful still.

Title: Is Lambda Still Supported In Python?


答:
I think you've probably covered much of this already, but I'd give some further consideration to:

Low memory environment, e.g. mobile with small RAM or embedded devices. While your current customers may not need this, who knows if your library is suddenly in huge demand for engine management systems or home routers.

Highly concurrent environment, e.g. more threads and cores than you've ever considered possible. While you may have single-threaded and multi-threaded code paths as a compile option, it's possible that a massive number of threads may expose contention you didn't know you had.

Can I supply my own allocators? If not, what happens if I redefine malloc or operator new() to use a slab allocator or otherwise non-standard memory mechanism - can your code still cope?

Are you relying on initialisation order anywhere? Any statically-allocated variables?

Title: Processor architectures for testing C/C++ portability

Body:
Currently I'm working on a C/C++ code-base which is fairly portable, it can compile on most Unix like systems as well as MS-Windows (MSVC), using various popular compilers.

Previously I've found testing on different OS's and architectures can help find obscure bugs or bad assumptions.

I worry with the dominance of x86/amd64 our code-base may unknowingly become less portable.

Besides testing on a big-endian system (to find obvious errors with big/little endian), are there some architectures which have characteristics making them better for stress-testing software portability?

Examples of possible differences.

different endian.

different behavior when threading.

behavior of stack memory.

size of primitive types (char, short, int, long, float... etc).

alignment/padding of structs (which might hide errors).

difference in optimizations made by the compiler.

Are there some architectures which have more significant differences to x86/amd64, making them better candidates for exposing code portability issues? (and have C/C++ compilers and libraries - libc, libstdc++).

Asking because its a sizable time-investment to setup a new system, even if its emulated.

in case its not clear what I mean by processor-architectures, eg (x86, amd64, ia64, mips, risc, arm, m68k, ppc, itanium)

Note, I'm not proposing this as a primary way to discover bugs, we run multiple static analysis tools and tests, but in the past we have found errors in code because of differences in less common platforms (SGI, SPARC, Solaris, BSD's etc. However some of these systems are fading out of use)


答:
Unless each subtype adds distinct behavior, the differences will present themselves as attributes of the various instances, e.g., breed, color, weight, etc. I doubt very much you'll need to model a TwentyEightPoundBlackIrishWolfhound as a subclass.

If you're building a Twenty Questions game (Is it an animal, vegetable, or mineral?) a concrete Animal class might make sense.

Title: Should an Animal be abstract or allow for instantiation to represent a "general" instance?

Body:
After a short discussion in the comments here I have come to wonder whether or not a baseclass like Animal in the traditional OOP example should be marked as abstract or not.

Personally I believe it should: there is no such thing as an "animal", it is merely a term that groups certain subtypes based on what they are. Any instance of an "animal" should be a subtype, a concrete example.

The comment that followed on this was

There most certainly is such a thing as an Animal. Or would you insist that Dog be broken down into Affenpinscher, IrishWolfhound, SiberianHusky, EnglishSetter, and 600 other breeds?

which is a fair remark but that is different from the original situation where the hierarchy was

And there are no subclasses of Dog in the first place. Should there have been then yes, Dog should be abstract because the tree includes more specific leafs for that specific type.

I can only assume that the reason you wouldn't make it a specific subtype is when you simply don't know it. I would instead add a "default" implementation of a dog to account for this so I can keep the Dog class itself abstract so there wouldn't be any ambiguity possible: you are forced to either create a specific dog or indicate that you don't know the type.

Furthermore it also allows you to create abstract methods that every dog should implement for themselves because they are dogtype-specific. By using a non-abstract class you can't do this and you'll have to remember to override each method in the subclasses.

In the above tree I would make Dog, Mammal and Animal abstract and allow the others to be instantiated.

The question boils down to this: should you be able to instantiate a class that exists to indicate a subspecies or should you defer the creation of such a "general" object to a subtype?


问:
implementing dynamic query handler on historical data

Context:

I have historical data about property (house) sales collected from various sources in a centralized/cloud data source (assume info collection is handled by a third party)

Planning to develop an application  to query and retrieve data from this centralized data source

Example Queries:

Simple : for given XYZ post code, what is average house price for 3 bed room house?

Complex: What is estimated price for an house at "DD,Some Street,XYZ Post Code" (worked out from average values of historic data filtered by various characteristics of the house: house post code, no of bed rooms, total area, and other deeper insights like house building type, year of built, features)?

In addition to average price, the application should support other property info ** maximum, or minimum price..etc and trend (graph) on a selected property attribute over a period of time**. Hence, the queries should not enforce the search based on a primary key or few fixed fields

In other words, queries can be

What is the change in 3 Bed Room house price (irrespective of location) over last 30 days?

What kind of properties we can get for X price (irrespective of location or house type)

The challenge I have is identifying the domain (BI/ Data Analytical or DB Design or DB Query Interface or DW related or something else) this problem (dynamic query on historic data) belong to, so that I can do further exploration

My findings so far

I could be wrong on the following, so please correct me if you think so

I briefly read about BI/Data Analytics - I think it is heavy weight solution for my problem and has scalability issues.

DB Design - As I understand RDBMS works well if you know Data model at design time. I am expecting attributes about property or other entity (user) that am going to bring in, would evolve quickly. hence maintenance would be an issue. As I am going to have multiple users executing query at same time, performance would be a bottleneck

Other options like Graph DB (http://www.tinkerpop.com/) seems to be bit complex (they are good. but using those tools meant for generic purpose, make me think like assembly programming to solve my problem )

BigData related solution are to analyse data from multiple unrelated domains

So,
Any suggestion on the space this problem fit in ? (Especially if you have  design/implementation experience of back-end for property listing or similar portals)

答:
From my experience, your main problem is how to let the user specify the queries, rather than the data model, and thus old school relational may well work for you. Here's why.

If you are pulling data from many different sources, you will end up putting them through some sort of interface. As you do this, you will discover an underlying interface, meaning you will find the most appropriate way to present the data from  the various sources. (I've actually done this with about 12 different banks). Some of the sources will have extra data that has no counterpart in the other sources, while others will have an idiosyncratic way to show something. But eventually, you will settle upon something that covers most of your use cases. This is of course assuming there's a reason why you need a mixed set of sources.

The querying is the hard bit. If users are not supposed to learn SQL you will need to build something that constrains them but allows the complexity you want to provide.

As for performance, I don't see it being that big a problem. People searching for house price data are just reading some historic rows that won't change, easily scaled in any modern db. One major complication is if you were to try to fill in missing data based on some sort of proxy model. Then all bets are off, and your performance would depend on algo efficiency.


问:
Clarification about MVC Design pattern
I've been reading up on MVC and I had a doubt. The example where the Model, View and Controller are all individual classes whose objects are created and used to deploy the application in another class. A GUI I've designed treats the Model, View and Controller as separate classes and for the most part changes can be made to each without breaking the other .However these separate classes are referenced within the Controller (UI) class. I have no 4th class that calls and creates objects for the Model, View and Controller. Does my setup still follow the MVC design methodology? Thanks.</p>

答:
First of all, what you're talking about is a design pattern. What this means is you constrain yourself to only doing certain manipulations in order to make your application more readable and maintainable. Keeping things separate, with specific purposes for each component will help to this end.

As for your specific question, it sounds fine to me. You don't need a 4th class to call the parts, it's a question of whether the parts call what they're supposed to, and importantly don't call parts that they shouldn't.

Title: Clarification about MVC Design pattern


问:
What are the warning signs of impending doom to watch out for on a project?
Having worked on a failed project is one of the few things that most programmers have in common, regardless of language used, industry or experience.

These projects can be great learning experiences, soul-crushing disasters (or both!), and can occur for a multitude of reasons:

upper management change of heart

under-skilled / under-resourced team

emergence of superior competitor during dev cycle

over/under management

Once you've worked on a couple of such projects, is it possible to recognise at an early stage exactly when a project is doomed to fail?

For me, a big sign is having a hard & fast external deadline combined with feature creep. I've seen projects which were well planned out and proceeding right on schedule go horribly off the rails once the late feature requests started to roll in and get added to the final "deliverable". The proposers of these requests earned the nickname of Columbo, due to rarely leaving the room without asking for "just one more thing".

What are the warning signs you look out for that set off the alarm bells of impending doom in your head?

答:
Everyone is physically and mentally exhausted

Customers / users are clearly unhappy either about timescales or what they're seeing

The originally beautiful design now feels compromised

You're resigned to shipping with some relatively significant bugs that you'd really rather fix but aren't going to be able to

You're remaining pride is in the act of shipping rather than what you're shipping - closer to a survivor mentality than professional pride

The team is scared that there are certain things that don't work and are ignoring those sections and hoping for the best because they're scared of what might be in there

Everyone is convinced that they've gone above and beyond (and they're right)

People are showing signs of burnout (general pessimism, disinterest, anger)

(Cribbed from Jim McCarthy's Dynamics of Software Development).


问:
Recording unstructured suggestions and feedback in an issue tracker?
I'd like to advocate the use of issue-tracking software within an organisation that currently does not use it.

But there's one aspect of their situation for which I'm unsure of what to suggest: their projects frequently receive informal verbal feedback or casual comments in meetings or in passing from a wide group of interested parties, and all this information needs to be recorded.

Most of these messages are noise, but they're vital to record and share with developers for two reasons:

Good suggestions often come out of this process.

It can be necessary to have evidence of clients' comments when they forget previous instructions or change their mind.

Is this the sort of information that should be stored in an issue-tracking system, or kept apart in a separate solution? Can issue-tracking system have good support for this sort of unstructured information?

答:
Why not. As long as you can record the difference between 'feature requests' and 'bugs' (many times they're the same thing) then I don;t seem any problems with doing so.

Redmine, for example, comes out of the box with tracker types for bugs and features.

Your main issue is keeping a ticket updated with any conversation around the feature request - if there is extended discussion by people without access to the tracker itself, then you'll have to find a way to feed that into the ticket (either give them access, I know systems that can add notes to a ticket by email) or get an internal owner for each ticket to update it accordingly.

I've seen bugs that go on with extended discussion whether it is a bug or 'working by design', bugs where no-one quite knows what the problems is, and bugs where no-one can agree what kind of fix to put in. These are not particularly any different from your feature request.

As an extra, putting feature requests in the same ticket tracker means you can track the changes - from vague feature request to a set of design requirements to work instructions, to bugs rising from the implementation. That level of traceability is priceless.