答:
From Software Estimation by Steve McConnell (ch. 21.1, p. 237-238):

Common business systems (internal intranet, management information system etc.) - 3:1 to 20:1 (often no test specialists at all)

Common commercial systems (public internet, shrink wrap etc.) - 1:1 to 5:1

Scientific and engineering projects - 5:1 to 20:1 (often no test specialists at all)

Common systems projects - 1:1 to 5:1

Safety critical systems - 5:1 to 1:2

Microsoft Windows 2000 - 1:2

NASA Space Shuttle Flight Control Software - 1:10

The data in here is based on observations of organizations that my company and I have worked with in the past 10 years.

As you can see from the data, ratios vary significantly even within specific kinds of software. This is appropriate, because the ratio that will work the best for a specific company or specific project will depend on the developmental style of the project, the complexity of the software being tested, the ratio of legacy code to new code, the skill of the testers compared to the skill of developers, the degree of test automation, and numerous other factors.

Title: Programmer-Tester-Ratio

Body: Are there any substantiated recommendations how many testers a team should have per programmer? I'm more interested in opinions referring to an old-school development approach (no agile stuff) and larger projects. Sources are welcome.</p>


问:
Is it OK to use sample code from blogs, GitHub, etc... in commercial applications?
When searching the web for a solution to a particular problem, I often find a perfect solution posted on someone's blog, or in a public repository (GitHub, Google Code). Most of the time, the code has no copyright information, nor does the author mention any sort of attribution rules. </p>

<p>I'm pretty sure short snippets are fine, but what if I copy a handful of classes verbatim (again, no copyright notices, TOS, attribution requests, etc...)? Am I under any legal obligation to the original author? </p>

答: The thing is, if person A writes a piece of code, and publishes it with a big "all rights reserved notice", and person B copies it to his blog and strips away the notice, and then you find it in person B's blog and you go "oh, what do you know, a nice piece of non-copyrighted free code!" and go ahead and use it, you would still be liable.  (In theory, if you are ever discovered.)</p>

ContentLicense: CC BY-SA 3.0


问:
Years experience over unfinished degree?
I'm currently in my placement year and working for a great software development company. It was always my intention of getting to this stage through university, getting enough academic experience as well as the year’s placement and then try to get a full time programming job without the need to finish my degree. I decided this from an early stage as I have never really liked the whole university environment. I was so unhappy at university and I’m so happy now I’m on my placement year, I really don’t know if I can go back.

My question is, do you think companies will take me on if I apply for other jobs after my placement year and not penalize me for not finishing my degree?

I guess at the end of the day I don't want to look back on my life and think "god, why didn't I just spend one more year being unhappy to have a job I love" but I know that even if I get a degree I could still end up without a programming job and this worries me more than anything.

答: Personally, I feel that I learned more in my last year of school than I did in the first 3 combined.  I'm not sure how your curriculum is structured but as I went on I had less required courses and was able to pick more courses that were interesting to me. If your curriculum is at all similar I would recommend going back as it's possible that if you don't you will miss out on the most valuable part of your education.</p>


问:
Release cycle as a game
I thinking about how increase developer's commitment to release and create release cycle as a game for more fun in office.

Current suggestions

Building tower from bricks

Climbing on some hypothetical everest, where each camp is release stage

Some badges system, like StackExchange system

答:
I'm sorry, but your current ideas sound like bullshit managerial metaphors to try and trick your underlings into caring.

Building tower from bricks

This one reeks of a thin veneer of false incentive. A physical reminder of the work ahead and behind. I understand the theory. It's supposed to make it fun and give people a physical thing to take pride in. But I have never seen such a ploy work. At best it comes off as "yeah, that's Bob's thing, he likes to see how we're doing". At worst the reinforces the cynical ones to feel like they're being treated as stupid children. Even as as child I could see through this sort of bullshit.

Climbing on some hypothetical everest, where each camp is release stage

As depicted as what? A chart with a mountain in the background? Same sort of managment fluff as the brick tower. If you want to make your motivational powerpoint slides more cute, sure, go for it. But "cute" doesn't get code out the door.

Some badges system, like StackExchange system

Now, this one I had to contemplate. At SE, I come here of my own free will and participate because I care. ie, I'm already motivated. The bronze badges are mostly bullshit incentivators to go try out all the different aspects of SE. The  'nice answer' and 'good answer' badges I actually do kind of care about. Because those are a judgement of my peers. Nameless, faceless peers that melt into the masses in a way that is completely unlike a small development team. You could try an anonymous employee of the month submission.

But if you want to gameify code releases, you should actually incentive your coders. I wouldn't particularly hand out money. See RSA motivate. No, if the team makes a goal, give them a reward. Real rewards. From wearing jeans, free pizza, extra time off, an Xbox in the lounge, choosing their next project, or actual money. Let them all submit reward proposals and vote on what they want. Veto what you will and then organize a tiered reward system which makes meeting and beating deadlines a game with actual rewards. Without real rewards, gamification only works on the gullible and easily deceived.

ContentLicense: CC BY-SA 2.5

Title: Release cycle as a game


问:
How to handle large numbers?
Well, I've just started doing puzzles and it's so annoying to see puzzles which are easy to do but also need to handle very large numbers. That's the problem.

Say I have to deal with numbers like 10 ^ 6 / 2147483647 / etc. Need to do arithmetic operations on!

However, I feel that these shouldn't be handled in brute force way but the math theorems/ statements just don't click in my mind at times.

