问:
What are the differences between AppMobi and PhoneGap?
I am new to the cross platform application development. I came across the very similar cross platform frameworks AppMobi and PhoneGap.

I want to know

Is there any differences between apk/ipa created using Appmobi and
apk/ipa created using PhoneGap?

Is there any difference in native features that can be used ?

What are the advantages of appmobi over phonegap or PhoneGap over
Appmobi?

Also other differences between these two.

答:
Disclosure: I work for appMobi.

There are many similarities between the two, in fact some of appMobi's functions are built on PhoneGap. Fundamentally, they both encapsulate HTML5/CSS3/JS into a webview that is exposed to the user from a native "Container". They both offer an API that lets you access the device's OS in a way that is impossible for a web app to do.

The bulk of the differences stem from the fact that PhoneGap was created as an open source project by many people who were each trying to solve their own problem or support development on a different platform, and appMobi has focused on creating a programming ecosystem that allows development of cross platform apps using HTML5. appMobi has focused on iOS and Android as its targets, and was the first to offer a cloud-based "build" system that accepts your HTML5 code and encapsulates it to create app store-ready binary files for a variety of app stores. Following the acquisition of the PhoneGap dev team by Adobe, there is now a paid cloud build service similar to appMobi's.

PhoneGap follows the typical open source model of allowing the developer to assemble their tool set using whatever tools they can find. There is no integrated PhoneGap IDE, emulator or debugging service. To be sure, these things exist, but they are not integrated and require you to build and learn them individually. In trying to present a fully formed HTML5 development toolset, appMobi provides an integrated toolset - IDE, emulator, local and remote debugger, and the build service mentioned above.

Because mobile games are well over 50% of the top 100 mobile apps, appMobi has developed numerous technologies that allow HTML5 mobile apps to perform well enough to compete with natively coded games. These include - directCanvas (10x graphic rendering acceleration), MultiSound (Sound acceleration, looping, one shots, etc), Social Badges and Leaderboards, and cross platform in-app payments.  PhoneGap has no game acceleration or support tech like that.

Finally, PhoneGap is solely a development tool. When you use PhoneGap build to create your IPA or APK file, you are done. appMobi's goal is to enable HTML5 to compete with iOS and Android as a mobile platform, so appMobi has created a number of cloud services that deliver value to your apps when they are used on the user's device. In effect, appMobi fills in the gaps that HTML5 has, making it competitive with iOS and Android.
These services are all cross platform (you write it once and it works on iOS/Android/??). They include rich media push messaging, in-app payments, user authentication, gamification, hosting, and user activity analytics.

PhoneGap's tools are free, but they charge for the build service. appMobi's tools and build service are free, but they charge when your app becomes successful (over 10,000 monthly users).

More recently, the HTML5 development tools created by appMobi (XDK, Build System, Debugging tools, jqMobi) were acquired by Intel and are now part of the Intel HTML5 Development Tools suite.

The cloud services mentioned above are still provided by appMobi. The cloud services now support apps that were developed with native iOS (XCode), Native Android (Java), and Native Windows 8 (XAML) as well as hybrid HTML5 (appMobi or PhoneGap), and good old web apps.


问:
Are only companies and no private programmers allowed to use VS Studio 2012 Express Desktop?
Programming is my hobby and I've just downloaded VS Studio 2012 Express Desktop.

Now I am going to register it but they want me to tell them business information

Are only companies and no private programmers allowed to use VS Studio 2012 Express Desktop?
And what shall I type in these text fields?

答:
You can put your home address, I don't think it is intended only for businesses, I guess is in the same stride with Visual Studio Shell to try and attract also the opensource community.

From the License documentation

A number of free development tools are also available, including
  Visual Studio Express 2012 for Windows 8, Visual Studio Express 2012
  for Web, and Visual Studio Express 2012 for Windows Desktop. These
  tools provide a subset of the functionality available in Visual Studio
  Professional 2012 and are specific to writing applications targeting
  these platforms. Each of these Visual Studio Express 2012 products is
  licensed per user and subject to the use terms included with the
  product. Visual Studio Express can be used to build production
  applications.

So it is free, but you are right you need to register after all.  Try to put None for the organization, and 0 for numbers of employees. Business address, fill your address or whatever address you think is relevant maybe school its your choice an privacy.

ContentLicense: CC BY-SA 3.0


问:
Why isn't functional language syntax more close to human language?
I'm interested in functional programming and decided to get head to head with Haskell. My head hurts... but I'll eventually get it...
I have one curiosity though, why is the syntax so cryptic (in lack of another word)?

Is there a reason why it isn't more expressive, more close to human language?

I understand that FP is good at modelling mathematical concepts and it borrowed some of it's concise means of expression, but still it's not math... it's a language.

答:
I think the difference has to do with the way functional/declarative programming makes statements about a problem as though it's a math problem, where as imperative programming describes a process.  In the business world, computer programs wrap or replace physical processes, so you may find a language that reflects this to be more intuitive.

It turns out that the functional style lends itself to making safe use of multiple processors (because it minimizes mutability and side effects) - something we will see more of in the future.  Also, most modern functional languages have collections with iterators you can pass functions to.  These methods can split their workload over multiple processors very efficiently without you even knowing about it.


问:
Good technologies for developing a modular server component in .net?
I am using WPF, Prism and Unity to develop the user interface for a .net application.  The UI will run from a PC, but I also need to develop a separate complex server component that will provide services to the PC component via WCF.

Prism and Unity have proved to be of great value in creating a modular application, at least as far as the user interface is concerned.  I would also like to make the server component modular, but I cannot find anywhere what techniques, patterns and technologies are suitable.  I have considered:

Unity or one of the other DI containers

Selected parts of Prism, such as modules and events

Are these suitable for developing a modular server component?  Or are these UI technologies only and should I be looking at something completely different?

答:
There are a couple of good guidelines to follow to ensure modularity of your server side components, one good rule of thumb to keep in mind as you're designing the assemblies and their responsibility boundaries can be to make it easy to fulfill the client side requests in-proc on the client side. This will help you design the server side component so that it will be capable of completing it's tasks in multiple scenarios more cleanly.

I would suggest reading through this:
http://apparch.codeplex.com/releases/view/19801

That said, here's my general suggestions:

DI, yes. However you do it, use it to abstract the layers of the service.

Design and implement the crux of what you want your server side piece to be, in a class library with no references to service pieces

Recognize the fact that it's a "service" is merely an effect of it's hosting process, and should not be an inbuilt piece of the business logic itself.

At the very least, the horizontal segmentation should create a boundary between service hosting, and logic components, likely for modularity you'll want more horizontal boundaries than this one.

Make everything below your hosting layer, completely ignorant of other services as much as possible. You want external dependencies to hang off your graph as near to the top of the stack as possible.


问:
When does 'optimizing code' == 'structuring data'?
A recent article by ycombinator lists a comment with principles of a great programmer.

#7. Good programmer: I optimize code. Better programmer: I structure data. Best programmer: What's the difference?

Acknowledging subjective and contentious concepts - does anyone have a position on what this means?  I do, but I'd like to edit this question later with my thoughts so-as not to predispose the answers.

答:
Nine times out of ten, when you structure your code/models well, optimization will become obvious. How many times have you seen a hornets nest and found it totally suboptimal, where upon restructuring it, lots of redundancies became extremely obvious.

A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away.
  - Antoine de Saint-Exupery

A well structured system will be minimal in nature, and due to it's minimal nature it will be optimized because how little there is to it relates directly to how little it does to accomplish it's goal.

Edit:
To expound upon the point other's have taken away from this, it's also completely accurate to see the statement as identifying the relation between code and data. That relation is thusly: If you change the structure of your data, you will need to change your code to respect the altered structure. If you wish to optimize your code, chances are you will need to change the structure of your data to make your code capable of handling the data more optimally.

That said, there is a totally separate possibility that was being eluded to here, and that would be that this fellow having relations with YCombinator may be referring to code AS data in the LISP tradition of homoiconicity. It's a stretch to surmise this as the meaning in my mind, but it is YCombinator so I wouldn't rule out that the quote is simply saying LISPers are the "Best Programmer"s.


答:
I think the author is hinting that any restructuring of the data leads to code restructuring. Therefore, restructuring the data with the goal of optimizing your system will force you to optimize your code as well, prompting the "what's the difference?" response.

Note that an "uber-excellent programmer" may reply to "what's the difference?" that there is some difference left in there: once you venture into optimizing for improved use of the CPU cache, you may keep the layout of your data structures the same, but change the order in which you access them can make a great deal of a difference.

Title: When does 'optimizing code' == 'structuring data'?

Body:
A recent article by ycombinator lists a comment with principles of a great programmer.

#7. Good programmer: I optimize code. Better programmer: I structure data. Best programmer: What's the difference?

Acknowledging subjective and contentious concepts - does anyone have a position on what this means?  I do, but I'd like to edit this question later with my thoughts so-as not to predispose the answers.


问:
Why should one use a single-use temporary variable?
Let's say we have a class called 'Automobile' and we have an instance of that class called 'myCar'. I would like to ask why do we need to put the values that our methods return in a variable? Why don't we just call the method?

For example, why should one write:

```<code>string message = myCar.SpeedMessage();
Console.WriteLine(message);
</code>```

instead of:

```<code>Console.WriteLine(myCar.SpeedMessage());
</code>```

答:
In this case it doesn't really matter but when you're working with bigger systems it can be an issue as:

It makes debugging a lot easier

If you have a habit of compacting your code as far as me it makes it actually readable ie:

square(getNum1(var1,var2[(param1+(param2%2))]),obj1.getNum2(((ptr1+dynamicOffset1)+5)(getMult(NULL))))


