问:
Naming convention for iOS/OSX open-source projects
Not always but most of the time, you will find iOS or Mac OS X open-source projects with names starting with the initial letters of the author first and last names. If a project were to be authored by Nick Leblanc, the project would be read as NLMyProject.

Examples:

RMSwipeTableViewCell by Rune Madsen,

EBCardCollectionViewLayout by Ezequiel Becerra,

SDiPhoneVersion by Sebastian Dobrincu,

LNNotificationsUI by Leo Natan.

Where does that come from? Did one person wrote it this way first and then everyone else followed?

I couldn't find anything about it, even in the Apple Guidelines. Is that idiom written anywhere?

答:
Objective C, like C, has no namespaces.  This means that if someone has already defined a function foo or a class Bar, it must be globally unique and you can't define it.  This can result in a lot of headaches when you have your code and then add another library and suddenly things break in strange places.

There is a guideline presented by Apple for this in Programming with Objective C: Conventions section of the iOS developer library:

Some Names Must Be Unique Across Your App

Each time you create a new type, symbol, or identifier, you should first consider the scope in which the name must be unique. Sometimes this scope might be the entire application, including its linked frameworks; sometimes the scope is limited just to an enclosing class or even just a block of code.

Class Names Must Be Unique Across an Entire App

Objective-C classes must be named uniquely not only within the code that you’re writing in a project, but also across any frameworks or bundles you might be including. As an example, you should avoid using generic class names like ViewController or TextParser because it’s possible a framework you include in your app may fail to follow conventions and create classes with the same names.

In order to keep class names unique, the convention is to use prefixes on all classes. You’ll have noticed that Cocoa and Cocoa Touch class names typically start either with NS or UI. Two-letter prefixes like these are reserved by Apple for use in framework classes. As you learn more about Cocoa and Cocoa Touch, you’ll encounter a variety of other prefixes that relate to specific frameworks:

...

Your own classes should use three letter prefixes. These might relate to a combination of your company name and your app name, or even a specific component within your app. As an example, if your company were called Whispering Oak, and you were developing a game called Zebra Surprise, you might choose WZS or WOZ as your class prefix.

So, they libraries that you mention kind of break this convention, but get at the heart of the problem of the lack of namespacing within Objective C.

Further Reading

Namespacing by NSHipster

What is the best way to solve an Objective-C namespace collision?

How does one use namespaces in iOS objective-c code?


问:
Applications using GPL code and run-time libraries of proprietary IDEs
The GPL is described as a 'highly viral' license (if an application contains code which is licensed under GPL, distribution requires open sourcing of the whole application).

Do I understand correctly that linking GPL code with closed source run-time libraries provided by many commercial integrated software development environments has the effect that no (external/public) distribution of the resulting application is possible, simply because the closed source run-time libraries are not under GPL?

答:
It is a bit more nuanced than a straight up yes or no.

In general, it is correct that you must be able (and legally allowed) to distribute the source code of all libraries that are used in a program that contains GPL licensed code.

The nuance comes when dealing with GPL licensed code and libraries that are part of the core infrastructure of a computer (OS Kernel, windowing system, etc.) and libraries that implement a standard interface. Under GPL, those libraries are exempt from the viral nature of the GPL.

The standard libraries for the major programming languages are likely to be intended to fall under this exemption, so I wouldn't worry too much when using a piece of GPL code in your Windows application written using Visual Studio.

ContentLicense: CC BY-SA 3.0


问:
Best IDE for HTML, CSS, and Javascript for mac
I'm currently looking to move to using an IDE for web development. The options I'm considering are:

Aptana Studio

Coda

Expresso

Please base your answers on the following criteria, in descending order of importance:

Supports HTML, CSS, JavaScript

Powerful (having good code completion, good debugger, great syntax highlighting etc)

Fast and light

Supports HTML5, CSS3, and major JavaScript frameworks (JQuery or YUI)

Great design (both usability and aesthetics)

Supports PHP, Ruby, and Python

Has Git integrated

I've updated the question to be more objective. I'm mainly looking for an answer that addresses how well each of the IDEs addresses my criteria.

答:
Netbeans

It fits everything apart from "Fast and light". It's fast enough which is all you need.

Best tools I've seen for history and file diffs that you won't find in something
small like coda.

There is a git
plugin which works really well.

Auto-completion for PHP is very good,
better than eclipse based IDEs.

Support for web frameworks like rails
and symfony.

You might also want to look at Komodo.

ContentLicense: CC BY-SA 2.5


问:
What is the best C++ interview question?
If you could ask a C++ programmer one question to measure their C++ skills, what would it be?

The question I think is best is: Can you call "delete this;" inside a member function? (I put this as a link so you can think it through first, then go to The Best C++ Interview Question – Ever! to see the correct answer.)

I don't ask this because I expect most people to know the answer. If they did it would not be that useful a question. I ask to see if they can work their way to the correct answer and how they do so.

答: I don't think there is a best C++ question. C++ is such a large language, and with C++0X it's grown, that you can be in strong in a certain subdomain of the language and no little about another part of the language. A 'one shot' question will only exercise someone's knowledge of a small part of the language and risk overlooking his or her's knowledge of other aspects of the language.</p>


问:
What to do about "stopping point syndrome"?
I have noticed a behavior in myself that I call "stopping point syndrome"... it means I cannot stop working until I reach a "stopping point" (or I become exhausted).  In other words, if I am in the zone working on getting a feature completed, I won't stop until I get it done.   If it's a bug I'm working on, this effect is even more pronounced... I won't stop until it's fixed, or at the very least, understood.  Even though I work from a laptop and have VPN and could easily go home and pick up on the work later that evening, that fact does not help me leave work... it's like I'm afraid I will die before I find the bug.

I have a very hard time explaining this to family members who can't figure out why I never come home from work at the same time and sometimes come home at 11 pm.  Even managers have been mystified by this, and I've noticed that most of my colleagues have no trouble working the same hours every day.

Does anyone else have this problem?  Should I be worried about this and/or try to change it?  If so how?

答: I used to have a little application which would reboot my computer on a timer. I'd set it for whenever I was supposed to be done by. My computer took 5 minutes to boot, which was enough of a disruption to my workflow to convince me to go home. I combined this with making sure that my outside-of-work life was as full of activities that I have trouble stopping, and am eager to start, as my work life was. It took some effort to find such activities, but it was worth it. </p>


问:
What list of database features/elements are necessary for a programmer to understand?
What database features/elements are necessary for a programmer to understand in order to create non-trivial applications?

I was once asked in a job interview (by a DBA) to rate my understanding of database concepts -- I thought it would be interesting to get opinions.

I'm looking for basic and advanced skills, also any opinions on where developers are typically the weakest (what lack of skills or knowledge creates the most problems).  Also, is it better that developers are need-to-know, and pass more advanced work onto a DBA -- where does that "line in the sand" exist?

答:
For DBA :-

1) Configuration change/upgrading to new version

2) Backup and recovery

For designer :-

1) Normalization

2) indexing, keys, constraints, triggers, views etc.

3) Performance tuning, memory vs. speed

For Developer :-

1) Basic SQL

2) Low level connectivity (OCI,ODBC, JDBC, Hibenrate etc. depending on their field)

3) multiple connections behavior


问:
Is it appropriate to ask for reasons after rejected after the interview?
I thought I did okay in the interviews but apparently the interviewers didn't think so. Is it appropriate to ask for a reason after I have received the rejection email? After all I don't want to annoy the HR person.

I am a student, so not so much job hunting experience so far. Bear with me if this question sounds stupid.

答: You can definitely ask back. Nobody is stopping you. But most probably the answer will be "You do not fit our requirements". </p>


答:
If you asked it like you just asked us, you'll have a much better shot at getting a useful answer.  Emphasize that you are new to the workforce and really value the time the interviewer spent considering you.  Ask what you lacked, perhaps that you could have predicted coming into the interview, that affected your consideration and eventual rejection.  Most importantly, don't be defensive.  You understand that the interviewer made a choice that was right by their own ends and you aren't trying change their minds.

It's been my experience that about a third of interviewers, just give a cagey vibe once they've decided to reject you (or even sooner), and don't really answer any questions at all past that point.  Another third are a bit more open, and will answer some questions, but not others, especially about matters that might reveal more than really necessary about their hiring process.  the remaining third stay friendly and open for as long as you do the same, and are happy to help you in this way.

Title: Is it appropriate to ask for reasons after rejected after the interview?

Body:
I thought I did okay in the interviews but apparently the interviewers didn't think so. Is it appropriate to ask for a reason after I have received the rejection email? After all I don't want to annoy the HR person.

I am a student, so not so much job hunting experience so far. Bear with me if this question sounds stupid.


答:
My experience has been that rejection emails usually contain some kind of generic explanation, such as "your skills and experience were not as good a fit for what we were looking for as some other candidates who applied for this role". If the rejection email has any substance whatsoever at all, I'd probably just leave it at that.

If you really did get one that's totally without explanation, then what Manoj R says above is correct: you'll likely just get that generic answer added.

As for whether it's appropriate: I would say it could be borderline, depending on how you do it. If there is any hint of defensiveness, or of prodding for too much detail, then it probably is a tad inappropriate. But if you genuinely approach it as a curious student, then you can probably get away with it. But the chances of getting a truly useful explanation are relatively slim, imho. Unless the interviewer/HR was an extremely friendly and informal person.


