答:
After all, we always end at managing hierarchical structures - be it a class hierarchy of a program, or the program itself built from different modules connecting you to an "internal world" (GUI, DB connection, data bound business logic, etc.). But this is philosophy, how should it work in your case?

You have nodes in this tree, each item is an "object instance"; while their behavior (where you can put them, the list of allowed child nodes, etc) is common for some sets, like "classes". Yes, this is just like a program code. If you know Java reflection enough, you can even use POJO classes and inheritance hierarchy to build this component, with an IoC container or a factory mechanism to build the actual instances. But I think you don't want that, because that is a heavy language hacking, so...

First, create a "class" object that will describe the behavior of the items. That contains class identifier, "field" names and the allowed types and count of items, etc.
Example: the "root" class is "Player Properties", have "Physical/Mental", "Medical", "Weapons" field. This type is "final": right now you don't want to have different player types. Hint: later on you can do it, using the same tools to handle "non-human monsters"... :-)

The "Medical" field is

"singleton": the player can't have multiple "Medical" information

the child type is fixed, only object of "Medical" type can be used here

required: when you create a player, it must have a "Medical" field

Contrary: Weapons member is not required, it should be created when the first weapon is added to your player. This means: when you "edit" your "object" (now the player), and want to allow adding a new item to it, you should not limit the selection by the actual properties of the instance (which now does not contain "Weapons"), but show all fields of the class definition, and lazily create the new field (child node) when first used. This will create an extensible environment. Later, you can add "Friends" field with multiple player... er... references (see later).

Follow the process with the actual "classes". It will help you refine your ideas, like: it seems better to separate weapon types (swords, daggers, bows, ...), handle ammo somehow (knowing that perhaps the player does NOT have a bow but can collect arrows, but using certain weapons require and decrement ammo, some of them can be found, others are lost...) under "Weapons" class: it is easier to survey, and also show if your player only carries that item or can use it as well (has the skills). On the other hand: you surely will change this structure later on, as you develop your game.

Create a globally available "class store" that you initialize when your game starts, and serve the class definitions when anyone refers to their name. The class def objects must be immutable in this case.

"Objects" are easier: they can be derived from the same root class that contains a reference to the class definition, and generic access to the fields as well. Perhaps use a HashMap to contain those children, identified by the field name. Remember: some of those fields contain a single object, others a set of objects. These instances are mutable of course.

Now for the interface. First, you should check the JTree tutorial..., and it now should be obvious. Each "object" can be represented by a DefaultMutableTreeNode, the "userObject" of the node should be your object (I think the toString() of that node is displayed as the label of the node, but you can create custom cell formatter). Whenever you open a node, you browse the fields of the object, and create child nodes under the parent (if you want to do it dynamically) - or browse the whole tree and build the TreeNode structure when you display the JTree (hint: there is a JTree constuctor with a TreeNode parameter).

When you select a node in the tree, you have the Object instance. By its class, you can display a proper editor panel, or a generic one generated by the class definition (like: tab panels with the fields, editors for the actual field by the field declaration: a button that creates a child of the proper type of lets you select one of the available classes; and editor fields for that instance, like weapon properties). After modifying the structure, you must refresh the tree itself - the TreeModel and its fire...change functions are your friends.

Looks nice? Or too complex? Well, this is a small fraction of the story. I have not talked about

the class definition hierarchy / or categorization. You better use one of them when you will support adding different classes to the same field (like different kinds of swords). A pro for categorization: a class can have multiple categories, not a fixed inheritance tree, a good stuff when you want to collect "all skills" of a player when spending the XP on skill improvements... :-)

persistence support: you have to create a generic solution to store the object hierarchy externally, like in a properties or JSON file. Use a human readable format, NO binary serialization, if you want to keep your brain in good shape.

instance storage: you will soon realize that the "world" of your game is better to be kept in one place. A certain sword is NOT a property of your player, but an entity in the world in your game (the player can lose it, someone can find it, etc), so many of these "objects" in your tree are actually REFERENCES to entities (while others, like the health of the player are really only attributes). You will have to separate the two types, have a global storage for the instances that can resolve references. This will also save you when serializing the game state, and multiple entities refer to the same other entity (like the "Location" of multiple players to the same temple).

(and to mention the real brain grinder: the similarity of the class storage and instance storage; the fact that type declaration can be object instances themselves in the same way as your program components, active windows, user sessions, etc. This is the land of maniacs like me.)

Anyway, I hope you can use something of this warmup session.

Title: How should I create a mutable, varied jtree with arbitrary/generic category nodes?

Body:
Please note: I don't want coding help here, I'm on Programmers for a reason. I want to improve my program planning/writing skills not (just) my understanding of Java.

I'm trying to figure out how to make a tree which has an arbitrary category system, based on the skills listed for this LARP game here. My previous attempt had a bool for whether a skill was also a category. Trying to code around that was messy. Drawing out my tree I noticed that only my 'leaves' were skills and I'd labeled the others as categories.

What I'm after is a way to make a tree which attempts to separate Model and View, and allow adding an arbitary type of child node (with a separate way of being edited/rendered) to an arbitrary parent.

N.B Everything here is bought as a skill, even where it seems like a property. The End-Users will see this as buying skills (which they do on paper atm) so should be presented as such, all on the same page.

Explanation of tree: The Tree is 'born' with a set of hard coded highest level categories (Weapons, Physical and Mental, Medical and more etc.). From this the user needs to be able to add a skill. Ultimately they want to add the 'One-handed Sword Specialisation' skill (not item) for instance. To do so you'd ideally click 'add' with Weapons selected and then select One-handed from a combobox node that appears on that child, then click add again and enter a name in a text field on that child node that appears. Then click add again to add/specify a 'level' or 'tier' for that leaf; first proficiency, then specialisation (for example).

Of course if you want to buy a different skill it's a completely different route to the leaf. You might not need a combo box at the same level down the tree as you did with the weapon example, and need some other logic behind it too. This is what I'm having trouble getting my head around let alone programming in; how to make a set of classes and not specify what order to attach them together in, but still have them all fit.

What is a good system for describing this sort of tree in code? All the other JTree examples I've seen have some predictable pattern, and mine doesn't. I don't want to have to code this all in 'literals', with long lists of what type (combo-box, text field etc) of children node should be allowed on what parent. Should I be using abstract classes? Interfaces?

How can I make this sort of cluster of objects extensible when I add in other skills not listed above that behave differently?

If there is not a good system to use, is there a good process for working out how to do this sort of thing?

The gears in my head are turning:

I always need to:

Check the parent

Provide options based on the parent

I'm begining to think becasue of this commonality I need some sort of abstract/interface skill class that defines/outlines common methods for skill and category. I can (hopefully) put rules and options in a database and read to-from there. The question is I think now, between an abstract or interface method and how to bes implement that.


问:
What is a "wrapper" program?
Where I work, employees use a third-party desktop program for their clients. This program saves data to a flat file. My colleague wants to write a Java program that uploads that flat file to a remote server, opens the desktop program when the flat file is downloaded from a Web site, and checks if the desktop program is running or not by looking at the Windows processes.

He keeps calling this helper/utility program a "wrapper." But it doesn't wrap anything! I tried to clear it up with him, but he said, "Well, I call it a wrapper." He now has everyone in the company calling it a "wrapper." What would you call it? I say that it's a helper program or utility program.

答: Sounds to me like a service, not a wrapper.  Services are these vigil little creatures that watch from afar for specific conditions to leap into the fray and handle some odd job.  I think service is technically a keyword reserved by Microsoft Windows, though so was the term 'thread' until it was used in a broader context.  So feel free to adapt that word.  At least it's more accurate than wrapper.</p>

ContentLicense: CC BY-SA 3.0

Title: What is a "wrapper" program?

ContentLicense: CC BY-SA 2.5


问:
Efficient way to find unique elements in a vector compared against multiple vectors
I am trying find the number of unique elements in a vector compared against multiple vectors using C++. The vectors are in sorted order and it can be of size 2,000,000.

Suppose I have,

```<code>v1: 5, 8, 13, 16, 20
v2: 2, 4, 6, 8
v3: 20
v4: 1, 2, 3, 4, 5, 6, 7
v5: 1, 3, 5, 7, 11, 13, 15
</code>```

The number of unique elements in v1 is 1 (i.e. number 16).

I tried two approaches.

Added vectors v2,v3,v4 and v5 into a vector of vector. For each element in v1, checked if the element is present in any of the other vectors.

Combined all the vectors v2,v3,v4 and v5 using merge sort into a single vector and compared it against v1 to find the unique elements.

Note: sample_vector = v1 and all_vectors_merged  contains v2,v3,v4,v5

```<code>//Method 1
unsigned int compute_unique_elements_1(vector<unsigned int> sample_vector,vector<vector<unsigned int> > all_vectors_merged)
{
    unsigned int duplicate = 0;
    for (unsigned int i = 0; i < sample_vector.size(); i++)
    {
        for (unsigned int j = 0; j < all_vectors_merged.size(); j++)
        {
            if (std::find(all_vectors_merged.at(j).begin(), all_vectors_merged.at(j).end(), sample_vector.at(i)) != all_vectors_merged.at(j).end())
            {
                duplicate++;
            }
        }
    }
    return sample_vector.size()-duplicate;
}

// Method 2
unsigned int compute_unique_elements_2(vector<unsigned int> sample_vector, vector<unsigned int> all_vectors_merged)
{
    unsigned int unique = 0;
    unsigned int i = 0, j = 0;
    while (i < sample_vector.size() && j < all_vectors_merged.size())
    {
        if (sample_vector.at(i) > all_vectors_merged.at(j))
        {
            j++;
        }
        else if (sample_vector.at(i) < all_vectors_merged.at(j))
        {
            i++;
            unique ++;
        }
        else
        {
            i++;
            j++;
        }
    }
    if (i < sample_vector.size())
    {
        unique += sample_vector.size() - i;
    }
    return unique;
}
</code>```