问:
MIPS has been used a multiprocessor architecture in the past. Is anyone using it in a multicore SoC?
I have been reading about the MIPS architecture and learned that it has been used a multiprocessor architecture in the past.  Is anyone presently using it in a multicore SoC?</p>

答: Loongson: both multi-core and with MIPS  architecture. It seems that it is developed in China mainly by Chinese engineers and academics but also is the result of a public-private partnership. </p>


答:
I don't agree with the statement mentioned above, well at least without explanation. I see coding is the activity involving the utilization of some data structures. Data structures would generally influence coding. So there is a difference between the two in my opinion.

I think the author should have written the last part as "Best programmer: I optimize both."

There is a great book (at least it was in when published) called: Algorithms+Data Structures = Programs.


答:
Consider the most obvious example of this - "searching for user data is too slow!"

If your user data is not indexed or at least sorted, then restructuring your data will quickly yield increased code performance. If the data is structured properly and you're just iterating through the collection (rather than using the indexes or doing something like a binary search) then modifying the code yields increased code performance.

Programmers are problem solvers. While it is useful to distinguish between algorithms and data structures, they cannot often exist in isolation. The best programmers know this, and don't isolate themselves unnecessarily.


答:
Optimizing code can sometimes improve speed by a factor of two, and occasionally by a factor of ten or even twenty, but that's about it.  That may sound like a lot, and if a 75% of a program's execution time is spent in a five-line routine whose speed easily could be doubled, such an optimization may well be worth making.  On the other hand, one's selection of data structures may affect execution speed by many orders of magnitude.  A modern hyper-optimized multi-threaded processor running super-optimized code to look up data by key in a 10,000,000-item linear linked list stored in RAM would be slower than a much slower processor running a rather simply-coded nested hash table.  Indeed, if one had the data laid out properly, even a 1980's computer fetching data from a hard drive might beat the modern CPU using the inferior data structure.

That having been said, designing efficient data structures often requires more complex trade-offs than optimizing code.  For example, in many cases the data structures which allow data to be accessed most efficiently are less efficient to update (sometimes by orders of magnitude) than those which allow fast updates, and those which allow the fastest updates may allow the slowest access.  Further, in many cases, data structures which are optimal for large data sets may be comparatively inefficient with small ones.  A good programmer should strive to balance those competing factors with the amount of programmer time required to implement and maintain various data structures, and be able to strike a decent balance among them.


答:
Best programmer: What's the difference?

Best programmer? No. Lousy programmer. I'm assuming the word "optimization" means those things that programmers typically try to optimize, memory or CPU time. In this sense, optimization goes against the grain of almost every other software metric. Understandability, maintainability, testability, etc.: These all take short shrift when optimization is the goal -- unless what one is trying to optimize is human understandability, maintainability, testability, etc. Not to mention cost. Writing an speed / space optimal algorithm costs considerably more in terms of developer time than does naively coding the algorithm as presented in some text or journal. A lousy programmer doesn't know the difference. A good one does. The best programmer knows how to determine exactly what needs to be optimized and does so judiciously.


问:
ASP.NET Webforms developers and web designers: how to interact?
I'm an ASP.NET Webforms developer, and I face some problems when I deal with designers.

Designers always complain about the asp.net server controls. They'd rather just have an html file and create css files along with the required images to go with those. Sometimes, if the design phase is done in advance, I get html files with related css files, but then we face many problems integrating the design with the aspx files (sever controls an telerik controls ... etc).

What I want to ask about is:

How do I overcome these problems? The designers prefer php- and mvc developers because of the problems with .net server controls. I need to know how to interact with the designers in the correct way.

Are there any tools or applications to provide the designers with the rendered (html
page) of the .aspx pages? By that I mean the page in runtime rather than the aspx in Visual Studio. They do use Web Expression but they want the rendered page in html as well.

答:
As a hybrid developer, myself (having done a lot of work in both back-end and front-end roles, often together), I have a long-standing dislike of the ASP.NET WebForms model as well... while its initial design impetus was to provide easy, drag-and-drop design tools to democratize web development (the same way that Visual Basic made app-programming accessible to the non-CS-major), the methods it used to try to force state on a stateless environment (the web) are ham-handed and forced (oh ViewState, how I loathe thee!).

They also violate some of the central principles of markup development and styling, just by the very fact that, by default, ASP.NET takes over the ID attribute, forcing CSS designers to use classes the same way that IDs were meant to be used, layering elements in deep stacks of divs and nested tags that can make styling the controls a nightmare in all but the most simplistic systems.

Given these things, your path is not an easy one, as I assume a rewrite for MVC would be cost-or-time-prohibitive.

Is there any way to provide the designer an environment in which to run the web application, so they can see their CSS changes in real-time? When I'm doing design work in ASP.NET WebForms, I find it invaluable to be able to fire up the web app on my own machine, make tweaks to the CSS, and run it locally to see how that affects the app.

One option might be to set up a virtual machine tailored specifically to ASP.NET development that the designer can run from their workstation, so they don't have to mix their two toolsets, and if they happen to screw something up in the dev-space, it can always be reloaded from a functioning image.