How could I possible handle such puzzles (shouldn't use external lib)

答:
If you are working your way through a puzzle challenge and large numbers start to show up then the challenge isn't so much finding the answer (as others have noted, libraries exist for working with large numbers) but rather the challenge is to develop your own library to work with large numbers. This can be quite challenging as you are usually going to have to split the number up in some way across several different memory spaces. For integers this is fairly straightforward, if time consuming to read up on and implement; however, support for floating point values will definitely improve your math skills!

To get you started, the following sites have some open source code that you might want to read through to see how they work with the numbers:

http://leemon.com/crypto/BigInt.html

http://gmplib.org/

Plus, the Wikipedia page on arbitrary-precision arithmetic can send you off on some interesting directions as well.

http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic

Title: How to handle large numbers?


问:
Can we say objects have attributes, states and behaviors?
I was reading through Oracle's introduction to OOP concepts and I came across this description:

Real-world objects share two characteristics: They all have state and
  behavior. Dogs have state (name, color, breed, hungry) and behavior
  (barking, fetching, wagging tail). Software objects are conceptually
  similar to real-world objects: they too consist of state and related
  behavior.

My problem with that passage is that when describing state its mixes attributes there too. For instance, the name and color of a dog are its attributes, while it being hungry or thursty are its states.

So in my opinion it's more accurate to break the characteristics of objects into three parts: attributes, states and behaviors.

Sure, when translating this into a programming language I can see that the three-fold partition becomes a two-fold one, because both attributes and states will be stored into fields/variables, while behaviors will be store into methods/functions.

But conceptually speaking it makes more sense to have the 3 things separate.

Here's another example: consider a lamp. Saying that both the lamp size and whether or not it's turned on are states is a stretch in my opinion. The lamp size is an attribute, not a state, while it being turned on or off is a state.

Or did I miss something?

答:
I think it's more accurate to say objects have only two characteristics.  Taking Oracle's example:

Dogs have state (name, color, breed, hungry) and behavior (barking, fetching, wagging tail). Software objects are conceptually similar to real-world objects: they too consist of state and related behavior.

The fact that the values (state) for name, color, breed, and hungry are stored in the object in attributes is an implementation detail.  You don't really need attributes at all.

If you're going to include attributes as a third characteristic, then you'd also have to include methods as a fourth, since (like state) behaviors of objects can change as well.  State and behavior are two abstract characteristics of objects.  Attributes and methods are concrete implementations of those concepts.


问:
Why should we use low level languages if a high level one like python can do almost everything?
I know python is not suitable for things like microcontrolers, make drivers etc, but besides that, you can do everything using python, companys get stuck with speed optimizations for real hard time system but does forget other factors which one you can just upgrade your hardware for speed proposes in order to get your python program fit in it, if you think how much cust can the company have to maintain  a system written in C, the comparison is like that:
for example: 10 programmers to mantain a system written in c
and just one programmer to mantain a system written in python,
with python you can buy some better hardware to fit your python program, I think that low level languages tend to get more cost, since programmers aren't so cheaply than a hardware upgrade,
then, this is my point, why should a system be written in c instead of python?

答:
The main reason is because the software was already written in C (or C++ or whatever) before Python became a legitimate choice.

If it's a question of rewriting your million lines of C code into Python or continuing with the C code, then the choice is clear. If you spend 12 month rewriting the code in Python, then that's 12 months where you're not adding new features and you'll basically spend 12 months getting back to exactly where you were.

Not to mention that fact that you'll probably have missed all those corner-case bugs that had been fixed over the years in the C version, but not really called out in the code so when your Python dev comes along to port it and says "why does the code do this? That seems wierd... I'll just do it this other way" he's actually forgetting about that customer from 6 years ago who lost 12 months worth of payroll because of this obscure bug in their RAID controller that was worked around with just that specific piece of code.

It's basically the same answer people get when they ask "Why doesn't Microsoft rewrite Windows or Office or (insert-product-here) in .NET? I thought .NET was the poster-child for all Microsoft development these days?"

Now, when it comes to developing new products, then Python (and all the other possible choices) become a more viable option. But  you've still to weigh the benefit of going with Python (or whatever) over C or C++, particularly when your new product may be interfacing with lots of existing code that you've already got written in C or C++.


答:
The real-world connections are misguided. Here's how I would teach it(c++ approach):

Computers support two different storage formats: data and code

data looks like bits 010101010101

code looks like asm instructions

data bits have two different values, it's either 0 or 1

data is abstracted to data types: int i=1; is just short notation to some bits 0000001

code will look like a function: int f(int a) { return a+a+a; } is short notation for some asm instructions

when you have several variables, you combine them to a struct: int a; float b; can be placed to a struct AB { int a; float b; };

when you combine some code pieces to it, you get a class: class ABf { int a; float b; float sum(float c) const { return a+b+c; } };

Then for data we have variable names which can be used to find the value:
   a+b+c
to access the data.

And then we have normal function calls:
 int k = f(10);
to access the asm instructions "stored" inside f-function.

Then there is object instances:
 ABf var;

And the member function calls:
 int k2 = var.sum(10.0);

functions have types int f(int);

member functions have types int ABf::sum(float);

There is this-pointer with type ABf*

variables like a and b and c are context dependent, if they're inside member function, they could mean this->b, or just b.

Member functions int ABf::sum(float c) is just short notation for int sum(ABf* this, float c);

the word "state" just means the same as data

the word "behaviour" just means the same as code

the word "attribute" just means the same as data.

So there isn't really anything different between state and attribute. It's just random collection of bits. It's just arbitrary distinction to separate them. Just need to know what it's alias for.

Title: Can we say objects have attributes, states and behaviors?

Body:
I was reading through Oracle's introduction to OOP concepts and I came across this description:

Real-world objects share two characteristics: They all have state and
  behavior. Dogs have state (name, color, breed, hungry) and behavior
  (barking, fetching, wagging tail). Software objects are conceptually
  similar to real-world objects: they too consist of state and related
  behavior.

My problem with that passage is that when describing state its mixes attributes there too. For instance, the name and color of a dog are its attributes, while it being hungry or thursty are its states.

So in my opinion it's more accurate to break the characteristics of objects into three parts: attributes, states and behaviors.

Sure, when translating this into a programming language I can see that the three-fold partition becomes a two-fold one, because both attributes and states will be stored into fields/variables, while behaviors will be store into methods/functions.

But conceptually speaking it makes more sense to have the 3 things separate.

Here's another example: consider a lamp. Saying that both the lamp size and whether or not it's turned on are states is a stretch in my opinion. The lamp size is an attribute, not a state, while it being turned on or off is a state.

Or did I miss something?


问:
Describing the Difference Between Web Library and Web Framework
I talked myself into a hole at work, and I need some good ideas to help me better describe why we should include both Dojo and Knockout in our new web project.

A little background: I do mostly computer-computer interactions when I program; updating states, reading/writing to the database -- Knockout is exactly where I want to be.

So I said, "I don't want to use Dojo"...meaning, "I don't want to do client side user experience/visual effects programming". I think it's a great to utilize other people's work, and I think re-inventing the wheel is a bad thing, generally. I just don't enjoy the process as much. But now its turned into an "all or nothing" decision.

Please help me come up with a good way to describe the difference between a library and a web framework, and not in this technical way. I need something simpler to get my point across.

答:
The Design Patterns and the OO movement guys had a definition along the lines of:

An application uses parts of a library, and provides the missing parts in a framework.

Django is a framework in which the user provides a data model, page templates, and URL routing information to have a working Web Application. PIL is a library for manipulating images in Python.


问:
How old is "too old"?
I've been told that to be taken seriously as a job applicant, I should drop years of relevant experience off my résumé, remove the year I got my degree, or both. Or not even bother applying, because no one wants to hire programmers older than them.1

Or that I should found a company, not because I want to, or because I have a product I care about, but because that way I can get a job if/when my company is acquired.

Or that I should focus more on management jobs (which I've successfully done in the past) because… well, they couldn't really explain this one, except the implication was that over a certain age you're a loser if you're still writing code. But I like writing code.

Have you seen this? Is this only a local (Northern California) issue?

If you've ever hired programmers:2

Of the résumés you've received, how old was the eldest applicant?

What was the age of the oldest person you've interviewed?

How old (when hired) was the oldest person you hired?

How old is "too old" to employed as a programmer?

1 I'm assuming all applicants have equivalent applicable experience. This isn't about someone with three decades of COBOL applying for a Java guru job.

2 Yes, I know that (at least in the US) you aren't supposed to ask how old an applicant is. In my experience, though, you can get a general idea from a résumé.

答:
Think about your weekend.

You leave work on Friday, drive home, have dinner, and relax.  On the weekend, maybe you do some work around the house, travel a little, partake in some hobbies.  Basically, you enjoy your time off work and find other things to do.

Now, how do you feel on Sunday night?  How does the thought of driving into work Monday morning make you feel?  Do you get a sick, sinking feeling in your stomach at the thought of having to spend the next five days pounding out code?

Or, after having had a nice refreshing weekend, are you looking forward to getting back into the office and tackling some of the problems that remained unsolved when you left on Friday?  Do you look at Monday as a chance to review last week's code while refreshed and revigorated?

If the first scenario is you, then perhaps it's time to get out now.  If programming doesn't continually challenge and intrigue you anymore, you're just not going to be happy doing it.  Simple as that.

If, however, you are constantly thinking to yourself "I can't believe I get paid to do something I love", then there's no reason to ever quit.

Title: How old is "too old"?


问:
Anybody use the Team Software Process (TSP) and/or Personal Software Process (PSP)?
More info on it here:
http://en.wikipedia.org/wiki/Team_Software_Process

What has your experience been?

答:
TSP was basically introduced and pitched to management by consultants as a means of helping to achieve the goal of CMMI level 3 certification. I could go on and on about the ensuing disaster that happened once this process began being forced upon a development staff of agilists who were actually producing high value software for the customer on a regular basis, but instead I'll talk about the TSP methodology.

TSP is waterfall process incognito... period. The system itself is designed for repeatable process and nowhere does it advocate any value in the software that is being delivered. Its chief concern is making sure that a process is being captured, recorded, followed and measured. The development of TSP came about because organizations were struggling to meet the rigorous demands of CMMI. It was seen as a bridge to get to CMMI. It was founded in academia and in my experience it struggles in the domain of business application development.

Do you enjoy programming with a log book and a stop watch? That is how you measure your work. The data is supposed to be protected so that it can't be used against individual developers by management. It took about 2 months before management started asking the Team Leads for the individual metrics. You can just imagine how awesome people's metrics started looking after they learned that management was reviewing them.

TSP was presented as a load-balanced type of 3 month iterative process. By this I mean that a stack of work is presented and agreed to up front with the customer. There is a series of ceremonial meetings where requirements are drawn in blood and work is planned out. Each developer will get handed a stack of that work. It's basically a micro push system. Once a developer runs out of work, they can take over the load of other developers that may be falling behind. Priority of requirements are not considered or racked and stacked. Everything is just considered work that must be done and from that you derive a Work Breakdown Structure. Let's be clear - work doesn't mean programming. You might spend the majority of your time writing up design documents and cross referencing that design to your software requirements specification. Oh, and recording in your workbook every step of the way... remember to click that stop watch.

Within that 3 month iteration work proceeds strictly according to a waterfall system. There are no concepts of Test Driven Development or Emergent (simple) design. TSP follows a Requirements document, design document, coding, test and deployment phased approach. All of these phases must be well documented as part of the process and followed strictly with checklists. All of these phases are linear in nature and a series of metrics are recorded for each phase. I once visited another site where TSP was being implemented and I was adamantly told that people don't do testing before or during coding. These people were basically operating in the stone age and had no concept of test driven development.

There are various roles that each developer also has to play besides the reason that they were hired in the first place. These roles are essentially a way to enforce process capitulation upon the development staff. Like having a friendly North Korean neighbor that likes to check up on you once a week just to see how your doing. The developers on my team absolutely hated having these additional roles such as process enforcer, planning enforcer, meeting enforcer, etc. As for developer collaboration... virtually non existent. Remember you've been handed your work for the next 3 months. Its boils down to a group of individuals masquerading as a team.

Once a week the "team" gets together to review metrics that have been recorded in the workbooks. Earned Value charts are reviewed, risk analysis diagrams are mined closely, but more importantly it is a good once a week session to vent frustration with having to follow the process when all people want to do is build great software.

We lost a lot of talented developers during this experiment. I mean some really talented people. TSP is Scientific Management and Taylorism wrapped up in a nice package that upper management types seem to love. I have since left the organization and moved on to other headaches however I will never work with TSP again in my career. I think its safe to say many of my former coworkers have the same view.


问:
Do Universal iOS Apps have more "issues" when new versions of iOS come out?
I was discussing developing an iOS App with a client and I mentioned that we should ideally have a Universal App that would perform as an iPhone App on an iPhone and as an iPad App on an iPad.

The client likes the idea of an iPad-specific version of the App but prefers the idea of a separate App entirely for the iPad version. And not for some "Angry Birds/Angry Birds HD" type of reason (the App in question will be free, so there's nothing to be gained financially) but rather because "other [organizations in his industry] have told him" that "Universal Apps have more compatibility issues with older devices when new versions of the operating system [iOS] are released" and having discrete apps for this alleviates this issue.

I believe he may have been referring to the concept of an App requiring a version of iOS that is more recent than the last one available on the phone. Or maybe the concept of releasing an App or an update that requires a version of iOS beyond the last one available on a device (original iPhone is stuck at 3.1.3 forever, iPhone 3G is stuck at 4.2.1 forever). But I presume you can still make a Universal App for 3.1.3 since the original iPad shipped with iOS 3.2 and Universal Apps existed before 4.0. And while I'm having a difficult time finding out what the minimum iOS version is for Apps submitted to the App Store, I presume that the original iPhone can still download and buy Apps or else the one guy in the office here who still has his OG iPhone would probably have complained more by now.

But I really don't know. Do Universal Apps have more issues with compatibility on devices (and more specifically older devices) than individually developed separate (but otherwise pretty equivalent) Apps? Has anyone ever run into this?

答:
The basic rule is that the more different hardware environments and OS versions you need to support with a single release, the more complex the code can get and the more media and UI assets that may be required.  This complexity and asset management can result in more testing and QA efforts required and/or more potential issues, compatibility problems or bugs.

Universal iOS apps also don't allow segmenting the market based on demand-price sensitivity, potentially reducing profit potential.

But I've done Universal iOS apps, and for these few apps, did not run into any unusual OS compatibility issues, other than the need for a lot more continuous device testing on all the different devices.


答:
Because even when you're not writing "low-level applications" such as device drivers, the need for low-level code tends to show up in all sorts of places, especially for performance optimizations in computation-intensive parts of your app.  This is common enough even in apps written in C and other static, fully-compiled languages, and it only gets worse when you start throwing inherently slow "high-level" language features such as dynamic typing and managed pointers into the equation.

When you have a language that abstracts away all the low-level details, such as Python, you are not able to get down to the level required to fix problems like this.  That's why you tend to see the pattern of writing the core code in a compiled language, and then implementing lightweight business logic in a scripting language that runs on top of the core code, increasing in popularity quite a bit lately.

Title: Why should we use low level languages if a high level one like python can do almost everything?

Body:
I know python is not suitable for things like microcontrolers, make drivers etc, but besides that, you can do everything using python, companys get stuck with speed optimizations for real hard time system but does forget other factors which one you can just upgrade your hardware for speed proposes in order to get your python program fit in it, if you think how much cust can the company have to maintain  a system written in C, the comparison is like that:
for example: 10 programmers to mantain a system written in c
and just one programmer to mantain a system written in python,
with python you can buy some better hardware to fit your python program, I think that low level languages tend to get more cost, since programmers aren't so cheaply than a hardware upgrade,
then, this is my point, why should a system be written in c instead of python?


问:
Does using new techniques hurt productivity?
It seems that as experience with the specific set of tools you have to work with grows, the incentive to try out new things weakens.

When I was new at this programming job, trying out new things, researching online, made me more productive, because I often found a way (or library) that made the task easier that the code framework already in place. So using something new -- to me as well as in the context of the given codebase -- made me more productive.

Now I noticed, that there are more and more instances where, for a given problem, I know that there probably is a better solution "out there", and finding it would -- presumably -- improve the code. However, given my now intimate knowledge of the code base, it is by far easier to use the suboptimal tools we have, and get a solution (including tests) running than find someting new and "better" and "improve" the codebase.

So there is this tension: "do it properly" vs. "get the job decently done".

Is this something that happens to a lot of developers? Is this a known specific problem? (Is it a real problem after all?) Does it actually have to do with increasing levels of experience?

Oh, and note: I still like my job and like to keep it. It's just that it seems the -- always interesting! -- research part get's smaller as I learn the code base and problem sets we face with our app.

答:
Yeah, I've had that happen. Usually you have to do risk-analysis on how much time it will cost to learn the new technique, and can you recover and use an older technique in case the new technique fails to live up to expectations. I prefer to learn new techniques when I can but when the pressure is on and I can't afford to spend time trying new things that might fail, I stick with tried-and-true methods.

In general, I find the best time to learn new techniques is at the begining of a new project. There's usually not too much pressure and if you find something new that works well, you can easily integrate it with the rest of the project, going forward. The worst time to try and learn new things is the last couple of frantic weeks before a big deployment.


答:
It happens all the time. I've said this in other posts, but more times than not, you're not in the business of developing elegant code, you're in the business of shipping a product. As such, you'll be hard pressed to find any manager who's willing to allocate n hours for you to fix something that isn't broken and really (at the end of the day) doesn't greatly enhance the end user experience. You'll be just as hard pressed to find a manager willing to allocate n hours to research (with no clear end goal) other than "there's probably something out there that's better" than what's being done.

Having said that, if there are bottlenecks in your application that you've discovered using profiling tools and such and you can clearly quantify the expected user experience enhancement that fixing them would bring, then you should (fairly easily) get time to do some R&D work to optimize them using techniques that you can find from various sources.

Title: Does using new techniques hurt productivity?

Body:
It seems that as experience with the specific set of tools you have to work with grows, the incentive to try out new things weakens.

When I was new at this programming job, trying out new things, researching online, made me more productive, because I often found a way (or library) that made the task easier that the code framework already in place. So using something new -- to me as well as in the context of the given codebase -- made me more productive.

Now I noticed, that there are more and more instances where, for a given problem, I know that there probably is a better solution "out there", and finding it would -- presumably -- improve the code. However, given my now intimate knowledge of the code base, it is by far easier to use the suboptimal tools we have, and get a solution (including tests) running than find someting new and "better" and "improve" the codebase.

So there is this tension: "do it properly" vs. "get the job decently done".

Is this something that happens to a lot of developers? Is this a known specific problem? (Is it a real problem after all?) Does it actually have to do with increasing levels of experience?

Oh, and note: I still like my job and like to keep it. It's just that it seems the -- always interesting! -- research part get's smaller as I learn the code base and problem sets we face with our app.


问:
What is the purpose of including header files in the solution in Visual Studio?
So I have including the files to my projects by simply : #include "myheader.hpp" and adding the headers into the solution explorer.

But recently I have realized that I may omit the step of adding the headers to the solution explorer because it does not change anything. The only important fact is to define proper include directories in project properties.

Am I missing something here ? Can someone clever explain this to me ?

答:
Mainly just to give you single click editing.

The solution explorer doesn't effect the dependancy of the build/compiler.

edit. Sometime's it's necessary if you need to 'compile' a header eg. a COM .idl or some Qt moc header file.


问:
Make a big deal out of == true?
There is a colleague of mine who constantly writes:

```<code>if (someBool == true)
</code>```

It drives me up the wall!  Should I make a big deal of it or just drop it?

答:
Such coding would have rubbed me the wrong way before too. Although your example identifier is named "someBool", using that coding style inadvertently on a variable which wasn't guaranteed to be a boolean could have unintended behavior. If the value of "someBool" isn't exactly "true" or "false", the result will be false.

I encountered a very subtle bug this past year caused by such a coding style which was difficult to identify because one's eyes gloss over such constructs. You'd think, "How could it be wrong?" The same holds true for such well-understood expressions as "(var)" or "(!var)", that you read or code them without verifying their behavior.

So I've introduced a couple of coding standards to reduce the existence of such bugs in the codebase and the likelihood that such subtle bugs will accidentally creep in sometime in the future.

All expressions must be parenthesized per their intent.

All boolean tests must be expressed in the negative, like "suchBool != false".

By cleaning up code not conforming to the new style, I've identified and corrected a few more instances of such subtle bugs.

Title: Make a big deal out of == true?


答:
It's often risky to try new things. We sometimes get into trouble because we tend to do two things:

Overestimate how useful the cool/new/snazzy thing is. We see some cool example, some code thrown online. Very cool we think. Very cool! In X I can do task Y ten times faster. Its clearly superior. We don't yet see all the "unknown unknowns". We haven't been tripped up by the problems that the salespeople of the new thing omit. We don't have enough expertise in the new thing to see the landmines waiting down the road.

Underestimate how useful the existing tools/framework/software/things are. We often weren't there when the current system was initially built. We don't appreciate the delicate tradeoffs that were made. Its easy to play Monday-morning quarterback on an existing system, but it works. Its probably got a lot of weirdness due to very specific tradeoffs between keeping it maintainable, working, and performing well. Yeah sure its weird. Maybe most importantly, the team is an expert on the current weirdness and known how to work around the weirdness. They know the landmines and the traps and the pitfalls to avoid. In fact its precisely because we see all the warts in the current way of doing things that we're even interested in playing with new things.

But failing to try new things and acting too conservative is probably even more dangerous. Sure we need to tread carefully, but if we don't figure out how to build the best mouse trap, our competitors a little more willing to try something new will come along and kick out butts! Acting to conservative and failing to evolve can result in inevitable doom especially in a competitive market.

So yes we need to balance maintaining and shipping the current thing with some level of playful/educational experimentation with new ways to solve problems keeping in mind that many of those new ways are dead ends while others may payoff. IMO This is a good reason many companies have 20% time to play with new things. They know a lot of times they don't work out, but many of the ideas that come out of 20% time become gangbusters. Without time to play and experiment you can easily stagnate as a company and really screw yourself over.


答: Some source control systems may not add the header files to source control if they are also not added to the solution file. Your mileage may vary, depending on the source control you use and how you use it.</p>

Title: What is the purpose of including header files in the solution in Visual Studio?

Body:
So I have including the files to my projects by simply : #include "myheader.hpp" and adding the headers into the solution explorer.

But recently I have realized that I may omit the step of adding the headers to the solution explorer because it does not change anything. The only important fact is to define proper include directories in project properties.

Am I missing something here ? Can someone clever explain this to me ?


问:
How can programming ability be used to help people in poverty?
As a student studying Computer Science in college, I often hear from friends working on various humanitarian projects, and I want to do something myself. But it seems that programmers don't have as many obvious avenues to help out as, say, doctors or teachers. What are some ways in which programmers can put their talent to use for people in poverty?</p>

答: Has no you yet posted a link to hackers for charity? They have a list of volunteer positions that need to be filled, many of which can be done over the web.</p>


问:
Google Closure Compiler - what does the name mean?
I am curious about the Google Closure Compiler. Why did they name it that? Does it have anything to do with lexical closures?

EDIT: I tried researching it in the FAQ and documentation, as well as doing Google searches such as "closure compiler name". I couldn't find anything definite, hence the reason I am asking. I don't think I will get a profoundly helpful answer but I was hoping that I could at least satisfy my curiosity.

I am not trying to solve a specific problem. I am just curious.

答: The Closure Compiler is part of the Closure Tools, Google's collection of tools to facilitate working with javascript. The word "Closure" simply refers to a language feature popularly associated with javascript, though it is not the only or first language to use it. Use of "Closure" seems to be more marketing fun than a deep statement about the working or functionality of any tool in the collection.</p>


问:
Software licenses in practice
Almost all questions and information on both SO and "Google" describes how different licenses works and what license to choose for your work?

But how do they work in reality.

Almost everyone I have spoken to have vastly different thoughts of how they work, including hard core open source developers that gladly share their libs and consultants who is only interested in money and would never reveal their libs.

First I will give my impression of how they work in practice with three questions / statements and you can agree or disagree with me on those.

Lets say I make a large application and have a small portion of that from GPL code, then the copyright holder can't do much about it as it's deemed non essential code for my application and thereby the "law" rules over the GPL?

If the code is generic the copyright doesn't hold. For example if I make a tutorial on how to set up a chess engine no one have to care about my license. That's because my code is mechanical in nature.

If I use a lot of GPL code that is essential for my application and don't disclose it and someone finds out, my "punishment" will be to release all my source code, large companies are terrified by this.

But for a small hobby developer this isn't much of an issue as the software wouldn't be written at all or would be open sourced from the start anyway? I don't like this approach personally because I find it unethical and disrespectful to the original author.

EDIT: Clarified as a comment made was that I din't ask a question. My question is are the 3 statements correct.

答:
There is very little or no precedent for what the "law" actually thinks about most open source licenses in most jurisdictions.  One thing to note is that breaking an Open Source License is likely to not be considered copyright infringement.  It's a breach of contract.  The work was not used without permission, permission existed and the terms were violated.  Copyright holder vs infringer is very different from licensor vs noncompliant licensee in court.  (and very different across jurisdictions)

There is so little precedent I think it would be speculation to say what your "punishment" might be in a case that actually went to trial.  Generally for a breach of contract it would be monetary damages.  Nobody can say if a particular judge or jury would require the defendant to retroactively comply with the original terms.  It would be surprising though.

The 'punishment' would really be the damage to reputation.  The cost of the PR effort for a large well known company to recover from the fallout of getting caught "stealing from the community" is the real disincentive in my opinion.

Title: Software licenses in practice


问:
What are your initial three steps when you are first presented with a software problem?
I am curious about the very early steps that a programmer's mind takes when it first encounters a problem that it is supposed to solve. How do you start reasoning about it ? What are the first questions you ask yourself ??.

Ok, let me make it more concrete for those of you who think the question is too vague or entirely situation dependent. Pick any of the following   requirements and think out loud about your very first hunches/impressions/tendencies about how to solve it.

1) build a simple word processor with about as much functionality as MS Word Pad

 2) design a single person card game (e.g. Solitaire)

 3) build a scientific calculator

 4) Any  problem of your choosing with similar scale/complexity as the above three