Of these two techniques, I see that Method 2 gives faster results.

1) Method 1: Is there a more efficient way to find the elements than running std::find on all the vectors for all the elements in v1.

2) Method 2: Extra overhead in comparing vectors v2,v3,v4,v5 and sorting them.

How can I do this in a better way?

[edit]
Vectors are in sorted order.

答:
It sounds like your data are strings and you used numeric values to more easily illustrate aspects of the problem like each vector being sorted, but having a lot of vectors to iterate across.

Dynamic programming may provide great opportunities to get big savings in efficiency.  Typically, dynamic programming executes part of your algorithm to generate a partial solution that can be reused in later iterations to save time.  There is a great version of the travelling salesman problem that does this for huge time savings (at the trade-off of needing huge amounts of memory).

If you know some things about your data, say that it is limited to integer values between 0 and 99, a simple approach would be to make a table of 100 booleans, parse the vectors once to mark the table to show which elements are present, then compare your test vector against the table.

If this were a search algorithm, and the input were a key of multiple strings and the sorted multiple vector data were keywords from documents, you could pick from many methods to collect the unique strings in a representation suitable for binary or other search.  Storage needed for this helper data structure will depend on how many unique strings are in the input data set.  It might be surprising for even data as varied as English text how few unique strings can be found in two million vectors of even a few hundred words each.


问:
Password Validation using regular expressions in html 5
this question may sound stupid, but no one has ever taught me this. I have an HTML input for a password field, and you can only log on with one specific password with JS. Could someone please give me a syntax on assigning a variable to document.getElementById(""); syntax or a different syntax? Thanks.</p>

答:
I guess you are trying to use password in your page. If the purpose of registration is to confirm that the person exists and has supplied a valid email address then at the first instance you should email them a random password rather than having them choose their own and use it immediately.

Here is a good article that walks you through JavaScript: Password Validation using regular expressions and HTML5.

In addition you may get a wealth of information about HTML DOM Password Object here.


问:
Why would one bother marking up properly and semantically?

Note that I (try) to mark up as semantically as possible because I like they way it looks and feels, but not because I'm aware of any other stunning advantages. The point of my question is to be able to educate others

Well, I've seen a lot of articles and tutorials which often state "Let's mark this up in the most semantic possible way".

But a strange thought came to me, why?

Why would one need (or want) to bother with the specific elements which convey the correct semantic meaning? Specifically, I'm referring to the new HTML5 elements, such as <time>, <output>, or <address>. Especially, if the page "works" (it renders nicely in all browsers).

Why would I want to use elements like <time> or <address>, where nothing at all (or at the worst case, a generic ) works just as nicely?

I'm asking this because I'm seeing a multitude of (very popular) websites (this one included) which does not follow these so-called best practices.

答:
The answer to that is simply to convey information and to structure your document.

When you use spans and divs, you document does not have a structure. There is no lists, no paragraphs, no tables, no hyperlinks. Nothing. There is really no point to choose HTML as a markup language and then ignore the vocabulary it offers to express and structure your content. Structure is the important word here btw. HTML is for structuring not displaying. That's what CSS is for.

If you markup your code semantically, you are giving human readers as well as machines a chance to understand the data inside your elements. If you use span and div elements all the way, you will not have this extra information and inferring them from the values alone might not be possible.

Likewise, if I want to scrape websites and only extract the headings to create Table of Contents for them, my spider would need to know what the heading are. It cannot do that without the appropriate elements.

Last but not least, if you use divs and spans only, you will have a hard time styling these with CSS. CSS Selectors work on the structure of your document and if that is mostly ambiguous structure, CSS rules get iffy to apply. How do you decide whether div div div really refers to table tr td or body ul li? You'd have to add classes and ids then, but then you are reinventing the wheel.

Also see the recommendation of the W3C

Using the appropriate semantic elements will make sure the structure is available to the user agent. This involves explicitly indicating the role that different units have in understanding the meaning of the content. The nature of a piece of content as a paragraph, header, emphasized text, table, etc. can all be indicated in this way. In some cases, the relationships between units of content should also be indicated, such as between headings and subheadings, or amongst the cells of a table. The user agent can then make the structure perceivable to the user, for example using a different visual presentation for different types of structures or by using a different voice or pitch in an auditory presentation.


答:
One reason you don't see a lot of sites following semantics perfectly is that there isn't a business case for it a lot of the time. If it drives sales (or a related category like exposure) then it is worth their money to write semantic HTML.

The best case I can make for semantic use of tags is when you are consuming or using HTML with a tool.  For instance, using semantic tags allows you to directly style elements without fear of adding or removing styles from something else.  Additionally, if you ever have to parse HTML using a scraper or anything of the like then you would certainly appreciate well-formed and semantic HTML as it becomes easier to write XPath and DOM queries to find what you need.

I should note that classes are not a direct replacement for semantic tags.  I have a reusable classes [error, information, warning] that convey different meanings and therefore styles based on the tag they are attached to.

Title: Why would one bother marking up properly and semantically?

Body:
Note that I (try) to mark up as semantically as possible because I like they way it looks and feels, but not because I'm aware of any other stunning advantages. The point of my question is to be able to educate others

Well, I've seen a lot of articles and tutorials which often state "Let's mark this up in the most semantic possible way".

But a strange thought came to me, why?

Why would one need (or want) to bother with the specific elements which convey the correct semantic meaning? Specifically, I'm referring to the new HTML5 elements, such as <time>, <output>, or <address>. Especially, if the page "works" (it renders nicely in all browsers).

Why would I want to use elements like <time> or <address>, where nothing at all (or at the worst case, a generic ) works just as nicely?

I'm asking this because I'm seeing a multitude of (very popular) websites (this one included) which does not follow these so-called best practices.


问:
License for Opensource project

Possible Duplicate:

  Licensing for hosted open source and 3rd party libraries

I am newbie in the open source community world. I am planning to develop a open source project, hosted on github. The project would be using other open source components like- NHibernate, FNH, Log4net, CommonLibrary, Autofac, Quartz.Net Scheduler etc etc

My questions are:

Would there be any restrictions on using above OSS components? for

example: I plan to use MIT license, but Quartz.Net Scheduler uses

Apache license, would there be any restrictions?

How do I get a license for my own project? Do I need to register my
project somewhere?

What is the best practice to mention credits to the OSS compoenents used?

Many thanks,

答:
How do I get a license for my own project? Do I need to register my project somewhere?

NO, you do not need an official registration to be done.

For open-source projects you just need a disclaimer saying which open-source licencing you have used and under which open-source licence are you providing the project.

Here you a good reference to look for Open Source Licenses.

Title: License for Opensource project


答:
Free Functionality

Properly using s means you can click the label to enter the text field. Many browsers will add logical default functionality to many tags per the official specification, meaning you can use fewer JavaScript plugins and write less code than a site made entirely out of
s and s.

Accessibility

Related to free functionality, semantics mean a lot to screen reader software. Text in front of an input field won't be read in quite the same way as a  will. Screen readers will ignore most of your CSS, so it's mostly up to the structure of your HTML.

Logical CSS

Why use a div #header when you can use a  and style that directly? Semantic tags make it easier to mark things up and make your style much more portable; if you have a certain style for strikeout and always use  elements the style is much more portable.  means the same thing to everyone, but everyone will name their .deletedText class differently.

It also helps keep everyone on the same page in large projects; no one enjoys learning other people's esoteric class naming conventions.

SEO

Search engines like Google have made increased use of semantic HTML and metadata. Google's Rich Snippets also use special metadata meant to convey semantic content.

Why it's not all that common

It takes work, and people are used to judging a website by how it looks and works. Often there's no accounting for semanticness because people who write the business case for apps don't understand it or why it's important.

It's very hard for non technical people to understand or evaluate HTML semantics.

If a website looks good and it appears to work, why fret? Many people may not even know there is anything more to it. Similar to accessibility, this tends to get ignored until someone on your team really understands this.

If you want semantic HTML to be a priority on your project, you need to present the case for it. Showing your team/boss how your website works in a screen reader is also a helpful tool.

Body:
Free Functionality

Properly using <label>s means you can click the label to enter the text field. Many browsers will add logical default functionality to many tags per the official specification, meaning you can use fewer JavaScript plugins and write less code than a site made entirely out of <div>s and <span>s.

Accessibility

Related to free functionality, semantics mean a lot to screen reader software. Text in front of an input field won't be read in quite the same way as a <label> will. Screen readers will ignore most of your CSS, so it's mostly up to the structure of your HTML.

Logical CSS

Why use a div #header when you can use a <header> and style that directly? Semantic tags make it easier to mark things up and make your style much more portable; if you have a certain style for strikeout and always use <del> elements the style is much more portable. <del> means the same thing to everyone, but everyone will name their .deletedText class differently.

It also helps keep everyone on the same page in large projects; no one enjoys learning other people's esoteric class naming conventions.

SEO

Search engines like Google have made increased use of semantic HTML and metadata. Google's Rich Snippets also use special metadata meant to convey semantic content.

Why it's not all that common

It takes work, and people are used to judging a website by how it looks and works. Often there's no accounting for semanticness because people who write the business case for apps don't understand it or why it's important.

It's very hard for non technical people to understand or evaluate HTML semantics.

If a website looks good and it appears to work, why fret? Many people may not even know there is anything more to it. Similar to accessibility, this tends to get ignored until someone on your team really understands this.