Yes, this means that the designer will have to learn how to press F5 to run the app. (Or just give them access to FTP to the directories where the CSS, JS and images are, even, on a test environment!) It also means that they'll see a lot of back-end code, though if you tell them to just ignore your .cs or .vb files, that will go a long way to keeping them from panicking... Of course, that means that you have to be sure you're not doing things like setting styles from your codebehind files... (but you wouldn't do that, would you, as that ties data and view too closely, right?).

If your site is structured well, with distinct CSS and JS files, and not a lot of inline styling forced on the markup, it's possible they can get most of their job done by just having them avoid the <% %> areas. On the other hand, it might also give the designer a little more appreciation for what you have to go through, when trying to translate their static HTML/CSS into something that works for a dynamic app.


答:
Data structures drive a lot of things relative to performance.  I think that we can look at problems hard and long with a preconceived idea about the ideal data structure, and in this context of thinking, even create proofs (often by induction) of optimality.  For example, if we put a sorted list into an array and evaluate things like the cost to insert an element we might decide on average we need to shift 1/2 of the array for each insertion.  For each binary search, we can find a matching item (or not) in log n steps.

Alternatively, if we defer our decision about data structure (avoid premature optimization) and study the data coming in and the context where we will use it, how big it is, what latencies occur and which ones matter to users, how much memory we have vs. would use with data representations we know or can devise.

In an area like sorting and searching, there is a lot to know.  Truly great programmers have been working on this a long time.  Understanding these problems well is useful, and it is a great thing if you know more methods than when you finished undergrad data structures class.  Binary trees can provide superior performance for insertions in exchange for higher memory use.  Hash tables provide even bigger improvements, but for more memory still.  A radix tree and radix sort can carry improvements even further.

Creative structuring of the data can help reframe a problem and open the door to new algorithms that make hard applications faster and sometimes impossible tasks possible.


问:
Is Haskell's type system formally equivalent to Java's?
I realize some things are easier/harder in one language than the other, but I'm only interested in type-related features that are possible in one and impossible/irrelevant in the other.  To make it more specific, let's ignore Haskell type extensions since there's so many out there that do all kinds of crazy/cool stuff.</p>

答:
Java's type system lacks higher kinded polymorphism; Haskell's type system has it.

In other words: in Java, type constructors can abstract over types, but not over type constructors, whereas in Haskell, type constructors can abstract over type constructors as well as types.

In English: in Java a generic can't take in another generic type and parameterize it,

```<code>public void <Foo> nonsense(Foo<Integer> i, Foo<String> j)
</code>```

while in Haskell this is quite easy

```<code>higherKinded :: Functor f => f Int -> f String
higherKinded = fmap show
</code>```

Body:
Java's type system lacks higher kinded polymorphism; Haskell's type system has it.

In other words: in Java, type constructors can abstract over types, but not over type constructors, whereas in Haskell, type constructors can abstract over type constructors as well as types.

In English: in Java a generic can't take in another generic type and parameterize it,

public void <Foo> nonsense(Foo<Integer> i, Foo<String> j)

while in Haskell this is quite easy

higherKinded :: Functor f => f Int -> f String
higherKinded = fmap show


问:
How to calculate Sin function quicker and more precisely?
I want to calculate y(n)=32677Sin(45/1024•n), where y is an integer and n ranges from 0 to 2048. How can I make this process quicker and more precisely?
   Now I want to show you a reference answer:
   Since   Sin(a+b)=Sin(a)Cos(b)+Cos(a)Sin(b)
   And  Cos(a+b)=Cos(a)Cos(b)-Sin(a)Cos(b).
   So I can store  Sin(45/1024•1) and  Cos(45/1024•1) only.Then use this formula:

Sin(45/1024•2)=Sin(45/1024•1+45/1024•1),
    Cos(45/1024•2)=Cos(45/1024•1+45/1024•1),
  Sin(45/1024•n)=Sin(45/1024•(n-1)+45/1024•1),
    Cos(45/1024•n)=Cos(45/1024•(n-1)+45/1024•1) ,
This way maybe quicker without storing large array.

答:
Compute the table at compile time instead of run time.

You're doing a 2048-element table of 16-bit scaled integer values.

Write a cheap Matlab script, with a print that gives a data line suitable for your final programming language.  Cut-and-paste the result into your source code, as a constant data table, and do a table lookup at run time.  This pushes the initial computation time off into the build cycle, instead of the program startup time.


问:
Is it bad practice to use the same name for arguments and members?
Sometimes I write constructor code like

```<code>class X
{
public:
  X( const int numberOfThingsToDo ) :
    numberOfThingsToDo( numberOfThingsToDo )
  {
  }

private:
  int numberOfThingsToDo;
};
</code>```

or in C#

```<code>class X
{
  public X( int numberOfThingsToDo )
  {
     this.numberOfThingsToDo = numberOfThingsToDo;
  }

  private int numberOfThingsToDo;
}
</code>```

I think the main reason is that when I come up with a suitable member name, I see no reason to use a different one for the argument initializing it, and since I'm also no fan of using underscores the easiest is just to pick the same name. After all it's suitable.
Is this considered bad practice however? Any drawbacks (apart from shooting yourself in the foot when forgetting the this in C#)?

答:
It doesn't much matter.  If there is a universally agreed practice for the language, then follow that.  If not, then follow whatever practice is the consensus for your team.  If you are working alone, then do as you please.

Distinguishing between local variables and data members should not be a problem.  If you have so many variables in scope that it is a problem, then your class is too large.


答:
This is perhaps one of those programming religion type of issues. Some think shadowing, at least in constructors and setters, is the exactly right thing to do do. I even saw it promoted as a "should" practice (but not a "shall") in a couple of coding standards. Others think it is absolutely horrendous. Some coding standards designate this as a "shall not" practice. Personally I don't like the practice, but my personal dislike isn't strong enough that I feel compelled to write it into the standards I write or help write. "Don't fight the small stuff" and "don't start programming religion wars" take precedence over my personal feelings in this regard.

As a side note, GNU's C++ compiler, along with others, provide a -Wshadow option or equivalent that warns about parameter names shadowing data member names. Note: This option is not a one of those enabled by -Wall. Apparently the GNU compiler authors don't want to start a religious war, either.

There is a third option with C++: Use shadowing where appropriate in the declarations of constructors and setters, but use different names in the definitions of those member functions. As far as the compiler is concerned, there's nothing wrong with giving a parameter a different in the declaration (prototype) of a function and the function's definition. I don't particular like this practice, but I have seen it used intentionally, not just accidentally.

Title: Is it bad practice to use the same name for arguments and members?

Body:
Sometimes I write constructor code like

```<code>class X
{
public:
  X( const int numberOfThingsToDo ) :
    numberOfThingsToDo( numberOfThingsToDo )
  {
  }

private:
  int numberOfThingsToDo;
};
</code>```

or in C#

```<code>class X
{
  public X( int numberOfThingsToDo )
  {
     this.numberOfThingsToDo = numberOfThingsToDo;
  }

  private int numberOfThingsToDo;
}
</code>```

I think the main reason is that when I come up with a suitable member name, I see no reason to use a different one for the argument initializing it, and since I'm also no fan of using underscores the easiest is just to pick the same name. After all it's suitable.
Is this considered bad practice however? Any drawbacks (apart from shooting yourself in the foot when forgetting the this in C#)?


问:
Whiteboard "testing" during an interview: legitimate way to back up your (whiteboard) code?
As I get it, having an error (even a typo like or missing ";") in your whiteboard code will often cost you some interview points. Avoiding that will inevitably make one proof-reading code again and again (losing time and possibly neural energy / concentration) or even using a simpler (and thus less effective) algorithm -- and both these ways are "costly" again!

So, why not just fast write code as elegant and effective as you would having a (unit) testing framework at your disposal and then just normally test it it (just on the whiteboard)?

Has anyone tried / seen this approach? Is the whole idea worthy?

[this also applies to the pen-and-paper case of course]

答:
I absolutely want you to test the whiteboard code I ask you to write. I want you to talk out loud while you write it, look it over, spot most of the syntax mistakes you made, and point out how it could be more efficient. In fact, that's kind of the point of doing it at the whiteboard. It's not a one-shot, write-it-all-out, uh-huh-you-get-70/100 kind of thing. It's a conversation, mediated by code and held at the whiteboard instead of across my desk.

Here are some great ways to fail the "Whiteboard coding" test:

refuse it

don't ask a single clarifying question (language, platform, something about the requirements) AND don't tell me your assumptions about any of it AND make assumptions that are way off what I would have answered

(eg: write it in Fortran, interpret "display" or "print" as "write to the event log", that sort of thing. I might allow it if you told me in advance those were your assumptions)

ask me what language I want it in, receive an answer that is in the job description, and then write it in a different language because you're not comfortable in the language I asked for.

(We're consultants here. I am testing for consultant behaviour as much as coding. Asking the client is only correct if the client actually has a choice. Controlling conversations with people who will pay you is hard. This is lesson 1. It's a mark against you on any topic, but for the specific "you're hiring an X programmer but I don't want to write in X for you" you now have two big black marks.)

show me what an architecture astronaut you are by filling two whiteboards with interfaces, factory patterns, abstractions, injections, and tests when I wanted you to "print the numbers from one to 5".

(you think I'm exaggerating but I had a guy who generalized my problem dramatically - sticking to the example above let's say instead of 1 to 5 his solution would do any arbitrary sequence of integers (got from where? I wondered) and was 5 times as long as anyone else's - and he forgot to actually call the function that did the work. Repeated prompting and suggesting that he walk through it as though he was the debugger did not lead to his noticing that the function was never called.)

I always say "do you like that?" "can you improve that?" "walk me through that" and the like. Typically the missing semi colon gets spotted, or the off-by-one, in that conversation. If not, I usually mark it up to nerves.

Other things you may not think matter at the whiteboard that matter to me:

when you're done, can I still read it? Have you smudged, scribbled over, switched colours, drawn arrows, crossed out and generally left a mess that can't now be used? Or are you aware that whiteboards are erasable, pointed to lines of code in the air instead of circling/arrowing them, and left me something I could take a picture of and keep in the design file?

how much did you ask me as you did it? Do you like to be left alone and not discuss your code, or do you see code as a collaborative thing? How did you respond when I asked you things while you were still writing it?

did you sneer at the "easy" task or faint at the "hard" one? Were you rude about being asked to show you can code? Are you easily intimidated by a technical problem, or arrogant about your ability to come up with a good algorithm?

are you working it out in your head, or remembering a solution you read somewhere? I can usually tell for the hard problems.

did you plan ahead about where you started writing? Folks who run out of whiteboard usually start too low or write too big - I can tell they didn't know this was going to be 20 lines of code and so only left room for 5 - believe it or not this tiny detail is mirrored in bigger estimating tasks as well.

did you look it over before you said you were done? Did I see you pointing or tapping your way through it and testing it yourself before I asked you to? When I prompted you, or asked you specific questions about it, did you look at it again, or just go from memory? Are you willing to consider that your first draft might not be complete?

I strongly recommend practicing coding at the whiteboard. I always warn interviewees that they will be asked to do it. If you have access to an actual whiteboard then set yourself some simple problems and practice doing them there. It will help your performance and your confidence.

Sorry I know I'm in TL;DR territory but here's the thing - coding at the whiteboard is about more than coding. It's a test of more than your grasp of syntax. There are a lot of behaviours of good programmers that are demonstrated in your response to this task. If you think it's only about coding you are missing the point.

In other conversations about whiteboard testing, people tell me I may reject a good candidate with it. Honestly, that's a risk I'm willing to take. Every hiring round contains several people I could hire. Some people with great resumes, who are doing ok in the question-and-answer part of the interview, fall apart at the whiteboard and clearly cannot (with any amount of prompting) write simple code in the language they claim to know. I might have hired some of these. Any tool that prevents that is a tool I will continue to use. I have never ended up in a no-one to hire boat because all my candidates messed up at the whiteboard and I don't expect I ever will.

ContentLicense: CC BY-SA 2.5


问:
what are the advantages and disadvantages of putting code for an unfinished project on github
I'm stating to work on a project that I intend to release as open source via the githubs. What are the advantages of putting the code on github from the outset, as opposed to waiting until the project is in a working state before publishing.

If it matters, this particular project is a C# app/service, and I have only a free github account (so I can't make it private and then pull back the covers later)

答:
I say why not have the best of both worlds.

The nice thing about git and decentralized source control in general is you don't have to stick to one host. You could make a private bitbucket or github repo and a public github repo. Right now push your changes to the private repo, and when your project is more complete(or reaches a milestone) you can push to the public repo... and you can later make the private repo public and have a presence on both Bitbucket and Github

ContentLicense: CC BY-SA 4.0


答:
WCF services and MVVM are more than sufficient to provide the functionality you describe in loosely coupled, modular, and scalable fashion.

I suspect your confusion may be coming from viewing the Model and the WCF services as only a means to retrieve data.  A service can be much more than just another layer in the data feed stack though.  Services can be used to trigger ad-hoc actions, calculations, or just about whatever else your application may need.  For that matter, Models and Services can both be composed of calls to one or more other services.

At an abstract level, a service is merely an invokable function that fulfills a contract.  It doesn't care if the contract actions are data or server oriented.

Your models may not have much to them if all that is required is invoking a particular service without exchanging any data beyond authentication tokens, if even that. That's perfectly okay in some scenarios, depending upon what the service is doing.

Title: Good technologies for developing a modular server component in .net?

Body:
I am using WPF, Prism and Unity to develop the user interface for a .net application.  The UI will run from a PC, but I also need to develop a separate complex server component that will provide services to the PC component via WCF.

Prism and Unity have proved to be of great value in creating a modular application, at least as far as the user interface is concerned.  I would also like to make the server component modular, but I cannot find anywhere what techniques, patterns and technologies are suitable.  I have considered:

Unity or one of the other DI containers

Selected parts of Prism, such as modules and events

Are these suitable for developing a modular server component?  Or are these UI technologies only and should I be looking at something completely different?


答:
Former Designer here, turned Dev, and I used to piss and moan about Web Controls too. Honestly, its MUCH cheaper for a designer to adjust their practices than for a .NET Developer to delve into a custom impelmentation of a GridView because the designer INSISTED that each TD have a 'rel' tag (or whatever).

As Arseni Mourzenko very wisely pointed out, the decision to use Webforms is a company choice that limits some of the control over the HTML while granting some efficiencies in coding. Unless the company is willing to re-consider (which they should NOT do just to please the designers), then the designers need to accept this reality. Here's a few things they can do:

1) Stop depending on ID's for anything. Even though this felt wrong at first, I found that life was actually a lot easier when I styled everything with classes (and inheritance, of course). First of all, it equalized all my selector weights. In CSS inheritance, ID trumps CLASS. It was actually kinda nice to have everything be a child and/or class selector, and made figuring out the specificity order a little simpler. Same thing in the JS layer, it gave me ZERO pain to swap out my ID-based selectors for class-based ones.

2) Teach them what RadioButtonLists and CheckboxLists convert into, along with Label = span, Panel = div and the other non-obvious control-to-html stuff. The way .NET renders these to HTML was a little weirder than I expected, and it was much easier for me to create screens when I knew how the HTML would come out of those controls.

3) Have them do their designers IN ASPX DIRECTLY, not raw HTML (!important) . Teach the designers the basics of GridViews, ListViews, etc. Give them some code snippets to push an anonymous object collection into a Grid/ListView control. If they can learn CSS then they can learn to copy-paste this code in. They can use the free version of VS Web Express, which is quite good at CSS & JS work now. These dummy web projects will give the designers a chance to enter some controls, then View Source to see how they are rendered.

4) Explain how the FORM tag is used in .NET. Forgot about this one earlier, but another thing the designer has to get used to is that usually, a single FORM tag wraps the entire page. This alters the way form controls behave, and you can't nest FORM tags without really weird side effects. Make sure the designers understand this or else their form HTML will be a nightmare to make into WebForms.