答:
1) Specify.  Break the problem down into core parts and figure out how they're supposed to work.  When the problem is already well-defined, such as a card game with known rules, a fair amount of this step can be glossed over, but it's good to go over it just to make sure you understand the problem domain as well as you think you do.

2) Set up a source control repository for the project.  Very important to do this before you even start writing any code.

3) Pull up your IDE and start hacking.

OwnerDisplayName: mumtaz

LastEditorDisplayName: mumtaz


问:
Scalable solution for website polling
I'm looking to add push notifications to one of my iOS apps. The app is a client for a website which doesn't offer push notifications.

What I've come up with so far:

App sends a message to home server when transitioning to background, asking the server to start polling the website for the logged in user.

The home server starts a new process to poll for that user. Polling happens every so many seconds / minutes.

When the user returns to the iOS app, the app sends a message to the home server to stop polling.

The home server kills the process polling for the user.

Repeat.

The problem is that this soon becomes stupid: 100s of users means 100s of different processes. It's just not scalable in the slighest.

What I've written so far is in PHP, using CURL to do the polling and I started with PHP a few days ago, so maybe I'm missing something obvious that could help me with this.

Some advice would be great.

答:
You might want to check out Comet
or BOSH

Which are two methods to simulate sockets over HTTP, they are way more efficient than polling, and technically could scale to the 10k if you use a light weight server such as Nginx which is alot better at handling concurent connections than apache.