答:
```<code>explain plan;
</code>```

<p>You need to be able to debug your SQL. This means you need to understand what the database chooses to dó and knowing how to change it's mind. </p>

Title: What list of database features/elements are necessary for a programmer to understand?

Body:
What database features/elements are necessary for a programmer to understand in order to create non-trivial applications?

I was once asked in a job interview (by a DBA) to rate my understanding of database concepts -- I thought it would be interesting to get opinions.

I'm looking for basic and advanced skills, also any opinions on where developers are typically the weakest (what lack of skills or knowledge creates the most problems).  Also, is it better that developers are need-to-know, and pass more advanced work onto a DBA -- where does that "line in the sand" exist?

Body:
explain plan;

You need to be able to debug your SQL. This means you need to understand what the database chooses to dó and knowing how to change it's mind.


答:
I am somewhat bemused as to why "can you delete this?" is considered to be an interesting question. Anyone who has written COM code in C++ knows that the very first thing you learn on day one of basic COM programming is how to use "delete this" correctly. I suppose it might be useful to determine whether, say, someone is lying on their resume about having written COM programs, but as a general knowledge C++ question, if someone couldn't answer it immediately then they are not going to be a good fit for my team.

Anyway, if your goal is to come up with a question that measures C++ skills, then picking one question is the wrong way to go. Turn it around. The right question to ask is:

On a scale from one to ten, how good a C++ programmer are you?

This is not the question that gets you the answer you want. Everyone says "eight" regardless. The question that gets you the answer you want is:

OK, so you're an eight. What is a problem area that you think a seven would have a difficult time working with?

And boom, now you've got them. If the candidate thinks that "something to do with recursion" or "when to use a virtual destructor" is the sort of thing that a seven has a hard time with, then you know that they know a little bit about recursion or destructors or whatever, and that their knowledge does not go much farther than that.

That should give you much better calibration than coming up with some trivia question. If you were to force me to come up with a good single question about a fact about C++, I'd probably ask something like "how would you design the semantic analyzer and code generator for the portion of a C++ compiler that deals with virtual methods called in a base class destructor?"  You should ask questions that have to do with real stuff that you work on, and that the candidate is likely to work on. That's a problem I had to work on once, and I think it would give a pretty good insight into how a person designs semantic analyzers and code generators, as well as their knowledge of C++.

Title: What is the best C++ interview question?

Body:
If you could ask a C++ programmer one question to measure their C++ skills, what would it be?

The question I think is best is: Can you call "delete this;" inside a member function? (I put this as a link so you can think it through first, then go to The Best C++ Interview Question – Ever! to see the correct answer.)

I don't ask this because I expect most people to know the answer. If they did it would not be that useful a question. I ask to see if they can work their way to the correct answer and how they do so.


问:
Does the usage of LINQ and Lambda Expressions lead to less readable code?
I'm having a discussion with a co-worker on Linq, I'll copy here:

Co-Worker: Lets be honest here. Linq
syntax sucks. It's confusing and
non-intuitive.

Me: oh come on, more
confusing than T-SQL?

Co-Worker: uh,
yes.

Me: it has the same basic
parts, select, where, and from

Co-Worker: Linq, to me, is a
bastardization of relational + OO.
Co-Worker: Don't get me wrong - it's
incredibly powerful, but they
repurposed SQL to use agains object
collections.

I'm of the opinion that using Linq + Lamda's is very powerful (he agrees), and also makes code easier to read (he disagrees on that point):

pickFiles = from f in pickFolder.GetFiles("*.txt")
where ValidAuditFileName.IsMatch(f.Name)
select f;
```
<p>or</p>
<pre class="lang-cs prettyprint-override"><code>var existing = from s in ActiveRecordLinq.AsQueryable<ScannedEntity>()
where s.FileName == f.FullName && s.DocumentType != "Unknown"
select s;
</code>```

or (VB code here)

   Dim notVerified = From image In images.AsParallel
     Group Join verifyFile In verifyFolder.GetFiles("*.vfy").AsParallel.Where(
      Function(v) v.Length > 0
      ).AsParallel
   On image.Name.Replace(image.Extension, ".vfy") Equals verifyFile.Name
     Into verifyList = Group
    From verify In verifyList.DefaultIfEmpty
    Where verify Is Nothing
    Select verify
```

To me this is clean and easy (at least easier than the alternatives) to read, what are your opinions on it?

答:
Co-Worker: Lets be honest here. Linq syntax sucks. It's confusing and non-intuitive.

You can't argue with that criticism. For your coworker, it sucks. We failed to design a syntax that, for them, was clear and intuitive. That's our failing, and you can pass on my apologies to your coworker. I am happy to take suggestions on how to make it better; what specifically does your coworker find confusing or unintuitive?

However, you can't please everyone. My personal opinion, and the opinion of most of the people I've talked to on the subject, is that the query comprehension syntax is much more clear than the equivalent imperative syntax. Clearly not everyone agrees, but fortunately we do not require consensus of all the millions of our customers when we do language design.

On the subject of what is "intuitive" though, I am reminded of the story of the English linguist who studied many different languages and finally concluded that English was the best of all languages because in English, the words come in the same order that you think them. Unlike French, where they're constantly saying things like "the dog white eats the meat red".  How hard it must be for French people to think the words in the correct order and then have to say them in the French order!  French is so unintuitive! It's amazing that the French manage to speak it. And German? where they think "the dog eats the meat" but then have to say "the dog the meat eats" !?! So unintuitive.

Often what is "intuitive" is merely a matter of familiarity. It took me months of working with LINQ before I stopped beginning my queries with the "select" clause.  Now it is second nature, and the SQL order seems bizarre.

Which it is! The scoping rules are all messed up in SQL. Something you might want to point out to your coworker is that LINQ was carefully designed so that (1) introduction of variables and scopes happens left-to-right (*), and (2) the order that the query appears on the page is the order in which it is executed. That is, when you say

from c in customers where c.City == "London" select c.Name
```

<p>the c appears in scope at the left, and stays in scope through the right.  And the order in which things happen are:  first "customers" is evaluated. Then the "where" is evaluated to filter the sequence. Then the filtered sequence is projected by the "select".  </p>

<p>SQL doesn't have this property. If you say</p>

