答:
Creating an index is a trade-off.  You have to determine whether the overhead of maintaining the index (and thus slowing down DML operations) and the additional space consumed by the index is worth the performance gain you get from the queries that use the index.  That, in turn, depends on how much the queries benefit and how critical those queries are.

The number of indexes on a table is irrelevent in this cost-benefit equation-- each index ought to be considered on its own (though the performance benefit of a particular index may be dependent on whether a different index is available for the query to use instead).

Title: How many indexes is too many indexes?

Body:
I have a table with about 37 indexes. Would that be considered too many? What are some best practices regarding indexing?

EDIT: It is warehousing data, updated daily with new transactions.  There are 47 million rows.  3 of the indexes are very necessary. The other 34~ are 'where' clause indexes intended to speed up queries.


问:
How many indexes is too many indexes?
I have a table with about 37 indexes. Would that be considered too many? What are some best practices regarding indexing?

EDIT: It is warehousing data, updated daily with new transactions.  There are 47 million rows.  3 of the indexes are very necessary. The other 34~ are 'where' clause indexes intended to speed up queries.

答:
Always you have to evaluate your write speed /maintenance requirements to read requirements. If you have almost a 100% read ratio to write ratio, and you update the data very infrequently or you even produce "read-only snapshots" of your database and use that for read scaling, fire away on the index front!

I would test all my scenarios very thoroughly on a production like system though, I have heard of scenarios where index adds have slowed down query compilation / updates considerably.

ContentLicense: CC BY-SA 3.0

Title: How many indexes is too many indexes?


答:
Most things that I have seen say that having more than 5 indexes will begin to slow down your insert speed.

Consider this, every index you have is like having a new table in your database with the same information just sorted a different way. Having 37 indexes is like having to do an insert 38 times!

No rule is going to be a solid number but unless this is some sort of historical record that will never change that may be to many.

Title: How many indexes is too many indexes?


问:
What are the benefits of closing every if-statement with an else in Python?
I am reading Learn Python the Hard Way by Zed Shaw.  In this lesson he writes: "Every if-statement must have an else."

What are the benefits of ending every if-statement with an else?  Are there any legitimate reasons not to end an if-statement with an else?

答:
I think he's trying to demonstrate something about flow control. What exactly he's trying to demonstrate is anyone's guess, but I think he's trying to make you stop and think about what the "path not taken" in any if-statement would do. Presumably he's run into a problem in the past where this type of thinking would have proven useful.

This type of rule is just way to absurd to apply in real life though.


答: there is no 'magic number'. Every index after 0 slows down insert/updates a bit, but that shouldn't stop you from creating needed indexes.  37 does sound like a lot, make sure you're not using unnecessary indexes. For example, usually if you have an index on columns A, B  you don't need a separate index on A.  Or if you have an index on A, B, C, D you don't need another index on A, B, C. And you probably don't gain much by having another index on A, B, C, E.</p>

Title: How many indexes is too many indexes?


问:
Do I need to test everything?
I'm going to start my first real project in Ruby on Rails, and I'm forcing myself to write TDD tests. I don't see real advantages in writing tests, but since it seems very important, I'll try.

Is it necessary to test every part of my application, including static pages?

答:
I would say to not start with TDD. Make an informed decision when you've spent more time learning architecture strategies in general. TDD won't let you skip that homework although you might start believing it does.

Here's my problem with it. When you say it seems like a lot of wasted time on stuff that will never break TDDers say you'll appreciate it when that one thing you didn't anticipate in a huge chain of dependencies gets busted. When you point out that it's impossible to predict such things before you write your app, which is uh... why we test, they tell you it's really more about design and not testing even though the testing comes in handy.

But aren't giant chains of unpredictable linked dependencies the product of crappy design?

So which is it?

Here's a thought. Let's not have huge complex chains of dependencies in the first place by considering the following two principles of object-oriented design from Design Patterns:

"Program to an interface, not an implementation"

That is to say, your objects should not care who is doing the calling or how they were made. Only that the proper args were fed in and that the methods they call from other objects they're directed to work as expected. Your chain of dependency in most cases should be at one linking point, the method call on the part of the caller and the spot where the args get dropped into your methods. That's where you log and validate and send useful messages for debug when things crap out.

And:

"Favor object composition over class inheritance"

Who's the dummy? The guy who did something to a class in a convoluted cascading inheritance scheme involving like 30 classes resulting in fringe case breakage, or the dev who came up with that architecture in the first place? TDD might help you get to the bottom of issues inside that leaning tower of class Pisa sooner than you could have without but does that make it any less painful to attempt to modify one of the endpoints of that code disaster the next time?

And that's where I get to the thing that bugs me. Does TDD really help design or does it enable bad architecture? It seems to me like it has potential to be a self-fulfilling strategy. The more your team doesn't have to own responsibility for poor architecture, the more helpful those granular testing components seem to become, but ultimately your app becomes an increasingly bigger PITA to work with (assuming they never gave much thought to architecture in the first place). And failure to acknowledge the consequences of that is hands down, always the most expensive mistake you can make when working on an application that's meant to be upgraded and modified over time.

Title: Do I need to test everything?


问:
What do you use macros in your editor for?
My editor of choice is Notepad++. It has macro capabilities, but as much as I think, I don't see how can I use it for anything.

Do you use macros in your editor that have made your work easier? (for general use I mean)

答:
I don't know about Notepad++, but I use macros in Emacs to do pretty much any sort of easily repeated task. These tasks can actually be fairly complicated.