As for the server with more than 100 connections you could get a amazon EC2 micro server instance for something like 19$ /month that lets you run nginx and could scale a lot better than apache.

Title: Scalable solution for website polling


问:
Is there a better way to design these classes?
I have two business classes: TimesheetDay and TimeSlot. One TimesheetDay can have one or more TimeSlots.

The TimesheetDay and TimeSlot classes will be dependent on an object that implements a corresponding TimesheetDayData and TimeSlotData interface. That way, I can write data classes to map the objects to a MySQL database, but if I use another way to store the data in the future, I can inject objects from a different dataclass.

These objects will not create other objects, and I refuse to use the "new" keyword in them. I want them to be testable in complete isolation.

For example, I instantiate a TimesheetDay object like this (in a container):

```<code>$mTimesheetDayData = new TimesheetDayMysqlData($databaseHost, $timesheetDayId);
$mTimesheetDay = new TimesheetDay($mTimesheetDayData);
</code>```

TimeSlot objects will be constructed the same way:

```<code>$mTimeSlotData = new TimeSlotMySqlData($databaseHost, $timeSlotId);
$mTimeSlot = new TimeSlot($mTimeSlotData);
</code>```

My problem lies in getting TimeSlot objects that the TimesheetDay contains. I can't have the TimesheetDay class creating objects. Otherwise, I might write a method that returns an array of TimeSlot objects, something like:

```<code>$timeSlotsForThatDay = array();
$timeSlotsForThatDay = $mTimesheetDay->getTimeSlots();
</code>```

But, that would require the method getTimeSlots() to create objects.

How would you handle this?

答: The TimesheetDay object should query the database for data to construct its list of TimeSlots, either when it is constructed, or the first time getTimeSlots is called.</p>


答:
I recommend to create one more class - TimesheetDataMapper, it would map mysql data and objects. As I understand, you intend to make TimesheetDay and TimeSlot as POPO (Plain Old Php Object). That is a good intention :)

So what you have to do is inject TimeSlotMySqlData into TimesheetDataMapper, there have a method getTimesheetDay($someCriteriaOrId); which would get the data from mysql based on criteria, create new object TimesheetDay, select time slot data & inject it into TimesheetDay.

```<code>class TimesheetDataMapper {
    protected function _getTimeSlotData($someCriteriaOrId)
    {
         $timeSlotsForReturn = array();

         $someTimeSlotListFromDb;
         foreach ($someTimeSlotListFromDb as $timeSlotData) {
             $timeSlotsForReturn[] = new TimeSlot($timeSlotData);
         }

         return $timeSlotsForReturn;
    }
    public function getTimesheetDay($someCriteriaOrId)
    {
        $timeSlotData = $this->_getTimeSlotData($someCriteriaOrId);
        $timesheetDay = new TimesheetDay($timeSlotData);

        return $timesheetDay;
    }
}
</code>```

You could also have some setters/getters on TimesheetDay / TimeSlot.

Title: Is there a better way to design these classes?

Body:
I have two business classes: TimesheetDay and TimeSlot. One TimesheetDay can have one or more TimeSlots.

The TimesheetDay and TimeSlot classes will be dependent on an object that implements a corresponding TimesheetDayData and TimeSlotData interface. That way, I can write data classes to map the objects to a MySQL database, but if I use another way to store the data in the future, I can inject objects from a different dataclass.

These objects will not create other objects, and I refuse to use the "new" keyword in them. I want them to be testable in complete isolation.

For example, I instantiate a TimesheetDay object like this (in a container):

```<code>$mTimesheetDayData = new TimesheetDayMysqlData($databaseHost, $timesheetDayId);
$mTimesheetDay = new TimesheetDay($mTimesheetDayData);
</code>```

TimeSlot objects will be constructed the same way:

```<code>$mTimeSlotData = new TimeSlotMySqlData($databaseHost, $timeSlotId);
$mTimeSlot = new TimeSlot($mTimeSlotData);
</code>```

My problem lies in getting TimeSlot objects that the TimesheetDay contains. I can't have the TimesheetDay class creating objects. Otherwise, I might write a method that returns an array of TimeSlot objects, something like:

```<code>$timeSlotsForThatDay = array();
$timeSlotsForThatDay = $mTimesheetDay->getTimeSlots();
</code>```

But, that would require the method getTimeSlots() to create objects.

How would you handle this?

Body:
I recommend to create one more class - TimesheetDataMapper, it would map mysql data and objects. As I understand, you intend to make TimesheetDay and TimeSlot as POPO (Plain Old Php Object). That is a good intention :)