5) Stay away from Themes and Skin. Even though the .NET framework has these tools to help style controls across an application, they are clunky and weird to normal Web Designers, and I never found them worth my time. They seem like a nice tool to devs who aren't well versed in CSS, but  will only slow down the designers. Let the designers work in their natural environment (html & css files) and they will be happier and more productive.

6) Keep "prototype" projects in your site solutions. To make sure the developers always have a target to code against, have the designers create a fake web project in your real solution to keep their ASPX-only pages preserved and untouched by the real developers. This means the designers can look back to their prototypes in the same solution as the real project to check on how the developers did, and the devs can run the prototype at any time to make sure their work matches the designers' intent.

Finally, resist any complaints to convert to MVC, unless you are ready to re-train your Devs. I love MVC personally, but if you've got a team with a ton of WebForms knowledge, don't go throwing that away for no reason. If your applications are having ViewState problems, SEO problems, or accessibility issues, then absolutely give MVC a hard look. But it will take a LOT more time to train WebForms devs on MVC than it will to train Designers how to use Web Controls.

At the end of the day, there was NO DESIGN I CAME ACROSS, that I couldn't personally make work in WebForms, even if I ended up swearing at that darn GridView for an hour before figuring it out.

Are there any tools or applications to provide the designers with the
  rendered (html page) of the .aspx pages?

Forget Expression (I never liked it). Get them the free version of Visual Studio (Web Developer Express). It can hook into whatever source control solution you have, and it will let the designers run their ASPX pages and see the rendered HTML in a browser. The CSS and JS tooling is much better than it used to be, and there are some awesome tools baked into extentions like Web Essentials. 1-click transforming of CSS rules into all their vendor-specific deviations, color pickers and palettes right in the VS interface, 1-click embedding of images INTO css files, 'LESS' CSS transformations (you can 'code' in CSS), F12 'Navigate To' on JavaScript, plus real intellisence,  and way more. Its a treasure trove for designers now, FYI, and your designers might not know about it since earlier version of Visual Studio treated CSS/JS as second-class citizens.

Title: ASP.NET Webforms developers and web designers: how to interact?

Body:
I'm an ASP.NET Webforms developer, and I face some problems when I deal with designers.

Designers always complain about the asp.net server controls. They'd rather just have an html file and create css files along with the required images to go with those. Sometimes, if the design phase is done in advance, I get html files with related css files, but then we face many problems integrating the design with the aspx files (sever controls an telerik controls ... etc).

What I want to ask about is:

How do I overcome these problems? The designers prefer php- and mvc developers because of the problems with .net server controls. I need to know how to interact with the designers in the correct way.

Are there any tools or applications to provide the designers with the rendered (html
page) of the .aspx pages? By that I mean the page in runtime rather than the aspx in Visual Studio. They do use Web Expression but they want the rendered page in html as well.


问:
"Comments are a code smell"
A coworker of mine believes that any use of in-code comments (ie, not javadoc style method or class comments) is a code smell.  What do you think?

答:
I think the rule is quite simple: imagine a complete stranger seeing your code. You probably will be a stranger to your own code in 5 years.
Try to minimize the mental effort to understand your code for this stranger.</p>

Title: "Comments are a code smell"


问:
Handling contacts imported from users email account
In my web application, I give the user the option to import all of his/her contacts from their email account, and then send out invites to all of these accounts or map the user to the existing accounts based on emails.

Now the question, is once all of these contacts are imported, would it be right to save these contacts back for repeated reminders, etc.?

I am quite confused here because that is the way all of the sites operate, but would that not be violation of data privacy? Is there an algorithm for this?

答:
I think it would only be valid to store those contacts for repeated reminders people if they explicitly opt in to do so.  Also very importantly, that reminder should not be sent unless the original user clicks on the magic button (s/he annoying their friends that's better than you annoying them).

Contacts for a user change all of the time anyhow, so inviting them to go through the process from scratch is probably better idea anyhow.


答:
Not only is it not bad, in my opinion, I personally prefer it.  If the language supports differentiating the member variable from the local variable, name them both the same and use that option (such as this in your case).

To me, it is much easier to understand this,

```<code>void setVariable(int varName) { this.varName = varName);
</code>```

than it is to understand setting the member variable to a local variable with a completely different name.

Like Kevin said, if the language, or your company, has a "best practice" for this already in place, use it to avoid confusion.  If not, then I think you're safe using the same name.  Most IDE's that are worth their weight will make the distinction obvious.

Body:
Not only is it not bad, in my opinion, I personally prefer it.  If the language supports differentiating the member variable from the local variable, name them both the same and use that option (such as this in your case).

To me, it is much easier to understand this,

void setVariable(int varName) { this.varName = varName);

than it is to understand setting the member variable to a local variable with a completely different name.

Like Kevin said, if the language, or your company, has a "best practice" for this already in place, use it to avoid confusion.  If not, then I think you're safe using the same name.  Most IDE's that are worth their weight will make the distinction obvious.


答:
I've used same name for a long time, and the only really problematic example I've found is the following in c++:

```<code>class A { A(int a_) : a(a) { } int a; }; // error, a uninitialized afterwards.
</code>```

Otherwise it seems to work every time. Some minor name conflicts can happen, and renaming the member to m_a will usually fix it ; but the uninitialized variable in the ctor init is the most problematic aspect.

Body:
I've used same name for a long time, and the only really problematic example I've found is the following in c++:

class A { A(int a_) : a(a) { } int a; }; // error, a uninitialized afterwards.

Otherwise it seems to work every time. Some minor name conflicts can happen, and renaming the member to m_a will usually fix it ; but the uninitialized variable in the ctor init is the most problematic aspect.


问:
Using "Google Guava" in coding interviews
I attended a in-person interview recently and performed well. But surprisingly I got rejected. When I asked the HR for reason, he contacted the technical interviewer and told me that I was syntactically wrong while coding.

I used Google Guava for coding. So my code looked like this:

List<String> items  = Lists.newArrayList()

instead of

List<String> items  =new ArrayList<String>();

I know that the code will compile and work as expected.Is it ok to use third party libraries like Google Guava in interviews?

答:
If you are doing something, non-standard at an interview - ask.  Or at least say you are using Guava.

I do ask a simple Java question early in an interview.  I usually tell candidates they can assume anything they want so long as they tell me what it is.  In a simple question like this, if the candidate asked to use Guice, I'd probably say not to - just use core Java.  I need to know candidates know core Java.

What happens if the interviewer doesn't know the library you chose or it isn't available at the company?  (Not everything open source can be used at every company.)

Try to avoid being clever at interviews.  Too many "Java developers" don't know how to write Java.  The interviewer has to assume incompetence before cleverness.


问:
The 10 minutes technical interview
I must do a quick assessment of dozens of fresh students very quickly. I have 30 minutes meeting with each of them (in two or three days). I want to use most of the time to discuss non technical aspects. So I plan to use 10 minutes for technical questions. The same questions for all of them.

They are all hired already (they are students), what I need to know is the average level in order to prepare a training.

Ideally, the difficulty must be progressive in order to set a level for each. Level I will average, and I'll do an average on each question too.

If you had only 10 minutes and 10 questions to ask to a candidate, what would be your top 10 ?

答:
My experience of students I'd pretty much start from scratch - I've found what people learn at University and what is useful are two pretty separate sets.

But as you have the chance to speak to them it would be silly not to take it.

My assumption is that there is little commonality in their background so I'm avoiding language specific questions.  The one exception I've made to this is an assumption that they've done something on the web but this question could be subbed for something equivalent if they're embedded specialists or whatever.

You've asked for them to be progressive which I've sort of tried to do but if my assumption about no commonality is correct right / wrong questions are relatively tricky and a lot of their competence will come from how good their answers to more general questions are.

Anyway...

1) What languages and technologies have you been exposed to?  How many of these (and which ones) have you spent more than 50 hours actually programming (that is not including lectures, lab time and so on but including projects and assignments where you were coding solo).