A recent example is this: I had a CSV file from a database and wanted to convert it to JSON using a uniform pattern. It looked something like this (I don't remember exactly what it was):

```<code>10, 85, 0.1345, Hostname1, Intel, Xeon
9, 74, 0.21453, Hostname2, Intel, Xeon
...
</code>```

I needed to convert it to something like:

```<code>[{"a" : 10, "b" : 85, "c" : 0.1345, "hostname" : "Hostname1", "cpu" : "Intel", model: "Xeon"},
...
</code>```

Using an sort of script to do this would have take too long, so all I did was convert the first row manually while recording my keystrokes and then replay them on the rest of the file. It worked really well--while the execution time was slow, it only took less than a minute of my time, which is very important for a one-off task!

Pretty much any sort of repeated manipulation like this is a great use case for a keyboard macro. I have definitely saved myself a lot of time thanks to Emacs macros!

Body:
I don't know about Notepad++, but I use macros in Emacs to do pretty much any sort of easily repeated task. These tasks can actually be fairly complicated.

A recent example is this: I had a CSV file from a database and wanted to convert it to JSON using a uniform pattern. It looked something like this (I don't remember exactly what it was):

10, 85, 0.1345, Hostname1, Intel, Xeon
9, 74, 0.21453, Hostname2, Intel, Xeon
...

I needed to convert it to something like:

[{"a" : 10, "b" : 85, "c" : 0.1345, "hostname" : "Hostname1", "cpu" : "Intel", model: "Xeon"},
...

Using an sort of script to do this would have take too long, so all I did was convert the first row manually while recording my keystrokes and then replay them on the rest of the file. It worked really well--while the execution time was slow, it only took less than a minute of my time, which is very important for a one-off task!

Pretty much any sort of repeated manipulation like this is a great use case for a keyboard macro. I have definitely saved myself a lot of time thanks to Emacs macros!


问:
How to minimize the data loss when laying off a programmer?
I was just laid off and it was the standard process that is used in the US: call the person to talk to personnel, and remove access to the network while that is going on, then have someone help pack, always have someone with the person until they are escorted from the property.

That is supposed to keep an unhappy developer from deleting or damaging software or data: to mimimize data loss.

However, it still results in a lot of data loss, as all of the work the programmer was working on is dropped: software not checked in is possibly lost, documents not finished are lost, releases in process are slowed down or stopped, and a huge amount of knowledge could be lost.

It seems the potential data loss is more than offset by the actual data loss.  How can all losses, both potential and actual, be mimimized?

答:
Well, I'd imagine the common case is to know for a bit that you're going to lay someone off.  If that's the case, you can always assign them to wrap up current project that they're workign on prior to laying them off.  I mean, it's pretty Machiavellian, but you could essentially tell them they were getting a cool new assignment next week but first had to knowledge transfer their current work to a replacement.

Personally, I couldn't live with myself if I engaged in this sort of deception, but I think it would accomplish what you're asking about here.


问:
How should I describe the process of learning someone else's code? (In an invoicing situation.)
Edit: Justin Cave made a good point that this sort of communication should be up front in my quoting / estimations.  Is this case, I'm still interested to know what sort of language people use to describe the 'existing code learning' activities.  Especially to a company who haven't dealt with software contractors before.  End edit

I have a contract to upgrade some in-house software for a large company.  The company has requested multiple feature additions and a few bug fixes. This is my first freelance style job.

First, I needed to become familiar with how the application worked - I learnt it as if I was a user.

Next, I had to learn how the software worked.  I started with broad concepts, and then narrowed down into necessary detail before working on each bug fix and feature.

At least at the start of the project, it took me a lot longer to learn the existing code than it did to write the additional features.

How can I describe the process of learning the existing code on the invoice?  (This part of the company usually does things in-house, so doesn't have much experience dealing with software contractors like me, and I fear they may not understand the overhead of learning someone else's code).  I don't want to just tack the learning time onto the actual feature upgrade, because in some cases this would make a 'simple task' look like it took me way too long.  I want break the invoice into relevant steps, and communicate that I'm charging for the large overhead of learning someone else's code before being able to add my own to it.

Is there a standard way of describing this sort of activity when billing for a job?

答:
Nothing on an invoice to a customer should be a surprise to the customer.  Given that, I'm hoping that you already set the expectation with the customer that a significant fraction of your time would initially be spent familiarizing yourself with the application both from a user perspective and from a developer perspective.  And your estimates for the first few features hopefully specified that they included a decent amount of time for familiarizing yourself with the code.

If you've already set that expectation with the customer that most of the time on the initial invoice is going to be spent familiarizing yourself with the application, it shouldn't matter too much exactly how you list it on the invoice.  Use whatever language you used when providing the estimates and setting the expectations.  If you're only trying to communicate this now, you've got a problem.


答:
When a company is at the point of layoffs, the loss of an individual programmer's work is a rather minor concern.

The layoff, especially if it involves multiple people (and it usually does) is assumed to set back the project by a significant amount, and that's just the price that you have to pay. Sometimes entire projects have to get dropped, because there aren't enough people to do the work. Or the people who are left behind are expected to muddle through as best they can. Sometimes, with deadlines left intact.

Title: How to minimize the data loss when laying off a programmer?

Body:
I was just laid off and it was the standard process that is used in the US: call the person to talk to personnel, and remove access to the network while that is going on, then have someone help pack, always have someone with the person until they are escorted from the property.

That is supposed to keep an unhappy developer from deleting or damaging software or data: to mimimize data loss.

However, it still results in a lot of data loss, as all of the work the programmer was working on is dropped: software not checked in is possibly lost, documents not finished are lost, releases in process are slowed down or stopped, and a huge amount of knowledge could be lost.

It seems the potential data loss is more than offset by the actual data loss.  How can all losses, both potential and actual, be mimimized?


答:
In my capacity as a freelancer, I would probably term this something like "Knowledge Assimilation", in the general sense.  And, this would have been included in any estimate provided initially to the customer.

It may not help you here, but for future reference, I suggest that you make this more of an active task in the future.  For instance, invoice the customer for time you spent going through and adding comments to non-commented code, adding unit tests to untested code, etc.  These are examples of tasks that add at least a little value while facilitating your understanding of the code base.

Even if there isn't much difference between reading and reading while documenting, your customer will probably have a small psychological preference for these more 'active' tasks.  And, you might actually learn more by documenting someone else's code than you would simply by reading it.  (This will certainly be the case if you write tests against their code).

If you do this, you can have an invoice line-item that says something like "Knowledge Assimilation and Legacy Code Testing/Documentation".

Edit:  In your situation as described, I would honestly probably eat the cost of this activity.  I can't speak to your financials, and I don't mean to presume, but when you're getting started, I'd put a lot higher value on racking up testimonials and pleased customers than some hours of billing.  If that means an effective lower rate in the early-going, it may be a good investment.  Eating some billable hours in the long run is probably a small price to pay for a satisfied customer that thinks he or she got a fair shake.

Title: How should I describe the process of learning someone else's code? (In an invoicing situation.)

Body:
Edit: Justin Cave made a good point that this sort of communication should be up front in my quoting / estimations.  Is this case, I'm still interested to know what sort of language people use to describe the 'existing code learning' activities.  Especially to a company who haven't dealt with software contractors before.  End edit

I have a contract to upgrade some in-house software for a large company.  The company has requested multiple feature additions and a few bug fixes. This is my first freelance style job.

First, I needed to become familiar with how the application worked - I learnt it as if I was a user.

Next, I had to learn how the software worked.  I started with broad concepts, and then narrowed down into necessary detail before working on each bug fix and feature.

At least at the start of the project, it took me a lot longer to learn the existing code than it did to write the additional features.

How can I describe the process of learning the existing code on the invoice?  (This part of the company usually does things in-house, so doesn't have much experience dealing with software contractors like me, and I fear they may not understand the overhead of learning someone else's code).  I don't want to just tack the learning time onto the actual feature upgrade, because in some cases this would make a 'simple task' look like it took me way too long.  I want break the invoice into relevant steps, and communicate that I'm charging for the large overhead of learning someone else's code before being able to add my own to it.

Is there a standard way of describing this sort of activity when billing for a job?


答: Generally, the manager of the person can login to the laid-off person's old machine and look for any code to commit before the company reformats it for someone else. Of course in a lot of layoffs the project is put on hold anyway, so nobody cares.</p>


问:
Why was Tanenbaum wrong in the Tanenbaum-Torvalds debates?
I was recently assigned reading from the Tanenbaum-Torvalds debates in my OS class. In the debates, Tanenbaum makes some predictions:

Microkernels are the future

x86 will die out and RISC architectures will dominate the market

(5 years from then) everyone will be running a free GNU OS

I was a one year old when the debates happened, so I lack historical intuition. Why have these predictions not panned out? It seems to me, that from Tanenbaum's perspective, they're pretty reasonable predictions of the future. What happened so that they didn't come to pass?

答:
Software Experts Ignored the Economics Of Hardware

...or "Moore was right and they were both wrong"

The biggest thing that was overlooked in this debate was the impact of CPU manufacturing technology and economics, driven by shrinking transistor sizes as expressed in Moore's Law (not surprising as though they knew a lot about CPU hardware, these guys studied and debated software, not CPU manufacturing or economics). Fixed manufacturing costs which are amortized over CPU's (e.g. ISA design, CPU design and CPU production facilities) have grown rapidly, thereby increasing the value of economies of scale; with per unit CPU costs (in terms of "bang for the buck" & "bang for the watt") plummeting, the cost of a CPU needn't be amortized over such a broad selection of functions to provide value, so computing in products with fixed function has exploded; CPU transistor budgets have grown exponentially, therefore wasting a fixed number of transistors due inefficiencies in ISA design is of no consequence.

1. CPU Scale Wins Over CPU Diversity

The importance of economies of scale has made the benefits of a ISA/CPU targeting a larger (therefore broader) market outweighs the potential benefits from design choices which narrow the market for an ISA/CPU. OS's can address larger and larger portions of the market per supported ISA/CPU, so there is little need (or even no need) for porting exercises to allow an OS ecosystem to thrive. The problem domains ISA's & CPU's target tend to be so broad that they mostly overlap, so for any software beyond a compiler, the size of porting exercises has also diminished. Arguably, both Torvalds & Tanenbaum overestimated the portion of kernel design and implementation that now needs to be ISA or even CPU specific. As Tanenbaum described, modern OS kernels do abstract out the distinctions between CPU's & ISA's. However, the CPU/ISA specific code in modern OS's is much smaller than a microkernel. Rather than implementing interrupt handling/scheduling, memory management, communication & I/O, these non-portable bits address only a tiny fraction of the implementation of those services, with the vast majority of the architecture of even these core OS functions being portable.

2. Open Source Won the Battle, But Lost the War

More bang for the buck means that a larger share of computing is performed by fixed function products, where the ability to modify the product is not part of the value proposition for the customer. Now ironically, open source has flourished in these fixed function devices, but more often than not, the benefits of those freedoms being realized more by those making the products rather than end users (which actually was true of the software market even back then: Microsoft was a big consumer of open source software, but their customers were not). Similarly, one could argue that open source has struggled more in the general purpose desktop space than anywhere else, but as the web and cloud computing has grown, desktop computing has increasingly been used for a narrower purpose (primarily running a browser), with the remaining functions running in the cloud (ironically, primarily on open source platforms). In short: open source does really own the general purpose computing space, but the market has become more sophisticated; computing product packaging less often stops at general purpose function, but continues along to product intended for fixed functions, where much of the advantage of open source computing is in conflict with the product goals.

3. 2n Growth Means Fixed k Savings Are Not Important

The exponential growth of transistor budgets has brought with it the realization that the transistor budget cost of a CISC architecture is almost completely fixed. RISC's strategic advantage was that it moved complexity out of the CPU's instruction set and in to the compiler (no doubt partly motivated by the fact that compiler writers benefited far less from complex ISA's than human developers coding in assembly, but compilers could much more easily reason mathematically about, and therefore exploit, a simpler ISA); the resulting transistor savings could then be applied to improving CPU performance. The caveat was that the transistor budget savings from a simpler ISA was mostly fixed (and overhead in compiler design was mostly fixed too). While this fixed impact was a huge chunk of the budget back in the day, as one can imagine it only takes a few rounds of exponential growth for the impact to become trivial. This rapidly declining impact combined with the afore mentioned rapidly increasing importance of the CPU monoculture meant a very small window of opportunity for any new ISA to establish itself. Even where new ISA's did succeed, modern "RISC" ISA's are are not the orthogonal ISA's described by the RISC strategy, as continued growth in transistor budgets and broader applicability of SIMD processing in particular has encouraged the adoption of new instructions tuned for specific functions.

4. Simple: Separation Of Concerns. Complex: Separation Of Address Space.

The modern Linux kernel (along with most other kernels) fits the rather loose definition of a macrokernel and not the rather than the narrow definition of a microkernel. That said, with its driver architecture, dynamically loaded modules and multiprocessing optimizations which make kernel space communications increasingly resemble a microkernel's message passing, it's structure more closely resembles a microkernel design (as embodied by Minix) than the macrokernel design (as embodied by Linux's design at the time of the discussion). Like a microkernel design, the Linux kernel does provide generalized communication, scheduling, interrupt handling, and memory management for all other OS components; its components do tend to have distinct code and data structures. While modules are dynamically loaded, loosely coupled pieces of portable code, that communicate through fixed interfaces, the don't employ one remaining property of microkernels: they aren't user space processes. In the end, Moore's Law ensured that issues motivated by hardware concerns like portability (a concern of Tanenbaum's) & performance (a concern of Torvalds') diminished, but software development issues became of paramount importance. The remaining unrealized advantages that a separation of address spaces could provide are outweighed by the additional baggage imposed on the OS software due to design limitations and increased complexity of component interfaces.

Interestingly, what has been a strong trend is the emergence of the hypervisor, which much like microkernels, abstracts out the hardware. Some claim that hypervisors are microkernels. Hypervisor architecture is different though, as responsibilities meant to be owned by microkernels are handled by the "guest" kernels sitting atop, with hypervisors multiplex between them, and the hypervisor abstraction is not generic messaging and memory address space, but predominantly actual hardware emulation.

In Conclusion: The Future Favours Those Who Adopt Least Strict Semantics

*..or "nitpickers suck at predicting the future"

In practice a lot of the rightness/wrongness in the debate is a matter of semantics (and that was part of what Torvalds was arguing and IMHO Tanenbaum failed to fully appreciate). It's hard to make precise definitions about the future because there are so many factors outside of the argument that can come in to play; looser semantics means your predictions are a larger target on the dartboard than the other guy's, giving you way better odds. If you ignore semantics, the arguments advanced by both Torvalds and Tanenbaum were right about a lot of things and wrong about very little.

tl;dr

Most ISA's don't fit the semantic definition of RISC, but harness most of the design advantages which were distinctive of RISC CPU's at the time; the amount of OS which is CPU specific is less than Tanenbaum expected, let alone Torvalds; open source does dominate general purpose computing, but the consumers of that market are now primarily those who package computing in to more fixed function products where much of the benefit of open source software isn't realized; separating out OS function across address spaces didn't prove to be beneficial, but separating out OS function across "virtual" hardware has. If you want to claim your predictions proved right, leave yourself as much semantic maneuvering room as possible, just like Mr. Torvalds.

P.S. A final ironic observation: Linus Torvalds is one of the strongest proponents of keeping as much new functionality as possible up in user space and out of the Linux kernel.


问:
Should you use "internal abbreviations" in code comments?
Should you use "internal abbreviations/slang" inside comments, that is, abbreviations and slang people outside the project could have trouble understanding, for instance, using something like //NYI instead of //Not Yet Implemented?

There are advantages of this, such as there is less "code" to type (though you could use autocomplete on the abbreviations) and you can read something like NYE faster than something like Not Yet Implemented, assuming you are aware of the abbreviation and its (unabbreviated) meaning.

Myself, I would be careful with this as long as it is not a project on which I for sure will be the only developer.

答:
There is only one abbreviation* that can be used in comments :

```<code>// TODO :
</code>```

it is easy to grep and locate.

* Or something similar.

Body:
There is only one abbreviation* that can be used in comments :

// TODO :

it is easy to grep and locate.

* Or something similar.


答:
Since you have 47 Million rows and your are using the database for reporting, then we are talking about a Data Mart/Warehouse type of application rather than OLTP application.

You need to consider using a Star Schema to start with and you may (based on the features in your choosen database) to build static aggregate tables connected to dimension tables to provide summaries using batch processing. The above will provide you better performance and possibly less indexes. You can gain further performance by shutting off (some) of your indexes during load and re-building them after load is complete. Building an index over 47 million rows is very fast.

Above all, you need to justify the need of every index as a general database design practice. This can only be done by examining, in details, user reporting needs. Remember that even if you define indexes, your query may not use one or more of them, so your user needs, query analysis and good database design should help you determine exactly whether to use an index or not and the type of index required.

I have designed several database and data marts, but honestly, never seen that number of indexes per table.

Title: How many indexes is too many indexes?


问:
how to choose a web framework and javascript library?
I've been procrastinating learning some framework for web apps w/ some library for AJAX, something like django with prototype, or turbogears with mootools, or zeta components with dojo, grok, jquery, symfony... The point is to spend some of my spare time, have "fun" and create cool stuff that hopefully is some useful. I think maybe I wouldn't like something like GWT or pyjamas because I wouldn't like to "get married" with some technology, I want to keep my freedom to add another javascript library, and so on.

I didn't decide even the language yet, but I think I'd prefer python. PHP could be fine if there is some framework that is nice enough.

Besides that, I don't even know where to start. I don't feel like learning a framework to then realize there is something that I cannot comfortably do, switch to another framework then find that a third framework has something really cool, etc. And the same goes for javascript libraries. So, some guidance would be really appreciated. I don't really know why are so many options available and what do they aim for, I guess some of them focus on some aspects and some on others, but I just want to make cool and nice apps that I can easily maintain, without spending too much time on coding or learning and avoiding the "trapped in the framework" feeling, when doing something is awfully complicated (or even impossible) with compared with the rest of things or doing that same thing on a different framework.

I guess in the end I'll go for django and jquery since they are the most widely used options, afaik, but if I was going for the most widely used options I guess I should choose Java or PHP (I don't really like Java for my spare time, but php is not so bad), so I preferred to ask first.

I think the question has to consider both, framework and library, since sometimes they are coupled. I think this is the place to ask this kind of things, sorry if not, and thank you.

答:
The choices you're considering are pretty much mine although I'm not sure Django is the most widely used yet. Whoever told you that has good taste though.

They are very flexible and will get out of your way when you want them to. The flipside is that both assume you know a thing or two about how browsers and the www actually work. jQuery is more of a tool for doing core JS tasks quickly and handling cross-browser normalization but there is a UI library you can attach to it and countless plugins of varying quality. If you know CSS and have programming experience, JQ should be pretty easy to learn for amateur use.

Django is more of a framework but like JQ it's easy to tell it to get the f out of your way and write your own Python or handle an SQL statement yourself. Like JQ it doesn't so much solve every problem for you as much as it just knocks a lot of the unfun stuff out of the way and provides some really powerful tools for building things quickly without sacrificing flexibility. Everybody stole its templating system and the regexed URLConfig approach to selecting controllers for a given page is awesome. I know the basics but haven't done a lot of DB work. This is another factor in Django's favor. It abstracts a lot of that out for you. Also, the instant admin feature is nice. It is definitely not on rails. You can pretty much organize files however you want.

Make no mistake though. If you're new to web development, you've got a lot of stuff to learn about other than writing code. Especially if you want to do anything fancy on the front end.


答:
My take is that this kind of firing/layoff is usually only done when the management and even the person in question know that it's going to happen, it's just a matter of timing. It also usually happens due to project cancellation or personal/political reasons so what's coming is obvious to everyone.

In the first case, the project is no longer important to the company, it's already written off as a loss, so losing data/code from it isn't a concern. They're more concerned about pilferage of hardware or losing data like customer lists and such. Sometimes this can be tied to a change in the business, such as a merger. In that situation, a transition period may be used to allow the affected personnel to exit on a friendly basis.

In the second case, the developer in question will have most likely already been sidelined in some fashion. They may be assigned to "junk" projects or doing report queries and the like just to keep them busy until all the firing logistics are right (such as it being "rank and yank" time). The developer will also realize this most of the time and should have already planned their exit strategy. Some toxic companies have a Trump-like fire on the spot policy. If you have the misfortune to work at a place like that and can't find a decent place to work, just be prepared to deal with irrational disruptions at any point.


问:
Do you sign contracts digitally or still on paper? And what do clients think?
We are all getting used to checking a box and putting our name in a text field to create a contract with an airline, a hosting company, or a software download. However, for some reason I am still asking clients to sign our contracts for website development on paper, and send me a scan. Few complain about this procedure, but I am personally thinking: what am I doing, doing this the old fashion way?! Signing contracts digitally would be faster, more convenient for clients and for me, and easier to store.

So to me it appears to be time to start creating some contract agreement online that clients can read, then print their name, and mark a box "I AGREE WITH THIS CONTRACT AND BY PRINTING MY NAME I AGREE TO SIGNING THIS", or something like that. I would record their IP, browser data, and time of signing. If I really want to ensure their identity, I could link this to OpenID and require them to log in with their e-mail so that I can ensure that they are logged in on an existing e-mail account. Sounds OK to me.

My question is: is this practice becoming a standard practice in professional IT services? Are you (as a professional) doing this? If you are, how do clients react? Any drawbacks doing this?

EDIT:

This question is not about the legal aspects. It is about common practices among programmers and web-development companies, and what clients think of this.

答:
If something ever went to court issues relating to how easy it would be to forge the signature might come up.  Since it would be easy for you to forge acceptance by recording their IP, browser data, and time of signing without their actual signature or consent, it might be a problem to convince a judge or jury that they really agreed to the contract.

Also, I'm not a lawyer, and it's possible that things that make no sense to programmers have been specifically legislated regarding electronic signatures, or even faxed signatures.  I'm just pointing out one possible issue with your proposed solution, there are certainly other issues regarding signatures, contracts, and the law that I'm unaware of.


答:
It's definitely not a standard practice.

Ignoring the legal aspects, most larger companies that purchase IT services are organized with the expectation that there will be a paper contract.  There are groups of people that review the terms of the contract.  There are groups of people that review the cost.  And quite possibly there is someone else with signature authority that has to actually sign the contract.  For that sort of workflow, having a paper document to pass around makes everyone's life easier.  And that's before considering the possibility that the customer requests a change to the terms of the contract

Digital signatures make much more sense for business to consumer transactions where the consumer is the one reviewing the contract (or, more likely, blindly accepting it), the consumer is the one that reviews the cost, and the consumer is the one that clicks the signature button because there is no need for any sort of workflow and no realistic option for the customer to request a change in the terms of the contract.

Title: Do you sign contracts digitally or still on paper? And what do clients think?

Body:
We are all getting used to checking a box and putting our name in a text field to create a contract with an airline, a hosting company, or a software download. However, for some reason I am still asking clients to sign our contracts for website development on paper, and send me a scan. Few complain about this procedure, but I am personally thinking: what am I doing, doing this the old fashion way?! Signing contracts digitally would be faster, more convenient for clients and for me, and easier to store.

So to me it appears to be time to start creating some contract agreement online that clients can read, then print their name, and mark a box "I AGREE WITH THIS CONTRACT AND BY PRINTING MY NAME I AGREE TO SIGNING THIS", or something like that. I would record their IP, browser data, and time of signing. If I really want to ensure their identity, I could link this to OpenID and require them to log in with their e-mail so that I can ensure that they are logged in on an existing e-mail account. Sounds OK to me.

My question is: is this practice becoming a standard practice in professional IT services? Are you (as a professional) doing this? If you are, how do clients react? Any drawbacks doing this?

EDIT:

This question is not about the legal aspects. It is about common practices among programmers and web-development companies, and what clients think of this.


问:
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 concentrated on power consumption from the beginning. This has given them a huge advantage in almost anything that's battery powered.

The popularity of x86 is primarily for historic reasons -- it's been there forever, and it's been good enough that most of the market has had little reason to switch to anything else.


答:
Microkernels replace method calls with inter-process messaging, which adds development complexity for some hypothetical benefits. As it turns out for the most part you can get just about the same advantages from good componentization even if everything is living in one big process.

The question is no longer relevant. CISC architectures no longer exist, all modern processors are RISC in their hearts, but that didn't kill the x86 instruction set. x86 processors since the Pentium-Pro era (17 years ago) use op-code translation to allow an essentially RISC core to look like an x86 CPU from the outside.

Classic Worse is Better. Iteration, pragmatism, network and ecosystem effects beat purity every time.

Title: Why was Tanenbaum wrong in the Tanenbaum-Torvalds debates?

Body:
I was recently assigned reading from the Tanenbaum-Torvalds debates in my OS class. In the debates, Tanenbaum makes some predictions:

Microkernels are the future

x86 will die out and RISC architectures will dominate the market

(5 years from then) everyone will be running a free GNU OS

I was a one year old when the debates happened, so I lack historical intuition. Why have these predictions not panned out? It seems to me, that from Tanenbaum's perspective, they're pretty reasonable predictions of the future. What happened so that they didn't come to pass?


答:
the only way you can prove that the signer actually signed is to have some non-repudiation mechanism in place

one way is to use public private key pair but then you'd have to prove that the private key used actually belonged to the signer this requires either a trusted third party or a second channel


问:
Does giving a developer a slower development machine result in faster/more efficient code?
Suppose I give my developers a screaming fast machine.  WPF-based VS2010 loads very quickly.  The developer then creates a WPF or WPF/e application that runs fine on his box, but much slower in the real world.

This question has two parts...

1) If I give a developer a slower machine, does that mean that the resulting code may be faster or more efficient?

2) What can I do to give my developers a fast IDE experience, while giving 'typical' runtime experiences?

Update:

For the record, I'm preparing my even-handed response to management. This isn't my idea, and you folks are helping me correct the misguided requests of my client.  Thanks for giving me more ammunition, and references to where and when to approach this.  I've +1'ed valid use cases such as:

- specific server side programming optimizations

- test labs

- the possibly buying a better server instead of top of the line graphics cards

答:
I can only imagine the profile experience while using a slow machine. Yikes.

In short. Hell No.

Also have at least 4gb of ram so you can have 2gb on your main machine, 1 for a VM and the other 1 for the extra memory the VM needs and for you to have memory leeway.

Also two processors are a must so if an app locks/eats CPU up the developer doesnt have to painfully way to ctrl-alt-del something.

ContentLicense: CC BY-SA 2.5


问:
How should I evaluate new browser languages?
In these days there are many projects whose aim is to bring new languages to the browser by compiling them to JavaScript. Among the others one can mention ClojureScript, CoffeScript, Dart, haXe, Emscripten, Amber Smalltalk.

I'd like to try a few of these out, but I am not sure what I should be looking for when evaluating these languages to see if they are suitable for production.

How should I evaluate a new browser language, and what are the pitfalls I should be looking for?

答:
Checklist:

Potential Lose Concerns:

How does it handle a moderately complex webApp in all browsers you typically support.

How often do bugs get fixed?

How are the compiler debugging options?

What happens when you want to integrate with other dev's JS code?

What happens when you want to explain your code to JS developers who need to work with yours?

What happens if the community behind it walks away and JS eventually evolves beyond it leading to breakage when the JS down-compiler continues spitting out code that is no longer legal.

What benefit is it to your career as a developer if it never gains popularity and you pissed away years of professional experience on a fad language produced by people who just don't wanna like anything that doesn't work like the languages they know better?

Hopeful Win Concerns:

Does it help you produce faster?

Is it an absolute joy to work with?

Does it Make Working With the DOM easier than native JS (kind of a clunky API)

Is it easier for dirt cheap but otherwise completely useless sweatshop devs who can barely understand the Java they pretend they know to produce viable front-end code? (hint: no, it's not)

Obviously I've got a bit of a slant here but I have no problem with other languages getting popular on the front end. But not down-compiled to JS. That's just somehow offensive to me as a JS developer. If JS does what you need it to do, bend fold and mutilate it into something that works better for your thought process. It's flexible like that. The core syntax can't be altered but you can redefine the way you personally solve problems with it very easily once you know it fairly well.


问:
Storing data offline with javascript
My question is about storing data offline and potentially whether I will need to bring in an outside programmer or could this be learned within a few weeks?

The website I am working on will have an interface where users will login and go through a series of quizzes in the form of checkbox, drop down menus, and others. Each page/quiz area could have 20-100 total checkboxes in a series of 3-5 rows because of the comprehensive nature of course.

This I can do - I know how to code the quiz and return a correct or incorrect answer based on each individual checkbox and present a cumulative score (ie: you got 57% correct).

The issue lies in the fact that I would like to save the users results and keep them informed of their progress. When they complete all of the quizzes, I would like to have a visual output of their performance in each area. Storing the output from their results offline is where I think I may run into a problem with my lack of coding experience. I would also like to have a sidebar with their progress of each section (10-15) with a green percentage completion bar or a % correct which would draw from this.

I have never had to code something that stores information like this offline - so back to my question - would it be better to learn the language needed or bring in a coder/developer for the back end stuff.

答: If it's not critical that the answers be super-secure, just throw it into a cookie. All you need is some kind of a string codified into quiz numbers and answers right? You can parse it and evaluate to establish whether they were correct and spit out percentage complete/correct etc based on the info I'm assuming you already have baked into your JS.</p>

Title: Storing data offline with javascript


问:
Simple C: How do I scan this information in properly?
OK this is a simple question but for some reason I just can't get it right. I have to scan from a file hundreds of lines of code and store it in a array (which I can normally do a ok job with) however At one point the code will specify a number that then corresponds to the next batch of chars ints and floats going into various arrays.

As I know I am not describing this correctly here is a example.

one line of the file I am reading will contain something close to this.

0221 T 2 S P 850 150 0.90 0.75 500 24 2 2012 G A 7 9600.00 0.1 1000 Name_of_place

0104 L 1 F 400 1.00 0.75 500 24 2 2012 G A 7 9600.00 0.1 1000 Ballroom

the problem I am having is This part here

0221 T 2 S P 850 150 0.90 0.75 500 24 2 2012 G A 7 9600.00 0.1 1000 Name_of_place

0104 L 1 F 400 1.00 0.75 500 24 2 2012 G A 7 9600.00 0.1 1000 Ballroom

The rest after this is Generally the exact same however at this point the number at the front descides all the values that are going in. I am almost completely lost on how to write a way that can scan this and store the data into arrays correctly

答:
One way to do it is to scan each line into an appropriately sized buffer using fgets:

```<code>fgets(buffer, BufferSize, fp);
</code>```

and then use the string tokenizer:

```<code>char* pch = strtok(buffer, " ");
venue.code = atoi(pch);
pch = strtok(NULL, " ");
venue.type = pch[0];
pch = strtok(NULL, " ");
venue.numberOfSeatingTypes = atoi(pch);
</code>```

Once you've grabbed the sizes of the variable bits, you can then malloc space for them:

```<code>venue.seatingTypes = (char *)malloc(sizeof(char) * venue.numberOfSeatingTypes);
venue.seatingSize = (int *)malloc(sizeof(int) * venue.numberOfSeatingTypes);
</code>```

And then continue using the string tokenizer in a loop to get the variable seating types and size of each type.

Be aware that the string tokenizer is not re-entrant, so you may be better off using the re-entrant version.

Body:
One way to do it is to scan each line into an appropriately sized buffer using fgets:

fgets(buffer, BufferSize, fp);

and then use the string tokenizer:

char* pch = strtok(buffer, " ");
venue.code = atoi(pch);
pch = strtok(NULL, " ");
venue.type = pch[0];
pch = strtok(NULL, " ");
venue.numberOfSeatingTypes = atoi(pch);

Once you've grabbed the sizes of the variable bits, you can then malloc space for them:

venue.seatingTypes = (char *)malloc(sizeof(char) * venue.numberOfSeatingTypes);
venue.seatingSize = (int *)malloc(sizeof(int) * venue.numberOfSeatingTypes);

And then continue using the string tokenizer in a loop to get the variable seating types and size of each type.

Be aware that the string tokenizer is not re-entrant, so you may be better off using the re-entrant version.


问:
Is it a waste of time to free resources before I exit a process?
Let's consider a fictional program that builds a linked list in the heap, and at the end of the program there is a loop that frees all the nodes, and then exits. For this case let's say the linked list is just 500K of memory, and no special space managing is required.

Is that a waste of time, because the OS will do that anyway?

Will there be a different behavior later?

Is that different according to the OS version?

I'm mainly interested in UNIX based systems, but any information will be appreciated. I had today my first lesson in OS course and I'm wondering about that now.

Edit: Since a lot of people here are concerned about side effects, and general 'good programming practice' and so. You are right! I agree 100% with your statements. But my question is only hypothetical, I want to know how the OS manages this. So please leave out things like 'finding other bugs when freeing all memory'.

答:
Some C++ GUI libraries leak resources like this.  This is not a value judgement, but leaking resources and letting the OS reclaim them is a somewhat common occurrence in "real code."

It's always good practice to clean up though, you never know when you'll want to integrate that tool with something else, and then the work is already done (instead of going into the wayback/ remembering machine and remembering all the spots you intentionally leaked).

In one case we actually found a bug because the deallocation was causing a crash because some other memory bug had overwritten the header that delete uses.  So, sometimes it can actually help you to find bugs in other areas to free all your resources (you can find an overrun in the previous block).


答:
Problem Diagnosis.

It's a familiar term, if you ever get your auto fixed or go to a doctor, diagnosis is a common term for figuring out what's wrong.  It is also accurate, you have to go under the hood and see how everything is connected to figure out what's not working.  It really is akin to working on an engine without the manual, and the company went and made the engine without looking at another engine before (so it's likely unique).

A long-winded or strangely-worded line item will get more questions which you really don't want.  "Problem diagnosis" is a more or less universally-understood concept.


答:
Still almost 100% on paper, even getting signed hardcopies after scanning the originals.

I always assumed it was due to the legal standing, and difficulty tampering, but what do I know?


问:
How would you know if you've written readable and easily maintainable code?
How would one know if the code one has created is easily readable, understandable, and maintainable? Of course from the author's point of view, the code is readable and maintainable, because the author wrote it and edited it, to begin with. However, there must be an objective and quantifiable standard by which our profession can measure code.

These goals are met when one may do the following with the code without the expert advice of the original author:

It is possible to read the code and understand at a basic level the flow of logic.

It is possible to understand at a deeper level what the code is doing to include inputs, outputs, and algorithms.

Other developers can make meaningful changes to the original code such as bug fixes or refactoring.

One can write new code such as a class or module that leverages the original code.

How do we quantify or measure code quality so that we know it readable, understandable, and maintainable?

答:
The proof is in the pudding.  Watch what happens after handing it off to a reasonably competent person.  If they don't need to ask many questions relative to the difficulty of the code, you've done a good job.

This was an early lesson in my career.  A mentor said, "Document everything, so that you can escape the program later on.  If you don't anticipate questions when the answers are fresh in your mind, you'll have to figure them out when they're not."


问:
Where Can I List My Opensource Project?

Possible Duplicate:

  How can I get the word out about a new (open-source) library I've developed?

I have hosted my latest project, a JVM-based MIDI processor/API called Mjdj MIDI Morph, on Github (here and here). Now I need to bring some interest to it, even if it's negative interest (so I can improve it). I've looked up open source list on Google and end up with such things as this page on Wikipedia, which makes it quite clear that they don't want your project if it's new. Where should I list my project? Short of adwords and talking it up in forums and trade shows, where should I submit my URLs?

答: Suggest it to Dan Benjamin, and he might discuss it on his software development podcast, The Dev Show. Your website has black text on a white background, so your project has a good chance of making it into the show.</p>

Title: Where Can I List My Opensource Project?


答:
Since it's line-oriented, I'd start by reading a line (e.g., with fgets).

Then I'd parse out the individual items in a line using sscanf. At least if I'm understanding correctly, you need to scan the first three (or so) fields, then based on the contents of (some of?) those, decide how to parse the rest of the line. That's, again, fairly straightforward. Just read in N fields (N=3, I think), then you'd do something like:

```<code>switch (venue_type) {
    case 'S':
        // read whatever
    case 'F'
        // read stuff for ballroom
    case 'T':
        // read stuff for theater
}
</code>```

It may be easiest to re-read the line from the beginning for each type of venue, rather than trying to continue after the third (or so) field that you've already read.

Title: Simple C: How do I scan this information in properly?

Body:
OK this is a simple question but for some reason I just can't get it right. I have to scan from a file hundreds of lines of code and store it in a array (which I can normally do a ok job with) however At one point the code will specify a number that then corresponds to the next batch of chars ints and floats going into various arrays.

As I know I am not describing this correctly here is a example.

one line of the file I am reading will contain something close to this.

0221 T 2 S P 850 150 0.90 0.75 500 24 2 2012 G A 7 9600.00 0.1 1000 Name_of_place

0104 L 1 F 400 1.00 0.75 500 24 2 2012 G A 7 9600.00 0.1 1000 Ballroom

the problem I am having is This part here

0221 T 2 S P 850 150 0.90 0.75 500 24 2 2012 G A 7 9600.00 0.1 1000 Name_of_place

0104 L 1 F 400 1.00 0.75 500 24 2 2012 G A 7 9600.00 0.1 1000 Ballroom

The rest after this is Generally the exact same however at this point the number at the front descides all the values that are going in. I am almost completely lost on how to write a way that can scan this and store the data into arrays correctly

Body:
Since it's line-oriented, I'd start by reading a line (e.g., with fgets).

Then I'd parse out the individual items in a line using sscanf. At least if I'm understanding correctly, you need to scan the first three (or so) fields, then based on the contents of (some of?) those, decide how to parse the rest of the line. That's, again, fairly straightforward. Just read in N fields (N=3, I think), then you'd do something like:

switch (venue_type) {
    case 'S':
        // read whatever
    case 'F'
        // read stuff for ballroom
    case 'T':
        // read stuff for theater
}

It may be easiest to re-read the line from the beginning for each type of venue, rather than trying to continue after the third (or so) field that you've already read.


答:
Let's run trough your examples, shall we?

Airlines, hosting companies, and software downloads are all paid in advance.

Big Corps (many airlines, some hosting company, and some software house) that sell over the internet usually have troops of lawyers, paid by the hour, ready to challenge any judge and law that says their contracts, and the provisions in them, have no legal standing.

Airlines, anyway, don't make you (don't need you to) sign a contract when you buy a ticket in real life. (Software houses with prepackaged products, too: no signature when they give you a DVD in a big box)

Hosting companies may, physically, always terminate your service at any moment, without even telling you. If that happens, the fact the non-signed contract between you and them may be proven to have no legal standing, would only benefit them.

Software houses selling non-customized products by the download, have copyright in their favour and usually very little expenses directly associated with a single sale. If you don't pay, you have no right on your copy of the software, if you pay, you still only get a license to use it. (some of the clauses of it, still, may be non-enforceable - i.e. illegal) Anything you do with that software you downloaded that isn't using it on your own, is, by default, illegal, with or without a contract standing.

So, here's our problem: software houses that customize products for clients, (i.e. 90% of them) instead:

take big money from a little number of valued clients

usually only get a fraction of the price in advance

won't be able to pay employees if they lose one or two clients

are selling something that hasn't been written yet

are selling a product that may need to pass some certification

need to set a delivery date

Not getting paid or not getting the product you ordered is... pretty likely, and not funny.

You must be damn sure your contract stands in court, so, paper it is.


答:
With a client that likes to understand how things work and listens to me with dreamy eyes, I'd go with a straight Codebase Familiarization. I'd have already explained him what a stream of pain he's putting me into, and the advantage of coming to me for further upgrades.

With the other type of customer... (same treatment, but he doesn't evidently listen to a single word I'm saying) I'd go with something on the lines of:

Planning Phase

Intervention Planning

(I'd use this one, actually, but I'd write that in Italian, in which it sounds way better)

Then, maybe... Solution Planning

I like the Diagnosis part of the Problem Diagnosis suggestion by anon, but the Problem doesn't sound right to me. It can be open to mild, biased, ignorant, and superficial criticism... that may leave a bad taste behind.

You know, everybody wants to throw a dart at the external consultant, and they do. (...like he wasn't good enough to understand the root of the problem while talking to them, and had to invoice his cluelessness, or god knows what)


问:
Best approach for a database of long strings
I need to store questions and answers in a database. The questions will be one to two sentences, but the answers will be long, at least a paragraph, likely more.

The only way I know about to do this right now is an SQL database. However, I don't feel like this is a good solution because as far as I've seen, these databases aren't used for data of this type or size. Is this the correct way to go or is there a better way to store this data? Is there a better way than storing raw strings?

答:
Mongodb is great, but you know SQL. There is nothing wrong with storing long answers in fields. You can store images or even files in SQL.  I think the max field size is 2gb.

I'm almost positive this answer itself is being stored in a table field somewhere.

As for there being thousands of them, no problem. Even millions shouldn't be an issue. You might consider utilizing full text indexing if you're searching the field for keywords or something. But I try not to optimize till I see a problem. Computers are cheap, storage is basically free.

ContentLicense: CC BY-SA 4.0


答:
Fixing a bug: root cause analysis.

New feature: analysis, design, integration, and testing.

Introducing new bugs: job security. :)


答:
There is no problem storing long text in databases (SQL or otherwise).  Thats how virtually every blog entry (think Wordpress), news article, and forum post (think phpbb) on the internet is stored.  I don't know the specific details of stack exchange's setup, but I'm sure your question is stored in a database, too.  Most SQL databases have a TEXT field type or the equivalent just for the purpose of storing textual data of any length.  Many also have full text searching systems in place.

Make technical decisions based on technical knowledge and understanding, not feelings.

Title: Best approach for a database of long strings

Body:
I need to store questions and answers in a database. The questions will be one to two sentences, but the answers will be long, at least a paragraph, likely more.

The only way I know about to do this right now is an SQL database. However, I don't feel like this is a good solution because as far as I've seen, these databases aren't used for data of this type or size. Is this the correct way to go or is there a better way to store this data? Is there a better way than storing raw strings?


答:
There is a great article on the ecosystems and design philosophies behind these two architectures. I think it was in wired but basically arm is RISC based. Thats reduced instruction set. Back in the early 90s apple switched to the PowerPC chip based on the belief RISC chips would soon deliver higher efficiencies.

Meanwhile intel was adding instruction sets to its core. Remember the MMX suffix in mid to late 90s?

Well, Intels size and creativity (and some big ass cpu fans!) held divergence in performance/efficiency at bay for much longer than expected but mobile devices benefit greatly from the reduced power consumption and no one wants a CPU fan on their iPhone...

The irony is, apple switched to x86 at the end of the 90s for OSx.

Title: Why does ARM processors dominate Mobile platforms while x86 dominates Desktop/Server platforms

Body:
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>


答:
The biggest point here is that, ARM's power consumption is greatly desirable for the portable devices. Almost 75% the mobile devices run ARM processor.

There's an excellent article about the comparison of both platforms.
http://vanshardware.com/2010/08/mirror-the-coming-war-arm-versus-x86/

Also ARM's business model is slightly different from AMD or Intel. They license their technology than manufacturing their own chips. There's a strong point here is that, people really don't want to buy microprocessor alone and they will be embedded in a device or form factor. Now Intel is trying to compete in this space by bringing in less power consuming chips. Also the PC sales are declining more than ever before.


答:
Managing memory is the best-practice while taking decision to release it in a context is optimization!

Now the ball is in our court!

Title: Is it a waste of time to free resources before I exit a process?

Body:
Let's consider a fictional program that builds a linked list in the heap, and at the end of the program there is a loop that frees all the nodes, and then exits. For this case let's say the linked list is just 500K of memory, and no special space managing is required.

Is that a waste of time, because the OS will do that anyway?

Will there be a different behavior later?

Is that different according to the OS version?

I'm mainly interested in UNIX based systems, but any information will be appreciated. I had today my first lesson in OS course and I'm wondering about that now.

Edit: Since a lot of people here are concerned about side effects, and general 'good programming practice' and so. You are right! I agree 100% with your statements. But my question is only hypothetical, I want to know how the OS manages this. So please leave out things like 'finding other bugs when freeing all memory'.


问:
Best books on the theory and practice of software architecture?
I have a couple of developers at my company who wish to move from programming into architecture. What are the best books out there on the theory and practice of software architecture? Include a cover picture if you can.

Feel free to include general books, and also books that relate to a specific technology.

答:
Microsoft have some really good stuff on this. For a start they have a great free book available here:

http://msdn.microsoft.com/en-us/library/ff650706.aspx

Plus a lot of their white papers on design are here:

http://msdn.microsoft.com/en-us/practices/bb190351

You probably want to read up on design patterns:

http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612

And then there's the classics - mythical man month, code complete, pragmatic programmer etc. A bit of googling will help you find the good books.


答:
What I'd suggest that, please go and read Code Complete 2 first. This will help you to shape your thoughts and find the best way of doing things.

In the architecture perspective, it's good start with GOF or Head First Design Patterns.

Patterns of Enterprise Application Architecture is an excellent book

Title: Best books on the theory and practice of software architecture?

Body:
I have a couple of developers at my company who wish to move from programming into architecture. What are the best books out there on the theory and practice of software architecture? Include a cover picture if you can.

Feel free to include general books, and also books that relate to a specific technology.


答:
Yes it's the correct way to go. Storing strings in a SQL database is what you want to do.  One of my tables in the DB has over a gig of plaintext data and it performs fine.

If you're worried about storage space - remember that it's cheap!

If you're worried about performance - then don't worry, a good database can scale up (or out) to however much data you want to throw in it.

The last thing you want to do is start optimising now for the sake of it (compressing strings before you put them into the DB or something nuts) before it actually becomes a problem. You're just giving yourself more work.


问:
Challenges to the Agile approach on government projects
A previous Agile discussion here had good answers specifying what is critical to the success of implementing Agile methodology in software development.  Most of the points were the typical organizational and management challenges, but one point worries me and it is that the client must be involved throughout the process.

The client is the one thing that you cannot control realistically, perhaps your business model gears you to government contracted work for instance where an intensely strict contract obligates the company to:

Provide X features exactly as requested

Feature requests will be thrown over a wall, don't bother us we don't want to hear it.

There is no concept of feature priority in the customer's mind, they are all important or we wouldn't have asked for them.

The project will cost no more and no less than Y regardless of overruns or deadlines.

Absolute, strict, final and non-negotiable deadline for complete delivery of all work.

We have never worked with such a client before but the money on the project is just too good to pass up.  We need this work.

I came here and worked HARD to change processes within to move towards Agile development and here I don't know how to reconcile where this project fits into our new process.   I have never before had the luxury of open-minded hands-off management that trusted me to lead the development team and processes down this path and now that we are here I can't honestly tell myself that this project will truly be done in an Agile way.  I feel like management trusted me to lead this path and that I let them down because this situation we are in now so clearly calls for Waterfall.  I am afraid that I might lose their trust if I backtrack now.

Other answers like the one here say Agile is impossible with this kind of client, do you agree?  Have any of you been in a similar situation and made it work?  What strategies did you implement to make Agile happen successfully?

答:
Sadly what you've described is the typical customer view of how a software project should be tackled.  This is not to say that the customer is being unreasonable; after all -- isn't this how one would execute the building of anything else (a house, for instance?).  That being said though, I'm not really offering anything more than what we all already know.  What you're asking is ... is application of agile practices feasible in this situation?

I have the benefit of having just finished a project that is similar in many respects to the situation that you describe, i.e.,

Fixed (in stone, come hell-or-high-water) deadline.

Functional Requirements Document ("the bible").  Unsurprisingly inadequate.

Traditional roles: Project Manager, Business Analyst.

Weakly engaged business users (can you say "no product sponsor"?).

... and of course, the forward-thinking development team is trying to work in an agile fashion, despite the above:

2 week iterations;

Stand-ups;

Retrospectives;

Pair programming;

TDD;

Continuous integration.

Is any of this remotely meaningful to Business though? No.  Two months to deadline, the up-until-then carefully observed iterations and planning meetings are abandoned in a frenzy of headless-chicken-itis.

The answers that others have provided above are to a greater or lesser degree compromises.  In my opinion, agile (whether "Agile" or "agile") is "done in" in a pernicious fashion when we compromise.  In my opinion:

There is no compromise, or there is no agile.

The very spirit of agile is about cutting to the chase, removing the waste, being brutally honest with oneself.  It is a now well-documented and undeniable fact that software estimation on large projects is a gamble at best.  Is it not our duty as software professionals to educate prospective clients of this?  If clients are unwilling to accept that we're the experts, then isn't it our professional duty to walk away?


答:
It's sad how so many programmers think technology has all the solutions, when it's not really a problem that needs a solution, and worse - theres already one that works.

Paper signitures have been around for ever, are recognised by courts and have plenty of case law behind them. Digital signitures are new, not well understood (except by geeks such as us), complex and rely on technology, with virtually no case law behind them.

Legal cases that establish case law are long, drawn out, protracted and most importantly, expensive. Are you prepared to be the case that is used to establish case law? "Feeling lucky, well, are you punk.......".

Apart from that, your customers probably expect paper contract, and certainly will not reject them, and will be comfortable with them.


答:
My mechanic sends me a bill "Change oil, spark plus, check filters, tyre rotations. Fix engine rattle, road test.....

Parts (itemised),

Labour x @ $y/hour = z)