So what you have to do is inject TimeSlotMySqlData into TimesheetDataMapper, there have a method getTimesheetDay($someCriteriaOrId); which would get the data from mysql based on criteria, create new object TimesheetDay, select time slot data & inject it into TimesheetDay.

class TimesheetDataMapper {
    protected function _getTimeSlotData($someCriteriaOrId)
    {
         $timeSlotsForReturn = array();

         $someTimeSlotListFromDb;
         foreach ($someTimeSlotListFromDb as $timeSlotData) {
             $timeSlotsForReturn[] = new TimeSlot($timeSlotData);
         }

         return $timeSlotsForReturn;
    }
    public function getTimesheetDay($someCriteriaOrId)
    {
        $timeSlotData = $this->_getTimeSlotData($someCriteriaOrId);
        $timesheetDay = new TimesheetDay($timeSlotData);

        return $timesheetDay;
    }
}

You could also have some setters/getters on TimesheetDay / TimeSlot.


问:
Any good tips for a PHP Programmer for starting on Iphone and ipad apps? (have pc only)
I am trying to learn creating apps for IPhone and IPad, apps like database oriented websites where user can save their data.

I am a normal php programmer and use only Windows PC.

Any good tips that you guys can suggest me to begin with would be highly appreciated.

Thanks!

答:
Apple Developer site is one of the most important and useful for learning. Register on it and get access to many articles and docs:

Guides and Sample Code

The Objective-C Programming Language

The Swift Programming Language

iOS Human Interface Guidelines (for iOS development)

Mac OS X Human Interface Guidelines (for MacOS development)

And example:
Start Developing iOS Apps (Swift)

See also this thread -
iPhone development on Windows

OwnerDisplayName: Aamir Siddique

OwnerDisplayName: beryllium


答:
If you're really serious about iOS/macOS programming, you might wanna spend a lot of times perusing Apple's documentation. You might wanna use a real Mac computer for this, and spend like $99 (varies between countries) for testing your app in real devices (You can postpone this until you're ready to test/distribute though, because it's only for one year of iOS app developer account)

Also, in XCode, there's a documentation reference, where you can add Apple's docset, so you can look at the documentation in XCode and download sample codes without accessing the internet. The documentations are plenty.

You might wanna start with learning the Objective-C first, because you need to know the language first. It's different than C. Although similar in some parts.

And then you can start move to iOS (cocoa touch) core competencies, that will teach you about the methodology and the basic things you really need to know about iOS applications.

After that you might want to move to programming guides, like View Controller's programming Guide, Core data programming guide, Web Services Programming Guide, etc.

But, if you really don't care about all the essentials, and just want a quick access using your own web programming skills, you can use Appcelerator Titanium (for example), where it allows you to write codes in javascript/HTML/CSS and even PHP for desktop app and it will interpret your code into iOS native language. But you will also learn its extensive API, and you'll probably end up rewrite it in iOS native language if some weird bugs happened. The good thing about Titanium is you can use the same codes for Android (and someday Blackberry) application. Some said that Titanium is quick to learn but only good for prototyping.

Title: Any good tips for a PHP Programmer for starting on Iphone and ipad apps? (have pc only)

Body:
I am trying to learn creating apps for IPhone and IPad, apps like database oriented websites where user can save their data.

I am a normal php programmer and use only Windows PC.

Any good tips that you guys can suggest me to begin with would be highly appreciated.

Thanks!

OwnerDisplayName: Coolant


答:
I started programing in Xcode with a background in PHP and ActionScript two years ago. What I have accomplished to date is amazing. The thing that helped me the most was sites like this one where you can collaborate with others. The best way to use a site like this is sparingly when your at your wits end, then don't seek direct help but rather better understanding of what your trying to do. I also use Mac Guides and developer support tools. Both the guides and tools change and you can spend a lot of time upgrading before your even finished so use them sparingly as well. Try to spend most of your time learning "Why" not "How".

What you will need to proceed quickly is a Mac and an IPod or Ipad. I tried to go the PC development route first and ran into many snags. The set backs are the up front money for the Mac and dev-device, and the time spent in learning a new OS. The Mac's interface feels left handed as apposed to the PC, and I spent a lot of time fighting the OS just to get around and find files etc.

I estimate that I spent one year getting oriented to the "Mac OS," it's not about just pointing and clicking you need to know a lot of backend stuff as well. I also spent about a year in Xcode, and example trials. I learn hands on and never picked up a book. Some people do well with books, but i usually find that the authors are more interested in displaying how smart they can sound as apposed to step by step teaching. Google should become your coding partner when you have a question or seek answers, and you should also find a good Repository for code.

Hope this helps you save time and money. Maybe you can be up and running in just a year if you don't try the PC route first.

OwnerDisplayName: hodji


答: I don't think PHP is the way to go here, what your writing is backend code. I have written something very similar to this. I used ruby, eventmachine, em-http-request and beanstalkd. It worked well and was dead simple.</p>

Title: Scalable solution for website polling

Body:
I'm looking to add push notifications to one of my iOS apps. The app is a client for a website which doesn't offer push notifications.

What I've come up with so far:

App sends a message to home server when transitioning to background, asking the server to start polling the website for the logged in user.

The home server starts a new process to poll for that user. Polling happens every so many seconds / minutes.

When the user returns to the iOS app, the app sends a message to the home server to stop polling.

The home server kills the process polling for the user.

Repeat.

The problem is that this soon becomes stupid: 100s of users means 100s of different processes. It's just not scalable in the slighest.

What I've written so far is in PHP, using CURL to do the polling and I started with PHP a few days ago, so maybe I'm missing something obvious that could help me with this.

Some advice would be great.


答:
Consider learning to write web apps using HTML5 on your PC first, and then running these web apps on iOS devices using Safari or web clippings.  You can use PHP for any remote web services used by the web app on the device.

You will very likely want an iOS device or two to learn 1st hand what makes good iOS app designs.

If you want to do iOS native App store apps, the best path is to get a Mac and try learning some Objective C, even if you choose to depend on some 3rd party development environment or language later.  You can't code native apps using PHP.


问:
Does it hurt to learn bits of many programming languages?
I started my programming career with BASIC, during 9th grade. I learned a bit of BASIC by writing simple programs to add, subtract and to print. Then I went to the university and took Computer Information and Systems Engineering. In the first year I was taught C, and I have good command over it.

Next I learned C++ in the second year. It just taught me some knowledge of OOP. Now I am doing PHP (along with HTML). I have not mastered C++, BASIC or PHP. I am now planning to move to mobile development. But I feel that I have not covered everything in the languages I learned.

Does it really matter?

答:
On the contrary, I think it hurts when I don't/am not able to learn a new programming language. It may be because of the lack of time or some other reasons. As far as I see, programmers/software developers are in love of challenging the languages, putting better things/products, and when you see that you are doing same thing always, you don't feel good. So you want a new challenge, a new language, something new to learn and put more products by it.

So I think it gives me excitement to follow new languages, new libraries, new approaches, new technologies. But I don't have time to get all of them, and people may not be able to go enough deep always. So it hurts not to learn more; but doesn't not hurt to learn more.


问:
Years experience over unfinished degree?
I'm currently in my placement year and working for a great software development company. It was always my intention of getting to this stage through university, getting enough academic experience as well as the year’s placement and then try to get a full time programming job without the need to finish my degree. I decided this from an early stage as I have never really liked the whole university environment. I was so unhappy at university and I’m so happy now I’m on my placement year, I really don’t know if I can go back.

My question is, do you think companies will take me on if I apply for other jobs after my placement year and not penalize me for not finishing my degree?

I guess at the end of the day I don't want to look back on my life and think "god, why didn't I just spend one more year being unhappy to have a job I love" but I know that even if I get a degree I could still end up without a programming job and this worries me more than anything.

答:
There are three angles to having degree:

The formal enhancement of your education - pretty obvious, but if you have some great tutors and colleagues, it can really fine tune the grey cells. In my case it was a piece of paper (actually two pieces) that opened the first door - I had been programming already best part of 10 years.

A piece of paper - it won't open every door but it is unlikely to close many. At the start of your career you don't have many bragging opportunities so a degree is one piece of advertising that could get you noticed.

Extra curricula - this will make you a better person(usually). Time to make some mistakes. Time to try out some ideas. Time to have fun. Time to figure out what you really what. Once you get on the treadmill it is damn difficult to get off - mortgages, wives, kids all get in the way of those great ideas. This can also provide bragging opportunities during the job search.


问:
How to handle large numbers?
Well, I've just started doing puzzles and it's so annoying to see puzzles which are easy to do but also need to handle very large numbers. That's the problem.

Say I have to deal with numbers like 10 ^ 6 / 2147483647 / etc. Need to do arithmetic operations on!

However, I feel that these shouldn't be handled in brute force way but the math theorems/ statements just don't click in my mind at times.