If you want semantic HTML to be a priority on your project, you need to present the case for it. Showing your team/boss how your website works in a screen reader is also a helpful tool.


答:
The short answer is “No good reason in practice.” Almost all arguments given in favor of “semantic” markup are just thoughts of what could or should happen, rather than something tangible. For example, search engines are often referred to, but there is no public evidence of their caring the least about time or output or address.

Indirectly, we can infer that they won’t care in the foreseeable future. The schema.org site, by some leading search engines, clearly favor a specific approach to “semantic markup” based on something completely different, namely microdata (itemscope and related attributes). And they actually do this mainly for large commercial or community sites.

Using span or div works more nicely than the HTML5 novelties, as the latter are not recognized by old versions of IE even for the purposes of styling. So you need some trickery to make them “work” even as container elements.

However, there are some “semantic” elements that have real meaning assigned to them by browsers, assistive software, or search engines. Using h1 for the main heading has always been good practice for such reasons. Using label for form field labels has real impact on usability and accessibility. And so on; see The pragmatic guide to HTML: Principles.


问:
How should I create a mutable, varied jtree with arbitrary/generic category nodes?
Please note: I don't want coding help here, I'm on Programmers for a reason. I want to improve my program planning/writing skills not (just) my understanding of Java.

I'm trying to figure out how to make a tree which has an arbitrary category system, based on the skills listed for this LARP game here. My previous attempt had a bool for whether a skill was also a category. Trying to code around that was messy. Drawing out my tree I noticed that only my 'leaves' were skills and I'd labeled the others as categories.

What I'm after is a way to make a tree which attempts to separate Model and View, and allow adding an arbitary type of child node (with a separate way of being edited/rendered) to an arbitrary parent.

N.B Everything here is bought as a skill, even where it seems like a property. The End-Users will see this as buying skills (which they do on paper atm) so should be presented as such, all on the same page.

Explanation of tree: The Tree is 'born' with a set of hard coded highest level categories (Weapons, Physical and Mental, Medical and more etc.). From this the user needs to be able to add a skill. Ultimately they want to add the 'One-handed Sword Specialisation' skill (not item) for instance. To do so you'd ideally click 'add' with Weapons selected and then select One-handed from a combobox node that appears on that child, then click add again and enter a name in a text field on that child node that appears. Then click add again to add/specify a 'level' or 'tier' for that leaf; first proficiency, then specialisation (for example).

Of course if you want to buy a different skill it's a completely different route to the leaf. You might not need a combo box at the same level down the tree as you did with the weapon example, and need some other logic behind it too. This is what I'm having trouble getting my head around let alone programming in; how to make a set of classes and not specify what order to attach them together in, but still have them all fit.

What is a good system for describing this sort of tree in code? All the other JTree examples I've seen have some predictable pattern, and mine doesn't. I don't want to have to code this all in 'literals', with long lists of what type (combo-box, text field etc) of children node should be allowed on what parent. Should I be using abstract classes? Interfaces?

How can I make this sort of cluster of objects extensible when I add in other skills not listed above that behave differently?

If there is not a good system to use, is there a good process for working out how to do this sort of thing?

The gears in my head are turning:

I always need to:

Check the parent

Provide options based on the parent

I'm begining to think becasue of this commonality I need some sort of abstract/interface skill class that defines/outlines common methods for skill and category. I can (hopefully) put rules and options in a database and read to-from there. The question is I think now, between an abstract or interface method and how to bes implement that.

答:
I'm not going to give you a long answer, but I've faced this kind of situation before and frankly, I gave up trying to use any existing data structure. I simply created my own object that could accept new parents and children similar to an XML Node.

In your case however, I think using an Xml Class will help. You can then have properties for each node that can tell you if a class is a skill and you can easily obtain parents and children of any node you want for use in a combo box or otherwise.

Also, I'd like to add you shouldn't run from the thought of having lots of texts/strings. Games usually involve AI, and AI usually involves lots of texts.


问:
Tabs versus spaces—what is the proper indentation character for everything, in every situation, ever?
The coding standards for the code hosted in drupal.org suggest to use two spaces to indent the code; other sites suggest to use tabs to indent the code.

What is the proper indentation character for everything, and in every situation? Please explain the answer you give.

答:
Some relevant opinions that may be of interest:

Guido says spaces

Joel says spaces

Atwood says spaces

Zawinski says spaces, sort of


问:
A question on nature of generated assembly in C++ and code Algebra
I wrote this code:

```<code>#include <iostream>
int main()
{
    int a;
    std::cin >> a;
    if(a*a== 3){
        std::cout << a;
    }
    return 0;
}
</code>```

On MSVC I turned ON all optimization flags. I expected that since a*a can never be 3, so compiler should not generate code for the section:

```<code>if(a*a== 3){
    std::cout << a;
}
</code>```

However it generated code for the section. I did not check GCC or LLVM/CLang.

What are the limits of expectation from a C++ compiler in these scenarios?

答:
I'm pretty sure there's a similar question over on StackOverflow with an excellent answer from Eric Lippert, but SO is down just now for some maintenance. I'll post a link when I find it, but my recollection is that Lippert's answer was along the lines of:

Yes, a compiler can check for that sort of thing, but since time and manpower are limited, that would mean not implementing some other feature. It just comes down to a matter of priorities.

Apologies to Eric Lippert if I got that wrong... Again, I'll post a link once SO is back.

Update: Here's the answer I was thinking of.


答:
1) Would there be any restrictions on using above OSS components? for
  example: I plan to use MIT license, but Quartz.Net Scheduler uses
  Apache license, would there be any restrictions?

Yes and No. It depends. Oh, and I'm not a lawyer :-)

This is a bit complicated. At least that's what I thought when I published my first OSS project.

Some of the existing licenses are very similar and it's no big deal to use them together in your project.

For example, there are several "permissive" licenses that basically say "do what you want, but don't sue me if something goes wrong".

For example, the MIT License and the BSD license are two of them, and IMO you can use them together.

On the other hand, the GPL license says that if you use a GPL-licensed component, your actual project must be under the GPL as well.

This prevents GPL-licensed components from being used in projects under most (if not all) of the other existing licenses.

If I'm not sure whether I can use a ABC-licensed library in my XYZ-licensed project or not, I just google something like "abc xyz compatible" (or actually "use abc license in xyz licensed project"), or search for it here on Stack Exchange.

You can find a lot of these questions here, for example:

Is BSD license compatible with Apache?

MIT app executing a GPL command

Call GPL software from non-GPL software

https://stackoverflow.com/questions/7800486/using-mit-license-in-an-apache-2-0-licensed-project

3) What is the best practice to mention credits to the OSS compoenents used?

That's how I do it:

What's the best way to acknowledge many FOSS sources in a single project?

Title: License for Opensource project

Body:
Possible Duplicate:

  Licensing for hosted open source and 3rd party libraries

I am newbie in the open source community world. I am planning to develop a open source project, hosted on github. The project would be using other open source components like- NHibernate, FNH, Log4net, CommonLibrary, Autofac, Quartz.Net Scheduler etc etc

My questions are:

Would there be any restrictions on using above OSS components? for

example: I plan to use MIT license, but Quartz.Net Scheduler uses

Apache license, would there be any restrictions?

How do I get a license for my own project? Do I need to register my
project somewhere?

What is the best practice to mention credits to the OSS compoenents used?

Many thanks,


答:
Simple Mutable JTree Example

Code (complied and tested with Java 7 to make above image):

```<code>import java.awt.*;
import javax.swing.*;
import javax.swing.tree.*;

public class SimpleTree extends JFrame {
    public static void main(String[] args) {
        new SimpleTree();
    }

    public SimpleTree() {
        super("Mutable Varied JTree");
        Container content = getContentPane();
        N root = new N("Root");

        N weapons = new N("Weapons").add(
            new N("One-handed").add(
                new N("Sword").add("Proficiency", "Specialization"),
                new N("Mace").add("Proficiency")),
            new N("Bow").add("Proficiency"));
        root.add(weapons);

        N phys = new N("Physical & Mental").add(
            new N("Life"),
            new N("Strength").add(
                "Double", "Triple", "Quadruple"));

        root.add(phys);
        N med = new N("Medical");
        med.add(new N("Bind Wounds"));
        med.add(new N("Set Broken Bones"));
        root.add(med);

        JTree tree = new JTree(root);
        content.add(new JScrollPane(tree), BorderLayout.CENTER);
        setSize(275, 300);
        setVisible(true);
    }

    private class N extends DefaultMutableTreeNode {
        public N(String s) { super(s); }
        public N add(String... strs) {
            for (String s : strs) {
                super.add(new N(s));
            }
            return this;
        }
        public N add(N... ns) {
            for (N n : ns) {
                super.add(n);
            }
            return this;
        }
    }
}
</code>```

Special Thanks to This JTree tutorial

Update: Discussion of Possible Solutions

There is a tutorial on making a dynamic tree, using buttons at the bottom of the frame to add/Remove/Clear nodes.

For combo-boxes and such, you want to take objects of the appropriate swing class and have them be something like a JComboBox that implements java.swing.tree.MutableTreeNode.  The Java Swing Tutorial has a list of controls.

You still need to make a user-interface element to let people choose which kind of node they want to add, and to edit the node.  If they add a combo-box, they will need to be able to define which choices the box will make available.

You need an underlying data model to save your data.  You could use the default serialization scheme built into all Java objects, but it's for prototyping only - it will break if you ever change your program code.  You will need to either use a database with either JDBC or JPA or you will need to write your own serialization routines (or use a library that handles serialization for you) using something like JSON or XML as a storage format.

Update: Proposed Solution with Project Overview