He does not break down the labour, neither should you.  Bill for total hours, and describe what you did.


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

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

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

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

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

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

答:
The term "scope", here, refer to the time that a variable exist in life.
It starts when the constructor is called and ends when the destructor is called.

In C++ and Java the variable begin to exist when its definition is encountered, and end it existence when the end of block that contains such definition is reached (either by the sequential flow or by a "jump-ahead" instruction like break, goto, return, throw)

In C# all variables declared in a block are created at block entrance, but initialized accordingly to their definition (so they cannot be used before, although they already "exist" in term of allocated space, and hence can be referenced, since their address is already known)

Inside a local block this is much more a sophism, that doesn't make any real difference to the programmer, but -on wider scopes- lets the compiler able to generate the code also in presence of "circular dependencies", that in C++ have to be avoided with other tricks like header guards or two-phase construction etc.

Title: What is meant by Scope of a variable?


问:
Dealing with the customer / developer culture mismatch on an agile project
One of the tenets of agile is ...

Customer collaboration over contract negotiation

... another one is ...

Individuals and interactions over processes and tools

But the way I see it, at least when it comes to interaction with the customer, there is a fundamental problem:

How the customer thinks is different to how a software engineer thinks

That may be a bit of a generalisation, yes.  Arguably, there are business domains where this is not necessarily true---these are few and far between though.  In many domains though, the typical customer is:

Interested in daily operational concerns--short-range tactics ... not necessarily strategy;

Understandably, only concerned with the immediate solution;

Practical thinkers, not abstract thinkers;

Much more interested in "getting the job done" than considering how the solution will support future concerns.

On the other hand, in the ideal, software engineers who practice agile are:

People who think alot about quality;

Individuals who appreciate how a little bit of upfront work can save a ton in effort down the line;

Experienced, analytical thinkers.

So there seems to be a culture discrepancy that tends to inhibit "customer collaboration".

What's the best way to address this?

答:
Well, first and foremost, Agile is not the solution for all the problems you have in your project.

How the customer thinks is fundamentally different to how a software engineer thinks

Yes. Sometimes it is true. There are even case where customers do not know what and how they want (ie; requirements are not clear). What ever, If you are agile you get the result after each sprint (say 2 weeks) and you get an opportunity to get customer feedback and make sure all are on the same page. This helps in identifying and fixing the issues early which will internally help build trust.

Also there is a saying, users are like crazy children, so when they are asking for a gun and you know it is not safe, you might consider giving a toy gun to calm them down.

What's the best way to address this?

As I have told already there are no magic stick that can solve all theses problems. You need to engage more with your customers so that there is a good understanding about what each others do. Promote the site visit, open feedback etc.