How could I possible handle such puzzles (shouldn't use external lib)

答:
While the exact solution depends on the actual problem, there are various approaches you can try to take before simply calculating in brute force using an arbitrary or multiple precision math library (BigInt, GMP, MPFR, ARPREC, etc.).

First, use some math. Can the expressions be simplified? You said that the source of these tasks involves puzzles, so I would be very inclined to look at this approach for a solution, as this may be a factor in the puzzles' aha moment. Equations with factorials, such as binomial probabilities can typically be simplified or calculated (indirectly) using mathematical techniques rather than brute force.

Factoring the numbers and cancelling common factors would be one of the first things I would try, by hand if need be. A multiple precision calculator can helpful.

Would re-framing the question or its values in either a different base (e.g. binary, hexadecimal) or a difference scale (e.g. logarithmic base 2, 10, or e -- natural) make the values easier to deal with? One example of a logarithmic scale, is the decibel, used for RF, and audio levels.

Using techniques not as commonly taught nowadays, but well known amongst programmers, engineers, mathematicians who are familiar with the slide rule can sometime be helpful.

Depending on the question, doing an approximation first can sometimes lead you towards the correct answer by preventing the minutiae from distracting you from attacking the problem creatively.

For your example; calculate a related (approximate), but simplified equation.

which is very close to the correct or exact answer

Another "trick" is to use modulo (mod, %, modulo, a \bmod n ) which is one of my favourite ways to reduce numbers, so if you know some basic abstract algebra you can sometimes work with modular arithmetic.

That is an off-the-cuff, very rough guide to how I would approach a "puzzle" equation or programming problem that involves large numbers.

Title: How to handle large numbers?


问:
web content management system
Quite a few of my friends want to have their own personal website to showcase their talents. However, they don't want to deal with such technical things as writing html and managing web server. Neither do I.

It would be nice that we go to our URL and view our pages and we edit and update our information when logging in. So basically the content displayed will be what we provide and at the same time we can choose from some provided templates for page layout and style.

It seems a typical content management system to me. If it is, I'd like to build a simple one myself because I'd like to have the experience of building a simple CMS. Since I have no previous experience for this, I need some help figuring out what is all I need for it. And, what are the most appropriate tools and technologies?

So far, I have html, css, JSP, Tomcat, SQLite in my mind. Is that enough? Are they the best combination?

Also, I have no idea how to approach the authorization and security aspects of building the system.

(PS: I'm not sure what tags are proper for my question. Feel free to edit them for me)

答:
The best way to learn to design a content management system is to customize an open source one for your needs.  Just getting one installed and running for the first time is a major achievement, then move onto theming and writing your own modules.

Then, and only then, will you have a reasonable idea of what it would take to design your own from scratch.  Doing it from scratch from the start isn't as valuable a learning experience as you might think, because you are mostly learning what doesn't work, and what does "work" is designed by a very inexperienced person.  There are a gazillion tiny little problems people have already solved that you aren't even aware exist yet.

Title: web content management system


答:
I think some of it comes down to having exerience and more in-depth knowledge of how to successfully solve some problems.

When you are new, all problems are also new and you need to research how to do them. But as you have solved the same type of problem repeately  the need to research goes down as you know a successful solution to that one.

Then you only tend to research the new problems or the ones where the old tried and true either no longer works (having been deprecated) or is causing a performance or failure problem. As you start to understand a complex system in more depth, you know you don't have the time realistically to use new techniques every time they come along and you have found through experience that a lot of the time the new technique doesn't live up to it's hype and creates more problems than it solved. So you become less inclined to use new tools and techiniques when you don't actually need them to solve the problem.

But less inclined should not mean you stop learning or never use a new technique, just that you are more judicious about when they are appropriate.


答:
1) Get it running.  Even if it does nothing but say hi.

2) Analyze.  Figure out what it needs, what would be nice, etc.

3) Have at it.  Add features one a time testing between each one.

Title: What are your initial three steps when you are first presented with a software problem?

Body:
I am curious about the very early steps that a programmer's mind takes when it first encounters a problem that it is supposed to solve. How do you start reasoning about it ? What are the first questions you ask yourself ??.

Ok, let me make it more concrete for those of you who think the question is too vague or entirely situation dependent. Pick any of the following   requirements and think out loud about your very first hunches/impressions/tendencies about how to solve it.

1) build a simple word processor with about as much functionality as MS Word Pad

 2) design a single person card game (e.g. Solitaire)

 3) build a scientific calculator

 4) Any  problem of your choosing with similar scale/complexity as the above three


问:
Abstract classes in package structure
I have an abstract class that will have many implementors. There are, of course, many places to put abstract classes in a Java package structure. Should the abstract class be in the same package as the implementors, or should it be in an "abstract package" package, or somewhere else? Please explain why you would place it there - I'm looking for design discussion, not just what I should do in this particular case.</p>

答:
I was just wondering about the same thing (but for interface classes). So lets add a post to this discussion.

I have a package com.cie.devices where I put devices which I control using Java software. Now comes the time where there are enough devices to start building a hierarchy of devices. I was wondering if I should put my TypeA interface for type A devices in com.cie.devices.typea, together with implementing classes. My main argument for not doing so was that putting interfaces in com.cie.devices made it easy to quickly identify all types of devices by looking at the interfaces in that package. My main argument for doing so is that it brings all type A related classes together.

In the end, I guess I'll all type related devices in the same package (i.e. all type A in com.cie.devices.typea) because 1) you already quickly see all types of devices looking at the subpackages of com.cie.devices, and 2) it unclutters the com.cie.devices packages which will probably still contain some lonely classes which do not have enough friends to be pushed a level lower in the class hierarchy.

So that's it. This is another case with another reasoning behind it.

Title: Abstract classes in package structure


问:
Suggestions for search methodology requested
I am throwing this question out to the 'greater creativity' for some suggestions on search methodology that might solve this problem. I have come up with a somewhat contrived example to attempt to explain the problem well enough that some solution(s) might be recommended.

The problem: We are using a relational DB (MSSQL), and need to search across products with the following constraints:

Availability

Market

Price

We also need to group and sort on price, market, and larger entity roll-up.

Let me see if I can explain using semi-real world entities: Think of an application that allows users to search for hotel rooms that they can book. The following criteria might be available for the search: days that the rooms would be booked for, the market in which they want a hotel room (e.g. NYC, Boston), amenities that the hotel room(s) might have (hot tub, fireplace, number of beds, suite or not).

In all cases, the search criteria above may or may not be selected. So, a very broad search is possible (on these dates, I don't care which market), or varying the levels of specificity (in NYC, 2 beds, with fireplace).

To add complexity, we also need to return the prices of the hotel rooms for the selected criteria. Obviously, special pricing, different prices for the different days of the stay (one price on Thursday night and a different price on Friday and Saturday nights for a weekend stay).

Some of the things we've played around with are: Solr, Endeca, SQL querying, implementing in C# code and optimizing when/where necessary (think of the decorator pattern).

What I'm looking for here is some suggestions from the community on: which of the above is NOT suited for this problem, which might be well suited for this problem, which other technology might work better that we haven't thought about, techniques that others have used on similar problems that worked well (non-technology specific).

答:
I am a big fan of Sphinx.  It is super fast, supports MSSQL and is pretty easy to use.  Not sure on the C# integration, but I think there are examples of using it there.

In your configuration you just setup what you want to index (i.e. tables and columns).  Then when you search you can search either just a single object type or across all object types.

There are quite a few sorting and filtering options as well including Faceting.


答: Those really aren't particularly huge numbers. Your example is well within the range supported by a C 'unsigned int' or 'long' on a typical x86 compiler, and vanilla configurations of python will automatically support arbitrary precision arithmetic. Part of your problem may be that in Python "^" is not the exponentiation operator, it's the bitwise 'XOR' operator. Try using 10**6 instead. Of course, using integer division the answer will be zero. Do you want floating point division instead?</p>

Title: How to handle large numbers?

Body:
Well, I've just started doing puzzles and it's so annoying to see puzzles which are easy to do but also need to handle very large numbers. That's the problem.

Say I have to deal with numbers like 10 ^ 6 / 2147483647 / etc. Need to do arithmetic operations on!

However, I feel that these shouldn't be handled in brute force way but the math theorems/ statements just don't click in my mind at times.

How could I possible handle such puzzles (shouldn't use external lib)


答:
Here's how it works in practice:

1) If you're a small fry, hobbist, or otherwise inconsequential. Licensing doesn't matter because nobody cares. That's not legally true, but it works out that way. Quite often you hear stories about previously small fries making it to the "big time" (for variable quantities of "big") and they wish they had cared more about their licenses.

2) You're a big corporation that wheels and deals in proprietary code. You collect a number of patents not to actually get royalties, but use as a nuclear option in case any of your competitors nukes you for violating their patents (which you are).

3) You're a hippie that uses open source software because you want to get things done with software rather than worry about who owns what and who gets paid to write the software.

IANAL, this isn't legal advice. It's more like a cynical reflection on the joke that is IP laws.

Title: Software licenses in practice

Body:
Almost all questions and information on both SO and "Google" describes how different licenses works and what license to choose for your work?

But how do they work in reality.

Almost everyone I have spoken to have vastly different thoughts of how they work, including hard core open source developers that gladly share their libs and consultants who is only interested in money and would never reveal their libs.

First I will give my impression of how they work in practice with three questions / statements and you can agree or disagree with me on those.

Lets say I make a large application and have a small portion of that from GPL code, then the copyright holder can't do much about it as it's deemed non essential code for my application and thereby the "law" rules over the GPL?

If the code is generic the copyright doesn't hold. For example if I make a tutorial on how to set up a chess engine no one have to care about my license. That's because my code is mechanical in nature.

If I use a lot of GPL code that is essential for my application and don't disclose it and someone finds out, my "punishment" will be to release all my source code, large companies are terrified by this.

But for a small hobby developer this isn't much of an issue as the software wouldn't be written at all or would be open sourced from the start anyway? I don't like this approach personally because I find it unethical and disrespectful to the original author.

EDIT: Clarified as a comment made was that I din't ask a question. My question is are the 3 statements correct.


问:
Most frequently used design patterns in refactoring (my example)
I've been doing quite a lot of refactoring of C++ and C# code recently, and found that 90% of the patterns I use are:

Template method

Factory

Singleton