The simplest solution might be to forget about databases and come up with the XML expression of the data first, then edit the XML file and just display the results as a JTree without special combo-boxes or anything.  I think this is what Chibueze Opata was suggesting with his answer.  A partial XML representation of this tree might look like the following:

```<code><folder name="Physical & Mental">
    <int name="Life">12</int>
    <drop-down name="Strength">
        <option name="Single" />
        <option name="Double" />
        <option name="Triple" />
        <option name="Quadruple" />
    </drop-down>
</folder>
<folder name="Medical">
    <text name="Bind Wounds" />
    <text name="Set Broken Bones" />
</folder>
</code>```

Here are some potential milestones for you:

Make up an XML or JSON data format, then write a program that reads a file of that format and displays it as a JTree without any combo-boxes, just folders and files.

Add swing controls to the JTree display

Expand your program to write that same file

Create a user interface so the user can add and edit nodes using the GUI

Make sure to save a backup of your program each time it works at the end of each milestone.  A source control system installed on another machine is ideal for this.  You can use github, or sourceforge, or some other public source control if you don't mind sharing your code and don't want to set up a server with source control on it.

Any of these solutions is a lot of work, and definitely bigger than a beginner project.  It means you will spend much more time learning Java Swing and XML or JSON than playing your LARP which is why I first explored options of making do with existing tools.  But the best way to learn anything is the way you are most motivated to learn.  So this may be a perfect project for you.

I hope that helps.

Body:
Simple Mutable JTree Example

Code (complied and tested with Java 7 to make above image):

import java.awt.*;
import javax.swing.*;
import javax.swing.tree.*;

public class SimpleTree extends JFrame {
    public static void main(String[] args) {
        new SimpleTree();
    }

    public SimpleTree() {
        super("Mutable Varied JTree");
        Container content = getContentPane();
        N root = new N("Root");

        N weapons = new N("Weapons").add(
            new N("One-handed").add(
                new N("Sword").add("Proficiency", "Specialization"),
                new N("Mace").add("Proficiency")),
            new N("Bow").add("Proficiency"));
        root.add(weapons);

        N phys = new N("Physical & Mental").add(
            new N("Life"),
            new N("Strength").add(
                "Double", "Triple", "Quadruple"));

        root.add(phys);
        N med = new N("Medical");
        med.add(new N("Bind Wounds"));
        med.add(new N("Set Broken Bones"));
        root.add(med);

        JTree tree = new JTree(root);
        content.add(new JScrollPane(tree), BorderLayout.CENTER);
        setSize(275, 300);
        setVisible(true);
    }

    private class N extends DefaultMutableTreeNode {
        public N(String s) { super(s); }
        public N add(String... strs) {
            for (String s : strs) {
                super.add(new N(s));
            }
            return this;
        }
        public N add(N... ns) {
            for (N n : ns) {
                super.add(n);
            }
            return this;
        }
    }
}

Special Thanks to This JTree tutorial

Update: Discussion of Possible Solutions

There is a tutorial on making a dynamic tree, using buttons at the bottom of the frame to add/Remove/Clear nodes.

For combo-boxes and such, you want to take objects of the appropriate swing class and have them be something like a JComboBox that implements java.swing.tree.MutableTreeNode.  The Java Swing Tutorial has a list of controls.

You still need to make a user-interface element to let people choose which kind of node they want to add, and to edit the node.  If they add a combo-box, they will need to be able to define which choices the box will make available.

You need an underlying data model to save your data.  You could use the default serialization scheme built into all Java objects, but it's for prototyping only - it will break if you ever change your program code.  You will need to either use a database with either JDBC or JPA or you will need to write your own serialization routines (or use a library that handles serialization for you) using something like JSON or XML as a storage format.

Update: Proposed Solution with Project Overview

The simplest solution might be to forget about databases and come up with the XML expression of the data first, then edit the XML file and just display the results as a JTree without special combo-boxes or anything.  I think this is what Chibueze Opata was suggesting with his answer.  A partial XML representation of this tree might look like the following:

<folder name="Physical &amp; Mental">
    <int name="Life">12</int>
    <drop-down name="Strength">
        <option name="Single" />
        <option name="Double" />
        <option name="Triple" />
        <option name="Quadruple" />
    </drop-down>
</folder>
<folder name="Medical">
    <text name="Bind Wounds" />
    <text name="Set Broken Bones" />
</folder>

Here are some potential milestones for you:

Make up an XML or JSON data format, then write a program that reads a file of that format and displays it as a JTree without any combo-boxes, just folders and files.

Add swing controls to the JTree display

Expand your program to write that same file

Create a user interface so the user can add and edit nodes using the GUI

Make sure to save a backup of your program each time it works at the end of each milestone.  A source control system installed on another machine is ideal for this.  You can use github, or sourceforge, or some other public source control if you don't mind sharing your code and don't want to set up a server with source control on it.

Any of these solutions is a lot of work, and definitely bigger than a beginner project.  It means you will spend much more time learning Java Swing and XML or JSON than playing your LARP which is why I first explored options of making do with existing tools.  But the best way to learn anything is the way you are most motivated to learn.  So this may be a perfect project for you.

I hope that helps.


答:
As there are sorted, you can use standard std::set_difference function:

```<code>unsigned int compute_uniqute_elements(vector<unsigned int> sample_vector, vector<unsigned int> merged_vectors)
{
    vector<unsigned int> difference;
    vector<unsigned int>::iterator it;
    it = std::set_difference(sample_vector.begin(), sample_vector.end(), it->begin(), it->end(), difference.begin());

    return std::distance(difference.begin(), it);
}
</code>```

Title: Efficient way to find unique elements in a vector compared against multiple vectors

Body:
I am trying find the number of unique elements in a vector compared against multiple vectors using C++. The vectors are in sorted order and it can be of size 2,000,000.

Suppose I have,

```<code>v1: 5, 8, 13, 16, 20
v2: 2, 4, 6, 8
v3: 20
v4: 1, 2, 3, 4, 5, 6, 7
v5: 1, 3, 5, 7, 11, 13, 15
</code>```

The number of unique elements in v1 is 1 (i.e. number 16).

I tried two approaches.

Added vectors v2,v3,v4 and v5 into a vector of vector. For each element in v1, checked if the element is present in any of the other vectors.

Combined all the vectors v2,v3,v4 and v5 using merge sort into a single vector and compared it against v1 to find the unique elements.

Note: sample_vector = v1 and all_vectors_merged  contains v2,v3,v4,v5

```<code>//Method 1
unsigned int compute_unique_elements_1(vector<unsigned int> sample_vector,vector<vector<unsigned int> > all_vectors_merged)
{
    unsigned int duplicate = 0;
    for (unsigned int i = 0; i < sample_vector.size(); i++)
    {
        for (unsigned int j = 0; j < all_vectors_merged.size(); j++)
        {
            if (std::find(all_vectors_merged.at(j).begin(), all_vectors_merged.at(j).end(), sample_vector.at(i)) != all_vectors_merged.at(j).end())
            {
                duplicate++;
            }
        }
    }
    return sample_vector.size()-duplicate;
}

// Method 2
unsigned int compute_unique_elements_2(vector<unsigned int> sample_vector, vector<unsigned int> all_vectors_merged)
{
    unsigned int unique = 0;
    unsigned int i = 0, j = 0;
    while (i < sample_vector.size() && j < all_vectors_merged.size())
    {
        if (sample_vector.at(i) > all_vectors_merged.at(j))
        {
            j++;
        }
        else if (sample_vector.at(i) < all_vectors_merged.at(j))
        {
            i++;
            unique ++;
        }
        else
        {
            i++;
            j++;
        }
    }
    if (i < sample_vector.size())
    {
        unique += sample_vector.size() - i;
    }
    return unique;
}
</code>```

Of these two techniques, I see that Method 2 gives faster results.

1) Method 1: Is there a more efficient way to find the elements than running std::find on all the vectors for all the elements in v1.

2) Method 2: Extra overhead in comparing vectors v2,v3,v4,v5 and sorting them.

How can I do this in a better way?

[edit]
Vectors are in sorted order.

Body:
As there are sorted, you can use standard std::set_difference function:

unsigned int compute_uniqute_elements(vector<unsigned int> sample_vector, vector<unsigned int> merged_vectors)
{
    vector<unsigned int> difference;
    vector<unsigned int>::iterator it;
    it = std::set_difference(sample_vector.begin(), sample_vector.end(), it->begin(), it->end(), difference.begin());

    return std::distance(difference.begin(), it);
}


问:
How can I implement a database TableView like thing in C++?
How can I implement a TableView like thing in C++?

I want to emulating a tiny relation database like thing in C++. I have data tables, and I want to transform it somehow, so I need a TableView like class. I want filtering, sorting, freely add and remove items and transforming (ex. view as UPPERCASE and so on). The whole thing is inside a GUI application, so datatables and views are attached to a GUI (or HTML or something).

So how can I identify an item in the view? How can I signal it when the table is changed? Is there some design pattern for this?

Here is a simple table, and a simple data item:

```<code>#include <string>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/random_access_index.hpp>

using boost::multi_index_container;
using namespace boost::multi_index;

struct Data
{
  Data() {}
  int id;
  std::string name;
};

struct row{};
struct id{};
struct name{};

typedef boost::multi_index_container<
  Data,
  indexed_by<
    random_access<tag<row> >,
    ordered_unique<tag<id>, member<Data, int, &Data::id> >,
    ordered_unique<tag<name>, member<Data, std::string, &Data::name> >
  >
> TDataTable;

class DataTable
{
public:
  typedef Data item_type;
  typedef TDataTable::value_type value_type;
  typedef TDataTable::const_reference const_reference;
  typedef TDataTable::index<row>::type TRowIndex;
  typedef TDataTable::index<id>::type TIdIndex;
  typedef TDataTable::index<name>::type TNameIndex;
  typedef TRowIndex::iterator iterator;

  DataTable() :
    row_index(rule_table.get<row>()),
    id_index(rule_table.get<id>()),
    name_index(rule_table.get<name>()),
    row_index_writeable(rule_table.get<row>())
  {
  }

  TDataTable::const_reference operator[](TDataTable::size_type n) const
  { return rule_table[n]; }

  std::pair<iterator,bool> push_back(const value_type& x)
  { return row_index_writeable.push_back(x); }

  iterator erase(iterator position)
  { return row_index_writeable.erase(position); }

  bool replace(iterator position,const value_type& x)
  { return row_index_writeable.replace(position, x); }

  template<typename InputIterator> void rearrange(InputIterator first)
  { return row_index_writeable.rearrange(first); }

  void print_table() const;

  unsigned size() const
  { return row_index.size(); }

  TDataTable rule_table;
  const TRowIndex& row_index;
  const TIdIndex& id_index;
  const TNameIndex& name_index;
private:
  TRowIndex& row_index_writeable;
};

class DataTableView
{
  DataTableView(const DataTable& source_table) {}
  // How can I implement this?
  // I want filtering, sorting, signaling upper GUI layer, and sorting, and ...
};

int main()
{
  Data data1;
  data1.id = 1;
  data1.name = "name1";
  Data data2;
  data2.id = 2;
  data2.name = "name2";

  DataTable table;
  table.push_back(data1);
  DataTable::iterator it1 = table.row_index.iterator_to(table[0]);
  table.erase(it1);
  table.push_back(data1);
  Data new_data(table[0]);
  new_data.name = "new_name";
  table.replace(table.row_index.iterator_to(table[0]), new_data);
  for (unsigned i = 0; i < table.size(); ++i)
    std::cout << table[i].name << std::endl;

#if 0
  // using scenarios:
  DataTableView table_view(table);
  table_view.fill_from_source(); // synchronization with source
  table_view.remove(data_item1); // remove item from view
  table_view.add(data_item2); // add item from source table
  table_view.filter(filterfunc); // filtering
  table_view.sort(sortfunc); // sorting

  // modifying from source_able, hot to signal the table_view?
  // FYI: Table view is atteched to a GUI item
  table.erase(data);
  table.replace(data);
#endif

  return 0;
}
</code>```

答: If your using the QT SDK you can use the QTableView. You could also look at the source code for QTableView to get an idea how to build your own TableView class.</p>


问:
skills that can't be outsourced- web development related
I never know where it's acceptable to post something like this, so please forgive if it's in the wrong place. I'm very interested in going further in to web development; I know a bit of javascript, a bit of php, and so forth, but I'm now seeing these services that will go from psd to wordpress for 200 bucks and I'm wondering how the hell is anyone able to compete with this? So I'm wondering if those more knowledgeable than me could tell me what areas are the least likely to be able to be outsourced, for 5 bucks to some kid in Uzbekistan( no offense to that kid).. do you think it's on the database management side, or maybe app development? ideas appreciated. </p>

答:
I think all purely technology related skills have potential to be outsourced. However, business knowledge of how complex applications should work is not easily outsourced.

Thus, creating code is easily outsource-able but business domain related knowledge is not.

In other words, try to give more importance to the business and data flow side of the application. People who know the business flow side of applications with all rules are the ones who are hardly replaced, even if there are tons of documentation.

This is true for complex applications with hundreds of business rules.


问:
Stop myself from over-complicating applications
Recently I worked on a fairly large project involving C# and MVVM. This application had around 160 projects in the solutions each seprarated into their own layers. As I have been working on this application for almost a year, building it from scratch as part of a team, I am now coming off that project and onto smaller more trivial projects.

As I was beginning to develop a small in-house tool I found myself trying to mimic the larger applications structure and layering but in the end I just had a simple application with several DLLs which I know I wouldn't have done if I had not worked on that larger application before.

I am just wondering if there are any techniques I can utilise to stop myself from turning a "code-behind" style trivial application into a full blown MVVM application?

Or should I continue developing as I am and try to keep the unnecessary fluff out of the project?

答:
I am just wondering if there are any techniques I can utilise to stop myself from turning a "code-behind" style trivial application into a full blown MVVM application?

Yes you can easily stop yourself from over-engineering the application. Always look for the simple solutions over complex, and remember KISS and YAGNI principles.


问:
Legally, can I re reuse code for different customers?
The company I work for develops custom factory automation applications for multiple customers. Even though each application is custom, they contain common code which is re-used across projects.

One of the customers is now looking for the source code to their application, which  has caused a major storm in the company. Management have decided that we can't give them the source to the shared components as they are used by other customers. I've been asked to modify the shared components 'enough' so as they aren't common.

So my questions are:

1) Legally, should there be any problem with re-using common components for different customer?

2) If I really need to modify the common components, then how much is 'enough' ? (I know this sucks, but I either do this or hand in my notice).

Oh yeah, and my company has no license in place with any of these customers.

答:
This sound to me as a lacking policy of your company with customers. In another words, your agreement with customer should indicate who once the copyright of the product and the source.

In most cases, software contacts do indicate that provided software is build on COTs and some proprietary systems. Thus the common components which may also referred as base engine is never provided back to customer as a source-code. However, customer business specific customization and development code is usually provided back to the customers.

1) Legally, should there be any problem with re-using common components for different customer?

There might be issues if not indicated in the agreement contract. At least it is a strong case to be considered in the US. I would advice to get a legal consultation from lawyer. It would eliminate all law suits that your company may face with.

2) If I really need to modify the common components, then how much is 'enough' ? (I know this sucks, but I either do this or hand in my notice).

I would try to separate the base/core engine functionality from the rest custom implementation in first place. Afterwords, i would deliver only that customized code a s source code, and base engine as a core dll.


问:
Purpose of NOP instruction and align statement in x86 assembly
It has been a year or so since I last took an assembly class. In that class, we were using MASM with the Irvine libraries to make it easier to program in.

After we'd gone through most of the instructions, he said that the NOP instruction essentially did nothing and not to worry about using it. Anyway, it was about midterm and he has some example code that wouldn't run properly, so he told us to add a NOP instruction and it worked fine. I asked I'm after class why and what it actually did, and he said he didn't know.

Anybody know?

答: at least one reason to use NOP is alignment. x86 processors read data from main memory in quite big blocks, and start of block to read is always aligned, so if one has block of code, that will be read much, this block should be aligned. This will result in little speedup. </p>


问:
What does it mean “you can pick K to be whatever you want” in Excess-N notation?
I prefer providing an example to explain the following paragraph:

However, since excess K representation using N bits has two parameters, K and N, you can pick K to be whatever you want. You can have more positive numbers than negative, not include zero, and so forth.

答:
It means you can pick an arbitrary value for K. In Excess-K notation, you take your base 10 number and add K before converting to base 2.

For instance:

```
To represent the numbers -255 to -128,  N = 7,  K = 255  -- all numbers are negative
To represent the numbers -100 to 27,    N = 7,  K = 100  -- more numbers are negative
To represent the numbers -4 to 123,     N = 7,  K = 4    -- more numbers are positive
To represent the numbers 42 to 169,     N = 7,  K = -42  -- all numbers are positive
```

The usefulness of Excess-K notation is that you can sort the numbers as if they were unsigned ints, unlike in twos-compliment where the negative numbers are sorted as bigger than positive numbers. This is used, along with other parts of the the IEEE Floating Point specification, so that you can interchange between (signed) ints and floats easily.

Interestingly, incrementing a float as if it were an int moves it away from zero to the closest number representable by a float, because adjacent floats have adjacent integer representations if they have the same sign. You can look at This post and others by the same author for more interesting floating point information.

Body:
It means you can pick an arbitrary value for K. In Excess-K notation, you take your base 10 number and add K before converting to base 2.

For instance:

To represent the numbers -255 to -128,  N = 7,  K = 255  -- all numbers are negative
To represent the numbers -100 to 27,    N = 7,  K = 100  -- more numbers are negative
To represent the numbers -4 to 123,     N = 7,  K = 4    -- more numbers are positive
To represent the numbers 42 to 169,     N = 7,  K = -42  -- all numbers are positive

The usefulness of Excess-K notation is that you can sort the numbers as if they were unsigned ints, unlike in twos-compliment where the negative numbers are sorted as bigger than positive numbers. This is used, along with other parts of the the IEEE Floating Point specification, so that you can interchange between (signed) ints and floats easily.

Interestingly, incrementing a float as if it were an int moves it away from zero to the closest number representable by a float, because adjacent floats have adjacent integer representations if they have the same sign. You can look at This post and others by the same author for more interesting floating point information.


问:
Best thing to do about projects supporting multiple versions of Visual Studio?
I have an open source project that works on .Net 2.0 and up. The thing is though that I prefer to use Visual Studio 2012, which forces the solution and project files to only work with VS2010/2012.

What exactly should I do? I don't want for my users to have to create a solution from scratch if they don't have access to VS2010, but yet, I also don't want to attempt to keep 3 different project files in sync(VS2005, VS2008, and VS2010/2012)

What is the usual solution for this?

答:
What is the usual solution for this?

Try to split your source project to versions. (v1.0- VS08 , v2.0 - VS12). You may still keep .NET 2.0 compatible code with VS2008, and name it as version v1.0, while having your next version be compatible with .NET 5.0 framework and named as v3.0.


答:
Soft skills like communication and diplomacy are what you are looking for. Technical skills are well and good but in order to be out-source proofed to any real degree, you need to provably easy enough to work with that no off-shore agency could replace precisely whatever it is you do in totality.