Make sure your product owner and the stake holders attend the sprint demos and gives valuable suggestion to improve the product.


问:
How to improve testing your own code
Today I checked in a change on some code which turned out to be not working at all due to something rather stupid yet very crucial.
I feel really bad about it and I hope I finally learn something from it. The stupid thing is, I've done these things before and I always tell myself, next time I won't be so stupid... Then it happens again and I feel even worse about it.

I know you should keep your chin up and learn from your mistakes but here's the thing: I try to improve myself, I just don't see how I can prevent these things from happening.

So, now I'm asking you guys: Do you have certain groundrules when testing your code?

答:
Do you have certain groundrules when testing your code?

Always unit test your code, and try to reach as high coverage as possible.

Some additional general points :

invest some time into design and planing before starting to code

refactor your code!

Title: How to improve testing your own code


答:
In many domains though, the typical customer is:

Interested in daily operational concerns--short-range tactics ... not strategy;

Only concerned with the immediate solution;

Generally one-dimensional, non-abstract thinkers;

Primarily interested in "getting the job done" as opposed to coming up with a lasting, quality solution.

And to be frank, they usually have good reasons to think like this. First of all, they are running a business, which should generate revenue today and tomorrow, not in some distant future. Secondly, they aren't technical experts - they don't know what's possible and what's not, and what the consequences of specific architectural / design / implementation choices are. This is what we know.