Are these generally the most commonly used patterns in refactoring or is it just me?
Can you share your refactoring experiences?

答: We're using a lot of pub-sub, facade (oh man this is useful to make readable code), templating lately.  We hardly ever use Singleton, but that's because DI has taken care of all of that.</p>


答: It looks like you have a performance problem. This can be caused by many things. For one, are you running the query against several web services or directly through your database? How is the database schema organized? Do you use normalized database or a star-schema type? How about your indexes? How do you handle optional information (any number of beds and any price)? There are lots of factors that could affect the performance. You need to sit with DBA and examine your SQL and plan statistics and review your schema carefully. Without knowing more details about the architecture and the other specific points mentioned above, it is not possible to make a recommendation (at least that is what I think).</p>

Title: Suggestions for search methodology requested

Body:
I am throwing this question out to the 'greater creativity' for some suggestions on search methodology that might solve this problem. I have come up with a somewhat contrived example to attempt to explain the problem well enough that some solution(s) might be recommended.

The problem: We are using a relational DB (MSSQL), and need to search across products with the following constraints:

Availability

Market

Price

We also need to group and sort on price, market, and larger entity roll-up.

Let me see if I can explain using semi-real world entities: Think of an application that allows users to search for hotel rooms that they can book. The following criteria might be available for the search: days that the rooms would be booked for, the market in which they want a hotel room (e.g. NYC, Boston), amenities that the hotel room(s) might have (hot tub, fireplace, number of beds, suite or not).

In all cases, the search criteria above may or may not be selected. So, a very broad search is possible (on these dates, I don't care which market), or varying the levels of specificity (in NYC, 2 beds, with fireplace).

To add complexity, we also need to return the prices of the hotel rooms for the selected criteria. Obviously, special pricing, different prices for the different days of the stay (one price on Thursday night and a different price on Friday and Saturday nights for a weekend stay).

Some of the things we've played around with are: Solr, Endeca, SQL querying, implementing in C# code and optimizing when/where necessary (think of the decorator pattern).

What I'm looking for here is some suggestions from the community on: which of the above is NOT suited for this problem, which might be well suited for this problem, which other technology might work better that we haven't thought about, techniques that others have used on similar problems that worked well (non-technology specific).


答:
how about:

```<code>int j = 1;
for (int i=1; i>=j; i++) ...
</code>```

Yep, I've seen it.

Title: Make a big deal out of == true?

Body:
There is a colleague of mine who constantly writes:

```<code>if (someBool == true)
</code>```

It drives me up the wall!  Should I make a big deal of it or just drop it?

Body:
how about:

int j = 1;
for (int i=1; i>=j; i++) ...

Yep, I've seen it.


问:
Does using new techniques hurt productivity?
It seems that as experience with the specific set of tools you have to work with grows, the incentive to try out new things weakens.

When I was new at this programming job, trying out new things, researching online, made me more productive, because I often found a way (or library) that made the task easier that the code framework already in place. So using something new -- to me as well as in the context of the given codebase -- made me more productive.

Now I noticed, that there are more and more instances where, for a given problem, I know that there probably is a better solution "out there", and finding it would -- presumably -- improve the code. However, given my now intimate knowledge of the code base, it is by far easier to use the suboptimal tools we have, and get a solution (including tests) running than find someting new and "better" and "improve" the codebase.

So there is this tension: "do it properly" vs. "get the job decently done".

Is this something that happens to a lot of developers? Is this a known specific problem? (Is it a real problem after all?) Does it actually have to do with increasing levels of experience?

Oh, and note: I still like my job and like to keep it. It's just that it seems the -- always interesting! -- research part get's smaller as I learn the code base and problem sets we face with our app.

答:
Here's some details:

There are deadlines: Programmer's should beforehand have all the details necessary available of the tools he's using. Reading some web site, finding some new cool thing, and then using it in production environment is a big no-no. You just don't have enough experience with the tool, and even more importantly, you just don't have the necessary time to start learning something new. If you want some cool new stuff, learn it half year or year before using it.

Make sure you know it properly before using it: Some nice new tool can be fun to use, but googling for solutions and then using them without properly learning them can be very bad. You just don't have enough experience with it. If you needed to google it to figure it out means that you just don't know it well enough to fix it when it breaks half the system.

Using the newest stuff is not doing it properly: the new stuff is not proven tech. Next year the tech is probably completely gone, you being the only one in the world using it any longer. Everyone else noticed it just does not work. It takes hard work to avoid the newest silver bullet, but it's worth it.

Focus on techniques that are your core knowledge: Every programmer knows only small part of the whole programming knowledge available in the world. The part where the programmer is comfortable enough using it is even smaller. The part which actually works is even smaller. Use only the knowledge which you have properly learned and you know that it works. This makes you faster programmer and results in better code.

Don't tweak it endlessly: Perfect code is a good goal, but this does not mean you write some crap first, and then endlessly tweak it to make it incrementally better. Write it perfectly the first time using the all the good knowledge you have. Trust yourself. Don't trust the world. Noone else knows exactly the same stuff you do. Their opinion doesn't matter. You're the programmer, you need to make it work. The world can't do it for you. Once it's done, Stop. Don't touch it until someone complains about it.

Spend time to learn new things: Everyone needs to continuously learn new things. Our future depends on it. Just refuse to use it! Learn new stuff, but don't use it until you're sure it's actually working. You'll get chance to use it next year, once it's proven tech. Or you just forgot it, like everyone else -- only the good stuff remains...

Do not lose the good stuff: Once you've successfully built big systems and fixed all the problems in them, and learned some nice techniques, the worst thing you can do is just dump that knowledge and go for something new. You already know how it works, what problems there are and how to solve those problems. Throwing it away is just waste of time.

Keep up with new tech: one of the new systems is going to be successful. It has something fundamentally better than anything else in the marketplace. You just don't know which one is the silver bullet. If you fail to find it in time, your knowledge will be outdated. The world can make you lose all the good stuff by removing access to the old systems.


问:
Should unit tests be stored in the repository?
I'm a growing programmer who's finally putting unit testing into practice for a library that I'm storing on GitHub.

It occurred to me that I might include the test suites in the repo, but as I look around at other projects, the inclusion of tests seems hit-or-miss.

Is this considered bad form? Is the idea that users are only interested in the working code and that they'll test in their own framework anyway?

答: Absolutely.  The extra bonus points here are in the ability to track that version X of a source file goes with version Y of a test.  In other words, you need to be able to go back to a previous version and pull the appropriate tests designed for that version (in case of an API change or somesuch).</p>


问:
Make a big deal out of == true?
There is a colleague of mine who constantly writes:

```<code>if (someBool == true)
</code>```

It drives me up the wall!  Should I make a big deal of it or just drop it?

答:
What about nullable bools? </p>

```<code>bool? MyFlag = null;

if (MyFlag == true)
    ;

if (MyFlag)  // error, doesn't compile!
    ;
</code>```

Title: Make a big deal out of == true?

Body:
What about nullable bools?

bool? MyFlag = null;

if (MyFlag == true)
    ;

if (MyFlag)  // error, doesn't compile!
    ;


问:
What is a "markdown-formatted" README file on Github?
It's unclear to me what the format is, if there's systematic/command-line requirements for creating it, etc.

Basically, just to need to know the specs, and if there's technical steps for generating the README file.

答:
Markdown is a simple syntax for providing semantic info and representing common formatting in plain text. Daring Fireball has a awesome syntax guide for standard markdown. GitHub then uses a variant of this that they call GitHub Flavored Markdown.

To set up your readme just create a plain text file and name it README (or README.md / README.markdown) and commit it to the root of your repo. GitHub will then pick this up as the project readme.


答:
Wikipedia — Markdown references the page "GitHub Flavored Markdown - Introduction" (archv.)

Quote from the page:

GitHub uses what we're calling "GitHub Flavored Markdown" (GFM) for messages, issues, and comments. It differs from standard Markdown (SM) in a few significant ways and adds some additional functionality.

The page also gives a description of the differences to standard Markdown.

There's also more information how Markdown is actually rendered by GitHub:

If you're interested in how we render Markdown files, you might want to check out Redcarpet, our Ruby interface to the Sundown library.

(Apparently, Sundown is the actual Markdown parser that is used behind the curtains.)

To add one more layer of abstraction, Sundown is a fork of even another Markdown parser :-)

Quote from Sundown's GitHub page:

Sundown is a Markdown parser based on the original code of the Upskirt library by Natacha Porté.

Title: What is a "markdown-formatted" README file on Github?

Body:
It's unclear to me what the format is, if there's systematic/command-line requirements for creating it, etc.

Basically, just to need to know the specs, and if there's technical steps for generating the README file.


问:
How to write less code
A quality what I would like to develop is to write more concise code. With writing more concise, at least in my opinion, the opportunity to add bugs to the code is smaller. It is easier to read the code for other.

My question is if it is something that just comes with experience or is it something you can do explicitly for developing that quality?

答:
In my opinion, writing less code can be done in several ways:

You Ain't Gonna Need It. Don't code something you don't need yet. Code only the requirements state so. This way, we will reduce the code needed to write.

Don't Repeat Yourself. I believe using CMS, framework or the third party library is one way to applying DRY principle.

Abstraction. And last but not least, abstraction programming can reduce the code very much too. By abstracting the code the chance to reuse the code will go higher because it reduces duplicacity.

Title: How to write less code