In short, you should strive to be more quality than quantity. Your qualities should be obvious but difficult to measure allowing those that are to speak for you from a hard data standpoint but at the same time adding that edge of being unquantifiably good in many areas.

Learning to talk to designers and UX people would be your best bet in terms of web development. Understanding usability and design and how to facilitate and work into that from the technical side are very valuable skills and highly unlikely to be truly outsourceable.

Title: skills that can't be outsourced- web development related

Body: I never know where it's acceptable to post something like this, so please forgive if it's in the wrong place. I'm very interested in going further in to web development; I know a bit of javascript, a bit of php, and so forth, but I'm now seeing these services that will go from psd to wordpress for 200 bucks and I'm wondering how the hell is anyone able to compete with this? So I'm wondering if those more knowledgeable than me could tell me what areas are the least likely to be able to be outsourced, for 5 bucks to some kid in Uzbekistan( no offense to that kid).. do you think it's on the database management side, or maybe app development? ideas appreciated. </p>


答:
IMO here are the activities which I've seen outsourced which have met with varying degrees of success:

Grunt programming (i.e. thrashing out 100's of screens, validation rules, data access layer etc)

Unit Testing of the above.

UI Test Automatation (robots / Selenium etc)

Tasks like SEO, backlinking etc

Data capture

Unit tests and grunt coding obviously can't be outsourced to the same partner :).
So you want to move through the above skills as quickly as possible, IMO. Another reason not to get stuck in the above activities for too long is that CASE tools, code generators, scaffolding etc make it easier and easier to automate the above.
The benefits of outsourcing the above isn't necessarily just cost, but also turnaround time - many offshore partners will work 24x7. (Time is important when you consider that your own staff can sit idle waiting for devs to complete work)

What I've not seen outsourced with repeatable success, are areas which involve high levels of technical risk, and those which involve direct engagement with customer, i.e. This is where you want to get yourself ASAP.

Sales / Account Management

Project Management

Enterprise / Business Requirements Analysis (Overall backlog)

Scoping / Deliverables of the current iteration / sprint (Specification)

Architecture of the System

Framework / Design of the system

Technically difficult or risky bits, e.g. integration, core business processes, or performance sensitive components

i.e. the outsourcing partner is provided with the v0.1 'thread' of an app or system containing an example of each 'layer' of code, and the cookie cutting is done offshore.

The obvious problem / consequence to outsourcing 'grunt' work is that our local junior devs don't get enough repetitive development or unit testing experience to build their skills sufficiently to become seniors (and no doubt our offshore partners are building their senior skills)


问:
How can we unify business goals and technical goals?

Some background

I work at a small startup: 4 devs, 1 designer, and 2 non-technical co-founders, one who provides funding, and the other who handles day-to-day management and sales. Our company produces mobile apps for target industries, and we've gotten a lot of lucky breaks lately. The outlook is good, and we're confident we can make this thing work.

One reason is our product development team. Everyone on the team is passionate, driven, and has a great sense of what makes an awesome product. As a result, we've built some beautiful applications that we're all proud of.

The other reason is the co-founders. Both have a brilliant business sense (one actually founded a multi-million dollar company already), and they have close ties in many of the industries we're trying to penetrate. Consequently, they've brought in some great business and continue to keep jobs in the pipeline.

The problem

The problem we can't seem to shake is how to bring these two awesome advantages together. On the business side, there is a huge pressure to deliver as fast as possible as much as possible, whereas on the development side there is pressure to take your time, come up with the right solution, and pay attention to all the details.

Lately these two sides have been butting heads a lot. Developers are demanding quality while managers are demanding quantity.

How can we handle this? Both sides are correct. We can't survive as a company if we build terrible applications, but we also can't survive if we don't sell enough. So how should we go about making compromises?

Things we've done with little or no success:

Work more (well, it did result in better quality and faster delivery, but the dev team has never been more stressed out before)

Charge more (as a startup, we don't yet have the credibility to justify higher prices, so no one is willing to pay)

Extend deadlines (if we charge the same, but take longer, we'll end up losing money)

Things we've done with some success:

Sacrifice pay to cut costs (everyone, from devs to management, is paid less than they could be making elsewhere. In return, however, we all have creative input and more flexibility and freedom, a typical startup trade off)

Standardize project management (we recently started adhering to agile/scrum principles so we can base deadlines on actual velocity, not just arbitrary guesses)

Hire more people (we used to have 2 developers and no designers, which really limited our bandwidth. However, as a startup we can only afford to hire a few extra people.)

Is there anything we're missing or doing wrong? How is this handled at successful companies?

Thanks in advance for any feedback :)

答:
Are you or your coworkers familiar with The Lean Startup movement? If management is demanding quantity that raises a red flag - because your customers don't want products with lots of features. They want products with those features they really care about. Building features customers don't care about is waste. And development has to be smart about quality. There is a right time to focus on quality: After a feature has been validated by the market, but before you scale it. Focusing on quality at the wrong time is another form of waste.

Other sources of information on the Lean Startup Movement are the Lean Startup Circle google group and Steve Blank, who arguably initiated the movement.


问:
Can I get a C++ Compiler to instantiate objects at compile time
I am writing some code that has a very large number of reasonably simple objects and I would like them the be created at compile time.  I would think that a compiler would be able to do this, but I have not been able to figure out how.

In C I could do the the following:

```<code>#include <stdio.h>

typedef struct data_s {
    int a;
    int b;
    char *c;
} info;

info list[] = {
    1, 2, "a",
    3, 4, "b",
};

main()
{
   int i;
   for (i = 0; i < sizeof(list)/sizeof(*list); i++) {
     printf("%d %s\n", i, list[i].c);
   }
}
</code>```

Using #C++* each object has it constructor called rather than just being layed out in memory.

```<code>#include <iostream>
using std::cout;
using std::endl;

class Info {
    const int a;
    const int b;
    const char *c;
public:
    Info(const int, const int, const char *);
    const int get_a() { return a; };
    const int get_b() { return b; };
    const char *get_c() const { return c; };
};

Info::Info(const int a, const int b, const char *c) : a(a), b(b), c(c) {};

Info list[] = {
    Info(1, 2, "a"),
    Info(3, 4, "b"),
};

main()
{
    for (int i = 0; i < sizeof(list)/sizeof(*list); i++) {
        cout << i << " " << list[i].get_c() << endl;
    }
}
</code>```

I just don't see what information is not available for the compiler to completely  instantiate these objects at compile time, so I assume I am missing something.

答: You're hosed. The problems are those const private data members and the constructor. These makes your class a non-aggregate class. The only way to construct an Info object is by calling the constructor, and the compiler doesn't do that.


问:
What is the difference between Times and Dup in Assembly Language?
In a bootloader, the second last line is :

TIMES 510-($-$$) db 0

Now, will this command also do the same :

db 510-($-$$) DUP (0)

If not why?

I know what TIMES does, but its not mentioned in my x86 book by Mazidi (Pearson Publication). Any idea why?

And what is the meaning of the $ sign exactly? Different sites have different information about $.

And is the line TIMES 510-($-$$) db 0 absolutely necessary even if my bootloader code is of 512 bytes in size?

So can anyone help me with these questions?

答:
TIMES and DUP are assembler specific commands, and as such aren't part of x86 assembly language. Same goes for $ and $$.

The $ symbol denotes the current address of the statement, and the $$ denotes the address of the beginning of current section. So the lines with DUP and TIMES calculate the current address in the section and subtracts it from 510. This effectively just zeroes out the section from the beginning to the current address.


答: One purpose for NOP (in general assembly, not only x86) it to introduce time delays. For example you want to program a microcontroller which has to output to some LEDs with a 1 s delay. This delay can be implemented with NOP (and branches). Of course you could use some ADD or something else, but that would make the code more unreadable; or maybe you need all the registers.</p>

Title: Purpose of NOP instruction and align statement in x86 assembly

Body:
It has been a year or so since I last took an assembly class. In that class, we were using MASM with the Irvine libraries to make it easier to program in.

After we'd gone through most of the instructions, he said that the NOP instruction essentially did nothing and not to worry about using it. Anyway, it was about midterm and he has some example code that wouldn't run properly, so he told us to add a NOP instruction and it worked fine. I asked I'm after class why and what it actually did, and he said he didn't know.

Anybody know?


答:
NOP means No Operation

It is generally used for inserting or deleting machine code or to delay execution of a particular code.

Also used by crackers and debuggers to set breakpoints.

So probably doing something like :
XCHG BX, BX
will also result in the same.

Sound to me as if there were few operations which were still under process and hence it caused an error.

If you are familiar with VB, i can give you an example :

If you make a login system in vb, and load 3 pages together - facebook, youtube and twitter in 3 different tabs.

And use 1 login button for all.
It might give an error if your internet connection is slow. Which means one of the pages hasn't loaded yet. So we put in Application.DoEvents to overcome this. Same way in assembly NOP can be used.


答:
Often times NOP is used to align instruction addresses. This is usually encountered for example when writing Shellcode to exploit buffer overflow or format string vulnerability.

Say you have a relative jump to 100 bytes forwards, and make some modifications to the code. The chances are that your modifications mess up the jump target's address and as such you'd have to also change the aforementioned relative jump. Here, you can add NOPs to push the target address forward. If you have multiple NOPs between the target address and the jump instruction, you can remove the NOPs to pull the target address backward.

This would not be a problem if you are working with an assembler which supports labels. You can simply do JXX someLabel(where JXX is some conditional jump) and the assembler will replace the someLabel with the address of that label. However, if you simply modify the assembled machine code(the actual opcodes) by hand(as it sometimes happens with writing shellcode), you also have to change the jump instruction manually. Either you modify it, or then move the target code address by using NOPs.

Another use-case for NOP instruction would be something called a NOP sled. In essence the idea is to create a large enough array of instructions which cause no side-effects(such as NOP or incrementing and then decrementing a register) but increase the instruction pointer. This is useful for example when one wants to jump to a certain piece of code which address isn't known. The trick is to place the said NOP sled in front of the target code and then jumping somewhere to the said sled. What happens is that the execution continues hopefully from the array which has no side-effects and it traverses forwards instruction-per-instruction until it hits the desired piece of code. This technique is commonly used in aforementioned buffer overflow exploits and especially to counter security measures such as ASLR.

Yet another particular use for the NOP instruction is when one is modifying code of some program. For example, you can replace parts of conditional jumps with NOPs and as such circumvent the condition. This is a often used method when "cracking" copy protection of software. At simplest it's just about removing the assembly code construct for if(genuineCopy) ... line of code and replacing the instructions with NOPs and.. Voilà! No checks are made and non-genuine copy works!

Note that in essence both examples of shellcode and cracking do the same; modify existing code without updating the relative addresses of operations which rely on relative addressing.


问:
Good practices for large scale development/delivery of software
What practices do you apply when working with large teams on multiple versions of a software or multiple competing projects? What are best practices that can be used to still get the right things done first?

Is there information available how big IT companies do development and management of some of their large projects, e.g. things like Oracle Database, WebSphere Application Server, Microsoft Windows, ....?

答:
It depends, but there are few aspects which are common in all sorts of programs.

Start the development from the systems point of view - Memory Management, Process Management, etc.

Perform efficient coding. Do not put in all the code in a single file. Make various function and call them, that's a good practice.

Try to shorten your code as much as possible and deploy as minimum number of variables as possible.

Focus more on saving system memory than saving drive space(although both are equally important). System memory has to be handled with care so that there isn't excess utilization than what the customer expects it to utilize. Nowadays we have hard drives with massive space so disc drive space won't be a problem, but again the efficiently you code, the better is disc managment.

You won't be told to do everything on your own, so focus more on your duty than worrying about the final outcome. Its a wonderful experience. And make sure you enjoy doing it :-)

All the Best.


问:
Why does ARM processors dominate Mobile platforms while x86 dominates Desktop/Server platforms
Almost all of the mobile phones, except the ones being produced by Intel, use ARM based processors while desktop/server industry is dominated x86 processors. </p>

<p>What features does one provide over the other with regards to the domination they have in their respective sectors? </p>

答:
ARM is a Micro - Controller designer (In General) and makes few micro - processors to for low end laptops with not a very high capability as that of Intel, whereas speaking of x86, it requires several other components such as RAM, Motherboard, etc. to function upon.

ARM inputs within itself the data signals which are derived from the battery of the Mobile Device and functions.

x86 on the other hand needs comparatively heavy power supply to power up the motherboard.

Besides when talking about x86, we mean only a Micro - Processor and not a Micro - Controller.

The difference lies within their functioning.

A Micro - Processor is only an accumulator and generator, i.e., it accumulates signals in binary and processes them. The motherboard it is embedded in channels the signals to various devices and they work accordingly. A ram is also necessary for quick functioning of the Micro - Processor commands or even beneficial to store in the data for a temporary period of time which can be POPPED or PUSHED by the Microprocessor.

Speaking of a Micro - Controller, it generally has an inbuilt RAM, 16 - 32 pins (even 48 or more). These pins do some or the other functioning of your mobile device. A Micro - Controller Pin can be programmed using C or Assembly to light up the screen, Turn on the Led, etc.

Now the main point of difference is that the power consumption of the x86 is high. But in recent days the Intel Technology have started making tablets which power a partial part of x86 and process just as a computer would do making data management, gaming, etc. amazingly fast.

Hope that helps Sir :)


问:
Has "Not everyone can be a programmer" been studied?
An old adage that many programmers stick to is "It takes a certain type of mind to learn programming, and not everyone can do it."

Now I'm sure that we all have our own trove of anecdotal evidence, but has this been studied scientifically?

答:
To those citing Dehnadi and Bornat's double-hump or goats-vs-sheep study, it's worthwhile to check out Mental Models and Programming Aptitude by Caspersen et al (2007) in which they attempt to replicate it:

Predicting the success of students participating in introductory
  programming courses has been an active research area for more than 25
  years. Until recently, no variables or tests have had any significant
  predictive power. However, Dehnadi and Bornat claim to have found a
  simple test for programming aptitude to cleanly separate programming
  sheep from non-programming goats. We briefly present their theory and
  test instrument.

We have repeated their test in our local context in order to verify
  and perhaps generalise their findings, but we could not show that the
  test predicts students' success in our introductory program-ming
  course.

Based on this failure of the test instrument, we discuss various
  explanations for our differing results and suggest a research method
  from which it may be possible to generalise local results in this
  area. Furthermore, we discuss and criticize Dehnadi and Bornat's
  programming aptitude test and devise alternative test instruments.


答:
Many years ago I did several courses that included military leadership theory.  Part of the theory was that there exists a leadership continuum, from those who are natural leaders to those who couldn't lead a dog on a leash.  The idea was that people were distributed on this leadership continuum in a bell curve, with most people being somewhere between the two extremes.  Apart from the few at the far extreme "couldn't lead a dog" end almost everyone could be taught the art of leadership.  The amount of effort required to turn someone into a leader depended on where they sat on the continuum.

I suspect programming has a similar continuum and a similar distribution.  There'll be those that just get it effortlessly, and those that could never get it if their lives depended on it.  But they're the few at the tail of the bell curve.  Most people sit between those extremes on the continuum.  They can learn to program but the effort required to teach them will depend on where on the continuum they sit.

Title: Has "Not everyone can be a programmer" been studied?

Body:
An old adage that many programmers stick to is "It takes a certain type of mind to learn programming, and not everyone can do it."

Now I'm sure that we all have our own trove of anecdotal evidence, but has this been studied scientifically?


答:
If you want all that extra stuff in there, fine - you'll have to instantiate them explicitly.

But there's nothing stopping you using the C way for your objects, just make and treat them as POC structs. C++ is that backwardly compatible. Alternatively, place a struct inside your class as a member variable and instantiate that.

With C++11 you can use initializer lists to construct your object, as per this SO answer

Title: Can I get a C++ Compiler to instantiate objects at compile time

Body:
I am writing some code that has a very large number of reasonably simple objects and I would like them the be created at compile time.  I would think that a compiler would be able to do this, but I have not been able to figure out how.

In C I could do the the following:

```<code>#include <stdio.h>

typedef struct data_s {
    int a;
    int b;
    char *c;
} info;

info list[] = {
    1, 2, "a",
    3, 4, "b",
};

main()
{
   int i;
   for (i = 0; i < sizeof(list)/sizeof(*list); i++) {
     printf("%d %s\n", i, list[i].c);
   }
}
</code>```

Using #C++* each object has it constructor called rather than just being layed out in memory.

```<code>#include <iostream>
using std::cout;
using std::endl;

class Info {
    const int a;
    const int b;
    const char *c;
public:
    Info(const int, const int, const char *);
    const int get_a() { return a; };
    const int get_b() { return b; };
    const char *get_c() const { return c; };
};

Info::Info(const int a, const int b, const char *c) : a(a), b(b), c(c) {};

Info list[] = {
    Info(1, 2, "a"),
    Info(3, 4, "b"),
};

main()
{
    for (int i = 0; i < sizeof(list)/sizeof(*list); i++) {
        cout << i << " " << list[i].get_c() << endl;
    }
}
</code>```

I just don't see what information is not available for the compiler to completely  instantiate these objects at compile time, so I assume I am missing something.


问:
Why did the web win the space of remote applications and X not?
The X Window System is 25 years old, it had it's birthday yesterday (on the 15'th).