So the answer is - hardly surprising - communication.

You need to communicate a lot, to educate each other, to make each other understand the point of view of the other party at least to a basic level. You need to explain them the short and long term consequences of possible alternatives. And you need to use language they understand.

If you say "this would be a hack, which makes the code less readable and extensible", they say, "yeah, whatever".

If you say "this would be a short term fix, which would make longer term development and maintenance more costly, and increase the risk of introducing bugs", they say "a ha, let's consider".

And if you say "this solution would cost you $100 now, but introduces $500 of technical debt which you are bound to pay back with interest sooner or later; OTOH this other solution costs you $400 now and leaves no technical debt; pick the one you want", they say "now we are talking!".

OTOH they can teach us a thing or two about the business perspective. Business wants usable and good enough - hardly perfect - solutions. And they know probably better than anyone that "perfect is the enemy of good". So you need to keep in mind that our job is to provide solutions to problems of our clients, rather than to produce technically perfect software. Sometimes these two converge to the same, but more often not. This may be seen as sad by many, but it is business reality. For me, if I managed to solve my customer's problem, and I see that it made their life visibly easier, I am as happy as they are. OTOH if I managed to implement the perfect design I had in mind, but the company goes bankrupt the following week, it is hardly a win to anyone is it?

A sensible business owner will understand - if you explain them using their own language - why is it important to keep software clean, to write unit tests, to refactor etc. Even though these do not seem to directly contribute anything in the short term, they are essential for long term maintenance. And sensible customers do care about the long term maintainability of their business, so they surely are willing to invest into it when they see the value their investment generates. However, both their resources and your time are limited, so you need to prioritize and focus on the most important things. But it is important only if it is important to both of you.