<pre class="lang-sql prettyprint-override"><code>SELECT Name FROM Customers WHERE City = 'London'
</code>```

then "Name" is brought into scope by something to its right, not to its left, and the query is executed in a completely messed up order; the middle clause is evaluated first, then the last clause, and then the first clause. That now seems crazy and unintuitive to me, having worked solely with LINQ for so long now.

(*) Scoping rules are a bit weird in LINQ with join clauses. But other than that, scopes nest nicely.

Body:
Co-Worker: Lets be honest here. Linq syntax sucks. It's confusing and non-intuitive.

You can't argue with that criticism. For your coworker, it sucks. We failed to design a syntax that, for them, was clear and intuitive. That's our failing, and you can pass on my apologies to your coworker. I am happy to take suggestions on how to make it better; what specifically does your coworker find confusing or unintuitive?

However, you can't please everyone. My personal opinion, and the opinion of most of the people I've talked to on the subject, is that the query comprehension syntax is much more clear than the equivalent imperative syntax. Clearly not everyone agrees, but fortunately we do not require consensus of all the millions of our customers when we do language design.

On the subject of what is "intuitive" though, I am reminded of the story of the English linguist who studied many different languages and finally concluded that English was the best of all languages because in English, the words come in the same order that you think them. Unlike French, where they're constantly saying things like "the dog white eats the meat red".  How hard it must be for French people to think the words in the correct order and then have to say them in the French order!  French is so unintuitive! It's amazing that the French manage to speak it. And German? where they think "the dog eats the meat" but then have to say "the dog the meat eats" !?! So unintuitive.

Often what is "intuitive" is merely a matter of familiarity. It took me months of working with LINQ before I stopped beginning my queries with the "select" clause.  Now it is second nature, and the SQL order seems bizarre.

Which it is! The scoping rules are all messed up in SQL. Something you might want to point out to your coworker is that LINQ was carefully designed so that (1) introduction of variables and scopes happens left-to-right (*), and (2) the order that the query appears on the page is the order in which it is executed. That is, when you say

from c in customers where c.City == "London" select c.Name

the c appears in scope at the left, and stays in scope through the right.  And the order in which things happen are:  first "customers" is evaluated. Then the "where" is evaluated to filter the sequence. Then the filtered sequence is projected by the "select".

SQL doesn't have this property. If you say

SELECT Name FROM Customers WHERE City = 'London'

then "Name" is brought into scope by something to its right, not to its left, and the query is executed in a completely messed up order; the middle clause is evaluated first, then the last clause, and then the first clause. That now seems crazy and unintuitive to me, having worked solely with LINQ for so long now.

(*) Scoping rules are a bit weird in LINQ with join clauses. But other than that, scopes nest nicely.


答:
I would ask them for the reason why virtual member function can not be used with template in C++. Of course, there is only few people who can actually answer the question immediately. But if an interviewee properly understands the core mechanics of C++(how template works in C++, how virtual function is implemented, how compiler and linker generate an executable from source code, etc.), you may get an answer with appropriate step-by-step leading questions.

Added : Template virtual member function in this answer means template function that is virtual member function of some class - not a regular member function in template class. Sorry for confusing :(


答:
Yes.  A good recruiter will give you a good answer.

Please note the recruiter found you good enough for an interview, so it is in his/her own interest to help you improve.


问:
What's your favourite quote about programming?
What's your favourite quote about programming?

One quote per answer, and please check for duplicates before posting!

答:
One accurate measurement is worth more
  than a thousand expert opinions.

Admiral Grace Hopper

LastEditorDisplayName: Roger Pate


问:
Percentage or Pixel for layouts?

What will you use for a webpage layout? Percentage or pixels?

When should one use one over the
other?

答:
What unit you use depends entirely on what you want to accomplish. The units most used in web layouts are:

px - absolute; one pixel

pt - absolute; 1/72 inch, about 1.3px for screen media

em - relative to parent font size; 1.0em = size of a character (width of uppercase M)

% - relative to parent

You use px for sizes that remain constant, for example a 1px border.

You use em for sizes that should follow the font size, for example a 3.0em margin.

You use % for sizes that should take up a percentage of the parent, for example a 50% width.

For web page layouts you normally use either pixels or percentages depending on if you want a fixed (pixel) layout or a fluid (percentage) based layout.

Title: Percentage or Pixel for layouts?


问:
Are there any actual examples of profitable programmer's "worker's cooperatives"?
http://en.wikipedia.org/wiki/Worker_cooperative

I'm curious whether there are, anywhere in the world, worker's cooperatives that center on a technology business that involves either programming, IT, or some sort of IT or programming related consulting or services.

The wikipedia link above is an overview of the concept. The short form explanation is that a co-op is a worker-owned business. Also there is the notion that every worker owns shares in the business.

I am interested in knowing whether an example of a "programmer's/IT co-op" even exists.

Note: I am not talking about nor asking about a government-funded incubator nor any other socialized, state supported group. I also don't mean "co-working", which is renting an office with other self employed people doing their own thing.

I mean a going, profitable IT business operating in a competitive environment that is worker-owned and run.

答:
I'm one of software.coop: that's our website and if you click About on our site, there's some background information, links to a case study and other co-ops we know. It needs tidying, but we're pretty busy. I think most tech-coop participants are profitable, even if some don't pay all that brilliantly yet.

(Posted at the request of Tshepang)


答: I tend to use pixels for width declarations (which generally are fixed), but em's for height. That way the layout resizes vertically - but maintains horizontal consistency. </p>

Title: Percentage or Pixel for layouts?

Body:
What will you use for a webpage layout? Percentage or pixels?

When should one use one over the
other?


问:
What is the (craziest, stupidest, silliest) thing a client/boss asked you to do?
See title, but I am asking from a technical perspective, not

Take my 40 year old virgin niece on a date or you're fired.

答:
I was working on a web project in ASP.NET which was to replace an existing PHP solution. The PHP site wasn't bad, just a little outdated so the new project was to upgrade it using a new platform. The first thing to do was setup the new infrastructure by having IIS and MSSQL servers as well as a source control system.

A few weeks into creating the new project the project manager became unhappy with the deployment process which involved getting the latest version of the code, then deploying a build to the test environment. He felt that this was time consuming and that having people work on the same code base and having to merge their changes the wrong way to do things.

His solution was that we go back to the "old way" of doing things: writing PHP on the production server in real time with no source control or deployment strategy. This way you could have instant results and it didn't involve setting up source control or other servers. Needless to say things did not go well. :)


答:
IT worker co-operatives (and more generally in the creative/knowledge industries) are a growing source of worker co-operatives in the UK.

Some examples:

http://www.ecobee.org

http://www.web.coop

http://www.software.coop (oh and hi MJ)

http://www.3mules.coop

http://www.atomised.coop

http://www.nomad.coop

http://www.netuxo.com

http://www.mc3.coop

http://www.analog.coop

More pure design including web:

http://www.wave.coop

http://www.alpha.coop

http://www.uhc.org.uk

http://www.design.coop

Because of this growth we (at Co-operatives UK) have created a guide to help them along, if you're interested.

http://www.creatives.uk.coop/

Title: Are there any actual examples of profitable programmer's "worker's cooperatives"?

Body:
http://en.wikipedia.org/wiki/Worker_cooperative

I'm curious whether there are, anywhere in the world, worker's cooperatives that center on a technology business that involves either programming, IT, or some sort of IT or programming related consulting or services.

The wikipedia link above is an overview of the concept. The short form explanation is that a co-op is a worker-owned business. Also there is the notion that every worker owns shares in the business.

I am interested in knowing whether an example of a "programmer's/IT co-op" even exists.

Note: I am not talking about nor asking about a government-funded incubator nor any other socialized, state supported group. I also don't mean "co-working", which is renting an office with other self employed people doing their own thing.

I mean a going, profitable IT business operating in a competitive environment that is worker-owned and run.

OwnerDisplayName: John Atherton


问:
What are the common misuses of "enum" in C?
I have seen C code where people used enum heavily. But all it does is confuse others. In many places plain integers can do the same thing with less ambiguity. What are the common misuses of enum?</p>

答:
One case I can think of, though haven't seen in the wild yet, is to abuse enums as a collection of disjointed integer constants:

```<code>enum somestuff { days_in_week = 7,
                 months_in_year = 12,
                 number_of_planets = 8,
                 fingers_per_hand = 5 };
</code>```

The most pathological, innocent looking example I can imagine would be

```<code>enum numbers { one, two, three, four, five, six, seven, eight, nine, ten };
</code>```

because one==0, two==1 etc.

Body:
One case I can think of, though haven't seen in the wild yet, is to abuse enums as a collection of disjointed integer constants:

enum somestuff { days_in_week = 7,
                 months_in_year = 12,
                 number_of_planets = 8,
                 fingers_per_hand = 5 };

The most pathological, innocent looking example I can imagine would be

enum numbers { one, two, three, four, five, six, seven, eight, nine, ten };

because one==0, two==1 etc.


答:
Yeah, I do it all the time.

Interestingly, the best managers I worked with were always ready to tell me to go home when I overdid it.

Title: What to do about "stopping point syndrome"?

Body:
I have noticed a behavior in myself that I call "stopping point syndrome"... it means I cannot stop working until I reach a "stopping point" (or I become exhausted).  In other words, if I am in the zone working on getting a feature completed, I won't stop until I get it done.   If it's a bug I'm working on, this effect is even more pronounced... I won't stop until it's fixed, or at the very least, understood.  Even though I work from a laptop and have VPN and could easily go home and pick up on the work later that evening, that fact does not help me leave work... it's like I'm afraid I will die before I find the bug.

I have a very hard time explaining this to family members who can't figure out why I never come home from work at the same time and sometimes come home at 11 pm.  Even managers have been mystified by this, and I've noticed that most of my colleagues have no trouble working the same hours every day.

Does anyone else have this problem?  Should I be worried about this and/or try to change it?  If so how?


答:
I thought I did okay in the
  interviews, but apparently the
  interviewers didn't think so

"Apparently"? Did you already get feedback, beyond not getting hired?

Bear in mind that your assessment of your performance may be entirely accurate. Someone else may just have done better. Or perhaps "okay" doesn't get over their particular bar; they may be looking for "outstanding".

Unless you're something exceptional, be prepared for interviews not resulting in offers to be the norm - since most companies interview multiple candidates for each role, all but one of those candidates is not going to get an offer, no matter how well (or badly) each performed.

But it shouldn't be a problem to request feedback from the interview process; pretty much the worst that can happen is that they don't provide it or that they take a long time to do so.


答:
I usually tell people if they call. Common reasons I give are:

The position was given to someone with more experience

The position was given to someone who we feel would be a better fit in our team. During our interview, you didn't defend your solution to the [foo] problem very well.

You missed the first interview and showed up late for the second. While you were more than qualified, I hired the candidate next in line.

You are completely overqualified for the position. I brought on someone who would find it challenging.

We want you, we simply can't afford you.

But, you have to be careful as well. You would be amazed at the smallest spark, the smallest mixing up of words or the smallest unintended written inflection that might spark a lawsuit (depending on where you are located). If you want feedback, it has to be over the phone. If you want an e-mail or a letter, it would simply say "Sorry we did not select you, we'll keep your CV on file." I have to do what our legal department says.

I don't send out formal letters, though (HR sends out the generic one, not me). Criticism is something that should be invited. So, if not selected .. if you call and ask me, I'll let you know how you can improve for your next prospect.

That is, of course to the best of my ability. Sometimes I hire just because I have a really good instinct about someone, even if they aren't the most experienced. In that case, unfortunately, all I have is a generic answer to give you. Something like:

It was a very tough decision. You did very well in the interview, your experience is more than adequate. I don't think there's anything better you could do in the future.

There's also factors that aren't easily explained. My previous boss could not stand jewelery on men. Knuth could interview and if he wore more more than a watch and a wedding band, he probably would not get hired. I don't think there's a good way to articulate that as an explanation for not hiring someone .. so no matter what they tell you, understand that personal bias does often come into play.


问:
Does hybrid hard drive improve programming experience?
I'm tired of how luggish my developments PC is. It's Core2 Duo, 2GB RAM, Seagate ST3500320AS HDD - not the top model, but quite a decent one.

Typically I open several copies of Visual Studio 2008, lots of tabs in Firefox, Outlook, MSDN, plus the programs I debug are quite huge, plus whatever Windows thinks it can't live without so I end up with Task Manager showing something like 2,5 GB pagefile usage.

All the software above becomes luggish to such extent that it's really annoying. Something like I click on a menubar in Visual Studio - and instead of just opening the menu it works the harddisk for say 10 seconds.

I'd like to have some magic "don't make me think" solution - so that it is installed once and then the lugs disappear or at least decrease significantly. It should not be very expensive - something like the current price of a hybrid drive.

Will a hybrid drive magically help overcome my problem once and for all? Do you have experience using hybrid drives for similar purposes?

答:
More RAM and an x64 OS.

Evidence:

We have two systems with minor HW differences that should account for 10..20% of build speed,  one running Vista x86, the other Windows 7 x64, the latter building twice as fast.

I've heard related advice before: using W2K / W2K3 instead of Windows 98 or XP, but didn't have a direct comparison.

My Tests:

VS 2008, W7 x64 system has a 4 core CPU with HT and 8GB RAM, building in 8 processes in parallel.

An SSD (OCZ Vertex 2) does not significantly improve build speed on repeated builds with Antivirus disabled.

```<code>                                  SSD          HDD
 1st after boot, AV on            17:14         25:16
 2nd after boot, AV on            16:56         20:59
 3rd after boot, AV on            16:50
 4th/3rd after boot, AV off       13:07         14:57