问:
When is it appropriate to develop a gui application, as opposed to a web application?
I've been thinking about an application that I want to develop for a while now. In short, I want this application to perform some crud operations. The application will be for a law firm so overall security is going to be very important. My primary programming language is php but I wouldn't mind learning some Java or possibly Objective C to make my application os-x and iOS native. Back to my question, what are the pros and cons to developing a gui application as opposed to just developing an app for the browser? The reason I ask is because if there are some benefits to developing an gui app in, say, objective c, then I guess I need to start focussing on learning the language.

Important considerations about the application I want to develop:

Database connectivity

Security(Very important)

答:
The main reason to write a native app over a Web app is if there is a compelling reason to use the client OS. It doesn't sound like you have that constraint.

You cannot use Java to develop iOS applications, so you would need to use either Obj-C or Mono or something similar.

Most CRUD apps are good matches for Web development, although you often need some form of specialized table (you probably already know that).


问:
Why is there such limited support for Design by Contract in most modern programming languages?
I recently discovered Design by Contract (DbC) and I find it an extremely interesting way to write code. Among other things, it would seem to offer:

Better documentation. Since the contract is the documentation, it's impossible for one to be out of date. Additionally, because the contract specifies exactly what a routine does, it helps to support reuse.

Simpler debugging. Since program execution stops the moment a contract fails, errors can't propagate, and the specific assertion violated will presumably be highlighted. This offers support during development and during maintenance.

Better static analysis. DbC is basically just an implementation of Hoare logic, and the same principles should apply.

The costs, in comparison seem to be rather small:

Extra finger-typing. Since the contracts have to be spelled out.

Takes some amount of training to get comfortable with writing contracts.

Now, being familiar with Python primarily, I realize that it is in fact possible to write up preconditions (just throwing exceptions for inappropriate input) and it's even possible to use assertions to test again certain postconditions. But it's not possible to simulate certain features such as 'old' or 'result' without some extra magic that would ultimately be considered un-Pythonic. (In addition, there are a few libraries that offer support, but ultimately I get the vibe it would be wrong to use them, as most developers don't.) I assume that it's a similar problem for all other languages (except of course, Eiffel).

My intuition tells me that the lack of support must be a result of some kind of rejection of the practice, but searching online has not been fruitful. I'm wondering if someone can clarify why most modern languages seem to offer so little support? Is DbC flawed or overly expensive? Or is it just obsolete due to Extreme Programming and other methodologies?

答:
As you say, Design by Contract is a feature in Eiffel, which has long been one of those programming languages that is well respected in the community but which has never caught on.

DbC is not in any of the most popular languages because it is only relatively recently that the mainstream programming community has come to accept that adding constraints/expectations to their code is a "reasonable" thing to expect of programmers. It's common now for programmers to understand how valuable unit-testing is, and that percolated up to programmers being more accepting of putting in code to validate their arguments and seeing benefits. But a decade ago, probably most programmers would say "that's just extra work for stuff you know is always going to be ok."

I think that if you were to go to the average developer today and talk about post-conditions, they'd nod enthusiastically and say "OK, that's like unit-testing." And if you talk about pre-conditions, they'd say "OK, that's like parameter validation, which we don't always do, but, y'know, I guess it's ok..." And then if you talk about invariants, they'd start to say "Gee, how much overhead is this? How many more bugs are we going to catch?" etc.

So I think there's still a long way to go before DbC is very broadly adopted.


答:
Mostly the reasons are as follows:

It's only available in languages which are not popular

It's unnecessary since the same stuff can be done different way in existing programming languages by anyone who actually wants to do it

It's difficult to understand and use -- it requires specialized knowledge to do it properly, so there are small number of people doing it

it requires large amounts of code to do it -- programmers prefer to minimize the amount of characters they write -- if it takes long piece of code, something must be wrong with it

the advantages are not there -- it just cannot find enough bugs to make it worthwhile

Title: Why is there such limited support for Design by Contract in most modern programming languages?

Body:
I recently discovered Design by Contract (DbC) and I find it an extremely interesting way to write code. Among other things, it would seem to offer:

Better documentation. Since the contract is the documentation, it's impossible for one to be out of date. Additionally, because the contract specifies exactly what a routine does, it helps to support reuse.

Simpler debugging. Since program execution stops the moment a contract fails, errors can't propagate, and the specific assertion violated will presumably be highlighted. This offers support during development and during maintenance.

Better static analysis. DbC is basically just an implementation of Hoare logic, and the same principles should apply.

The costs, in comparison seem to be rather small:

Extra finger-typing. Since the contracts have to be spelled out.

Takes some amount of training to get comfortable with writing contracts.

Now, being familiar with Python primarily, I realize that it is in fact possible to write up preconditions (just throwing exceptions for inappropriate input) and it's even possible to use assertions to test again certain postconditions. But it's not possible to simulate certain features such as 'old' or 'result' without some extra magic that would ultimately be considered un-Pythonic. (In addition, there are a few libraries that offer support, but ultimately I get the vibe it would be wrong to use them, as most developers don't.) I assume that it's a similar problem for all other languages (except of course, Eiffel).

My intuition tells me that the lack of support must be a result of some kind of rejection of the practice, but searching online has not been fruitful. I'm wondering if someone can clarify why most modern languages seem to offer so little support? Is DbC flawed or overly expensive? Or is it just obsolete due to Extreme Programming and other methodologies?


答:
One hypothesis is that for a sufficiently large complex program, especially ones with a moving target, the mass of contracts themselves can become as buggy and hard to debug, or more-so, than the program code alone.  As with any pattern, there may well be a usage past diminishing returns, as well as clear advantages when used in a more targeted manner.

Another possible conclusion is that the popularity of "managed languages" is the current proof of design-by-contract support for those selected managed features (array bounds by contract, etc.)


问:
Self-Executing Anonymous Function vs Prototype
In Javascript there are a few clearly prominent techniques for create and manage classes/namespaces in javascript.

I am curious what situations warrant using one technique vs. the other. I want to pick one and stick with it moving forward.

I write enterprise code that is maintained and shared across multiple teams, and I want to know what is the best practice when writing maintainable javascript ?

I tend to prefer Self-Executing Anonymous Functions however I am curious what the community vote is on these techniques.

Prototype :

```<code>function obj()
{
}

obj.prototype.test = function() { alert('Hello?'); };
var obj2 = new obj();
obj2.test();
</code>```

Self-Closing Anonymous Function :

```<code>//Self-Executing Anonymous Function
(function( skillet, $, undefined ) {
    //Private Property
    var isHot = true;

    //Public Property
    skillet.ingredient = "Bacon Strips";

    //Public Method
    skillet.fry = function() {
        var oliveOil;

        addItem( "\t\n Butter \n\t" );
        addItem( oliveOil );
        console.log( "Frying " + skillet.ingredient );
    };

    //Private Method
    function addItem( item ) {
        if ( item !== undefined ) {
            console.log( "Adding " + $.trim(item) );
        }
    }
}( window.skillet = window.skillet || {}, jQuery ));
//Public Properties
console.log( skillet.ingredient ); //Bacon Strips

//Public Methods
skillet.fry(); //Adding Butter & Fraying Bacon Strips

//Adding a Public Property
skillet.quantity = "12"; console.log( skillet.quantity ); //12

//Adding New Functionality to the Skillet
(function( skillet, $, undefined ) {
    //Private Property
    var amountOfGrease = "1 Cup";

    //Public Method
    skillet.toString = function() {
        console.log( skillet.quantity + " " +
                     skillet.ingredient + " & " +
                     amountOfGrease + " of Grease" );
        console.log( isHot ? "Hot" : "Cold" );
     };

}( window.skillet = window.skillet || {}, jQuery ));
//end of skillet definition

try {
    //12 Bacon Strips & 1 Cup of Grease
    skillet.toString(); //Throws Exception
} catch( e ) {
    console.log( e.message ); //isHot is not defined
}
</code>```

I feel that I should mention that the Self-Executing Anonymous Function is the pattern used by the jQuery team.

Update
When I asked this question I didn't truly see the importance of what I was trying to understand. The real issue at hand is whether or not to use new to create instances of your objects or to use patterns which do not require constructors/use of the new keyword.

I added my own answer, because in my opinion we should make use of patterns which don't use the new keyword.

For more information please see my answer.

答:
Here's the pattern that I just began using (have been using variations of it up until yesterday):

```<code>function MyClass() {
    // attributes
    var privateVar = null;

    // function implementations
    function myPublicFunction() {
    }

    function myPrivateFunction() {
    }

    // public declarations
    this.myPublicFunction = myPublicFunction;
}

MyClass.prototype = new ParentClass(); // if required
</code>```

A few thoughts on this:

You shouldn't get any (anonymous) traces in your debugger stack traces as everything's named (no anonymous functions).

It's the cleanest pattern that I've seen yet

You're able to easily group up your exposed API without having their implementations coupled to the declaration (meaning someone can easily grok your public class interface without having to scroll)

The only time that I'd use prototype anymore really is to define inheritance.

Body:
Here's the pattern that I just began using (have been using variations of it up until yesterday):

function MyClass() {
    // attributes
    var privateVar = null;

    // function implementations
    function myPublicFunction() {
    }

    function myPrivateFunction() {
    }

    // public declarations
    this.myPublicFunction = myPublicFunction;
}

MyClass.prototype = new ParentClass(); // if required

A few thoughts on this:

You shouldn't get any (anonymous) traces in your debugger stack traces as everything's named (no anonymous functions).

It's the cleanest pattern that I've seen yet

You're able to easily group up your exposed API without having their implementations coupled to the declaration (meaning someone can easily grok your public class interface without having to scroll)

The only time that I'd use prototype anymore really is to define inheritance.