You may want to refactor module A because the code in there is just awful, and you have a stupendous idea how to refactor the code to be concise, elegant and clean, using a design pattern you just read about. However, if that module hasn't been touched for years, and it works reliably, you are most likely better off focusing on module B, which is going to be extended next week with a very important new feature, and it contains tons of bugs already.

Title: Dealing with the customer / developer culture mismatch on an agile project

Body:
One of the tenets of agile is ...

Customer collaboration over contract negotiation

... another one is ...

Individuals and interactions over processes and tools

But the way I see it, at least when it comes to interaction with the customer, there is a fundamental problem:

How the customer thinks is different to how a software engineer thinks

That may be a bit of a generalisation, yes.  Arguably, there are business domains where this is not necessarily true---these are few and far between though.  In many domains though, the typical customer is:

Interested in daily operational concerns--short-range tactics ... not necessarily strategy;

Understandably, only concerned with the immediate solution;

Practical thinkers, not abstract thinkers;

Much more interested in "getting the job done" than considering how the solution will support future concerns.

On the other hand, in the ideal, software engineers who practice agile are:

People who think alot about quality;

Individuals who appreciate how a little bit of upfront work can save a ton in effort down the line;

Experienced, analytical thinkers.

So there seems to be a culture discrepancy that tends to inhibit "customer collaboration".

What's the best way to address this?


问:
what is best book to learn optimized programming in java

Possible Duplicate:

  Is there a canonical book for learning Java as an experienced developer?

Let me elaborate a little:

I used to be a C/C++ programmer where I used data structure concept like trees, queues stack etc and tried to optimize as much as possible, minimum no. of loops, variables and tried to make it efficient. It's been a couple of years that I started writing java codes, but it is simply not that efficient in terms of performance, memory intensive etc.

To the point:

I want to enter programming challenges using java so I need to improve my approach at things I program. So please suggest me some books that can help me learn to program better and have a chance in solving challenges in programming.

答:
Considering the fact that you were a C/C++ programmer that appears to understand how to do things efficiently, you can really just do the same things you did when programming in C/C++ to optimize Java code.

A great all around resource for data structures and algorithms, however, is Introduction to Algorithms (CLRS). All of the code snippets are java-style syntax


答:
Java is somewhat more distant from the actual machine than C++ due to the JVM design.   The general suggestion is to write very clean code so the JVM has the best possible conditions to compile it into machine code and know the various runtime implementations to choose the most appropriate at hand.

That said, the currently mostly recommended book to go from that is "Effective Java" by Joshua Bloch.  See http://en.wikipedia.org/wiki/Joshua_Bloch for ISBN numbers and links.   Highly recommended.

Title: what is best book to learn optimized programming in java

Body:
Possible Duplicate:

  Is there a canonical book for learning Java as an experienced developer?

Let me elaborate a little:

I used to be a C/C++ programmer where I used data structure concept like trees, queues stack etc and tried to optimize as much as possible, minimum no. of loops, variables and tried to make it efficient. It's been a couple of years that I started writing java codes, but it is simply not that efficient in terms of performance, memory intensive etc.

To the point:

I want to enter programming challenges using java so I need to improve my approach at things I program. So please suggest me some books that can help me learn to program better and have a chance in solving challenges in programming.


问:
Static class vs Singleton class in C#

Possible Duplicate:

  What is the difference between all-static-methods and applying a singleton pattern?

I need to make a decision for a project I'm working of whether to use static or singleton.

After reading an article like this I am inclined to use singleton.

What is better to use static class or singleton?

Edit 1 : Client Server Desktop Application.

Please provide code oriented solutions.

答:
Your code will be more flexible if you use a singleton.

The advantage is that the code that uses the singleton doesn't need to know if it is a singleton or a transient object. Using a static class means you have to call static methods explicitly. Think about dependency injection, for example.

Moreover, singleton, as a non-static class, can still implement an interface, supports inheritance, etc. For example, you can't inherit a static class and override a virtual method in it.

Title: Static class vs Singleton class in C#


答:
You have not mentioned whether it is a Web application or a standalone desktop application.

If it is a Web application, Static Classes can create some major problems in a concurrent environment (because of shared data), specially when you are also using static variables and static methods.

Title: Static class vs Singleton class in C#

Body:
Possible Duplicate:

  What is the difference between all-static-methods and applying a singleton pattern?

I need to make a decision for a project I'm working of whether to use static or singleton.

After reading an article like this I am inclined to use singleton.

What is better to use static class or singleton?

Edit 1 : Client Server Desktop Application.

Please provide code oriented solutions.


答:
Thorbjørn Ravn Andersen answered this really well, I'll put in a slightly different slant.