</code>```

(3rd line to test epeatability of results, the last line is the "stable" case where there's not much benefit anymore).

Memory seems not limiting: even in the more taxing release builds with full optimization, "in use" < 60%, most of the rest is on "Standby", i.e. probably used as cache.

I'm planning to run  some more detailed tests, (different threads in parallel etc.)

Body:
More RAM and an x64 OS.

Evidence:

We have two systems with minor HW differences that should account for 10..20% of build speed,  one running Vista x86, the other Windows 7 x64, the latter building twice as fast.

I've heard related advice before: using W2K / W2K3 instead of Windows 98 or XP, but didn't have a direct comparison.

My Tests:

VS 2008, W7 x64 system has a 4 core CPU with HT and 8GB RAM, building in 8 processes in parallel.

An SSD (OCZ Vertex 2) does not significantly improve build speed on repeated builds with Antivirus disabled.

                                  SSD          HDD
 1st after boot, AV on            17:14         25:16
 2nd after boot, AV on            16:56         20:59
 3rd after boot, AV on            16:50
 4th/3rd after boot, AV off       13:07         14:57

(3rd line to test epeatability of results, the last line is the "stable" case where there's not much benefit anymore).

Memory seems not limiting: even in the more taxing release builds with full optimization, "in use" < 60%, most of the rest is on "Standby", i.e. probably used as cache.

I'm planning to run  some more detailed tests, (different threads in parallel etc.)


问:
Is there any hard data on the (dis-)advantages of working from home?
Is there any hard data (studies, comparisons, not-just-gut-feel analysis) on the advantages and disadvantages of working from home?

My devs asked about e.g. working from home one day per week, the boss doesn't like it for various reasons, some of which I agree with but I think they don't necessarily apply in this case.

We have real offices (2..3 people each), distractions are still common. IMO it would be beneficial for focus, and with 1 day / week, there wouldn't be much loss at interaction and communication. In addition it would be a great perk, and saving the commute.

Related: Pros and cons of working remotely / from home  (interesting points, but no hard facts)

To clarify: it's not my decision to make, I agree that there are pro's and con's depending on circumstances, and we are pushing for "just try it". I've asked this specific question because (a) facts are a good addition to thoughts in arguing with an engineer boss, and (b) we, as developers, should build upon facts like every respectable trade.

答:
Research Material

There are a few but not all are current or applying exclusively to our field:

Work-at-home and the quality of working life

Substitution between working at home and out-of-home: The role of ICT and commuting costs

The perils of working at home: IRB “mission creep” as context and content for an ethnography of disciplinary knowledges

Working at home: An update

Satisfaction and perceived productivity when professionals work from home

Factors that Influence the Productivity of Software Developers in a Developer View

Restructuring workplace cultures: the ultimate work-family challenge?

NOTE: Some of the articles appeared in journals and aren't free.

Update - Personal Experience

I've now been doing this for about 4 months at the time of this update (2012-02-146), and here's a simple pro-con list:

Pros

time-table flexibility

to pick the kids up from school

to take care of family emergencies

to walk to the kitchen to grab coffee

productivity can sometimes be increased

less disruption from co-workers or open-space annoyances

own set of software and tools, workstation tweaking (as long as you don't indulge too much into it)

savings on travel

though we careful that if you still need to occasionally travel, you factor that in and don't end up paying more expensives travel cards in your area for one-off journeys or other similar issues

healthier eating (depends on the workplace and your cooking skills...)

if your IT requirements permit, you can check-in on work anytime you want, as you're always at your office

Cons

managing the time table is tricky

keeping relatives away is harder,they don't (and may take a very long time to, by the look of it) understand that boundaries are needed and need to be respected

whether it's your children and partner barging in to ask for help with something or discuss something important happening in their lives, which you could ignore at the office if you're in a meeting. Here, they barge into the meeting...

or your mother calling in the middle of the day "since you're working from home"

or the unexpected (like paramedics calling me on day to check on an old lady in my building, which I had just moved into, because they didn't get her phone number right and where trying to reach someone in the building by using the white pages: you just can't make that up)

productivity can also take a hit under some cirumstances

connectivity drops are a PITA

if you IT department is a bit "annoying", you may end up with no local software kit, no decent hardware, and not even a VPN access but just an RDP gateway to your old workstation back at the office (this purely sucks, be warned)

communication is more difficult, though possible:

face time is harder to arrange

your colleagues skype- or phone-screen you on occasions, and so do you the other way around

the coolest and most modern gadgets and virtual office tools won't match that the good ol' back and forth during a brainstorming session with a whiteboard, colored markers and a hand-full of sticky notes

crappier eating

you can tend to fall into a cycle of eating snacks and things you have readily available in your kitchen (and then end up spending more than you would at an office, where you might focus more)

you develop a tendency to check in out of office hours, which may not always be healthy (for your work habits, and for your family time)

A lot of these are obviously linked: if you get into a non-productive cycle and take some time to snap out of it, you might be tempted to eat junk snacks and all that.

There are also so variables that are neither pros nor cons, but will affect the experience:

is your boss the more "give-you-some-leash" type or the "whatchya-been-doing-these-past-5-minutes"?

it's understandable as you might (and I would assume you would) occasionally slack off, and might actually keep you on your toes

it gets you down, disrupts your concentration, and eats time for nothing if you were actually working

is your home more likely than your office to have environmental annoyances (for instance, I had roadworks for 2 weeks outside my window at home... but I had a pre-school under my window at the office)

Overall I am happy with the experience and have been trying to refine my process to work at home to the fullest extent of my produtivity, but it takes some discipline at first and then whenever life gets you a bit down (I find that it's harder to shake than in an office).

If I had the choice though, I'd much prefer to still work at the office with colleagues, but from the experience I'd say I wouldn't mind having subordinates requesting to telecommute (at least for a try-out).

I could go on longer, but this isn't hard-data, just personal feedback as originally promised.

Update 2 - More Personal (Bad) Experience

It's been longer now, and I have to say I've lost momentum on a few things and let myself get overworked at a given period and... it took me nearly 2 months to snap out of a near-depressive and vegetative state.

Which, granted, is what I expected to happen eventually and why I didn't really want to work from home in the first place, as the environment is more prone to this type of thing and makes it harder to kick the burn-out feeling than if you're at the office with your peers. It's also very frustrating when you know exactly how to snap out of it (it's all detailed up there: follow the dots and things will be fine, but actually doing it takes some will power, sometimes...) but just can't get yourself to actually do it.

If it does happen to you, grab a friend or co-worker and have them look over your shoulder every once in a while and get people to request more frequent status updates from you (not too many). Grab people that you know won't be (too) judgmental and won't make it a hassle for you, so that you have a motivator and a need to keep things going. Do force yourself to plan and time box your daily duties as much as possible.

It really got pretty bad for me at some point, as I had a lengthy period of professional overwork and a crazy load of these fun things life can throw at you.

Still not saying working from home is necessarily bad, but it does have its cons, and getting into this state is already bad enough, so you better have an environment that helps you shake it.

ContentLicense: CC BY-SA 4.0


问:
Should I bother to develop for JavaScript disabled?
Should I bother to develop for JavaScript disabled?

I feel that my time is better spent developing for the majority.

答:
Yes, you should.

If you perceive this as something that requires extra effort, you may be doing it the other way around.

Develop your pages to work without JavaScript first then add JavaScript-based improvements, Ajax effects and so on. They will work if JS is supported/enabled, otherwise your pages will degrade gracefully.

And please, don't develop the pages where:

The entire content is pulled from the database by JavaScript

The markup completely falls apart because the elements glued together and put into the right places by JavaScript not by CSS

Links in the navigation and in the body are not functioning without JavaScript (unless it's some framework like ASP.NET which relies on JavaScript for a reason)

It's just against the spirit of the web and against the common sense.

P.S. Spoken by a user of the NoScript.


问:
Stuff every programmer needs while working
I've been tasked with creating a fun and relaxing environment, one thing I know that I want is ergonomic mice and keyboards, others have suggested exercise balls and bands.

What is it that every programmer needs while working? What might not be necessary but would be nice to have anyway?

Note: this question was asked previously, but has been recommended to be posted here. See this link for the previous responses: https://stackoverflow.com/questions/3911911/stuff-every-programmer-needs-while-working-closed

答:
Good enough colleagues.

I'm in a private game programming school right now, and obviously there are not enough clever people in my class, unlike the one of the same year of the last year.

By clever enough I mean maturity, interests, programming experience and self-motivation to solve a problem by his own self rather than asking other student rather than the teacher.


答:
Studies and surveys on subjects such as the advantages of working from home can often end up being biased.

Here's a recent BBC article on the subject. There's a mention of viewership of a certain show rising during snow, but that does not necessarily mean people working from home were distracted by the TV schedule.

I think the bottom line is building up trust with the people you interact with, whether co-workers, bosses or clients.

Title: Is there any hard data on the (dis-)advantages of working from home?

Body:
Is there any hard data (studies, comparisons, not-just-gut-feel analysis) on the advantages and disadvantages of working from home?

My devs asked about e.g. working from home one day per week, the boss doesn't like it for various reasons, some of which I agree with but I think they don't necessarily apply in this case.

We have real offices (2..3 people each), distractions are still common. IMO it would be beneficial for focus, and with 1 day / week, there wouldn't be much loss at interaction and communication. In addition it would be a great perk, and saving the commute.

Related: Pros and cons of working remotely / from home  (interesting points, but no hard facts)

To clarify: it's not my decision to make, I agree that there are pro's and con's depending on circumstances, and we are pushing for "just try it". I've asked this specific question because (a) facts are a good addition to thoughts in arguing with an engineer boss, and (b) we, as developers, should build upon facts like every respectable trade.


答:
The biggest issue I've had with enumerations is them being defined twice.

```<code>EnumZ
{
    Yes,
    No,
    Maybeso
}
</code>```

and someone else, with a very similar name, would have

```<code>EnumZee
{
    No,
    Maybeso,
    Yes
}
</code>```

It's not a "quick catch" because that's the enum you made.. right? It's something you don't really see until you're stepping through the code and see that your 'No' is coming back as zero instead of one.

Title: What are the common misuses of "enum" in C?

Body: I have seen C code where people used enum heavily. But all it does is confuse others. In many places plain integers can do the same thing with less ambiguity. What are the common misuses of enum?</p>

Body:
The biggest issue I've had with enumerations is them being defined twice.

EnumZ
{
    Yes,
    No,
    Maybeso
}

and someone else, with a very similar name, would have

EnumZee
{
    No,
    Maybeso,
    Yes
}

It's not a "quick catch" because that's the enum you made.. right? It's something you don't really see until you're stepping through the code and see that your 'No' is coming back as zero instead of one.


答:
Absolutely

A site that doesn't work correctly without JavaScript should clearly notify the user. As much as possible should be made to work correctly without JavaScript. There are certain cases where this won't be possible, highly dynamic sites built on layers of AJAX and remote fetches are one of them. This doesn't mean that it's okay to show a blank page if I have JavaScript disabled.

Graceful degradation is extremely important, and it doesn't just apply to JavaScript, it applies to everything you code. Valid HTML markup, valid CSS, server side validation of everything.

Body:
Should I bother to develop for JavaScript disabled?

I feel that my time is better spent developing for the majority.


问:
Best practise to versioning Web Service WCF
I've a web service SOAP developed with WCF, there is a best practise to versioning it? when I change the contract I don't want to update all the client's referiments but I want simply publish a new version that coexists with the old.

STUDY-CASE:
I've a web service with one endpoint, all clients point to it,
soon I will have to change the contract and I search a way to avoid that all clients crash.
I know two ways to avoid this:

publish the web service with the new contract in another server

create a new file svc with the new contract

there are other ways?

答:
It depends on many things such as what changes you are going to make, what platform your clients are built on, what's your change tracking policy, etc.

For example if you just want to add a new property to a data contract or a new operation to a service contract it's safe to add it to your current implementation as long as the clients are version tolerant (DataContractSerializer is version tolerant) and it complies with your change tracking policy. However you would better stick to strict versioning strategy which requires creating a new contract and exposing it with a new endpoint in case the changes are more serious.

I suggested reading these articles:

Versioning Strategies

Best Practices: Data Contract Versioning

This should help you to choose the right version strategy and provide your with the best practices to follow.


问:
User story - design constraint
How can I put in the design constraint into a user story?

The system to be developed will generate a invoice when a payment is made, and will send the invoice to xMail (an emailing tool) which will then email the invoice to the customer.

How should I put the information where the system will send the invoice to xMail?

Note: xMail is just a random name as I could not reveal the actual name

答:
If it's a requirement, put it in the story. Just be sure it's an actual requirement and not an assumption you are making about the eventual implementation. </p>

<p>"As a user of the system, I want an invoice sent to xMail when I make a payment, so that we can support companies that exclusively support xMail"</p>

Title: User story - design constraint

Body:
If it's a requirement, put it in the story. Just be sure it's an actual requirement and not an assumption you are making about the eventual implementation.

"As a user of the system, I want an invoice sent to xMail when I make a payment, so that we can support companies that exclusively support xMail"


答:
Personally I use the NoScripts Firefox plugin when browsing, and I encourage others to use it to. On all the family PCs I maintain NoScripts is one of the mandatory bits of software I install. I set it up with a whitelist of the basic email and banking websites along with the popular social & video sites and explain to them how the temporary allow works. Judging from the popularity of this plugin I think there is a pretty good portion of people who use it.

At the very least I expect navigation functionality to work without scripts. If you have something specific like video that requires scripts then fine, but display a nice placeholder that says "scripts are required to view this video".

Making your navigation rely on scripts is a big mistake though. In many cases it will make me bounce off the site in disgust. An even bigger mistake is to have part of your site or navigation just completely disappear when scripts are disabled. Unless you highlight the fact that something is missing there's a good chance I won't even notice so will just leave your site thinking it wasn't there. Also, a full screen message that just says "this site requires scripts" won't get you very far, I need to see some level of content before I trust you enough to allows scripts.

Finally, don't forget that it's not just desktop PCs that are browsing your site, but mobile browsers are increasingly popular. Although mobile JavaScript support is getting better it's no where near perfect so unless you are going to heavily test all the different mobile browsers I would suggest you search the mobile version of your page pretty much scriptless.

Title: Should I bother to develop for JavaScript disabled?


问:
At what level of abstraction are data structured created?
I am learning about Linked List and Arrays in my data structures class. We are make them in Java. Are actual data structures designed in Java/C? Or are they made in lower level languages like assembly? The linked list we made in class just seems to simple, it makes me wonder how real data structures differ from what I am being taught.

Here is a code snippet from one of the files:

```<code>import java.util.*;