2) Describe the most complex program you've ever written.  What made it complex?

3) What were you taught at university (relating to programming) that you really don't think you understand properly?  If you think that you understood everything (check their grades at this point) then talk about an application or an element of an application that you've seen that you wouldn't know how to code and how you might start thinking about it.

4) What are the basic tenets of Object Oriented Programming?

5) Tell me as much about relational databases as you can in 1 minute

6) For a web application describe a method for maintaining information about the user between pages.  What advantages and disadvantages exist for the mechanism you've described.

7) Pick an piece of commonly used functionality within computing and explain to be very briefly how it works at a programmatic level (e.g. encryption, compression).  Also explain how you had to use that functionality you'd implement it (here I'd be looking for the fact that although you may know how something works, it's probably better to grab a library for it).

EDIT:  Restructured and added a couple of extra questions to make it more progressive as originally asked.

Title: The 10 minutes technical interview


问:
Resources for Test Driven Development in Web Applications?
I would like to try and implement some TDD in our web applications to reduce regressions and improve release quality, but I'm not convinced at how well automated testing can perform with something as fluffy as web applications.

I've read about and tried TDD and unit testing, but the examples are 'solid' and rather simple functionalities like currency converters, and so on.

Are there any resources that can help with unit testing content management and publication systems? How about unit testing a shopping cart/store (physical and online products)? AJAX?

Googling for "Web Test Driven Development" just gets me old articles from several years ago either covering the same examples of calculator-like function or discussions about why TDD is better than anything (without any examples).

答:
Test-Driven JavaScript Development is a really nice book from Christian Johansen, the developer behind Sinon.js and Buster.js, which covers subjects such as (taken from the website):

Understanding unit testing and TDD

Choosing the right unit testing framework

Building cleaner APIs, modularized and robust JavaScript

Continuously improving code through refactoring

Five practical TDD sessions: Ajax, DOM manipulation, Node.js and more

Test-driven tour to JavaScript for developers not familiar with the language

Currently we use Sinon.js with Mocha, but ready to switch to Buster.js, since its features are really neat!


答:
You say,

I know that the code will compile and work as expected.

... but as you've learned, it won't... because you didn't confirm that the correct version is available at build time, on the build machine(s).

That's not the point though. The point, and the root cause of your not getting hired, is that you failed to communicate with the interviewer. You didn't communicate a requirement or dependency for the code you were writing. Personally, I would consider that a large assumption (dependency management can be a pretty big deal that involves static analysis, code reviews, dev training, build, the installer/deployment, legal, SLAs, etc).

So now you know, and knowing is half the battle. But that doesn't really help. What does is a big tip that I got when doing interviews:

For every line you write on the whiteboard, say something relevant.

Start with these as you're writing each line:

"I'm thinking that ..."

"This makes sense because... "

"This assumes that... "

In your scenario, I would have said something along the lines of:

"I'm thinking that a simple list of strings should suffice, so I'll just pull one out of Guava."

... or even

"Is it safe to assume that the Guava libraries are available?"

As a point of interest, I write .NET/C# and I asked in an interview at Microsoft if it was safe to assume that I could use LINQ. The answer was no.

Title: Using "Google Guava" in coding interviews

Body:
I attended a in-person interview recently and performed well. But surprisingly I got rejected. When I asked the HR for reason, he contacted the technical interviewer and told me that I was syntactically wrong while coding.

I used Google Guava for coding. So my code looked like this:

List<String> items  = Lists.newArrayList()

instead of

List<String> items  =new ArrayList<String>();

I know that the code will compile and work as expected.Is it ok to use third party libraries like Google Guava in interviews?


问:
Should you promise to deliver a feature that you aren't sure if its implementable?
In an article from HN, I came across the following advice:

Always tell your customer/user "yes", even if you're not sure. 90% of
  the time, you'll find a way to do it. 10% of the time, you'll go back
  and apologize. Small price to pay for major personal growth

But I've always thought that one should do a feasibility analysis before making any kind of promises to a customer/user, so that they aren't misled at any point. At what circumstances, then, should the above advice applicable?

答:
It would be better to say "I think that can be done".  or "I'll check and get back to you".  I've had times where I've said no or counter proposed something.  If the customer wants "a browser based application that works without ever being connected to the internet and uses tactile feedback", it probably is possible.  But it is expensive and it would be more useful to discuss what the actual needs are.

The customer will respect you if you are honest.  In the advice in the question, the person is wrong 10% of the time.  If I work with someone who is routinely wrong one out of every ten times, I'm not going to trust him/her at all.  That's a horrible track record.


问:
How signing out a CLA prevents legal issues in open-source projects?
For example: yeoman. It's licensed under a BSD license. The CLA form (Contributor License Agreement) isn't project specific, and it can be signed electronically.

How and what issues can signing out this agreement prevent?

Does it matter how big or minor contribution I made?

Why some projects require signed CLA to accept patches, while others don't? (eg. node.js vs rails)

答:
CLAs generally exist to do several things:

They keep you from revoking your code down the road.  In countries that are signatory t to the Bern convention, authors exclusively retain copyright on all original works, with others allowed to copy it only with explicit permission.  A CLA makes you give that permission explicitly—and frequently in perpetuity, so you can't change your mind later.  This CLA contains such a clause, so no take-backs of code after you contribute.

They can keep you from suing them for patent infringement.  Some contributors are duplicitous, and might contribute code that they know is covered by one of their patents, hoping that they then sue everyone down the road when the code is widespread.  This has happened in some major standards bodies, and has also come up in open-source software.  The CLA here forbids you from pulling this stunt: when you submit code to this project, you also grant them, and their users, perpetual royalty free licenses to any patents you own that cover code you yourself submit.

It covers their ass if someone else sues them or claims copyright.  Most CLAs, including this one, make you swear that everything you're contributing is yours to contribute.  This basically serves as a way for Google (or some other upstream project), who gets sued for copyright infringement, to point at you and say, Sorry, but it wasn't us, it was him.

It can optionally reassign copyright, giving the parent organization some teeth to sue license violators.  Finally, while the CLA you linked does not do this, many open-source projects, including all run by the FSF, have a CLA that requires outright copyright assignment, which means that any code you submit will bear the copyright of the project, and not you.  This has two advantages to the parent organization: they don't need to round up all contributors ever if they want to sue for an open-source violation; and they don't need to consult with contributors if they want to change the license down the road.  Most CLAs that require copyright assignment also grant a perpetual royalty free license back to the contributor and their customers in a kind of reverse of the way other CLAs work.  As mentioned, this CLA does not require copyright reassignment.

Most fully volunteer projects, such as Rails and Node, do not require CLAs, if for no other reason than because there's no backing entity to require or do anything meaningful with them in the first place.  (FSF-backed projects are the major exception here, as previously noted.)  Most commercially backed open-source projects, such as those that are official Google/Oracle/Apple products, do require some form of CLA, both because most companies have lawyers who think about those kinds of things, and because there is a single backing entity to enforce that kind of thing.


问:
Separating validation from persistence in models?
Models in an MVC application gets kind of hard to test when validation of data and persistence of data is baked together in the model. I would like to test those separately to prevent doing integration testing instead of actual unit testing.

What patterns are available to keep validation and persistence separated?

答: You may want to take a look at the persistance and validation mechanisms used by the Eclipse Modeling Framework (EMF). Model persistance and validation are fully separated concerns, and there is good support for plugging in your own custom validation code.</p>


问:
Achieving decoupling in Model classes
I am trying to test-drive (or at least write unit tests) my Model classes but I noticed that my classes end up being too coupled. Since I can't break this coupling, writing unit tests is becoming harder and harder.

To be more specific:

Model Classes: These are the classes that hold the data in my application. They resemble pretty much the POJO (plain old Java objects), but they also have some methods. The application is not too big so I have around 15 model classes.

Coupling: Just to give an example, think of a simple case of Order Header -> Order Item. The header knows the item and the item knows the header (needs some information from the header for performing certain operations). Then, let's say there is the relationship between Order Item -> Item Report. The item report needs the item as well. At this point, imagine writing tests for Item Report; you need have a Order Header to carry out the tests. This is a simple case with 3 classes; things get more complicated with more classes.

I can come up with decoupled classes when I design algorithms, persistence layers, UI interactions, etc... but with model classes, I can't think of a way to separate them. They currently sit as one big chunk of classes that depend on each other.

Here are some workarounds that I can think of:

Data Generators: I have a package that generates sample data for my model classes. For example, the OrderHeaderGenerator class creates OrderHeaders with some basic data in it. I use the OrderHeaderGenerator from my ItemReport unit-tests so that I get an instance to OrderHeader class. The problem is these generators get complicated pretty fast and then I also need to test these generators; defeating the purpose a little bit.

Interfaces instead of dependencies: I can come up with interfaces to get rid of the hard dependencies. For example, the OrderItem class would depend on the IOrderHeader interface. So, in my unit tests, I can easily mock the behaviour of an OrderHeader with a FakeOrderHeader class that implements the IOrderHeader interface. The problem with this approach is the complexity that the Model classes would end up having.

Would you have other ideas on how to break this coupling in the model classes? Or, how to make it easier to unit-test the model classes?

Update after going through the answers:

I have done a little more thinking on this problem and noticed that some of these dependencies were not really necessary (as most answers pointed out). The reason why they existed is because my UI layer needed it. Basically, I have inserted these dependencies so that UI layer can easily navigate from child to the header and display some header fields at the child level views. Looking at it now, it looks so simple; however it took some time for me to figure out why these dependencies existed in the first place. Now, the UI will basically keep the header in its context when navigating to the child level views.