+1 - The JIT (Just In Time) compiler is generally very aggressive in its runtime optimisations and it learns as it goes.  Keeping your methods to ~<35 byte codes for example will ensure that they get inlined and there are many other tricks as well.  Also see Charlie Hunt's recent book on Java performance


答:
I agree with everything Martin said, +1 to that. To add a little, also consider that today your application has a global shared object and tomorrow you decide that you want to have more than one instance of it.

If you use a singleton, all you need to do is make your constructor public. But if you decide to use a static class, the change would have to be much more intrusive.

Also if you ever decide to add unit tests to your code, replacing a singleton instance with a fake one is much easier (change in one place) compared to having to deal with a whole bunch of static functions that all share global data.

Title: Static class vs Singleton class in C#


问:
Why choose an established CMS as opposed to building one from scratch?
A lot of my research over the next few weeks will be into different CMS's. I've already had a brief look at episerver and umbraco. While reading into these systems I can't help but think that providing content management features are achievable without learning the details and structure of many of these (rather large) CMS platforms.

I have, in the past, been given projects whereby my role as a developer must be kept separate to that of an editor (makes sense). i.e. It was my task to develop the design and functionality of the site and my clients' job to update the content. I've achieved this by also implementing a sort of 'portal' on which there were a couple of pages that would accept text input and picture uploads etc. (basically, whatever content they wanted), record this new content to the database and then by design the code-behind would read all this from the database into relevant controls (repeaters for example).

For me, this has been an effective enough way of my clients managing the content to deploy with my solutions. I know that I am wrong - and that CMS's are preferable to those that are built from the ground up - but other than the matter of cost, why?

答:
Stick to core business is a pretty good argument as well I would say. Just because you are building a car doesn't mean you should also create your own fuel as well. That's a completely different product and chances are pretty good that someone else will do it a lot better since your focus will be elsewhere.
Bugs in newly developed systems shouldn't be underestimated either. A cms that have been around a while will have a few bugs yes, but no where near the number that your new one will have. An existing cms have been tested by millions of users through the years. </p>

OwnerDisplayName: SkonJeet


答:
I think Effective Java (already mentioned) makes a pretty good start.

For more comprehensive references list, my favorite is one at Angelika Langer Links - Java Performance:

Books

"Java Platform Performance: Strategies and Tactics" by Steve Wilson & Jeff Kesselman

The book and related resources are available online at http://java.sun.com/docs/books/performance/ .

"Inside the Virtual Machine" by Bill Venners

Sample chapters of the book are available online at http://artima.com/insidejvm/ed2/index.html .

"Performant Java programmieren" by Hendrik Schreiber

Additional information (errata, links, downloads) can be found at http://www.tagtraum.com/performance/ .

"Garbage Collection" by Richard Jones & Rafael Lins
An excellent book on garbage collection algorithms in general; more information at http://www.cs.kent.ac.uk/people/staff/rej/gc.html .

Links & Resources

Sun Microsystems
A collection of links and resources at Sun Microsystems can be found at http://java.sun.com/docs/performance/ .

Jack Shirazi
Further resources for Java performance tuning including a list of tools can be found at http://www.javaperformancetuning.com/resources.shtml .

Articles, Papers & Specifications

JSR-163: Java Platform Profiling Architecture

The profiling architecture as designed for release in J2SE 5.0.  The specification group's page can be found at http://jcp.org/en/jsr/detail?id=163 .

WHITE PAPER: J2SE 5.0 Performance White Paper

The paper gives an overview of the performance and scalability improvements made in the J2SE 5.0 release along with various benchmarks to demonstrate the impact of these improvements. It has numerous links to further resources. http://java.sun.com/performance/reference/whitepapers/5.0_performance.html

For deeper drilling into Java performance topics, articles by Brian Goetz in Java theory and practice and Threading Lightly  series are hard to beat:

Performance management -- do you have a plan?

Urban performance legends

Synchronization optimizations in Mustang

Dynamic compilation and performance measurement

Urban performance legends, revisited

Garbage collection and performance

Introduction to nonblocking algorithms

Threading lightly, Part 1: Synchronization is not the enemy

Threading lightly, Part 2: Reducing contention

Threading lightly, Part 3: Sometimes it's best not to share


答:
If you do not have buy in from the customer, Agile can be nearly impossible.

By buy in, I mean getting some guarenteed percentage of a customer representatives time per week or month. This percentage will vary depending on the project.

Obviously they have their day job, so it's not just down to the customer representative themselve, it's down to their management to make time for them.

So getting agreement from management on the customer side is key to this problem


问:
Do I have to write a lot of boilerplate code if I keep working using Java?
I'm working for a company writing ERP applications. My problem is that I have to write tons of boilerplate code. I came up with ideas to automatize/prevent the drudgery but only some of them were accepted. I have been told by the lead developer that my ideas tend to be go far afield and I should write code everyone can understand.

I had a discussion about this lately and it seems to me that this kind of code ramp is within java's philosophy. I have to write lots of code to achiveve simple things not because it is necessary but because this is the way most of the people at the company think.

Is this universally applicable to most of the companies out there using java or this is just my company's view? Do I have to get used to the drudgery if I keep working for java-based firms?

答:
We are talking about quite different things here. Replacing boilerplate code with a completely different way of doing things, such as reflection, can be hairy. There can indeed be very good reasons against doing this even if it simplifies programming for you, such as loss of type safety and security, runtime cost, increased understanding and maintenance cost for others, etc. No idea whether or not that is the case in your situation, but it might well be.

However, simplifying the generation of boilerplate code is quite another thing. If it's repetitive enough that it can be completely automated, then I'd say yes, it absolutely should be automated. There's just too much that can go wrong maintaining such codebases by hand, and just too much effort saved not to do it. And if co-workers can't even understand how a code generator works, then, well, they shouldn't be co-workers in my book.


答: I dont believe that the use of 'boiler plate' code is related to a particular language, but rather that it is a design decision. For whatever reasons, the company you are currently working for has made that choice, possibly in relation to ease of maintenance or facilitating the operational support of the applications. 'Reflection is evil' is just a reflection on those reasons, an easy mantra to remember and put in practice.</p>

Title: Do I have to write a lot of boilerplate code if I keep working using Java?

Body:
I'm working for a company writing ERP applications. My problem is that I have to write tons of boilerplate code. I came up with ideas to automatize/prevent the drudgery but only some of them were accepted. I have been told by the lead developer that my ideas tend to be go far afield and I should write code everyone can understand.

I had a discussion about this lately and it seems to me that this kind of code ramp is within java's philosophy. I have to write lots of code to achiveve simple things not because it is necessary but because this is the way most of the people at the company think.

Is this universally applicable to most of the companies out there using java or this is just my company's view? Do I have to get used to the drudgery if I keep working for java-based firms?


答:
This question brings this old quote to mind:

"Debugging is twice as hard as writing the code in the first place.
  Therefore, if you write the code as cleverly as possible, you are, by
  definition, not smart enough to  debug it. [Brian W. Kernighan]"

In a team environment this would need to be expanded so that if the smartest person on the team writes the cleverest code they can, then the dumbest person onthe team doesn't have any hope of debugging it.

Also just noticed this quote:

Simplicity is prerequisite for reliability. [Dijkstra]


问:
Variable naming conventions?
I've just started using ReSharper (for C#) and I kind of like its code smells finder, it shows me some things about my writing that I meant to fix a long time ago (mainly variable naming conventions).

It caused me to reconsider some of my naming conventions for methods and instance variables. ReSharper suggests that instance variable be lower camel case and begin with an underscore. For a while I meant to make all my local variables lower camel case but is the underscore necessary? Do you find it comfortable? I don't like this convention but I also haven't tried it yet, what is you opinion of it?

The second thing it prompted me to re-evaluate is my naming conventions for GUI event handlers. I usually use the VS standard of ControlName_Action and my controls usually use hungarian notation (as a suffix, to help clarify in code what is visible to the user and what isn't when dealing with similarly named variable) so I end up with OK_btn_Click(), what is your opinion of that? Should I succumb to the ReSharper convention or there are other equally valid options?

答:
In my case, using camelcase and underscores helps with descriptive (read: long) variable names and code completion. I'm not quite sure how Visual Studio autocompletion works but in QtCreator and to a lesser extent, Eclipse, one can type, for example

```<code>sDI
</code>```

and have it expanded to

```<code>someDescriptiveIdentifier
</code>```

Saves a bit of typing in case you have names like

```<code>someDescriptiveName, someOtherDescriptiveName, someOtherButNotTheSameDescriptiveName
</code>```

which I tend to produce when in "descriptive naming mode".

Using underscores I can determine which name I want autocompleted

```<code>someDescriptiveIdentifier
</code>```

or

```<code>_someDescriptiveClassMember
</code>```

Hope my explanation is clear enough :)

Title: Variable naming conventions?

Body:
In my case, using camelcase and underscores helps with descriptive (read: long) variable names and code completion. I'm not quite sure how Visual Studio autocompletion works but in QtCreator and to a lesser extent, Eclipse, one can type, for example

sDI

and have it expanded to

someDescriptiveIdentifier

Saves a bit of typing in case you have names like

someDescriptiveName, someOtherDescriptiveName, someOtherButNotTheSameDescriptiveName

which I tend to produce when in "descriptive naming mode".

Using underscores I can determine which name I want autocompleted

someDescriptiveIdentifier

or

_someDescriptiveClassMember

Hope my explanation is clear enough :)