/**
 * A class that implements our simple List interface using a linked list.
 * The linked list includes a dummy head node that allows us to avoid
 * special cases for insertion and deletion at the front of the list.
 */
public class LLList implements List {
    // Inner class for a node.  We use an inner class so that the LLList
    // methods can access the instance variables of the nodes.
    private class Node {
        private Object item;
        private Node next;

        private Node(Object i, Node n) {
            item = i;
            next = n;
        }
    }

    private Node head;     // dummy head node
    private int length;    // # of items in the list

    /**
     * Constructs a LLList object for a list that is initially empty.
     */
    public LLList() {
        head = new Node(null, null);
        length = 0;
    }

    /*
     * getNode - private helper method that returns a reference to the
     * ith node in the linked list.  It assumes that the value of the
     * parameter is valid.
     *
     * If i == -1, it returns a reference to the dummy head node.
     */
    private Node getNode(int i) {
        Node trav = head;
        int travIndex = -1;
        while (travIndex < i) {
            travIndex++;
            trav = trav.next;
        }
        return trav;
    }

    /** getItem - returns the item at position i in the list */
    public Object getItem(int i) {
        if (i < 0 || i >= length)
            throw new IndexOutOfBoundsException();
        Node n = getNode(i);
        return n.item;
    }

    /**
     * addItem - adds the specified item at position i in the list,
     * shifting the items that are currently in positions i, i+1, i+2,
     * etc. to the right by one.  Always returns true, because the list
     * is never full.
     *
     * We don't need a special case for insertion at the front of the
     * list (i == 0), because getNode(0 - 1) will return the dummy
     * head node, and the rest of insertion can proceed as usual.
     */
    public boolean addItem(Object item, int i) {
        if (i < 0 || i > length)
            throw new IndexOutOfBoundsException();

        Node newNode = new Node(item, null);
        Node prevNode = getNode(i - 1);
        newNode.next = prevNode.next;
        prevNode.next = newNode;

        length++;
        return true;
    }

    /**
     * removeItem - removes the item at position i in the list,
     * shifting the items that are currently in positions i+1, i+2,
     * etc. to the left by one.  Returns a reference to the removed
     * object.
     *
     * Here again, we don't need a special case for i == 0 (see the
     * note accompanying addItem above).
     */
    public Object removeItem(int i) {
        if (i < 0 || i >= length)
            throw new IndexOutOfBoundsException();

        Node prevNode = getNode(i - 1);
        Object removed = prevNode.next.item;
        prevNode.next = prevNode.next.next;

        length--;
        return removed;
    }