As you probably are aware of, one of it's most important features is the separation of the server side and the client side in a way that neither Microsoft's, Apples or Wayland's windowing systems have.

Back in the days (sorry for the ambiguous phrasing) many believed X would dominate over other ways to make windows because of this separation of server and client, allowing the application to be ran on a server somewhere else while the user clicks and types on her own computer at home.

This use obviously still exists, but is marginalized at best. When we write and use programs that run on a server we almost always use the web with it's html/css/js.

Why did the web win, and X not? The technologies used for the web (said html/css/js) are a mess. Combined with all the back-end-frameworks (Rails, Django and all) it really is a jungle to navigate thru. Still the web thrives with creativity and progress, while remote X apps do not.

答:
I agree that, in principle, the two are similar. If you ask the question "how can we run code on a server but provide visualization on a remote client?", it's reasonable to think that independent teams could come up with either solution.

I suspect the reason one is more popular than the other in certain aspects is because the two approach the same problem from completely different perspectives. X is a technical solution to a technical problem, but the web evolved as a need to solve a social problem -- how can I take resources from a remote server and display it on my local machine, and do it in a way that is easy and convenient?

The web "won" because it solved a problem experienced by more people. Think of a car analogy: both luxury sedans and trucks ostensibly solve the same problem: how to transport something from one place to another.

The truck solved the technical problem of literally how to haul something from point A to point B, and for that it works quite well. The passenger car evolved as a need for people to be comfortable as they travel, and to carry more people and less manure. It became a necessity that required conveniences. Thus, over time, the number of passenger cars far, far outweighed the number of pickup trucks on the road (I'm guessing, based on observation of Chicago traffic, maybe it's different in Texas? :-)

So, like the car/truck analogy, the web and X11 both arguably solve the same technical problem, but they serve completely separate purposes.


问:
Reasons behind polymorphism related behaviour in java
I read this code somewhere