On the other hand, I have removed some of the dependencies via interfaces. These dependencies were mostly one-to-one; for example between Header and HeaderReport. Previously, HeaderReport depended on Header for retrieving information (items, date, etc...) and this made HeaderReport very hard to test. Now, the HeaderReport depends on the HeaderDataProvider interface and I am able to achieve complete isolation. HeaderReport is very easy to test with stub classes for the HeaderDataProvider interface.

It looks easy to create these abstractions (UI Layer - Model Layer - Backend Layer), however in reality, it really takes a lot of practice!

答:
Do the classes really need to be decoupled? In your example, from business point of view, the order header and order item are entities, that are really close. They probably form an aggregate. So trying to decouple those will create unnecessary complexity and will make reading the model confusing.

To solve this, I would try to locate aggregates in your code and then unit test whole aggregates.

Title: Achieving decoupling in Model classes


答: I realize you are trying to build the training based on what they don't know, and that you plan to have several "buckets" of training for different groups of students. Since you have only ten minutes alloted, why not make a list of things you are thinking of including in the training, and ask those specific questions. So you plan to teach them C#. Ask if they know it well. Ask if they've used any more recent features (LINQ, nullable types, generics, ...). If there's database content in your training, ask some questions about that. In the end you may see that one of the topics you had planned is unnecessary, because they all know it, and some other topics are needed by everyone, and so on. That's more practical than trying to come up with questions that are not related to either what you're able to train them on (context switch time on linux?) or not related to the work you intend to have them do after they're trained.</p>

Title: The 10 minutes technical interview

Body:
I must do a quick assessment of dozens of fresh students very quickly. I have 30 minutes meeting with each of them (in two or three days). I want to use most of the time to discuss non technical aspects. So I plan to use 10 minutes for technical questions. The same questions for all of them.

They are all hired already (they are students), what I need to know is the average level in order to prepare a training.

Ideally, the difficulty must be progressive in order to set a level for each. Level I will average, and I'll do an average on each question too.

If you had only 10 minutes and 10 questions to ask to a candidate, what would be your top 10 ?


答:
Would you have other ideas on how to break this coupling in the model classes? Or, how to make it easier to unit-test the model classes?

In my opinion, coding against the interfaces is the way to go. In another words, de-coupling your code by design is the approach that modern projects do follow. That greatly helps with the needs of unit-testing.

In another words, it is recommended to define your formal, precise and verifiable interface specifications for software components that you are planning to develop or trying to de-couple to remove dependencies.

Title: Achieving decoupling in Model classes

Body:
I am trying to test-drive (or at least write unit tests) my Model classes but I noticed that my classes end up being too coupled. Since I can't break this coupling, writing unit tests is becoming harder and harder.

To be more specific:

Model Classes: These are the classes that hold the data in my application. They resemble pretty much the POJO (plain old Java objects), but they also have some methods. The application is not too big so I have around 15 model classes.

Coupling: Just to give an example, think of a simple case of Order Header -> Order Item. The header knows the item and the item knows the header (needs some information from the header for performing certain operations). Then, let's say there is the relationship between Order Item -> Item Report. The item report needs the item as well. At this point, imagine writing tests for Item Report; you need have a Order Header to carry out the tests. This is a simple case with 3 classes; things get more complicated with more classes.

I can come up with decoupled classes when I design algorithms, persistence layers, UI interactions, etc... but with model classes, I can't think of a way to separate them. They currently sit as one big chunk of classes that depend on each other.

Here are some workarounds that I can think of:

Data Generators: I have a package that generates sample data for my model classes. For example, the OrderHeaderGenerator class creates OrderHeaders with some basic data in it. I use the OrderHeaderGenerator from my ItemReport unit-tests so that I get an instance to OrderHeader class. The problem is these generators get complicated pretty fast and then I also need to test these generators; defeating the purpose a little bit.

Interfaces instead of dependencies: I can come up with interfaces to get rid of the hard dependencies. For example, the OrderItem class would depend on the IOrderHeader interface. So, in my unit tests, I can easily mock the behaviour of an OrderHeader with a FakeOrderHeader class that implements the IOrderHeader interface. The problem with this approach is the complexity that the Model classes would end up having.

Would you have other ideas on how to break this coupling in the model classes? Or, how to make it easier to unit-test the model classes?

Update after going through the answers:

I have done a little more thinking on this problem and noticed that some of these dependencies were not really necessary (as most answers pointed out). The reason why they existed is because my UI layer needed it. Basically, I have inserted these dependencies so that UI layer can easily navigate from child to the header and display some header fields at the child level views. Looking at it now, it looks so simple; however it took some time for me to figure out why these dependencies existed in the first place. Now, the UI will basically keep the header in its context when navigating to the child level views.

On the other hand, I have removed some of the dependencies via interfaces. These dependencies were mostly one-to-one; for example between Header and HeaderReport. Previously, HeaderReport depended on Header for retrieving information (items, date, etc...) and this made HeaderReport very hard to test. Now, the HeaderReport depends on the HeaderDataProvider interface and I am able to achieve complete isolation. HeaderReport is very easy to test with stub classes for the HeaderDataProvider interface.

It looks easy to create these abstractions (UI Layer - Model Layer - Backend Layer), however in reality, it really takes a lot of practice!


问:
tail-like view on HTML logfiles
I'm working on an application that creates HTML log files. I'm tired of having to manually reload and scroll to the bottom in the browser to see the latest entries.

A solution that does not really satisfy me is using the Firefox plugins ReloadEvery and ScrollyFox. In many situations reloading frequency and scrolling speed are just to slow.

Of course I could actually use tail, but I would prefer a rendered HTML page.

Do you have any suggestions? Firefox extensions are preferred, but any other tip is appreciated, too.

答:
If there is a possibility to control the log structure - one possible solution would be to add an anchor such as:

```<code><a name='end' />
</code>```

just above  tag and then access the log using log.html#end - which coupled with an auto-refresh functionality (either by using a meta tag, JavaScript or a Firefox extension).

Title: tail-like view on HTML logfiles

Body:
If there is a possibility to control the log structure - one possible solution would be to add an anchor such as:

<a name='end' />

just above </body> tag and then access the log using log.html#end - which coupled with an auto-refresh functionality (either by using a meta tag, JavaScript or a Firefox extension).


问:
What does the arrow mean in a Class Diagram?
I need help trying to understand what the meaning of the arrow in a UML Class Diagram is, more specifically in this Composite Diagram. What's the difference between the simple line (from a class to another one) and the arrow (not the inheritance arrow, I refer to the black one)?

答:
Your picture shows several different relationships.

The relationship between the Client and BookComponent classes is a Containment relationship. I.e. the Client Contains an instance of BookComponent.

BookComposite and BookComponent has two relationships the open arrowhead is a Generalization relationship (i.e BookComponent generalizes BookComposite or in other terms BookComposite specializes/derives from BookComponent). The closed-arrohead with a diamond at the tail is an Aggregation. That is, BookComposite contains a Collection of BookComponent. The fact that the Diamond is not filled is significant too. It means that the lifecycle of the contained BookComponents is not tied to the life of the containing BookComposite. If it were filled instead of Aggregation, it would be a Composition and when BookComposite was destroyed, so would be the BookComponents

OwnerDisplayName: John Smith


问:
Naming for a REST webservice
I have a rest webservice with an endpoint www.foobar.com/service.svc/MAC  (migration authorisation code). Posting and getting to that adds and gets one MAC respectively. I now need to impliment a new enpoint for all MACs. What would that be? www.foobar.com/service.svc/MAC/All seems wrong. What would be correct and why?

答:
The following offers a suggested set of URI naming guidelines for REST services that have worked for me in practice.

The book RESTful Web Services RESTful Web Services defines three basic rules for url design which act as a great starting point:

Use path variables to encode hierarchy: /parent/child

Put punctuation characters in path variables to avoid implying hierarchy where none exists: /parent/child1;child2

Use query variables to imply inputs into an algorithm, for example: /search?q=jellyfish&start=20

 Other guidelines include:

URIs should ideally not change over time.

Services offering a uniquely identifiable resource via a key should use basic rest notation (e.g. /accounts/(accountid) )

Services offering optional search/filtering capabilities should use query parameter ? key1 = value & key2 = value notation (e.g. /instruments?ticker=FT)