    /** length - returns the number of items in the list */
    public int length() {
        return length;
    }

    /**
     * isFull - always returns false, because the linked list can
     * grow indefinitely and thus the list is never full.
     */
    public boolean isFull() {
        return false;
    }

    /**
     * toString - converts the list into a String of the form
     * {item0, item1, ...}
     */
    public String toString() {
        String str = "{";

        Node trav = head.next;    // skip over the dummy head node
        while (trav != null) {
            str = str + trav.item;
            if (trav.next != null)
                str = str + ", ";
            trav = trav.next;
        }

        str = str + "}";
        return str;
    }

    /**
     * iterator - returns an iterator for this list
     */
    public ListIterator iterator() {
        return new LLListIterator();
    }

    /*
     *** private inner class for an iterator over an LLList ***
     */
    private class LLListIterator implements ListIterator {
        private Node nextNode;          // the next node to visit
        private Node lastVisitedNode;   // the most recently visited node

        public LLListIterator() {
            nextNode = head.next;
            lastVisitedNode = null;
        }

        /**
         * hasNext - does the iterator have additional items to visit?
         */
        public boolean hasNext() {
            return (nextNode != null);
        }

        /**
         * next - returns a reference to the next Object in the iteration
         */
        public Object next() {
            if (nextNode == null)
                throw new NoSuchElementException();

            Object item = nextNode.item;
            lastVisitedNode = nextNode;
            nextNode = nextNode.next;

            return item;
        }
    }
}
</code>```

答:
The answer is both. Data Structures are implemented at all levels of abstraction as far as languages go. For a reasonably high level language like Java where memory allocation is automatically managed, you'd define the data structure in terms of Java classes and methods.

In C, you'd define structures (or arrays) and the functions that operate on them. Additionally, since C does not have automatic memory management, you'd need to also allocate the space for the data structures to exist and so forth. You'd also need to tell the compiler when to deallocate that memory so that you don't run out of memory (this is one way of getting memory leaks).

Java and C both compile to lower level languages, JVM bytecode and assembly language respectively. These each have their own representations of data and operations but they are more directly aligned with how the computer that the program is run on functions (in Java's case, it's a virtual computer but the process is similar). Memory management and so forth are specified by the compiler according to conventions set out by the compiler writers but if you were to write the assembly/bytecode yourself, you could do so but you'd need to be very aware of all of the operations required to move data and operate on it as well as have a good mental model of how the various registers and assembly commands map to the structure you've got in mind.

As far as the real data structures in the wild, they are often much more sophisticated than linked lists and arrays. They often use these as components but there is a whole class of tree based structures and graphs that don't necessarily use either one but can be implemented with either basic structure. Examples include heaps, tries, and R-trees.

As far as usage goes, however, it is much more common to pick a preexisting data structure from a library available to a language than to roll your own. The reasons for this are many and varied but the most common are performance, security, and reliability. Programming language designers tend to be very educated people with a great deal of knowledge as to what the best possible solutions for representing each data structure are and how to go about implementing that representation in a given language.

Python's lists for instance, use Timsort rather than Quicksort or Merge Sort because in practice it's a faster sort. Another good example is that of synchronized vs unsynchronized data structures in Java. Vectors are deprecated in favor of ArrayList. Vectors provide individually synchronized access to itself which is often problematic in a multithreaded environment (exactly why this is the case is best left for another day). There are other ways of implementing similar functionality but at less cost in terms of time and space so people tend to use those now.

So while rolling your own data structures is a fantastic thing to do for a learning exercise, it's something that you generally avoid unless you have no other option since the provided structures in the libraries of your languages are generally more thoroughly tested and more brutally optimized than anything you could hope to build on your own. That being said, it's good to know how all this stuff is supposed to work so you can properly analyze the problem at hand and pick the appropriate structures to help you solve it, even if you're only using off the shelf components.


答:
Linked lists and arrays are very simple, but they are also real data structures.  They're the simplest way to deal with a list of items, with linked lists simpler for lists whose size we don't know ahead of time, and arrays simpler for lists whose size (or maximum size) we do know.

You don't have to dip down into a different, lower-level language (like assembly) to make data structures.

The linked list we made in class just seems to simple

In programming, there is no such thing as too simple, unless it can't actually do what we need it to do.  Like Einstein said, "Everything should be made as simple as possible, but no simpler."

Don't think that just because a data structure being used by a program is simple that the program itself is simple -- you can do some very complex things with very simple data structures.

Sometimes data structures are nested inside each other to make more complex data structures.  For instance, you could have a linked list of arrays, or an array of linked lists.

Title: At what level of abstraction are data structured created?

Body:
I am learning about Linked List and Arrays in my data structures class. We are make them in Java. Are actual data structures designed in Java/C? Or are they made in lower level languages like assembly? The linked list we made in class just seems to simple, it makes me wonder how real data structures differ from what I am being taught.

Here is a code snippet from one of the files:

```<code>import java.util.*;

/**
 * A class that implements our simple List interface using a linked list.
 * The linked list includes a dummy head node that allows us to avoid
 * special cases for insertion and deletion at the front of the list.
 */
public class LLList implements List {
    // Inner class for a node.  We use an inner class so that the LLList
    // methods can access the instance variables of the nodes.
    private class Node {
        private Object item;
        private Node next;

        private Node(Object i, Node n) {
            item = i;
            next = n;
        }
    }

    private Node head;     // dummy head node
    private int length;    // # of items in the list

    /**
     * Constructs a LLList object for a list that is initially empty.
     */
    public LLList() {
        head = new Node(null, null);
        length = 0;
    }

    /*
     * getNode - private helper method that returns a reference to the
     * ith node in the linked list.  It assumes that the value of the
     * parameter is valid.
     *
     * If i == -1, it returns a reference to the dummy head node.
     */
    private Node getNode(int i) {
        Node trav = head;
        int travIndex = -1;
        while (travIndex < i) {
            travIndex++;
            trav = trav.next;
        }
        return trav;
    }

    /** getItem - returns the item at position i in the list */
    public Object getItem(int i) {
        if (i < 0 || i >= length)
            throw new IndexOutOfBoundsException();
        Node n = getNode(i);
        return n.item;
    }

    /**
     * addItem - adds the specified item at position i in the list,
     * shifting the items that are currently in positions i, i+1, i+2,
     * etc. to the right by one.  Always returns true, because the list
     * is never full.
     *
     * We don't need a special case for insertion at the front of the
     * list (i == 0), because getNode(0 - 1) will return the dummy
     * head node, and the rest of insertion can proceed as usual.
     */
    public boolean addItem(Object item, int i) {
        if (i < 0 || i > length)
            throw new IndexOutOfBoundsException();

        Node newNode = new Node(item, null);
        Node prevNode = getNode(i - 1);
        newNode.next = prevNode.next;
        prevNode.next = newNode;

        length++;
        return true;
    }

    /**
     * removeItem - removes the item at position i in the list,
     * shifting the items that are currently in positions i+1, i+2,
     * etc. to the left by one.  Returns a reference to the removed
     * object.
     *
     * Here again, we don't need a special case for i == 0 (see the
     * note accompanying addItem above).
     */
    public Object removeItem(int i) {
        if (i < 0 || i >= length)
            throw new IndexOutOfBoundsException();

        Node prevNode = getNode(i - 1);
        Object removed = prevNode.next.item;
        prevNode.next = prevNode.next.next;

        length--;
        return removed;
    }

    /** length - returns the number of items in the list */
    public int length() {
        return length;
    }

    /**
     * isFull - always returns false, because the linked list can
     * grow indefinitely and thus the list is never full.
     */
    public boolean isFull() {
        return false;
    }

    /**
     * toString - converts the list into a String of the form
     * {item0, item1, ...}
     */
    public String toString() {
        String str = "{";

        Node trav = head.next;    // skip over the dummy head node
        while (trav != null) {
            str = str + trav.item;
            if (trav.next != null)
                str = str + ", ";
            trav = trav.next;
        }

        str = str + "}";
        return str;
    }

    /**
     * iterator - returns an iterator for this list
     */
    public ListIterator iterator() {
        return new LLListIterator();
    }

    /*
     *** private inner class for an iterator over an LLList ***
     */
    private class LLListIterator implements ListIterator {
        private Node nextNode;          // the next node to visit
        private Node lastVisitedNode;   // the most recently visited node

        public LLListIterator() {
            nextNode = head.next;
            lastVisitedNode = null;
        }

        /**
         * hasNext - does the iterator have additional items to visit?
         */
        public boolean hasNext() {
            return (nextNode != null);
        }