```<code>class Foo {
    public int a;
    public Foo() {
        a = 3;
    }
    public void addFive() {
        a += 5;
    }
    public int getA() {
        System.out.println("we are here in base class!");
        return  a;
    }
}

public class Polymorphism extends Foo{
   public int a;
   public Poylmorphism() {
       a = 5;
   }
   public void addFive() {
       System.out.println("we are here !" + a);
       a += 5;
   }

   public int getA() {
        System.out.println("we are here in sub class!");
        return  a;
    }

    public static void main(String [] main) {
        Foo f = new Polymorphism();
        f.addFive();
        System.out.println(f.getA()); // SOP 1
        System.out.println(f.a);      // SOP 2
    }
}
</code>```

For SOP1 we get answer 10 and for SOP2 we get answer 3. Reason for this is that you can't override variables whereas you can do so for methods. This happens because type of the reference variable is checked when a variable is accessed and type of the object is checked when a method is accessed. But I am wondering, just why is it that way? Can anyone explain me what is the reason for this behaviour

答:
Your reference is of type Foo; it does not know the type of the object it's referring to.

Even with this, inheritance breaks encapsulation; by permitting the instance fields to be overridden too, encapsulation would be broken even more. Maybe in your subclass you are calling a method from the superclass which relates on the state of the instance field a. The superclass' implementation is based on it's own a (it cannot assume a superclass will exist and it will override it) and will have a very chaotic behavior if you change it by overriding it.

Also, instance field inheritance should not be permitted since instance fields should be made private.


答:
The technologies might try to solve similar problems now, but they sure didn't in the past.

Current HTML stack evolved over time from really simple text-document transfer, through "visual" documents with little scripting, into full-featured application platform.

At the time when HTML began, no one could ever dream about connecting to remote computer and running graphical applications there. Only after internet got better latency and throughput this became possible. Yet at that time, HTML was already ever-present. Everyone knew that this was way to give customers and users access to graphical application, that run on the remote machine.

And as with every "free" system, It became impossible to "reset" the whole thing and start anew to do it better this time. That's why we need to shut up and use HTML/CSS/JS and only wish people supporting it will finally wisen and bury it along with it's years long legacy.

This answers the question "Why did web win?". There wasn't any competition, web won before everything even started.

Title: Why did the web win the space of remote applications and X not?

Body:
The X Window System is 25 years old, it had it's birthday yesterday (on the 15'th).

As you probably are aware of, one of it's most important features is the separation of the server side and the client side in a way that neither Microsoft's, Apples or Wayland's windowing systems have.

Back in the days (sorry for the ambiguous phrasing) many believed X would dominate over other ways to make windows because of this separation of server and client, allowing the application to be ran on a server somewhere else while the user clicks and types on her own computer at home.

This use obviously still exists, but is marginalized at best. When we write and use programs that run on a server we almost always use the web with it's html/css/js.

Why did the web win, and X not? The technologies used for the web (said html/css/js) are a mess. Combined with all the back-end-frameworks (Rails, Django and all) it really is a jungle to navigate thru. Still the web thrives with creativity and progress, while remote X apps do not.


答: This probably isn't going to help you very much, but I'd suggest that you look into template meta programming. :-) </p>


答:
Because X requires you to have a CS degree to write an application. While Web requires that you have the ability to type (not even that).

Especially in the early days when web was just html. You could open a terminal and build a working display in 10 minutes and then interactively improve it with instant feedback. This low bar of entry spurred massive user uptake. Building a X-Server application on the other hand is non-trivial task even for experienced programmers.

It has taken 10 years for the Web to be a direct competitor to X applicatoin in terms of functionality and provide the same GUI like abilities. This functionality has been added to the language stack over time allowing developers to master one set of features before the next was added; so this gradual expansion of technological complexity has maintained the low bar (for people who are already in the field and there are lots of them). Jumping into the field now is a lot harder than it was 10 years ago but it is still possible and the instant feedback of the web makes learning more gratifying (humans need quick gratification to reinforce their drives).

Cost is another driver. The actually cost of learning enough programming skills to develop a X-Server is significant. Then additionally the availability of servers to run your application on has driven the cost up. Learning to write HTML was practically nothing to get "Hello World" page up and running and internet service providers provided free hosting to inspire you to get a web connection. So you could practice for free. When you eventually needed business hosting the availability of hosting companies has grown and the cost has always been relatively cheap.


答:
I'm not sure it's just programming.  I saw the same sort of phenomenon with people simply learning to use computers.  Back in college I was a lab assistant in a lab that hosted a computer literacy for seniors class.

Within two weeks I could identify those who would get it and those who wouldn't with basically 100% accuracy.  You either accepted that this is the way the computer works or you beat your head against it for the whole class.  There was no middle ground.  (The fact that it was a seniors class meant we had a lot of head-beaters which made the pattern much more obvious.)


问:
Is there a constant for "end of time"?
For some systems, the time value 9999-12-31 is used as the "end of time" as the end of the time that the computer can calculate. But what if it changes? Wouldn't it be better to define this time as a builtin variable?

In C and other programming languages there usually is a variable such as MAX_INT or similar to get the largest value an integer could have. Why is there not a similar function for MAX_TIME i.e. set the variable to the "end of time" which for many systems usually is 9999-12-31. To avoid the problem of hardcoding to a wrong year (9999) could these systems introduce a variable for the "end of time"?

**Real example **

End of validity date: 31/12/9999. (official documents are listed like this)
The blogger wants to write a page that is always on top, the welcome page. So it's given a date as far in the future as possible:

3000? Yes, the welcome page which you're facing is posted at 1 January
  3000. So this page will be kept on the top of the blog forever =) It's actually posted at 31 august 2007.

答:
You probably want an algebraic data type with variant for infinite big date. Then define comparison, in which infinite variant will be always bigger than any other date.

Example in Scala:

sealed abstract class SmartTime extends Ordered[SmartTime] { x =>
        def compare(y: SmartTime) = {
                x match {
                        case InfiniteFuture => 1
                        case InfinitePast => -1
                        case ConcreteTime(x) =>
                                y match {
                                        case InfiniteFuture => -1
                                        case InfinitePast => 1
                                        case ConcreteTime(y) => x compare y
                                }
                }
        }
}
case class ConcreteTime(t: Long) extends SmartTime
case object InfiniteFuture extends SmartTime
case object InfinitePast extends SmartTime
```

http://ideone.com/K5Kuk

Title: Is there a constant for "end of time"?

Body:
You probably want an algebraic data type with variant for infinite big date. Then define comparison, in which infinite variant will be always bigger than any other date.

Example in Scala:

sealed abstract class SmartTime extends Ordered[SmartTime] { x =>
        def compare(y: SmartTime) = {
                x match {
                        case InfiniteFuture => 1
                        case InfinitePast => -1
                        case ConcreteTime(x) =>
                                y match {
                                        case InfiniteFuture => -1
                                        case InfinitePast => 1
                                        case ConcreteTime(y) => x compare y
                                }
                }
        }
}
case class ConcreteTime(t: Long) extends SmartTime
case object InfiniteFuture extends SmartTime
case object InfinitePast extends SmartTime

http://ideone.com/K5Kuk


问:
Do you use ReSharper full time, or only enable it when needed?
Based on a multitude of questions related to temporarily disabling ReSharper, and also on certain research data, I can see that a considerable share of ReSharper users have it disabled most of the time. They tend to enable it for a limited period of time (say, several hours), do whatever they need to do using its functionality, and disable it back until the next time they feel they need to use it.

If you're using ReSharper (or other similar VS extensions, to that matter) in such occasional manner, can you clarify why you're doing this?

Is your behavior based on performance, or other considerations?

What kinds of tasks do you enable ReSharper for in this scenario?

答:
Looking through those links they are seem mainly to be about disabling certain features of Resharper rather than the product itself. Some of the formatting ones can be a pain if you don't know how to configure them (I don't really and just email their support).

You can disable the whole thing simply enough if you want though, it uses a lot of memory which is understandable but potentially problematic.

I refactor a lot, constantly, so it makes no sense to not have it switched on for me. That plus all the editor helpers.

I can't* code without it being installed, a core dozen or so features are wired into my muscle memory, things like Ctrl+T and Shift+Alt+L.

For VS 2010 I'd also recommend VS productivity tools. It has three or four things I love, but I'll just mention the fact it uses your editor scroll bar as a place to put extra information, like the location of search results in the file, breakpoints, that sort of thing.

*Ok, look I can code in notepad if I have to, but given the choice, I would never use Visual Studio again without Resharper.


答:
Is your behavior based on performance, or other considerations?

Performance of daily used tools is important and needs special attention in my view.

I have experienced issues while having Resharper installed on my development machine with VS2010. The main reason was in lack of memory(i had just 4GB). My VS solution has 48 projects including test projects as well. I saw usage of almost 2-3GB memory while debugging. As well as, unresponsiveness of VS2010. The usage of memory by ReSharper was around 300-700MB.

Solution to this issues was simple. Upgrade your hardware for productivity. After upgrading desktop memory to 8GB and installing SSD i am rarely face with such situation.
However, i also do believe you may disable ReSharper by using the configuration.

Overall, i think Resharper is very useful tool and provides a big productivity boost during the enterprise software development.

Title: Do you use ReSharper full time, or only enable it when needed?

Body:
Based on a multitude of questions related to temporarily disabling ReSharper, and also on certain research data, I can see that a considerable share of ReSharper users have it disabled most of the time. They tend to enable it for a limited period of time (say, several hours), do whatever they need to do using its functionality, and disable it back until the next time they feel they need to use it.

If you're using ReSharper (or other similar VS extensions, to that matter) in such occasional manner, can you clarify why you're doing this?

Is your behavior based on performance, or other considerations?

What kinds of tasks do you enable ReSharper for in this scenario?