Services expecting mandatory arguments over GET should have them as path variables (e.g. /accounthistory/(fromdate)/(todate)

All rest service names should use strict low case names (e.g. /client)

The elements of the URI should map to business entities and the mapping should be consistent. For example a business entity named contentpartner should be consistently referred to as contentpartner(s) in all URIs (rather than a mix of partner, cp etc).  A good starting point would be the name of the domain object.

Parameters that do not define a resource but qualify it (e.g. locale which feeds into the translations of the data) should not form part of the normal URI space.  Consider using headers or optional query parameters for these

Use nouns, not verbs.  The power of REST comes through the fact there is a limited verb set (operations) combined with a large set of nouns (or resources). Consequently the manner in which these nouns are constructed is of great importance.

Avoid suffixes.  When designingURIs it is paramount that they refer to the thing that is being operated upon rather than the operation being performed. Secondly, the client is interested in the resource - not the implementation of the server software that powers the service. It is desirable to avoid suffixes such as .jsp or .aspx.

Use Accepts Header for content negotiation

Keep It Intuitive. URIs should be human readable or guessable. The easiest way to do this is to construct a URI hierarchy, grouping related items together. Such patterns of category and subcategory are very easy to understand.

Title: Naming for a REST webservice


答:
I know you're trying to simplify your scenario to make it easier to discuss, but why does the OrderItem care about the Header? The Header is Aggregator (called the "Root" in DDD) and it is responsible for knowing about its components (OrderItem being one of them).

If you're discussing special cases like Discounts being applied to Orders containing for example 10 or more of a certain Item that would be a job of say a discount service to find which discounts apply as the order is being processed.

The same thing would apply to ItemReport...it is responsible for knowing the rules for how the items are selected, filtered, ordered, etc. The Item shouldn't be concerned with reporting, that's not its job.

Title: Achieving decoupling in Model classes


问:
Why SQL is not so widespread in large desktop applications?
As a software developer, I've worked on projects ranging from tiny home-made apps to medium-size enterprise applications. In nearly every project I used a database or regretted choosing not to use it from the beginning.

Now, I am wondering a few things about the databases and their usage in general applications:

Why Windows itself doesn't use any "central" SQL database? For example:

Errors Reporting data is stored in a bunch of files,

Windows Update stores everything in flat files,

Icons cache is stored in a very strange single file which doesn't seem to be accessed through SQL, etc.

Why so many large applications avoid using databases? For example, wouldn't Microsoft Outlook gain by using a real database instead of reinventing the wheel by having its own format for .pst files and storing some data in registry?

If database adds an additional layer of an overall complexity and a tiny performance loss, it is a price of a huge advantage of making the code simpler in most circumstances, especially when it comes to the storage of small organized chunks of data instead of large binary streams. So why so few products are actually using databases? Probably the only application I know which actually uses Sqlite database is Firefox, and maybe Microsoft Exchange (but the last one is not a desktop application)?

Also, wouldn't a set of applications, like Microsoft Office or Microsoft Expression, benefit from having an unified SQL database, making it easier to deploy the applications, to update/upgrade the data, to share data between those applications, to make backups, etc.?

答:
1) Generally speaking the overhead of running a full RDBMS is too great and it would be adding needless load to the system and complexity.

Having one installed makes your life easier as a developer but makes the life of the owner of the machine worse as their machine is likely to run slower and with more issues.  In developer vs. user confrontations the user should almost always win.

2) Many data stores have specific needs which are not met by something like SQL Server Express.

For instance, error logs should be written to the simplest possible thing to maximise the chance that the write will happen and the data will be available.  SQL Server is never going to be that simple.

For more complex applications the argument tends to be more around optimising for very specific user cases - flat files can be lightning fast.


答:
Given enough time, resources and flexibility around the definition of success anything is possible.  The white x-mass example is easy if you only want better than 50% accuracy and you have the user's geographical location and a little bit of statistical data.

The real first question in most projects is not if something is possible, but if it is reasonable given a certain set of circumstances.

Does the feature adds enough value to warrant the expense of the attempt?

Even if the idea would be pretty awesome, if it requires a long development period or the acquisition of some more exotic hardware it would be better for the client to know that up front and then steer the conversation back to more reasonable goals in most cases.

If someone is crazy enough to give you a blank check and no deadline then by all means tell them everything is possible, just let them know you have to invent & distribute several of the technologies involved in reaching the goal along the way.

On the other hand, when dealing with reasonable clients with reasonable resources there is sometimes nothing worse than telling the client some feature has to be cut after you have agreed to it because they may have already run off and spent time/money/resources promoting or documenting it and that 10% might have been the thing that got the project greenlit in the first place.  Fall into on of those situations and you have just lost a customer, and more than likely gained a very verbal bad reference in an entire market.

Title: Should you promise to deliver a feature that you aren't sure if its implementable?

Body:
In an article from HN, I came across the following advice:

Always tell your customer/user "yes", even if you're not sure. 90% of
  the time, you'll find a way to do it. 10% of the time, you'll go back
  and apologize. Small price to pay for major personal growth

But I've always thought that one should do a feasibility analysis before making any kind of promises to a customer/user, so that they aren't misled at any point. At what circumstances, then, should the above advice applicable?