        /**
         * next - returns a reference to the next Object in the iteration
         */
        public Object next() {
            if (nextNode == null)
                throw new NoSuchElementException();

            Object item = nextNode.item;
            lastVisitedNode = nextNode;
            nextNode = nextNode.next;

            return item;
        }
    }
}
</code>```


答:
I would say data structures exist at least one level of abstraction below the programming language level, if not everywhere. That's because compilers and interpreters create data structures out of whatever source code you give them.

If you're more interested in whether one of these hidden intermediate steps (compiler, interpreter, etc.) use data structures you would recognize, the answer is also likely yes. Clojure implements arrays as trees "under the hood" for example.


问:
Introduction to testing
I am very new to the concept of testing and I had not yet have any experience with this.

At my company, no one does write tests as of now, neither is any test framework set up or anything. Also, we don't have testers. You bet how testing works: send new version to one customer, then wait for his call... if he hasn't called in for 24 hours to report bugs, call him and ask, and if the program seems to work, send it to the other customers. And then, wait for their calls...

Now, you can guess how much I like this. In fact, it's down to two options by now: either I can change my company, or I can change to another company. For both, I could use some background knowledge on testing, which I am collecting right now. But where to start?

A friend told me the basics on how his company does automated tests each night - a status I want to establish in our company as well. I asked him to find out which frameworks they use for unit tests and web tests, and he will find out for me, but I would also like to ask you which ones are recommended or even de-facto standard.

What we deliver are ExtJS applications which do CRUD operations on data via C# backends into MSSQL databases.

So I guess I would have to look for

a webtest framework, which "clicks" through the browser/webapp

an extjs/javascript unittest framework,

a C# unittest framework (I will have a closer look at VisualStudio UnitTests on Monday)

perhaps a framework which tests whether web calls give correct return values, and how web calls react to "garbage in"?

perhaps even an sql unittest framework for stored procedures?

What exactly would I really need; and what would be best/most useful to start with? (from the accepted answer here I read "webtest" it is, but then, testing web calls could be easier to start with!?)

Are recommendable low-cost/no-cost frameworks available, or are there frameworks which provide a limited no-cost version, so I can try whether it suits my/our needs before I go to my boss for funding?

Where can I start finding information, are there good books on testing?

答:
This is all general, not specific to your needs.

Random stuff I learned from the process of adding unit tests to my C++ project (not all from personal experience):

integration tests are not like unit tests. There are a lot of harnesses that only support unit tests, not integration tests. The same script that calls your test harness should also run a code formatter and error out if it makes a diff.

A properly-written make test will be able to only rerun tests if the relevant code has been changed. Hint: each test binary outputs a log file (more useful than a stamp file).

a good test framework supports process-level isolation and splits the responsibility of choosing tests and recording their results from actually running them. TAP, which originated from perl, is a good example of doing this and is usable for any language.

Use a freaking CI service with a matrix. This is useful even without any testsuite, to catch compiler errors that only occur with one compiler version.

If your matrix is too big, or if your CI bot is taking to long for a single matrix entry, maybe you have too many bundled libraries. Even if it's a library specifically written for this project, if it is isolated enough to be a separate repo with its own CI builds (which indirectly generate binaries for use in your main project's CI builds), it should be. If it is not isolated enough, make it so.

it's impossible to unit test in the presence of global variables. Kill them with fire. If killing them is too hard, at least isolate them into a single Globals globals object per library/binary. But libraries should never expose an API that relies on globals anyway.

realistically, you won't add tests to all your old code. Rather, add tests both when writing new code and when bug reports come in.

when writing new code, first quickly write some code so you get an idea of what you really need, then delete it all and write unit tests, then build an implementation as necessary to pass the unit tests. This ends up being a lot easier.

your tests can and will rely on implicit assumptions about the class/function they're testing, but the tested class/function will be changed by an idiot someday (probably you).

My general advice is: do not tie yourself to one particular technology. You have special needs, write a little code that works with your code instead of twisting around to fit in a framework. TAP is particular good at letting you write your own glue instead of forcing you to use legos, and even letting you call out to other test harnesses.

Title: Introduction to testing


问:
Pattern to gain abstraction over assembly with no abstraction
I'm interacting with a large code base (in a single assembly) written by another department (let's call it BusinessAssembly). Precious few of the objects we need to use in that assembly use interfaces. As a result, LOTS of our projects need to reference that assembly because there is no abstraction available and tests are difficult to write.

To further complicate matters, it now looks as though we may need to be able to support multiple versions of the BusinessAssembly and switch between them either at build-time or run-time. E.g. BusinessAssembly2 will add new objects which we'll need to use, but BusinessAssembly1 won't contain those objects.

My only promising solution so far is to create two separate projects in our solution, one that references BusinessAssembly1 (BusinessProxy1) and another that references BusinessAssembly2 (BusinessProxy2). These projects would contain proxies and decorators around the individual BusinessAssembly objects (e.g. BusinessUserProxy), and those proxies and decorators would implement interfaces (IBusinessUserProxy).

If I've thought this through correctly, an abstract factory could then provide the requested proxy/decorator object from the correct proxy/decorator project at run-time and our other projects could abandon their references to the giant assembly and simply use the interfaces the various proxies/decorators implement.

I'm not trying to alter the behaviour of the objects, but another consideration here is that we would like to gain the ability to provide test doubles for the various BusinessAssembly objects, which this approach should provide.

However, this approach does come with a considerable amount of development overhead: when BusinessAssembly3 creates ten new objects, we'll need to write proxies and interfaces for each of those.

My question(s): Is it an acceptable use of proxies to merely provide an interface for an object that otherwise has no interface? Would a different approach avoid the development overhead?

Also, I'm terribly ill right now so let me know if I'm not being clear or if I didn't actually even type any real words here.

答:
If BusinessAssembly2 contains all of BusinessAssembly1's public members, then you could write one or more Interfaces for that subset of members, which could be used as a constructor parameter in one or more Facade classes, thereby providing Dependency Injection. That would allow you to switch between either version of the underlying business assemblies at either design time or runtime, as needed.

It would also allow you to build test classes that implement those interfaces, and pass those into your Facade for testing purposes.

You'd still need to create or extend your Interfaces and Facade classes when BusinessAssembly3 came out. I don't see any way around that, unless using the new classes directly is acceptable.

If those business assemblies are large, you could save yourself a lot of tedious manual work by building a little code generator that inspected them via Reflection and output Interfaces and Facade classes.


答:
Here are a few suggestions to at least get you started. Everything listed here is free.

a webtest framework, which "clicks" through the browser/webapp - Selenium

an extjs/javascript unittest framework - Jasmine or Mocha

a C# unittest framework - NUnit

perhaps a framework which tests whether web calls give correct return values, and how web calls react to "garbage in"? - NUnit, implemented as tests calling the web services and verifying expected responses

perhaps even an sql unittest framework for stored procedures - NUnit, implemented as tests calling the stored procs and verifying the expected results (either from the stored proc output, or with follow-up queries to confirm expected data changes)

By the way, I worked at a company that was nearly clueless about automated/programmatic testing (testing was done manually or not at all). But I threw together an automated UI regression test using Selenium, and it blew them away. Sometimes people just need a good demonstration.

Title: Introduction to testing

Body:
I am very new to the concept of testing and I had not yet have any experience with this.

At my company, no one does write tests as of now, neither is any test framework set up or anything. Also, we don't have testers. You bet how testing works: send new version to one customer, then wait for his call... if he hasn't called in for 24 hours to report bugs, call him and ask, and if the program seems to work, send it to the other customers. And then, wait for their calls...

Now, you can guess how much I like this. In fact, it's down to two options by now: either I can change my company, or I can change to another company. For both, I could use some background knowledge on testing, which I am collecting right now. But where to start?

A friend told me the basics on how his company does automated tests each night - a status I want to establish in our company as well. I asked him to find out which frameworks they use for unit tests and web tests, and he will find out for me, but I would also like to ask you which ones are recommended or even de-facto standard.

What we deliver are ExtJS applications which do CRUD operations on data via C# backends into MSSQL databases.

So I guess I would have to look for

a webtest framework, which "clicks" through the browser/webapp

an extjs/javascript unittest framework,

a C# unittest framework (I will have a closer look at VisualStudio UnitTests on Monday)

perhaps a framework which tests whether web calls give correct return values, and how web calls react to "garbage in"?

perhaps even an sql unittest framework for stored procedures?

What exactly would I really need; and what would be best/most useful to start with? (from the accepted answer here I read "webtest" it is, but then, testing web calls could be easier to start with!?)

Are recommendable low-cost/no-cost frameworks available, or are there frameworks which provide a limited no-cost version, so I can try whether it suits my/our needs before I go to my boss for funding?

Where can I start finding information, are there good books on testing?


问:
is there anything called logical schema and the conceptual schema of a database table?
i want to know whether there is anything called logical schema and the conceptual schema of database table. if so what is it.i searched lot of places for this specific two words, but did not find anything helpful.i would be grateful to anyone who provide me definition with an example.Thank you :)</p>

答:
Disclaimer: This is just a personal interpretation based on how I think most people generally use those terms.

A conceptual schema is more of a "rough draft", basically just trying to identify the key tables that would be needed, perhaps a few key columns for each, and how they would relate to one another. This might happen in the early analysis phase, or during a high-level design phase.

Later on, in the more detailed design phase, a logical schema would be an attempt to identify all of the tables and columns that will be needed. Maybe not the "final draft", but much closer to it.

Below is a simplified example of each.

Conceptual Schema example:

Tables:

Customer (id, name)

Product (id, sku, name, price)

OrderHeader (id, date, customer id)

OrderItem (id, order header id, product id, quantity)

Relationships:

1 Customer : 0..* OrderHeader

0..* Product : 0..* OrderItem

1 OrderHeader : 1..* OrderItem

Logical Schema example

Customer (CustomerId, Name, CreatedOn)

CustomerAddress (CustomerAddressId, CustomerId, StreetAddress1, StreetAddress2, City, State, Zip)

CustomerPhone (CustomerPhoneId, CustomerId, PhoneNumber, Extension)

Product (ProductId, SKU, Description, Size, Price)

OrderHeader (OrderHeaderId, CustomerId, DatePlaced, Status)

OrderItem (OrderItemId, OrderHeaderId, ProductId, Quantity)


问:
How should I break this user story into tasks
I am trying to understand how to create user stories and tasks. I have read articles stating that you should create small user stories and they should be a "vertical slice" of functionality instead of a "horizontal slice".

I have a user story:

As a buyer I want to add items to the shopping cart so that I later can buy the items.

From my understanding tasks should be the things you have to do in order to complete this user story. Am I right if the tasks should also be created as "vertical slices" instead of "horizontal". Instead of creating a task for "create shopping cart model" I would have a task "Update shopping cart service to be able to add products".

But with that task I only have one task, is it to big, should it be broken down in another way? Is it bad that a user story only have one task?

答:
When we talk about a vertical slice of functionality, we're talking about the user story only.

Tasks are broken down in to whatever the development team feels appropriate, to complete the story.


问:
2D Game Data Structure in OpenGL ES 2.0
I'm trying to come up with some data structures for rendering my map on OpenGL. It is going to be ~ 100x100 blocks(squares) total, with each block being around 100 pixels. However, the screen will only display about 20x10 of these blocks at a time, depending on character location. So from this post:

https://stackoverflow.com/questions/19979031/android-only-game-in-opengl-performance-in-c-ndk-vs-java-dalvik?newreg=53760d542cb94d05afe42faa39d1aef6

It says that I shouldn't do a lot of allocation with ByteBuffers. So here are approaches I came up with:

Allocate all 10,000 blocks, and simply change the vertices on every frame, for the ones I need to display. So no dynamic allocation, but a lot of up-front space.

Only allocate blocks as I need them. So if in a frame I move left, and have to display new blocks, I will allocate 10 blocks in OpenGL. That way I have less memory allocated at once. However there is dynamic allocation and I need to set up the textures on every frame.

Cache a few blocks of each type, and update the vertex information for them as I need them, that way I don't need to allocate a lot in the beginning, and I don't need to allocate anything dynamically. (So have 100 wall blocks, 100 door blocks, 100 floor blocks, all set up from the beginning)

Are any of these approaches the right way to go about doing this? Or how would one go about displaying a bunch of Bitmaps and updating their location on every frame? Or is Java a bad idea from the beginning, even for a simple 2D game?

答:
~10,000 textured quads is on the order of ~1MB. While max buffer size varies by GPU, 1MB should be no problem.

On the other hand, while repeatedly uploading geometry data to the GPU generally isn't advisable, you could easily get away with it in this case, with only ~200 quads visible at a time.

So I expect either approach would be fine, unless you're targeting extremely low-end devices.

If you did have a ton of geometry, and too much visible in one screen to upload it repeatedly, you could divide the geometry into several block regions and allocate/deallocate buffers as regions become visible or invisible.

Title: 2D Game Data Structure in OpenGL ES 2.0


答:
I think you might be approaching this the wrong way - walking into your bosses office and slamming down fact sheets on why it's important that you be allowed to work in your boxers is probably not going to impress anyone.

As Jon stated, this is a trust issue, but it's also a negotiation.  You need to spend some time with your boss to understand their vantage point in this argument.  It's possible he/she's had a very negative experience previously, or heard about a negative result of this policy from their colleagues.  You need to attack first, and remember that it's all about what you can offer your boss.  Perhaps he/she is worried that you won't get your tasks done -- maybe work in a mandatory stand-up session at the beginning of the day, or convince your fellows to provide specific updates at the end of the day to show what work was completed.  Offer a one-month trial and shave a little more time off of the last estimate you gave -- you'll have to work a little harder but you "should" have extra time now.  If you still cannot get them to agree -- look at allowing at least one or two days a month for "emergency" telecommuting (snow-days, sickness, Godzilla, etc).

Also (as stated previously) don't call it WFH (bad/soft connotation) -- it's telecommuting.


问:
What was the influence of Chris Okasaki's data structures on Scala?
I heard a friend say:

The first real use of Chris Okasaki's book was in Clojure's data structures

I heard another friend say:

No, they influenced the design of Scala in quite a subtle way.

My question is: What was the influence of Chris Okasaki's data structures on Scala? (An assumption is that this is a pre-Scalaz influence)

答:
Your friends comment

First of all, it is definitely not correct what your friend is stating. Okasaki's book has had a major influence on data structures in several languages.

Influence

First of all, I think that we can categorize "influence" as one of either:

Direct influence: Some programming language is implementing some of the data structures that are described.

Indirect influence: The data structures in a language are built using techniques described in the book, but might not be the actual data structures that are described.

In both cases, people can use the described data structures or a similar one, without actually having read his book directly. But when it comes to functional data structures, most people tend to read Okasaki's book.

Okasaki's influence on Scala

The Scala standard library offer both mutable and immutable collections. Obviously, only the immutable ones could be derived from Okasaki's work, so let us take a look at those:

List: A normal cons list (singly linked list). This concept has been widely known forever (almost) and generally widely used in almost all functional languages.

Stack: Just another abstraction put onto the list above. Nothing particularly Okasaki'ish here.

Queue: Scala's immutable queue is a "naive" implementation using using two lists. Although described in Okasaki's book, this queue structure was not something that was novel when the book came out. The problems with this data structure is that is that it can be potentially slow in a persistent setting, which Okasaki improves upon in his book - but it seems Scala has stuck with this implementation due to simplicity and raw speed.

Stream: A lazy memoized list. This is described in Okasaki's book, but is not something that was novel at the time.

TreeSet/TreeMap: An immutable red/black-tree. Again, this is described in Okasaki's book, but was widely known before that as well.

HashSet/HashMap/Vector: All are based on Phil Bagwell's Hash Array Mapped Tries. The vectors are similar to what you find in Clojure. Although tries are briefly described by Okasaki, they were known before, and this data structure is quite far from anything else described in there.

ListSet/ListMap/BitSet: Not described in Okasaki's book, as far as I remember.

As you can see, most of the data structures used precede Okasaki's book - and in that respect it does not fall under either the category direct or indirect influence as such.

Nevertheless, it would be naive to think that Okasaki's book hasn't influenced Scala at all. Okasaki's description of immutable red/black-trees is more a less the go-to guide for implementing these functionally. Purely Functional Data Structures really gathers a lot of material that would otherwise only be found in various research papers - so what I would really assume, would be that the book probably helped the developers into making the decisions that best fit the language.


问:
Use case diagram : distingishing the actor of a use case
I know a system contains a set of use case diagrams and not one use case diagram, but anyway in the first step to find the system requirements or to analyze them I have problem in distinguishing the actor of a use case.

suppose the system is : Library

one actor is the Member
and one actor is the Librarian.

a typical use case is Borrow a book

Suppose the one who interacts with the software is Librarian. Then borrow a book should be associated with librarian or the member?

In fact Borrow a book use case is a service of the system for the member. but the actor who interacts with it is the librarian.

In which stage and in which use case diagram I should use the member as actor and associate it with the Borrow a book use case? and in which diagram I should associate it with the librarian?

Also the librarian is really an actor of the system or its part of a system?

答:
Remember the definition of an actor: an entity that interacts with your system. The librarian is the one who is actually interacting with the system (the library), whereas the member is just requesting the librarian for a book, and does not care where the hell that book comes from. Then the member is an actor on the librarian, who is a system in herself.

The librarian: a system, actor on the library

Library: a system

Member: an actor on the librarian


问:
Begin and Finish or Pre and Post in async call pair?
In an async call pair you would rather have a BeginDoSomething & FinishDoSomething or PreDoingSomething & PostDoingSomething pair?

Cheers

答: I prefer pre and post but those are naming conventions that are personal preference. There is not right or wrong.


答:
In most cases both the librarian and the member could be seen as actors: the librarian is the primary actor and the member is the secondary actor.

The librarian is the primary actor: he fulfills the use case.

The member is needed for giving his library card to the librarian: without him/her there is no use case. And the member receives the book.

So they are both actors, but with a different importance to the use case.

Another example: If the borrowing system is automated, then the member is the only actor and the librarian is not needed to borrow the book. The member will trigger the use case, and the librarian only helps when necessary.

Title: Use case diagram : distingishing the actor of a use case

Body:
I know a system contains a set of use case diagrams and not one use case diagram, but anyway in the first step to find the system requirements or to analyze them I have problem in distinguishing the actor of a use case.

suppose the system is : Library

one actor is the Member
and one actor is the Librarian.

a typical use case is Borrow a book

Suppose the one who interacts with the software is Librarian. Then borrow a book should be associated with librarian or the member?

In fact Borrow a book use case is a service of the system for the member. but the actor who interacts with it is the librarian.

In which stage and in which use case diagram I should use the member as actor and associate it with the Borrow a book use case? and in which diagram I should associate it with the librarian?

Also the librarian is really an actor of the system or its part of a system?