问:
How to structure a set of RESTful URLs
Kind of a REST lightweight here... Wondering which url scheme is more appropriate for a stock market data app (BTW, all queries will be GETs as the client doesn't modify data):

Scheme 1 examples:

```<code>/stocks/ABC/news
/indexes/XYZ/news
/stocks/ABC/time_series/daily
/stocks/ABC/time_series/weekly
/groups/ABC/time_series/daily
/groups/ABC/time_series/weekly
</code>```

Scheme 2 examples:

```<code>/news/stock/ABC
/news/index/XYZ
/time_series/stock/ABC/daily
/time_series/stock/ABC/weekly
/time_series/index/XYZ/daily
/time_series/index/XYZ/weekly
</code>```

Scheme 3 examples:

```<code>/news/stock/ABC
/news/index/XYZ
/time_series/daily/stock/ABC
/time_series/weekly/stock/ABC
/time_series/daily/index/XYZ
/time_series/weekly/index/XYZ
</code>```

Scheme 4: Something else???

The point is that for any data being requested, the url needs to encapsulate whether an item is a Stock or an Index. And, with all the RESTful talk about resources I'm confused about whether my primary resource is the stock & index or the time_series & news. Sorry if this is a silly question :/

Thanks!

答:
The three approaches are roughly equivalent to each other, regardless of the way that you structure your hierarchy. This leads to an interesting observation: there may be no hierarchy there after all.

Consider this alternative:

```<code>/news/stock;ABC
/news/XYZ;index
/time_series/daily;stock;ABC
/time_series/stock;ABC;weekly
/time_series/XYZ;daily;index
/time_series/index;weekly;XYZ
</code>```

This URI structure gives away an important property of your service: the resources that you expose are not hierarchical in their nature, so any meaningful UIR would do.

You can take this to the max, and make your URIs look like this:

```<code>/news/stock?symbol=ABC
/news/index?symbol=XYZ
</code>```

or even like this:

```<code>/time_series?frequency=daily&kind=stock&symbol=ABC
</code>```

Though not as nice-looking, these alternatives make valid choices as well, and provide more flexibility in the way the clients can build their requests by allowing the identifying information come in arbitrary order.

Title: How to structure a set of RESTful URLs

Body:
The three approaches are roughly equivalent to each other, regardless of the way that you structure your hierarchy. This leads to an interesting observation: there may be no hierarchy there after all.

Consider this alternative:

/news/stock;ABC
/news/XYZ;index
/time_series/daily;stock;ABC
/time_series/stock;ABC;weekly
/time_series/XYZ;daily;index
/time_series/index;weekly;XYZ

This URI structure gives away an important property of your service: the resources that you expose are not hierarchical in their nature, so any meaningful UIR would do.

You can take this to the max, and make your URIs look like this:

/news/stock?symbol=ABC
/news/index?symbol=XYZ

or even like this:

/time_series?frequency=daily&kind=stock&symbol=ABC

Though not as nice-looking, these alternatives make valid choices as well, and provide more flexibility in the way the clients can build their requests by allowing the identifying information come in arbitrary order.


问:
How often is seq used in Haskell production code?
I have some experience writing small tools in Haskell and I find it very intuitive to use, especially for writing filters (using interact) that process their standard input and pipe it to standard output.

Recently I tried to use one such filter on a file that was about 10 times larger than usual and I got a Stack space overflow error.

After doing some reading (e.g. here and here) I have identified two guidelines to save stack space (experienced Haskellers, please correct me if I write something that is not correct):

Avoid recursive function calls that are not tail-recursive (this is valid for all functional languages that support tail-call optimization).

Introduce seq to force early evaluation of sub-expressions so that expressions do not grow too large before they are reduced (this is specific to Haskell, or at least to languages using lazy evaluation).

After introducing five or six seq calls in my code my tool runs smoothly again (also on the larger data). However, I find the original code was a bit more readable.

Since I am not an experienced Haskell programmer I wanted to ask if introducing seq in this way is a common practice, and how often one will normally see seq in Haskell production code. Or are there any techniques that allow to avoid using seq too often and still use little stack space?

答:
Unfortunately there are cases when one has to use seq in order to get a efficient/well working program for large data. So in many cases, you cannot do without it in production code. You can find more information in Real World Haskell, Chapter 25. Profiling and optimization.

However, there are possibilities how to avoid using seq directly. This can make code cleaner and more robust. Some ideas:

Use conduit, pipes or iteratees instead of interact. Lazy IO is known to have problems with managing resources (not just memory) and iteratees are designed exactly to overcome this. (I'd suggest to avoid lazy IO alltogether no matter how large your data is - see The problem with lazy I/O.)

Instead of using seq directly use (or design your own) combinators such as foldl' or foldr' or strict versions of libraries (such as Data.Map.Strict or Control.Monad.State.Strict) that are designed for strict computations.

Use BangPatterns extension. It allows to replace seq with strict pattern matching. Declaring strict constructor fields could be also useful in some cases.

It's also possible to use Strategies for forcing evaluation. Strategies library is mostly aimed at parallel computations, but has methods for forcing a value to WHNF (rseq) or full NF (rdeepseq) as well. There are many utility methods for working with collections, combining strategies etc.


答:
In order to better discuss the image, I annotated your image with some numbers. Hopefully this will help me be more clear in my writing.

There are really three types of lines used here - association (1), composition (4->2), and inheritance (3).

A solid line connecting two classes, such as between Client and BookComponent is simply an association relationship. It is often used to indicate that a class knows about (perhaps as in receives as an argument to a method) or has another class (perhaps as an instance variable). Without any decorations or with an arrow on both ends, the relationship is bidirectional - the two classes share the relationship and know about each other. In some cases, such as line 1 in the figure, the relationship is directional. The Client class knows about BookComponent, but the opposite is not true as BookComponent does not have a or know about Client. Note that there are also other annotations that can appear on association relationships, such as multiplicity or class roles.

The next line is the line that connects BookComposite to BookComponent. It's an association, much like the line between Client and BookComponent. However, the annotations at the points I labeled 2 and 4 add additional information about the relationship. Line in point 1, the arrow at point 2 means the same thing - BookComposite is aware of BookComponent instances, but not the other way around (a directional relationship). The annotation at point 4 indicates an aggregation relationship - BookComposite is a collection of BookComponent. However, it's not a strong relationship (as is the strong composition relationship), so aggregation indicates that a BookComponent can indicate in places outside a BookComposite (you don't need a BookComposite to have a BookComponent).

Something to note is that the arrow used to show directional associations is typically not a solid black arrow as shown in this image. I typically see it as an open arrow that looks more like a v than what is shown in your image.

Finally, the point labeled 3 is the inheritance relationship that you mentioned in your question.

If you're interested in more about UML modeling, I'd recommend purchasing UML Distilled. It's a good book by Martin Fowler that covers class, sequence, object, package, deployment, use case, state machine, activity, communication, composite structure, component, collaboration, interaction overview, and timing diagrams.

Title: What does the arrow mean in a Class Diagram?

Body: I need help trying to understand what the meaning of the arrow in a UML Class Diagram is, more specifically in this Composite Diagram. What's the difference between the simple line (from a class to another one) and the arrow (not the inheritance arrow, I refer to the black one)?


问:
Is Haskell's type system formally equivalent to Java's?
I realize some things are easier/harder in one language than the other, but I'm only interested in type-related features that are possible in one and impossible/irrelevant in the other.  To make it more specific, let's ignore Haskell type extensions since there's so many out there that do all kinds of crazy/cool stuff.</p>

答:
To complement the other answers, Haskell's type system doesn't have subtyping, while typed object oriented languages as Java do.

In programming language theory, subtyping (also subtype polymorphism or inclusion polymorphism) is a form of type polymorphism in which a subtype is a datatype that is related to another datatype (the supertype) by some notion of substitutability, meaning that program elements, typically subroutines or functions, written to operate on elements of the supertype can also operate on elements of the subtype. If S is a subtype of T, the subtyping relation is often written S <: T, to mean that any term of type S can be safely used in a context where a term of type T is expected. The precise semantics of subtyping crucially depends on the particulars of what "safely used in a context where" means in a given programming language. The type system of a programming language essentially defines its own subtyping relation, which may well be trivial.

Due to the subtyping relation, a term may belong to more than one type. Subtyping is therefore a form of type polymorphism. In object-oriented programming the term 'polymorphism' is commonly used to refer solely to this subtype polymorphism, while the techniques of parametric polymorphism would be considered generic programming...


问:
Does it make sense to use ORM in Android development?
Does it make sense to use an ORM in Android development or is the framework optimized for a tighter coupling between the UI and the DB layer?

Background: I've just started with Android development, and my first instinct (coming from a .net background) was to look for a small object-relational mapper and other tools that help reduce boilerplate clode (e.g. POJOs + OrmLite + Lombok).

However, while developing my first toy application I stumbled upon a UI class that explicitly requires a database cursor: AlphabetIndexer. That made me wonder if maybe the Android library is not suited for a strict decoupling of UI and DB layer and that I will miss out on a lot of useful, time-saving features if I try to use POJOs everywhere (instead of direct database access).

Clarification: I'm quite aware of the advantages of using ORM in general, I'm specifically interested in how well the Android class library plays along with it.

答:
It depends on what you do with your data model. If you have existing code that manipulates an object oriented model, and if you want to persist those objects in a sqlite database, you need an orm.

If you are writing new Android code from scratch, I would avoid an in-memory data model unless the app performs really complex OO manipulations, as a CAD program might, for example. But, for most programs, keep the data model in the database, and let the chain of Cursor, Adapter, and View objects do a lot of heavy lifting for you.


答:
I'm not sure that it'd be possible to do this in 10 questions in 10 minutes. Maybe give them 5 minutes to tell you what they know about .net. Then have a prepared list of maybe 20 topics and pick 2 or 3 from things that they've mentioned and 2 or 3 from things that they haven't.

For example you could begin:

Tell me briefly (you have 5 minutes)
  how you would produce a simple C#
  project in Visual Studio from creating
  it to running it.

Then after that:

OK, tell me a little more on the
  following. It's going to be
  quick-fire, 1 minute per answer, so
  don't try to be too detailed I just
  want a feel for what you're familiar
  with.

Then ask 5 questions for so from the followin:

Explain what a class is.

What's the difference between an abstract class
and an interface?

Briefly explain how
garbage collection works in .Net

....

How do you debug something if you
have a problem?

Yadda-yadda - I'm sure you'll be able to pick a long list to pick from the other answers

Title: The 10 minutes technical interview


问:
When does 'optimizing code' == 'structuring data'?
A recent article by ycombinator lists a comment with principles of a great programmer.

#7. Good programmer: I optimize code. Better programmer: I structure data. Best programmer: What's the difference?

Acknowledging subjective and contentious concepts - does anyone have a position on what this means?  I do, but I'd like to edit this question later with my thoughts so-as not to predispose the answers.

答:
To articulate my best guess at what the article means, I'll assume an unspoken subtext (which seems to be missing in the article) that any programmer should understand about optimization:

optimization comes only after you've got the program up and running correctly:

make it run correctly, then make it run fast

this principle is the point of Knuth's maxim, "premature optimization is the root of all evil"

if and when you've determined that optimization is not premature, you must measure it properly first to determine what actually needs optimizing, and again and again during optimization, to tell what effects your attempts at optimization are having.

if your code runs in development, the profiler is your friend in this.

if your code runs in production, you must instrument your code, and make friends with your logging system instead.

Now, then: your measurements will tell you where in your code the machine is burning the most cycles.  A "good" programmer will focus on optimizing those parts of the code, rather than wasting time optimizing the irrelevant parts.

However, you can often make larger gains by looking at the system as a whole, and finding some way to allow the machine to do less work.  Frequently, these changes require reworking the organization of your data; thus, a "better" programmer will find himself structuring data more often than not.

The "best programmer" will have a thorough mental model of how the machine works, a good grounding in algorithm design, and a practical understanding of how they interact.  This allows him to consider the system as an integrated whole -- he will see no difference between optimizing the code and the data, because he evaluates them at an architectural level.


问:
svn vs git for the sole developer?
If I am sole developer (I do not work in a team) working from my laptop (Windows OS and Linux VM) and backing up data to the cloud (Dropbox etc), then is git still better than svn for my version control needs?

I was thinking not since I wont need any of git's distributed features.  But is git such a better approach to version control that I should consider moving anyway?

With so many articles saying how people are moving from svn to git?  I was wondering, if they are talking about large or open projects with teams of developers vs the sole developer.

What do you think?

答:
In short: SVN is one repo and lots of clients, while GIT is a repo with lots of client repos, each with a user. Git is a decentralized to a point where people can track their own edits locally without having to push things to an external server.

SVN is designed to be more central where GIT is based on each user having their own GIT repo and those repos push changes back up into a central one. For that reason, GIT gives individuals better local version control.

GIT is really great on OS systems like Unix, BSD, Linux, Solaris and their derivatives. There is a little GUI that ships with GIT that works under a POSIX layer, but it's hardly as intuitive or powerful as TortoiseSVN. Thus, Git has very powerful command line that you would need to get used too.

In addition, Git is simply more versatile and allows offline development in a way subversion never really could.  Its available on almost every platform imaginable and has more features than you'll probably ever use.

If you're looking on getting out of SVN, you might want to evaluate Bazaar for a bit. It's one of the next generation of version control systems that have this distributed element. It isn't POSIX dependant like git so there are native Windows builds and it has some powerful open source brands backing it.

But you might not even need these sorts of features yet. Have a look at the features, advantages and disadvantages of the distributed VCSes. If you need more than SVN offers then consider one. If you don't, you might want to stick with SVN's (currently) superior desktop integration.

Title: svn vs git for the sole developer?


答:
This is the second question in short succession triggered by that article.

Good programmer: I optimize code. Better programmer: I structure data. Best programmer: What's the difference?

There's another name for this: premature optimization.

Never use early exits.

That's the "single point of entry / single point of exit" rule. It's a patch over the real problem, which is that exiting early might leave a mess. The right rule is "clean up your mess". An even better rule is to use data constructs that clean up after themselves so the programmer doesn't have to worry about cleaning up their mess.

And now, Always tell your customer/user "yes", even if you're not sure. 90% of the time, you'll find a way to do it.

This too is incredibly bad advice.

Sometimes your customer needs to be told no, or "in which millennium do you want this?" Don't promise something that will destroy your architecture, that will cost far more than the customer is willing to spend, or that you don't have a clue toward how to achieve it. You know the technology, not the customer. If you don't know how to do it, don't say you can do it. If you aren't sure, say you need time to research whether it's possible. It's better to be honest, and it will keep you out of trouble.

Customers quickly become ex-customers if you can't deliver on your promises. A 10% failure rate might sound small, but it is that 10% your customers will focus on. Sometimes they sue when you fail to deliver on what you promised. You really don't want that. Other times, making sure you do make good on a promise can make you go bankrupt, go insane, or lose your spouse because you're working 18 hour days. You don't want that, either.

Think of it this way: What do you think would happen to the airline industry if 90% of all airplane landings were successful? Do you think going back and apologizing for the 10% that crashed would fix anything?