答:
Absolutely not - you're thinking this from the wrong point of view. You didn't get the job because you've gotten "better, you didn't get it because you really didn't fit their startup attitude. (at least that's what it appears from the limited info you've given us).

You do have to fit with the company values, and if they're a startup then you should be emphasising fast development, cool toys, getting stuff delivered. Doing things "correctly" is not part of their plan, so shouldn't be your either. Its like going to a financial services company and wanting to bang out code rather than attend compliance review meetings and plan things to the nth degree.

So, "better" is entirely subjective.. you could have said "older and wiser". Note that interviewers tend to decide if you're a good fit almost immediately - 30 seconds or so - so if they've decided at that point, then there's no reason to keep you hanging around and waste everyone's time if they were not going to offer you the job anyway.

So to come across better in the future - take the coding tasks, but make sure they know you're attitude towards them is that they don't tell anything about your fuller abilities, you need to make sure they know you can do more than just code, you have good analysis and design skills, can lead and inspire others too, and that a coding task is just a warm up thing you do just to tick the interview box before you get to the real discussions. Think of yourself as more businessman rather than code nerd because as you get older, companies do not want you to sit in the corner like a 20 year old coding, they expect much more from you, more social skills, more business skills.

Obviously this doesn't always apply - you can end up going to crappy jobs with idiots who don't know what they want. In such cases, it's up to you to tease out of them what they're really after and gently guide the interview. If you can blow through the code test, and that upsets them, just say that it was something you've done recently and it was in your head already - like those trick puzzle questions that are really easy if you've already read the answer.


问:
User Acceptance Testing Defect Classification when developing for an outside client
I am involved in a large development project in which we (a very small start up) are developing for an outside client (a very large company).

We recently received their first output from UAT testing of a fairly small iteration, which listed 12 'defects', triaged into three categories : Low, Medium and High.

The issue we have is around whether everything in this list should be recorded as a 'defect' - some of the issues they found would be better described as refinements, or even 'nice-to-haves', and some we think are not defects at all.

They client's QA lead says that it is standard for them to label every issues they identify as a defect, however, we are a bit uncomfortable about this. Whilst the relationship is good, we don't see a huge problem with this, but we are concerned that, if the relationship suffers in the future, these lists of 'defects' could prove costly for us.

We don't want to come across as being difficult, or taking things too personally here, and we are happy to make all of the changes identified, however we are a bit concerned especially as there is a uneven power balance at play in our relationship.

Are we being paranoid here? Or could we be setting ourselves up for problems down the line by agreeing to this classification?

答:
What you need to understand is that in large corporations, there needs to be a clearly defined process, or else everyone's off doing their own thing, and team A doesn't know what Team B's definition of "defect" is.  So, there's probably a pretty strict classification system, so that teams can instantly know what other teams are talking about.

However, this doesn't mean that those terms should have any meaning at your organization.  In fact, just because it's a high priority for them doesn't necessarily mean it has to be a high priority for you (I know that's scary to think about because they're probably a huge customer).  In their eyes, whenever it does something unexpected, it's a defect, whether that unexpected is as designed or not.  Also, if you have complex software, it can be easy to get confused about how things are supposed to work.  I wish our bug tracking software had a closing reason of "You're not doing it right."

For instance, at my company last week (we're not a custom development shop, we have actual software products), a customer submitted a bug through their account rep, and acted like it was an actual bug, i.e., the product didn't work correctly.  I explained that the product worked as designed and as in the contract, what they wanted was an enhancement.  That's not as scary for management as "bug" or "defect".

Just make sure that you don't "fix" defects that are out of the scope of the project.  That's how you get mooching customers that assume you'll do everything for free.

ContentLicense: CC BY-SA 3.0


问:
Do other developers feel that as they get better, it becomes harder to get jobs?
When I was starting out, it seemed I had a much better time getting interviews and passing them. But now that I'm more experienced, I'm finding that its harder and harder to find a job. Do other developers out there feel the same way?

I'll give you an example. I did an interview last Wednesday. It was a small start-up with only one other engineer and the CEO. They flew me in from Ohio (they are SF based). When I got there, they had me write them a link shortener, which took me about 10 minutes to write. I was supposed to be there all day working on this. When I finished it early, the interviewer seemed kind of shocked. After that, we were talking, and I asked him what they use to store data. He told me Mongo. I ask why he decided to use mongo. He then stammered and mumbled his answer, which basically boiled down to "We're using it because Mongo is a the trendy database technology and we don't want to be left out", which I've found is pretty much most common reason people use NoSQL these days. The interviewer quickly ended the interview and pretty much shoved me out the door. I was supposed to have lunch with the CEO, but I he kicked me out before I had a chance. The intervier wasn't mean or rude, (and neither was I).

After I got back to Ohio, I got an email from them saying "I wasn't a fit". This sot of thing happens to me all the time. I'm starting to think "not a fit" can sometimes mean "are too high of a skill level that we are". Is this all in my head, or do other experienced developers notice the same thing happening? Back when I used to struggle with coding problems, I would work with the interviewer and it would be a positive thing and I'd get hired. But now I usually blow through the coding part, and the interviewer being left speechless is working against me. Should I feign struggling with coding problems?

答:
It may be that, over time, you've worked out what your strengths are and that the evidence of that is visible.  Less-experienced candidates tend to be willing to take on whatever subjects they encounter, using whatever tools are available, whereas experience is built on some degree of specialization and preference.

The other corporate attitude that weighs against people with specific talents is a twisted definition of 'team'.  Instead of viewing a team as a collection of people with varying talents that can be combined to achieve a goal, some see it as a box of interchangeable parts.  If I were staffing a start-up, I'd be looking for people who were better than me at things I don't do well rather than slightly less-competent clones.  However, I have met employers who, by their actions, are 180 degrees off that position.


问:
What's the first thing you write when trying out a new language?
I think everyone has their own program or set of features beyond "Hello World!", that they use when trying out a new language.

Mine is a guessing game:

```<code>I'm thinking of a number 1-10, guess what it is!
Guess: 3
Nope, too low!
Guess: 7
Nope, too high!
Guess: 5
Yes, You win!
Play again (Y/N)? N
</code>```

What do you write?

答: Whatever I needed to write in the new language in the first place.</p>

ContentLicense: CC BY-SA 2.5


问:
Data Flow Diagrams - Difference between Lines and Arrows
I'm currently working with Visio to create Data Flow Diagrams for a System Analysis and Design class but I'm unsure what the difference between ------ and ------> is. I can connect 2 shapes together with a line (process, entity, data store) but does the single line connecting the two mean data flow? Do I need to explicitly use the data flow arrow to show which way data is flowing?

(There doesn't seem to be tags for this topic, maybe im in the wrong place?)

答:
<img src="https://i.stack.imgur.com/1U0ae.png

yes,single line having arrow connecting the two enties is data flow

 arrow is used for show data flow between two entities & only line but two lines in parallel is used for indicating data stores

OwnerDisplayName: Ravindra bagale


答: A single line is not part of Data Flow Diagramming standard symbols. An Arrow is. Visio is a drawing tool, it does not enforce the diagramming standards.</p>

Title: Data Flow Diagrams - Difference between Lines and Arrows

Body:
I'm currently working with Visio to create Data Flow Diagrams for a System Analysis and Design class but I'm unsure what the difference between ------ and ------> is. I can connect 2 shapes together with a line (process, entity, data store) but does the single line connecting the two mean data flow? Do I need to explicitly use the data flow arrow to show which way data is flowing?

(There doesn't seem to be tags for this topic, maybe im in the wrong place?)


答:
Yes, you could set yourselves up for trouble by blindingly accepting the client classifications of bugs/defects/features/they-don't-know-what-they-want/requirements. As Greg Bair points out, there are cases where "You are doing it wrong" is the issue not the actual software.

These most often come up because the persons who define the requirements don't use the software day-to-day. One thing to help mitigate this would be to establish a channel to get direct user feedback instead of through the Sustainment/Support teams.

Ideally, your team would have a chance to talk to the individuals who entered the defects so you can extract specifics. Often times simply talking with the individual and explaining why something does what it does(even saying the requirements say it must) can get them to back of a defect.

Title: User Acceptance Testing Defect Classification when developing for an outside client

Body:
I am involved in a large development project in which we (a very small start up) are developing for an outside client (a very large company).

We recently received their first output from UAT testing of a fairly small iteration, which listed 12 'defects', triaged into three categories : Low, Medium and High.

The issue we have is around whether everything in this list should be recorded as a 'defect' - some of the issues they found would be better described as refinements, or even 'nice-to-haves', and some we think are not defects at all.

They client's QA lead says that it is standard for them to label every issues they identify as a defect, however, we are a bit uncomfortable about this. Whilst the relationship is good, we don't see a huge problem with this, but we are concerned that, if the relationship suffers in the future, these lists of 'defects' could prove costly for us.

We don't want to come across as being difficult, or taking things too personally here, and we are happy to make all of the changes identified, however we are a bit concerned especially as there is a uneven power balance at play in our relationship.

Are we being paranoid here? Or could we be setting ourselves up for problems down the line by agreeing to this classification?


问:
Torvalds' quote about good programmer
Accidentally I've stumbled upon the following quote by Linus Torvalds:

"Bad programmers worry about the code. Good programmers worry about
  data structures and their relationships."

I've thought about it for the last few days and I'm still confused (which is probably not a good sign), hence I wanted to discuss the following:

What interpretation of this possible/makes sense?

What can be applied/learned from it?

答:
I find myself writing new functions and updating existing ones a lot more often than having to add new columns or tables to my database schema.
This is probably true for all well designed systems. If you need to change your schema every time you need to change your code, its a clear sign you are a very bad developer.

quality of code indicator = [code changes] / [database schema changes]

"Show me your flowcharts and conceal your tables, and I shall continue to be mystified. Show me your tables, and I won’t usually need your flowcharts; they’ll be obvious." (Fred Brooks)

Title: Torvalds' quote about good programmer


问:
What do ptLineDist and relativeCCW do?
I saw these methods in the Line2D Java Docs  but did not understand what they do?

Javadoc for ptLineDist says:

Returns the distance from a point to this line. The distance measured is the distance between the specified point and the closest point on the infinitely-extended line defined by this Line2D. If the specified point intersects the line, this method returns 0.0

Doc for relativeCCW says:

Returns an indicator of where the specified point (PX, PY) lies with respect to the line segment from (X1, Y1) to (X2, Y2). The return value can be either 1, -1, or 0 and indicates in which direction the specified line must pivot around its first endpoint, (X1, Y1), in order to point at the specified point (PX, PY).

A return value of 1 indicates that the line segment must turn in the direction that takes the positive X axis towards the negative Y axis. In the default coordinate system used by Java 2D, this direction is counterclockwise.

A return value of -1 indicates that the line segment must turn in the direction that takes the positive X axis towards the positive Y axis. In the default coordinate system, this direction is clockwise.

A return value of 0 indicates that the point lies exactly on the line segment. Note that an indicator value of 0 is rare and not useful for determining colinearity because of floating point rounding issues.

If the point is colinear with the line segment, but not between the endpoints, then the value will be -1 if the point lies "beyond (X1, Y1)" or 1 if the point lies "beyond (X2, Y2)".

答:
ptLineDist is the shortest distance between a point and a line.

One trick to note is that it's an infinitely extended line, which means that the line is extended out to infinity in either direction and then the distance between the line and point is determined.

I don't do 2D programming work, but this could be handy if I were trying to determine how far an object (defined by a reference point) was from the horizon line of another object.

relativeCCW tells you which direction a line would have to rotate in order to direct itself at a point.  (I really wanted to say "point at a point" there).

I think their definitions of clockwise / counterclockwise are backwards, but whatever, at least they're defined.  I would experiment and validate the results.

This could be useful if I had a vector or an arrow and wanted to see which direction it needed to rotate from its base in order to align with my point.  So, if I were writing a compass application, I could keep track of which way to rotate to get to North.

Title: What do ptLineDist and relativeCCW do?


问:
What happens at control invoke function?
A question about form controls invoke function.

Control1  is created on thread1.
If you want to update something in Control1 from thread2
you must do something like:

```<code>delegate void SetTextCallback(string txt);

void setText(string txt)
{
  if (this.textBox1.InvokeRequired)
  {
     SetTextCallback d = new SetTextCallback(setText);
     this.Invoke(d, new object[] { txt });
  }
  else
  {
     // this will run on thread1 even when called from thread2
     this.textBox1.AppendText(msg);
  }
}`
</code>```

What happens behind the scenes here?

This invoke behaves different from a normal object invoke.
When you want to call a function in an object on a specific thread, then
that thread must be waiting on some queue of delegates, and execute
the incoming delegates.

Is it correct that the windows forms control invoke function
is completely different from the standard object invoke
function?

答:
To prevent thread issues, many Windows Forms operations have to happen on the UI thread. Invoke provides an easy way of accomplishing this without explicit thread management.

If you are curious about the internal workings, I would download a decompile tool (I believe Telerik JustDecompile is free) and look at System.Windows.Forms.Control.Invoke in the System.Windows.Forms DLL in the GAC.

BTW, it looks like it loads a reference to the UI thread and invokes your code in its environment.


问:
Has Little Endian won?
When teaching recently about the Big vs. Little Endian battle, a student asked whether it had been settled, and I realized I didn't know. Looking at the Wikipedia article, it seems that the most popular current OS/architecture pairs use Little Endian but that Internet Protocol specifies Big Endian for transferring numeric values in packet headers. Would that be a good summary of the current status? Do current network cards or CPUs provide hardware support for switching byte order?</p>

答:
I'd argue that it's not so much won as ceased to matter. ARM which makes up basically all of the mobile market is bi-endian (oh, the heresy!). In the sense that x86 basically "won" the desktop market I suppose you could say that little endian won but I think given the overall code depth (shallow) and abstraction (lots) of many of today's applications, it's much less of an issue than it used to be. I don't recall endianness really coming up in my Computer Architecture class.

I suspect that many developers aren't even aware of endianness or why it's important. Because for the vast (and I mean vast) majority it's utterly irrelevant to their daily working environment. This was different 30 years ago when everyone was coding much closer to the metal as opposed to manipulating text files on a screen in fancy and dramatic ways.

My general suspicion is that Object Oriented Programming was the beginning of the end of caring about endianness since the layers of access and abstraction in a good OO system hide implementation details from the user. Since implementation includes endianness, people got used to it not being an explicit factor.

Addendum: zxcdw mentioned portability being concern. However, what has arisen with a vengeance in the last 20 years? Programming Languages built on virtual machines. Sure the virtual machine endianness might matter but it can be made very consistent for that one language to the point where it's basically a non-issue. Only the VM implementors would even have to worry about endianness from a portability standpoint.

Title: Has Little Endian won?


答: It seems like this idea has various interpretations in the various types of programming. It holds true for systems development and also holds true for enterprise development. For example, one could argue that the sharp shift in focus toward the domain in domain-driven design is much like the focus on data structures and relationships.</p>

Title: Torvalds' quote about good programmer

Body:
Accidentally I've stumbled upon the following quote by Linus Torvalds:

"Bad programmers worry about the code. Good programmers worry about
  data structures and their relationships."

I've thought about it for the last few days and I'm still confused (which is probably not a good sign), hence I wanted to discuss the following:

What interpretation of this possible/makes sense?

What can be applied/learned from it?


问:
Why are invariants important in Computer Science
I understand 'invariant' in its literal sense. I also recognize them when I type code. But I don't think I understand the importance of this term in the context of computer science.

Whenever I read conversations\white papers about language design from famous programmers\computer scientists, the term 'invariant' keeps popping up as a jargon; and that is the part I don't understand. What is so special about it?

答: In the context of a programming language's type system, an invariant type is a non-convertible type. For example in java, when overloading a method, all parameters are invariant, while the return type is covariant (may be the same or a subtype).</p>


问:
Unit testing and Test Driven Development questions
I'm working on an ASP.NET MVC website which performs relatively complex calculations as one of its functions.

This functionality was developed some time ago (before I started working on the  website) and defects have occurred whereby the calculations are not being calculated properly (basically these calculations are applied to each user which has certain flags on their record etc).

Note; these defects have only been observed by users thus far, and not yet investigated in code while debugging.

My questions are:

Because the existing unit tests all pass and therefore do not indicate that the defects that have been reported exist; does this suggest the original code that was implemented is incorrect? i.e either the requirements were incorrect and were coded accordingly or just not coded as they were supposed to be coded?

If I use the TDD approach, would I disgregard the existing unit tests as they don't show there are any problems with the calculations functionality - and I start by making some failing unit tests which test/prove there are these problems occuring, and then add code to make them pass?

Note; if it's simply a bug that is occurring that can be found while debugging the code, do the unit tests need to be updated since they are already passing?

答:
Short Answer: Most probably unit tests are not well designed to cover the critical calculation scenarios. In addition, there might be business rule modifications/changes that are not covered in the existing unit tests, because of million reasons that one may face in a tightly scheduled development environment.

As was also mentioned:

Automatic unit testing doesn't imply that the final tests will cover all cases and code will be absolutely correct and bug-free. It is easy not to see some complex use-cases and possible bug.

There might be million reasons why it is NOT done right. My point is that you need to cover these cases with product owner, and then go through each unit test and verify the implementation by applying correct naming of each unit test, as well as by adding the missing once.

If I use the TDD approach, would I disgregard the existing unit tests as they don't show there are any problems with the calculations functionality - and I start by making some failing unit tests which test/prove there are these problems occuring, and then add code to make them pass?

TDD  (Test-driven development) will for sure help, but i would NOT discard the current set of unit tests as far as they do what they supposed to be doing.


问:
Review before or after code commit, which is better?
Traditionally we performed code review before commit, I had an argument with my colleague today, who preferred code review after commit.

First, here's some background,

We have some experienced developers and we also have new hires with almost zero programming experience.

We'd like to perform fast and short iterations to release our product.

All team members are located at the same site.

The advantages of code review before commit I've learned:

Mentor new hires

Try to prevent errors, failures, bad designs early in the development cycle

Learn from others

Knowledge backup if someone quits

But I've also had some bad experiences:

Low efficiency, some changes may be reviewed over days

Hard to balance speed and quality, especially for newbies

One team member felt distrust

As to post-commit review, I know little about this, but the thing I'm most worried about is the risk of losing control due to lack of review.
Any opinions?

UPDATE:

We're using Perforce for VCS

We code and commit in the same branches (trunk or bug fixing branches)

To improve efficiency, we've tried to split code into small changes. We've also tried some live dialog review, but not everyone followed the rule. This is another problem though.

答:
Just don't do code reviews at all. Either you believe your developers are capable of writing good code, or you should get rid of them. Errors in logic should be caught by your automated tests. Errors is style should be caught by lint and static analysis tools. </p>

<p>Having humans involved in what should be automatic processes is just wasteful. </p>

Body:
Just don't do code reviews at all. Either you believe your developers are capable of writing good code, or you should get rid of them. Errors in logic should be caught by your automated tests. Errors is style should be caught by lint and static analysis tools.

Having humans involved in what should be automatic processes is just wasteful.


答:
Are we being paranoid here? Or could we be setting ourselves up for problems down the line by agreeing to this classification?

This sounds to me as Client management topic/issue.

It seems that your development approach is using Agile/Scrum methodology which is the very correct for this type of client. However, your product owner may better know what is the client's real need and essential expectations - which should be the high priority to be included in the development and sprint planning.

Your approach to log all medium and lower level defects is important, because you may include them in other iterations or deliverable phases of the product. Thus, it comes to my previous point that product owner's clean understanding of essential business requirements is the key factor that you should take into account.


问:
What is meant by a "First Class Protocol"
The Node.js about page describes HTTP as being a "first class protocol" within node.js.  What does this mean?

http://nodejs.org/about

答: "First class" usually means that it has extensive support and will probably supported for quite some time before being dropped. It also means many things in the framework will bend to allow this support.</p>


问:
How to manage document format changes with local storage?
I'm programming a Javascript application which saves "documents" in localStorage. As the app evolves, naturally there are changes in the document format.

I've tried searching but not found anything – probably (at least partly) because of search term ambiguities.

What is a good practice in managing document format versions/upgrades with local storage implementation approach?

答:
One answer I see used in various languages is to version each stable format.  Later, when you change to a new format you write a translator that reads the older format and converts it to the new when loaded.

The translator is not only responsible for repackaging the data into the new format but also providing sensible defaults for new properties or merging extinct properties into existing ones if their meaning isn't meant to be lost.

You can keep creating new versions as long as you keep writing matching translators, the conversions will then happen serially from the first match up to your most recent (eg. v1 -> v2 -> v3 -> v4).

When the new data is saved out it automatically is set to the latest version.  In this way writing a utility to bulk-translate all old data (for major releases) is as simple as a loop:

```<code>while files
    read file
    write file
end while
</code>```

Body:
One answer I see used in various languages is to version each stable format.  Later, when you change to a new format you write a translator that reads the older format and converts it to the new when loaded.

The translator is not only responsible for repackaging the data into the new format but also providing sensible defaults for new properties or merging extinct properties into existing ones if their meaning isn't meant to be lost.

You can keep creating new versions as long as you keep writing matching translators, the conversions will then happen serially from the first match up to your most recent (eg. v1 -> v2 -> v3 -> v4).

When the new data is saved out it automatically is set to the latest version.  In this way writing a utility to bulk-translate all old data (for major releases) is as simple as a loop:

while files
    read file
    write file
end while


问:
How to get multiple open-source projects to use a standard way of doing something
- Problem

In the last couple weeks, I've used 3 different "repository" tools (listed in alphabetical order):

gradle

ivy

maven

I'm calling them "repository" tools because I've also used sbt -- which fortunately uses ivy to manage it's cache or local repository.

Each of these tools will create it's own repository. The defaults are:

~/.m2/repository for maven

~/.gradle/cache

~/.ivy2/cache

Why can't they all use the same cache?

- Goal

I'd like to change the world so that all three build tools could use the same cache. I'm looking for advice about issues I'm likely to run into and smart ways to get around them.

By "use the same cache", I do not mean "retrieve from another build tool's cache".

I mean "retrieve from and store in another build tool's cache".

While I could go ahead and submit issues to the three projects, I know from experience (as a developer on an open source project), that if you want something done, you're best off getting it done yourself.

Also, it seems like I need to get all 3 communities on board to some degree.

- Question

What is the recommended approach for getting this kind of thing done? How do I approach the different communities? Do I work on patches for the 3 different projects, or would it be better off to create my own "interface" project that deals with these issues and have the 3 tools interface with that? Is this a standards question that I need to address on that front?

Lastly, if I'm missing something and this is possible (in an globally configurable fashion), then please let me know.

答:
So the thing to do is politely reach out to the three project leads of the communities in question. Jason Van Zyl from Sonatype (Maven) is certainly the sort of person who will listen to ideas and I'm sure the other project leads are the same. You need to get a social consensus from the three leads that their communities would want to do this.

Assuming you get the social consensus then start an OSS project where the ideas can be prototyped and tried out.  Invite members from each community to join this project.

Usual OSS rules will then apply, hopefully the most meritocratic solution will rise to the top and you've helped change the world :-).

If you remember that OSS is mainly a social activity, not a technical one you'll have a chance.


答:
Endians only really matters when you are transferring binary data systems.

With the advancement of processor speed (and much much lower cost of storage) binary data interfaces are becoming rarer so you don't notice them at the application layer. You are either using a textual transfer format (XML/JSON) or you are using data layer abstraction that takes care of the translation for you (so you don't even notice that there is a translation).

But when you are coding at the binary data layer you do notice and it is very important. For example When I worked at VERITAS (Symantec now) I was building software that was being built on 25 different hardware platforms (not only big/little endian there are other types).

Title: Has Little Endian won?

Body: When teaching recently about the Big vs. Little Endian battle, a student asked whether it had been settled, and I realized I didn't know. Looking at the Wikipedia article, it seems that the most popular current OS/architecture pairs use Little Endian but that Internet Protocol specifies Big Endian for transferring numeric values in packet headers. Would that be a good summary of the current status? Do current network cards or CPUs provide hardware support for switching byte order?</p>


答:
Knowing how the data will flow is all important. Knowing flow requires that you design good data structures.

If you go back twenty years, this was one of the big selling points for the object oriented approach using either SmallTalk, C++, or Java. The big pitch -- at least with C++ because that's what I learned first -- was design the class and the methods, and then everything else would fall into place.

Linus undoubtedly was talking in broader terms, but poorly designed data structures often require extra rework of code, which can also lead to other problems.

Title: Torvalds' quote about good programmer


问:
Why is there a large discrepancy between the stackoverflow tag frequency and the TIOBE Index?
By recently looking at the TIOBE Programming Community Index (Sep 2012) I noticed the following order:

C

Java

Objective-C

C++

C#

PHP

When looking at the tag frequencies of stackoverflow however, the situation is as follows:

C#

Java

PHP

JS

Android

jquery (JS)

iphone (Objective-C)

C++

(Java takes the lead when accounting for Android tagged posts w/o a Java tag). JavaScript also likely has surpassed PHP in total numbers of programmers?

I realize the tag-frequencies may not be the best indicator, but it is likely a sufficient  measure nonetheless.

What am I missing that explains this discrepancy, especially for ANSI C and JavaScript ( #11 in the TIOBE index)?

Links:

Wikipedia TIOBE index

The Transparent Language Popularity Index

Jobs Tractor language trends

Github top languages

Langpop

答: The frequency of questions raised at Stack Overflow and similar sites may have some bearing on actual use but there is no strong correlation. Developers using a common language may find answers elsewhere or just not ask questions on Stack Overflow. Meanwhile, developers using a less common language may use Stack Overflow proportionately more.</p>


答:
The TIOBE index is based on search engine result numbers. This is influenced by the total number of websites that exist which mention a language, and the index size and algorithms of search engines. Specifically, C may benefit from a lot of old documents.

The tag frequencies on SO are based on questions asked on one specific website (which is not even very old). This is influenced by the composition of the SO community and the attractiveness of alternative resources. Specifically, C# got its top spot probably because the two founders of SO both promoted it on their popular blogs, which have large followings among Microsoft-centric developers.

So basically, the two indexes measure completely different things.

Title: Why is there a large discrepancy between the stackoverflow tag frequency and the TIOBE Index?

Body:
By recently looking at the TIOBE Programming Community Index (Sep 2012) I noticed the following order:

C

Java

Objective-C

C++

C#

PHP

When looking at the tag frequencies of stackoverflow however, the situation is as follows:

C#

Java

PHP

JS

Android

jquery (JS)

iphone (Objective-C)

C++

(Java takes the lead when accounting for Android tagged posts w/o a Java tag). JavaScript also likely has surpassed PHP in total numbers of programmers?

I realize the tag-frequencies may not be the best indicator, but it is likely a sufficient  measure nonetheless.

What am I missing that explains this discrepancy, especially for ANSI C and JavaScript ( #11 in the TIOBE index)?

Links:

Wikipedia TIOBE index

The Transparent Language Popularity Index

Jobs Tractor language trends

Github top languages

Langpop


答:
While C may be the most used programming language or the most popular programming language in general, it's certainly not the most popular language of the last few years. Most people starting out in programming today are exposed to a different set of languages and are likely to end up with something else as their first language. Schools drop C++ and pick up Java for their curriculum, and it's a worldwide trend. People who do websites as a part-time job in high school will likely end up using PHP. And so on.

So most beginners are beginners in something else than C. Hence the beginner questions that make up a substantial part of questions on SO will be asked regarding a different language than C. Even if the same people will end up picking up C later on, they won't be having the same kind of problems they had with their first language or they'll have enough experience to deal with simple issues on their own.

Still, when you weed out tags that are not strictly speaking programming languages, C ends up at a quite respectable 8th place. And looking at the way TIOBE index is made, C gains much as a part of the dreaded C/C++ HR combo. As far as I'm concerned, both C positions in the TIOBE index and on the "SO popularity list" are skewed, only in opposite directions.


答:
It would be nice to think there is a way to resolve this, but you'll find that as a very small supplier to a large company, they pretty much dictate terms. I've been in this situation for a long time with a huge multinational, and we have to learn to roll with their way of thinking.

The most important mitigation is to have good relationships with the people involved, especially the decision makers. Then you can gently influence, and if things get ugly, they will speak up for you.

Of course you can make sure you have good contract/legal terms that protect you, but they won't help much if the customer really decides they don't like you and is going to make life difficult. Which is why the personal relationships are so important.


问:
Subset whose sum gets closest to saturating some bound
I have a problem that boils to down having a set of integers and wanting the  subset of those integers whose sum is closest to some target without going over.  What's a good algorithm for doing this? Maybe it's even a well known problem whose name I don't know?</p>

答: It's the "Knapsack Problem" and is quite well known. Efficient algorithms are difficult as the problem is NP-Complete. This means you are not guaranteed a polynomial time solution for all cases of the problem though some algorithms do exist to solve it. They just do so rather slowly.</p>


答:
An example of your problem as I understand it is that you have numbers:

1,2,7,22,199,3,5,6,12

and you want a subset such that the sum of the numbers in the subset selected is larger than 17.

A simple approach would be to sort the input first to get:

1,2,3,5,6,7,12,22,199

now start adding until the sum > 17

you would have added enteritis 0,1,2,3,4,5,6 of the above array, those enteritis represent subset satisfying your criteria. However, for a set of inputs, the solution may not exist at all or there may be many solutions.

Title: Subset whose sum gets closest to saturating some bound

Body: I have a problem that boils to down having a set of integers and wanting the  subset of those integers whose sum is closest to some target without going over.  What's a good algorithm for doing this? Maybe it's even a well known problem whose name I don't know?</p>


问:
How to copyright and license individual code files
I have a habit of writing small, reusable components in my spare time.  I reuse these components with my clients' code bases.  It occurs to me there's a potential issue that using identical code for multiple clients may bite me back in the future.  I don't care who uses the code.  I just don't want a situation where one company tries to sue another for copyright infringement due to my actions.

I'm not familiar with common licensing schemes.  What do I need to specify in my code files to indicate that these protions are copyrighted to myself and usable by anyone, while differentiating them from the code specificly written for the client?  Where can I find more information on this scenario?

答:
First, read this: If I'm working at a company, do they have intellectual property rights to the stuff I do in my spare time?

Now with that information in hand, realize that depending on the property rights contracts you sign with your clients, you may or may not be able to do what you elicit that you're doing.

It depends entirely on the individual contracts you sign, also it depends on the similarity and if each piece is directly copied or written from memory each time. Especially the similarity part. Absolutely identical snippets from one to another when the first client owns property rights, would definitely be seen as a violation of an NDA in court at the least (copyright infringement/theft at the worst) most likely wherein you aren't allowed to disclose proprietary methods from your client to other companies. While you may have written their code, disclosure of said code in identical form from memory would be tantamount to disclosure of a company's strategic advantage from memory which you gained in a privileged capacity.

Again, this all depends on the contracts you sign, but pretty standard contracts would make a complete copy-paste illegal. However state laws may override certain forms of these things so if you are relying on yourself as a business owner to employ you, I would have said business owner consult a lawyer for advisement lest the business that employs you get into hot water.

Make no mistake however, these things are extremely common occurrences, and companies press charges on these things probably as commonly as the legal departments understand what a software developer's job even is :)


问:
What is the difference between `update` and `upgrade`
What is the difference between update and upgrade in the context of application software?

答:
Update - This is simply adding the new modified files in a small scale, but will have the originality with new additions to it.

Ex: updating the Virus Definition in your Antivirus

Upgrade - This is promoting from one level to another level, sometimes the out put product can be a totally changed version of the original which was existing earlier

Ex: Upgrading windows 98 to Windows XP


问:
Would I be able to use code hosting services to host malware code?
Let me start by saying that I am a computer security researcher. Part of my job is to create malware to deploy on a controlled environment in order to study or evaluate several aspects of computer security.

Now, I am starting to think that using an online code hosting service (such as BitBucket, Github, etc...) to have all my code in 1 place, would allow me to work on my projects more efficiently.

My question is: Are there any issues with this? I have studied those companies' privacy policies, and they state that they allow usage of their services for lawful usage. Since I am not distributing malware, but I am only using it on my machines and machines that I am authorized to use, aren't I allowed to use the service? For the usage that I am doing, malware is the same as any other software.

I recognise that I should be extremely careful with code hosting, as any mistake from my part could hold me liable for damages and leave me open against legal action. As such I am recognizing that I should use private repositories, so the code is not available to the public. But how private is a private repository? How can I trust that companies like them will not leak or sell a potential (electronic) viral weaponry that I may have created in the future?

答:
As a former host operator (so no, I'm not selling) I would suggest that you'd probably fall foul of the general T&Cs of all reputable hosts.

However, I'd suggest contacting some, and explain what you are wanting... assuming they know what's what, you may find them amenable - especially if you pick a smaller company where people lower down the food chain may have some decision making powers.

BigCo hosts will probably have no route to approve your request.

You may also have better chances if you are running a dedicated server, rather than a shared hosting provision.


问:
Is taking frequent breaks really that beneficial when programming?
I keep reading that it is recommended for a programmer to take frequent breaks while programming, and the usual recommendation I see is 5 minutes every half hour or 10 minutes every hour.

I gave it a try, but quite often I find something interesting during those 5 minutes, and it takes me away from what I was working on for longer than I planned. Either that, or my mind gets focused on something else and I find it hard to get back into my work and don't focus very well.

Is it really that beneficial to take frequent breaks while programming? Am I doing something wrong for it to be decreasing my productivity instead of increasing it?

答: Personally, I don't find a 5 minute break at my desk of any real value.  I'll get up and walk around instead and then come back and attack again with renewed vigor.  I'm also not real strict about the timing... if I'm on a roll, I definitely don't stop.  If I'm stuck, I stop before I get too frustrated.</p>


答: In the context of  @Andrew's answer, also keep in mind that BitBucket offers free private repos, so you could host your code there without as much concern for it getting into the wild. </p>

Title: Would I be able to use code hosting services to host malware code?

Body:
Let me start by saying that I am a computer security researcher. Part of my job is to create malware to deploy on a controlled environment in order to study or evaluate several aspects of computer security.

Now, I am starting to think that using an online code hosting service (such as BitBucket, Github, etc...) to have all my code in 1 place, would allow me to work on my projects more efficiently.

My question is: Are there any issues with this? I have studied those companies' privacy policies, and they state that they allow usage of their services for lawful usage. Since I am not distributing malware, but I am only using it on my machines and machines that I am authorized to use, aren't I allowed to use the service? For the usage that I am doing, malware is the same as any other software.

I recognise that I should be extremely careful with code hosting, as any mistake from my part could hold me liable for damages and leave me open against legal action. As such I am recognizing that I should use private repositories, so the code is not available to the public. But how private is a private repository? How can I trust that companies like them will not leak or sell a potential (electronic) viral weaponry that I may have created in the future?


问:
How is architectural design done in an agile environment?
I have read Principles for the Agile Architect, where they defined next principles :

Principle #1 The teams that code the system design the system.

  Principle #2 Build the simplest architecture that can possibly work.

  Principle #3 When in doubt, code it out.

  Principle #4 They build it, they test it.

  Principle #5 The bigger the system, the longer the runway.

  Principle #6 System architecture is a role collaboration.

  Principle #7 There is no monopoly on innovation.

The paper says that most of the architecture design is done during the coding phase, and only system design before that. That is fine.

So, how is the system design done? Using UML? Or a document that defines interfaces and major blocks? Maybe something else?

答:
Disclaimer: I am not an agile coach/architect - this is what I've seen in agile projects that I've worked on and I think it works well.

I don't think it's quite defined by Agile how you do architecture - agile focusses on development methodologies and practices. UML on the other hand is just a language to communicate your architecture which is beyond agile (you use it if it fits your project and your team).

One of the principles of architecture that really applies, is take the decision at the last possible responsible moment - meaning its fine if you haven't taken all the decisions at the beginning of the project, especially since you have least information at this stage. Over time, you may take decisions that "evolve" the architecture. Yes, this might look like some rework, but this is also due to the fact that you have learnt new things about the environment, the requirements, what is possible what is not, etc.

The main thing that you would like to avoid is architecture rot - where the code is not really conforming to any particular architecture and is just a tangled mess. The main difference compared to evolving an architecture, is that in the latter, you take concious decisions periodically and document them with clear reasons, and then follow through to make sure your code follows it.


问:
Is there a way to play the role of Javascript with any other language like C#?
Is there a way to play the role of Javascript with any other language like C#? One way came up in my head is, having silverlight installed, using C# instead of Javascript for all the client side scripting (Though C# is not a scripting language). Is it possible?

I am not talking about something like GWT(Java) or Script#(C#). Probably the question can be stated as- "With silverlight installed, can I do everything supported by Javascript(like DOM manipulation etc) with C#?" Hope it's clearer.

答:
With Silverlight installed, your client is coded in C# right?

You don't need DOM manipulation if you use Silverlight - Silverlight is a plugin that works inside the browser (similar to flash) and is a separate runtime. You can do things similar to DOM manipulations (for e.g. showing/hiding fields, animations, etc) but all this will now be done in XAML and C#, not with HTML and Javascript.

Hope that clarifies - a silverlight application has no need for Javascript features.


问:
Is "convention over configuration" not violating basic programming principles?
I was looking at the WPF MVVM framework Caliburn.Micro and read that a lot of standard things are based on naming conventions.

For example, automatic binding of properties in the View to properties in the ViewModel. Although this seems to be convenient (removes some boilerplate code), my first instinct reaction is that it isn't completely obvious to a new programmer that will read this code. In other words, the functionality of the application is not completely explained by its own code, but also by the documentation of the framework.

EDIT:

So this approach is called convention over configuration. Since I could not find any questions concerning this, I altered my question:

My question is:

Is convention over configuration a correct way of simplifying things, or is it violating some programming principles (and if so, which ones)?

答:
I don't consider "an application should be fully explained by its own code" a fundamental programming principle. There are lots and lots of things which are not explained by just looking at the code of an application. Apart from knowing the basic things of the programming language itself (syntax and semantics), you need to know the conventions. If an identifier in Java starts with a capital letter, it is a type. There are lots of these conventions you need to know.

Convention over configuration is about reducing the amount of decisions the programmer has to make about things. For some things this is obvious -- nobody would consider having a language where the capitalization of types is something you need to declare at the top of your program -- but for other things it is not so obvious.

Balancing convention and configuration is a difficult task. Too much convention can make code confusing (take Perl's implicit variables, for example). Too much freedom on the programmer's side can make systems difficult to understand, since the knowledge gained from one system is rarely useful when studying another.

A good example of where convention aids the programmer is when writing Eclipse plugins. When looking at a plugin I've never seen, I immediately know many things about it. The list of dependencies is in MANIFEST.MF, the extension points are in plugin.xml, the source code is under "src", and so on. If these things were up to the programmer to define, every single Eclipse plugin would be different, and code navigation would be much more difficult.


问:
Proper Use Of HTML Data Attributes
I'm writing several JavaScript plugins that are run automatically when the proper HTML markup is detected on the page. For example, when a tabs class is detected, the tabs plugin is loaded dynamically and it automatically applies the tab functionality. Any customization options for the JavaScript plugin are set via HTML5 data attributes, very similar to what Twitter's Bootstrap Framework does.

The appeal to the above system is that, once you have it working, you don't have worry about manually instantiating plugins, you just write your HTML markup. This is especially nice if people who don't know JavaScript well (or at all) want to make use of your plugins, which is one of my goals.

This setup has been working very well, but for some plugins, I'm finding that I need a more robust set of options. My choices seem to be having an element with many data-attributes or allowing for a single data-options attribute with a JSON options object as a value. Having a lot of attributes seems clunky and repetitive, but going the JSON route makes it slightly more complicated for novices and I'd like to avoid full-blown JavaScript in the attributes if I can. I'm not entirely sure which way is best.

Is there a third option that I'm not considering?

Are there any recommended best practices for this particular use case?

答:
As you pointed out, both of your approaches have good points, and drawbacks. I am currently working with the later, which I personally find easier to use. However, the first approach seems to be easier to read for others, so.. Instead of looking for an other, better solution you could just use both your ideas. How about this?

```<code><div data-foo="bar" data-bar="foo" data-other="example">
</code>```

Equals

```<code><div data-options="{foo: 'bar', bar: 'foo', other: 'example'}">
</code>```

Title: Proper Use Of HTML Data Attributes

Body:
As you pointed out, both of your approaches have good points, and drawbacks. I am currently working with the later, which I personally find easier to use. However, the first approach seems to be easier to read for others, so.. Instead of looking for an other, better solution you could just use both your ideas. How about this?

<div data-foo="bar" data-bar="foo" data-other="example">

Equals

<div data-options="{foo: 'bar', bar: 'foo', other: 'example'}">


答:
In other words, the functionality of the application is not completely explained by its own code, but also by the documentation of the framework.

The functionality of an application that uses a framework is always dependend on the framework, convention over configuration doesn't make a difference in that regard.

In my experience, convention over configuration not only makes code more readable, but it also reduces the possibility to introduce subtle bugs (especially copy-paste-bugs).

For example, let's assume in some framework A, event FooBar triggers a call to handleFooBar. In another framework B, this correlation is configured somewhere in an XMLfile.

So, in A, it's simply

```<code>handleFooBar() {
   ...
}
</code>```

and unless you have missspelled FooBar, it will be called whenever FooBar happens.

In B, it's again

```<code>handleFooBar() {
   ...
}
</code>```

but also

```<code><eventconfiguration>
  <event>
    <type>FooBar</type>
    <handler>handleFooBar</handler>
  </event>
</eventconfiguration>
</code>```

With hundreds of things to configure this way, it's all too easy to accidentaly create a subtle bug like

```<code><eventconfiguration>
  <event>
    <type>BarFoo</type>
    <handler>handleFooBar</handler>
  </event>
</eventconfiguration>
</code>```

because after copy-pasting, we've only changed <type> but forgot to change <handler>.

Since those configuration files are large and monotonous, it's less likely that someone will find the bug by proofreading than he would find a similar bug in actual program code.

Title: Is "convention over configuration" not violating basic programming principles?

Body:
I was looking at the WPF MVVM framework Caliburn.Micro and read that a lot of standard things are based on naming conventions.

For example, automatic binding of properties in the View to properties in the ViewModel. Although this seems to be convenient (removes some boilerplate code), my first instinct reaction is that it isn't completely obvious to a new programmer that will read this code. In other words, the functionality of the application is not completely explained by its own code, but also by the documentation of the framework.

EDIT:

So this approach is called convention over configuration. Since I could not find any questions concerning this, I altered my question:

My question is:

Is convention over configuration a correct way of simplifying things, or is it violating some programming principles (and if so, which ones)?

Body:
In other words, the functionality of the application is not completely explained by its own code, but also by the documentation of the framework.

The functionality of an application that uses a framework is always dependend on the framework, convention over configuration doesn't make a difference in that regard.

In my experience, convention over configuration not only makes code more readable, but it also reduces the possibility to introduce subtle bugs (especially copy-paste-bugs).

For example, let's assume in some framework A, event FooBar triggers a call to handleFooBar. In another framework B, this correlation is configured somewhere in an XMLfile.

So, in A, it's simply

handleFooBar() {
   ...
}

and unless you have missspelled FooBar, it will be called whenever FooBar happens.

In B, it's again

handleFooBar() {
   ...
}

but also

<eventconfiguration>
  <event>
    <type>FooBar</type>
    <handler>handleFooBar</handler>
  </event>
</eventconfiguration>

With hundreds of things to configure this way, it's all too easy to accidentaly create a subtle bug like

<eventconfiguration>
  <event>
    <type>BarFoo</type>
    <handler>handleFooBar</handler>
  </event>
</eventconfiguration>

because after copy-pasting, we've only changed <type> but forgot to change <handler>.

Since those configuration files are large and monotonous, it's less likely that someone will find the bug by proofreading than he would find a similar bug in actual program code.


答:
Disclaimer: I am an architect in an agile environment but, as Helmuth von Moltke the Elder says, "No battle plan survives contact with the enemy". In other words, practicalities mean that the exact letter of the guidelines cannot always be followed.

Most of the points raised above are followed as best the team can. However, principle 1 (The teams that code the system design the system) is really hard to follow when the team consists of tens (or hundreds) of developers split across different continents and time zones. This is nothing to do with the developers' skills or attitudes, more the logistical problem of them all being present to gather requirements from customers and understand existing complex systems.

So, how is the system design done? Using UML? Or a document
  that defines interfaces and major blocks? Maybe something else?

Often the architect identifies the major components then defines the interfaces between them (including nonfunctional requirements like security, speed and reliability) and delegates the internal design of the components to individual teams. This is a good compromise between letting the teams design their own components without requiring everyone to know everything about the system.

Every organization has its own set of standards for architectural designs and this sometimes varies from project to project within the organization. This design done before the team starts coding or as early as possible and usually contains (and is not a complete list):

Expanded requirements and scope definition. These include use cases or user stories that flesh out the higher level business requirements. I personally like to use RFC 2119 for non-functional requirements. Design is based on and traced back to these. Although it may not fit the common definition of design, these are often just as important.

An overview consisting of a high level network or component diagram and a page of text. This is for a very wide audience, from upper management down to dev and QA. This rarely uses UML or a defined notation due to the wide audience.

Details for individual components, often focusing on the interfaces or APIs between them as mentioned above. Interfaces may be specified as method signatures in the target language with precondition and postcondition details. Components may have network diagrams, such as showing the layout of VMs in a cloud or data center and their networking arrangements. Relational databases will usually have Entity-Relationship diagrams.

A list of architectural risks and their mitigations, if known. Like requirements, these demonstrate design decisions and trade-offs.

In short, the design of a system in an agile process is exactly the same as one in a traditional waterfall process. However, in agile environments, less of the design is done upfront and more of it is delegated to component teams. The key is determining how deep to go initially, which decisions to defer and identifying when decisions need to be made. Decisions that impact multiple development teams should be made earlier, especially scalability and security. Decisions like adding additional languages to an already internationalized product can be deferred until very late.

After the initial design is created, the architect works with each of the teams and reviews their designs. If additional design or design changes are required for a unit of work (such as a scrum sprint), the architect aims to have it available by the time that unit of work starts. The architect is also responsible for communicating any changes to affected teams or stakeholders.

Title: How is architectural design done in an agile environment?

Body:
I have read Principles for the Agile Architect, where they defined next principles :

Principle #1 The teams that code the system design the system.

  Principle #2 Build the simplest architecture that can possibly work.

  Principle #3 When in doubt, code it out.

  Principle #4 They build it, they test it.

  Principle #5 The bigger the system, the longer the runway.

  Principle #6 System architecture is a role collaboration.

  Principle #7 There is no monopoly on innovation.

The paper says that most of the architecture design is done during the coding phase, and only system design before that. That is fine.

So, how is the system design done? Using UML? Or a document that defines interfaces and major blocks? Maybe something else?


问:
Case insensitive keywords in a language
We're trying to write a custom scripting language. There has been a suggestion to make the language forgiving by providing case insensitive keywords.

I personally do not like the idea, but there are few people in my team leaning towards it, saying it will make the end user happy! Examples of languages like FORTRAN, BASIC, SQL are given saying that these are case insensitive.

Is this a good idea?

答:
You should decide based on the user experience you wish to present, not how easy or hard it is to implement.

If it will make it easier for your users to have case insensitivity then that's what you should implement.

As a case in point SQL is case insensitive. This makes it very easy to use in an interactive setting.

Another way to look at this is will there ever be a difference between keyword and Keyword in your language, and will this difference be meaningful to the user? For a scripting language I'd say the answer is "no".

Title: Case insensitive keywords in a language


答: I do take frequent breaks but they normally have a purpose (bathroom, food/coffee, etc). I tend to find that while I am away from my desk that I am still thinking of the problem at hand. However, this thinking is not distracted by the code in front of me and allows me to think more about the problem as a whole rather than nitpicking through details in front of me. Frequently when I return to my desk I have a new idea at how to approach the issue I am working on.

Title: Is taking frequent breaks really that beneficial when programming?

Body:
I keep reading that it is recommended for a programmer to take frequent breaks while programming, and the usual recommendation I see is 5 minutes every half hour or 10 minutes every hour.

I gave it a try, but quite often I find something interesting during those 5 minutes, and it takes me away from what I was working on for longer than I planned. Either that, or my mind gets focused on something else and I find it hard to get back into my work and don't focus very well.

Is it really that beneficial to take frequent breaks while programming? Am I doing something wrong for it to be decreasing my productivity instead of increasing it?


答:
Ask yourself who the end user is. If it's meant to be written by someone with programming experience in C or Javscript, or IT experience in Unix, then case sensitivity is probably the right thing to do, because that's what the user expects. But for most end-users, even power-users, this will be confusing.

VB/VBA/VBScript are case-insensitive, and this was a decision made to allow non-programmers to easily get the hang of the language. Excel formulas, not exactly scripts but as close as many users get, are not case sensitive. In most writing the choice of case can make the text look more or less professional and polished, but case it self won't change the semantic meaning of the words. That's why I believe non-developers will be confused by a case sensitive scripting language.

Again, this isn't a technical choice. It's a product-management choice that has to be made by the people who know the target audience well.

Title: Case insensitive keywords in a language

Body:
We're trying to write a custom scripting language. There has been a suggestion to make the language forgiving by providing case insensitive keywords.

I personally do not like the idea, but there are few people in my team leaning towards it, saying it will make the end user happy! Examples of languages like FORTRAN, BASIC, SQL are given saying that these are case insensitive.

Is this a good idea?


答:
Gave +1 to @JesperE, and like to add something:

is it violating some programming principles

Yes, "convention over configuration" violates the principle "explicit is better than implicit" (have a look, for example, at "Zen-Of-Python").

On the other hand, the opposite "configuration over convention" tends to violate "Simple is better than complex", and worse, it violates the DRY principle in a subtle way, since you need to repeat names used in your code also in your configuration.


问:
Data Flow Diagrams - Difference between Lines and Arrows
I'm currently working with Visio to create Data Flow Diagrams for a System Analysis and Design class but I'm unsure what the difference between ------ and ------> is. I can connect 2 shapes together with a line (process, entity, data store) but does the single line connecting the two mean data flow? Do I need to explicitly use the data flow arrow to show which way data is flowing?

(There doesn't seem to be tags for this topic, maybe im in the wrong place?)

答:
A line without an arrow (usually a dashed line) is a trust boundary and is usually drawn over and perpendicular to one or more arrowed lines. For example, it may indicate that entities on one side are on a web page and ones on the other are on the server. This is not a part of the traditional data flow diagrams but is used in threat modelling. See the STRIDE Approach MSDN article for examples.

A line with an arrow shows data flow from one entity to another in the direction indicated by the arrow.


答: Assumed your script language will be case sensitive - are you going to create a compiler or syntax checker that will tell the user if he makes a typo by using the wrong case in a variable name or a keyword? If not, that would be a very strong argument for making the language case insensitive.</p>

Title: Case insensitive keywords in a language


答:
Examples of languages like FORTRAN, BASIC, SQL are given saying that these are case insensitive.

The reason why FORTRAN and SQL (and COBOL) are case insensitive is that they were originally designed for use on machines where the normal character sets had only uppercase letters.  Case insensitivity in those languages (at least) is more a historical artefact than an language design choice.

Now you could argue that case insensitivity of more forgiving, but the flip side is that case sensitivity results in more readable code because it fOrCeS tHe cOdEr tO uSe cOnSiStEnT cApItAlIzAtIoN.

Title: Case insensitive keywords in a language


答:
It is completely dependent on your current state. If I'm stuck hard on something I'll flip over to Programmers.SE or SO and check some questions. I'll get up and go for a walk. Maybe get a soda or a slice of pizza. </p>

<p>If I'm in a groove I'm not going to be stopping. Breaks are beneficial when left up to the programmers judgement. </p>

Body:
It is completely dependent on your current state. If I'm stuck hard on something I'll flip over to Programmers.SE or SO and check some questions. I'll get up and go for a walk. Maybe get a soda or a slice of pizza.

If I'm in a groove I'm not going to be stopping. Breaks are beneficial when left up to the programmers judgement.


答:
Can you declare variables on-the-fly ? If so i would argue against case sensitive, as tracking down a bug caused by

```<code>ATypo = 42;
</code>```

as opposed to

```<code>Atypo = 42;
</code>```

is needlessly asking for debugging time, when having the two statements equivalent just makes life easier.

Title: Case insensitive keywords in a language

Body:
Can you declare variables on-the-fly ? If so i would argue against case sensitive, as tracking down a bug caused by

ATypo = 42;

as opposed to

Atypo = 42;

is needlessly asking for debugging time, when having the two statements equivalent just makes life easier.


答:
Some of "convention over configuration" just boils down to sensible defaults.  You should only have to configure something to use it for a non-standard purpose.  I have to compare Struts to Rails here.  In Rails, you have to put your "actions/screens" in a folder and then they just work.  In Struts, you still have to put them in a folder, but you also have to come up with an action-name AND a JSP file AND a form name AND a form bean AND specify how these three things work together in Struts-config.xml AND specify that the form belongs on the request (RESTful).  If that isn't enough, the form/form-bean mapping has its own section in Struts-config which is then mapped independently to the action section in the same file and it all relies on handwritten strings in the JSP file in order to work properly.  For each screen, that's at least 6 things you shouldn't have to do and as many opportunities to make an error.  I think you can set most or all of those things manually in Rails if you need to, but 2/3 of Struts development time is taken up building and maintaining unnecessary layers of complexity.

In all fairness, Struts 1 was designed when people were porting applications between the desktop and the web.  The flexibility that Struts has baked in makes it suitable for everything Rails does, plus everything a desktop application would need.  Unfortunately, the mountain of configuration that enables that flexibility is a huge ball and chain for someone who just needs to write a web app or just a desktop app.

I worked somewhere that they took the next step and argued, "Configuration over Code" but having seen that taken to its logical extreme, the result is that the configuration becomes a new coding language.  It was a shell game where complexity was pushed around without being tamed in any significant way.  And it gave me an appreciation for all the type-checking and other safety nets that a well-designed programming language has.  Some half-baked configuration file format that blows up with no error message if you add a space or an apostrophe is NOT an improvement over a quality programming language which has suites of editing tools and a quality compiler written for it.

I can't imagine that having sensible defaults violates any theoretical principals about extensibility and modularity.  A Ruby/Rails programmer would sooner jab a hot poker in their eye than switch to a framework like Struts 1 where all configurations are made explicitly in multiple XML files.  I'm not arguing Rails vs. Struts IN GENERAL, but that convention can be a huge productivity win.  These two technologies are the most extreme real-world comparison I've come across.

If you work in Java at all, check out Joshua Bloch's, "Effective Java," Item 2: "Consider a Builder when faced with many constructor parameters" pp. 11-16.  For most purposes, some parameters (configuration) is required, and some is optional.  The basic idea is to require only the necessary configuration and only make the user (which could be another program) specify additional options as needed.  I cleaned up a bunch of code with this pattern a month ago and it positively sparkles.


问:
Motivation for a service layer (instead of just copying dlls)?
I'm creating an application which has 2 different UIs so I'm making it with a service layer which I understood is appropriate for such scenario.

However I found myself just creating web methods for every single method I have in the BL layer, so the services basically built from methods that looks like this:

return customers_bl.Get_Customer_Prices(customer_id);

I understood that a main point of the service layer is to prevent duplication of code so I asked myself - why not just import the BL.DLL (and the dal.dll) to the other UI, and whenever making a change re-copy the dlls, it might not be so 'neat', but still less hassle than one more layer?

{I know something is wrong in my approach, I'm probably missing the importance of service layer, I'd like to get more motivation to create another layer, especially because as it is  I found that many of my BL functions ALREADY looks like:
 return customers_dal.Get_Customer_Prices(cust_id)
which led me to ask: was it really necessary to create the BL just because on several functions I actually have LOGIC inside the BL?}

so I'm looking for more motivation to creating ONE MORE layer, I'm sure it's not just to make it more convenient that I won't have to re-copy the dlls on changes?

Am I grasping it wrong? Any simple guidelines on how to design service layer (corresponding to all the BL layer functions or not? any simple example?) any enlightenment on the subject?

答:
I think the word 'service' gets bandied around so much that it's meaning nowadays is very overloaded and confusing.

There is a big difference between a 'service layer' and a 'web service [layer]'.

A 'service layer' is an abstraction behind which you put the business logic that will be consumed regardless of the UI. That way the UI layer can be as simple as possible (and it's as easy as possible to add more user interfaces later).

An important point to consider is that the service layer does not have to be a web service. Your BL.dll, as you describe it, is a service layer. If both of your user interfaces can consume the BL.dll, then you are just fine importing the BL.dll and going on from there. No need for a web service unless your application requires a web service for some other reason.

As a matter of fact, I wouldn't even consider a web service to be a 'service layer' at all. It's simply another form of UI. A special UI, to be sure; one designed to be consumed by other applications. But a UI nonetheless, especially in the sense that there shouldn't be any business logic in the web service layer, beyond authentication/authorization. The best web service layer will serve as a pass-through to the real service layer underneath.

In short, I don't see a reason that you should think about adding a 'web service layer' unless your application needs it (because the UI layers cannot consume your service layer dll directly).


问:
If you could only have one programming related book on your bookshelf what would it be and why?
One per answer please. I'll add my favourite as an answer.</p>

答: Easy.

Body: Easy.


问:
At which point do you "know" a technology enough to list it on a resume
I recently had a programmer in for an interview, who listed Python, PHP, Rails and ASP as a few of their skills. In the interview however, they interviewee didn't enough know what control structures and basic logic were, they had only followed a few demo tutorials.

So my question is this: At which point can you add a technology to your resume accurately. Is it when you can demonstrate all basic concepts, write a useful program in it, or are just comfortable using it without having to refer to the documentation every 30 seconds.

I don't believe this is overly subjective, a baseline should easily be established based on feedback.

答:
On my job applications I use two sections for technologies as I'd expect most do; first there is the general skills section and then the listing of specific experience in specific projects. Of course, while applying I list in both sections mostly those items that are relevant to the job in question.

Goals:

I feel that listing a technology in the general area is a strong statement and for a technology to reside in there I need to

be able to communicate with it

manage to work reasonably
productively with it

have some knowledge of the possible
boobytraps that lay within it.

Criteria

My very vague criteria for listing technologies in the general skills goes along these lines:

The proficiency of an average programmer who has used the technology to write programs consisting of about 10K SLOC.

The ability of an average programmer who has had to maintain the complexity of a program the size of approximately 30 objects.

The theoretical knowledge equivalent of an average book.

Basically that's at least some breadth in the area, handling of reasonable complexity, and some knowledge about the horrors that await.

Examples:

Proficient, PHP: Writing web applications with PHP has been my day job for several years, with the maintenance of several projects, reading of many books and a big portion of the manual behind me. This would go in both sections, were it relevant for the job.

Beginner, Scala: I'm in the middle of reading a Scala book with about 200 pages behind me and a few hundred lines of code written. I'd probably use it as a side note somewhere if I saw it in the job ad, like this: "The job you're offering also mentioned Scala which I'm studying right now and I'm more than willing to learn more about it."

Border case, Python: I've written a small shoot'em up game and several scripts in Python with the experience of a couple of thousand lines, reading a dozen of articles and tutorials on the web, and some parts of the manual. If the ad mentioned Python (and I'd be well qualified otherwise) I'd write about it in my resume in the experience section, perhaps  something akin to this: "I have created a shoot'em up game in Python with Pygame using object-oriented programming with bitmap graphics".

Naturally, a fine way of showing your real skill level is providing links for screenshots, diagrams, plans, data schemas, project history, blog postings and code in the application for the job.


答:
How many clients are you going to support? Depending on the underlying platform you develop on and how its versioning system works, you may have to recompile and deploy the entire application for updates.

As you've pointed out, currently your service will simply call into the layer below it, effectively duplicating code. If you have fewer than 10 clients (total, not at a given site/deployment), I would say strongly couple to the DAL/BAL. More than that, I would go service.

Title: Motivation for a service layer (instead of just copying dlls)?

Body:
I'm creating an application which has 2 different UIs so I'm making it with a service layer which I understood is appropriate for such scenario.

However I found myself just creating web methods for every single method I have in the BL layer, so the services basically built from methods that looks like this:

return customers_bl.Get_Customer_Prices(customer_id);

I understood that a main point of the service layer is to prevent duplication of code so I asked myself - why not just import the BL.DLL (and the dal.dll) to the other UI, and whenever making a change re-copy the dlls, it might not be so 'neat', but still less hassle than one more layer?

{I know something is wrong in my approach, I'm probably missing the importance of service layer, I'd like to get more motivation to create another layer, especially because as it is  I found that many of my BL functions ALREADY looks like:
 return customers_dal.Get_Customer_Prices(cust_id)
which led me to ask: was it really necessary to create the BL just because on several functions I actually have LOGIC inside the BL?}

so I'm looking for more motivation to creating ONE MORE layer, I'm sure it's not just to make it more convenient that I won't have to re-copy the dlls on changes?

Am I grasping it wrong? Any simple guidelines on how to design service layer (corresponding to all the BL layer functions or not? any simple example?) any enlightenment on the subject?


答:
The real determining factor is how often you're going to want to have multiple things with the same name.  Case insensitivity works in SQL because it's not often you want a column named SELECT.  It would be annoying in Java because every other line looks like Object object = new Object(), where you want the same name to refer to a class, an instance, and a constructor.

In other words, case sensitivity is mostly useful for overloading a name, and overloading is mostly useful in large, complex projects.  For more infrequent use, such as a scripting language, case insensitivity can make programming much simpler.

I made a rules language once where identifiers were not only case insensitive, they were whitespace insensitive.  I also allowed creating aliases that referred to the same identifier.  For example, ProgrammersStackExchange, programmers stack exchange, and PSE all resolved to the exact same symbol and could be used interchangeably.

For my domain that worked very well, because the domain had a lot of extremely well known ways to refer to the same thing, and naming conflicts were rare.  No one would be surprised by typing a query using one name and having the result use another.  Having language support made translating between the domain and the programming language very easy.  However, it also made certain tasks harder, like finding all references to a variable.  Thankfully, in my case those sorts of situations either rarely came up, or were fairly easy to build tool support to help, but you have to take your own situation into account.

Title: Case insensitive keywords in a language


问:
Accessing Repositories from Domain
Say we have a task logging system, when a task is logged, the user specifies a category and the task defaults to a status of 'Outstanding'. Assume in this instance that Category and Status have to be implemented as entities. Normally I would do this:

Application Layer:

```<code>public class TaskService
{
    //...

    public void Add(Guid categoryId, string description)
    {
        var category = _categoryRepository.GetById(categoryId);
        var status = _statusRepository.GetById(Constants.Status.OutstandingId);
        var task = Task.Create(category, status, description);
        _taskRepository.Save(task);
    }
}
</code>```

Entity:

```<code>public class Task
{
    //...

    public static void Create(Category category, Status status, string description)
    {
        return new Task
        {
            Category = category,
            Status = status,
            Description = descrtiption
        };
    }
}
</code>```

I do it like this because I am consistently told that entities should not access the repositories, but it would make much more sense to me if I did this:

Entity:

```<code>public class Task
{
    //...

    public static void Create(Category category, string description)
    {
        return new Task
        {
            Category = category,
            Status = _statusRepository.GetById(Constants.Status.OutstandingId),
            Description = descrtiption
        };
    }
}
</code>```

The status repository is dependecy injected anyway, so there is no real dependency, and this feels more to me thike it is the domain that is making thedecision that a task defaults to outstanding. The previous version feels like it is the application layeer making that decision. Any why are repository contracts often in the domain if this should not be a posibility?

Here is a more extreme example, here the domain decides urgency:

Entity:

```<code>public class Task
{
    //...

    public static void Create(Category category, string description)
    {
        var task = new Task
        {
            Category = category,
            Status = _statusRepository.GetById(Constants.Status.OutstandingId),
            Description = descrtiption
        };

        if(someCondition)
        {
            if(someValue > anotherValue)
            {
                task.Urgency = _urgencyRepository.GetById
                    (Constants.Urgency.UrgentId);
            }
            else
            {
                task.Urgency = _urgencyRepository.GetById
                    (Constants.Urgency.SemiUrgentId);
            }
        }
        else
        {
            task.Urgency = _urgencyRepository.GetById
                (Constants.Urgency.NotId);
        }

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

There is no way you would want to pass in all possible versions of Urgency, and no way you would want to calculate this business logic in the application layer, so surely this would be the most appropriate way?

So is this a valid reason to access repositories from the domain?

EDIT: This could also be the case on non static methods:

```<code>public class Task
{
    //...

    public void Update(Category category, string description)
    {
        Category = category,
        Status = _statusRepository.GetById(Constants.Status.OutstandingId),
        Description = descrtiption

        if(someCondition)
        {
            if(someValue > anotherValue)
            {
                Urgency = _urgencyRepository.GetById
                    (Constants.Urgency.UrgentId);
            }
            else
            {
                Urgency = _urgencyRepository.GetById
                    (Constants.Urgency.SemiUrgentId);
            }
        }
        else
        {
            Urgency = _urgencyRepository.GetById
                (Constants.Urgency.NotId);
        }

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

答:
You are intermixing

entities should not access the repositories

(which is a good suggestion)

and

the domain layer should not access the repositories

(which might be bad suggestion as long as your repositories are part of the domain layer, not the application layer). Actually, your examples show no case where an entity accesses a repository, since you are using static methods which don't belong to any entity.

If you don't want to put that creation logic into a static method of the entity class, you can introduce separate factory classes (as part of the domain layer!) and put the creation logic there.

EDIT: to your Update example: given that _urgencyRepository and statusRepository  are members of the class Task, defined as some kind of interface, you now need to inject them into any Task entity before you can use Update now  (for example in the Task constructor). Or you define them as static members, but beware, that could easily cause  multi threading problems, or just problems when you need different repositories for different Task entities at the same time.

This design makes it a little bit harder to create Task entities in isolation, thus harder to write unit tests for Task entities, harder to write automatic tests depending on Task entities, and you produce a little bit more memory overhead, since every Task entity now needs to hold that two references to the reposities. Of course, that may be tolerable in your case. On the other hand, creating a separate utility class TaskUpdater which keeps the references to the right repositories may be often or at least sometimes a better solution.

The important part is: TaskUpdater will be still part of the domain layer! Just because you put that update or creation code in a separate class does not mean you have to switch to another layer.

Title: Accessing Repositories from Domain


答:
Case sensitivity considered harmful.

Life is not case sensitive and neither are users or programmers.

Case sensitive languages are a historical accident, of constrained systems which found case-insensitive comparisons difficult. This handicap no longer exists, so there is no reason to make a case-sensitive computer system ever again.

I would go so far as to say that case sensitivity is evil, since it puts the convenience of the computer before that of the user.

(Related, I recall a few years back, some genius refused to pay his credit card bill because his name was in all caps, but he spelt it mixed case. Therefore, he argued, it was not properly addressed to him and wasn't a valid demand for payment. The Judge treated the argument as it deserved).

Title: Case insensitive keywords in a language


答:
I do 10 minutes breaks every 45 minutes of computer work.

During the 10 minutes, I walk, prepare a coffee and such trivial stuff. Sometimes, I take the time to clean my desk. But it has to be trivial things.

I use workrave to remind me when to stop.

What you do is actually task-switching. Your brain can't rest and start on something else when unfocused from the previous thing.

I'm currently trying what is called mindfulness. It works so well it is scary!


问:
Torvalds' quote about good programmer
Accidentally I've stumbled upon the following quote by Linus Torvalds:

"Bad programmers worry about the code. Good programmers worry about
  data structures and their relationships."

I've thought about it for the last few days and I'm still confused (which is probably not a good sign), hence I wanted to discuss the following:

What interpretation of this possible/makes sense?

What can be applied/learned from it?

答: Here's my interpretation of it:  You use code to create data structures, so the focus should be on the latter.  It's like building a bridge - you should set out to design a solid structure rather than one that looks appealing.  It just so happens that well written data structures and bridges alike look good as a result of their efficient designs.</p>

Title: Torvalds' quote about good programmer


答:
You shouldn't introduce case insensitivity without a very good reason to do so. For example, dealing with case comparisons with Unicode can be a bitch. The case sensitivity (or lack thereof) of older languages is immaterial, as their needs were very different.

Programmers in this era expect case sensitivity.

Title: Case insensitive keywords in a language


问:
What technologies are needed to be a freelance web developer / designer targeting small businesses?
First off, I'm not looking for this answer: "learn PHP/MySQL, JQuery, HTML/CSS...."

My background, I wear many hats, and do many things. Currently I manage investment accounts with a business partner who is also a friend. He happens to be attending business / law school perusing a joint JD and MBA. As a result, we're putting our into "coast", maintaining our current clients, but not acquiring more.

Recently I've picked up some freelance graphic design / web development / online marketing side work (Photoshop, HTML/CSS, WordPress) through some personal networks. The work is enjoyable; now I'm thinking about expanding it into a larger business with these primary goals:

augment my finances (I'm shooting for about $1,000-2,000 per mo.),

learn new technologies,

involve myself with meaningful work.

As an entrepreneur I don't mind the aspects of running a business that hassle other freelancers...

-- the marketing

-- the billing

-- etc.

I'm considering targeting the small to middle market businesses and organizations where I can contribute in marketing, design, and development building projects from the ground up. Thus I'll have freedom to decide the specific technology (I won't have to work with an existing code base).

What kinds of projects should I focus on? What technologies are a good fit for this style of work?

For example: It might be fun to develop with Ruby on Rails. However, maybe a lot of projects would be rolling out e-commerce solutions. Thus, I should focus on PHP due to more shopping cart options, skipping ROR entirely.

答: Try to get into SugarCRM or Magento everybody and their mom is in the CMS (wordpress, drupal, ...) and you will always be undercut in price. You want something with a pretty heavy ramp up time that's hard for people to just pickup. Then you can charge a much more reasonable rate.</p>


答:
The benefit of an application service (doesn't have to be a web service) over a dll is you can off-load the execution of the service on a separate machine (probably a server). In the case of your UI being a desktop app, the local machine doesn't need to have as much code installed nor does it need as much horsepower to run your app.

A website could still use this application service.

Like Andy B indicated, you need to determine how many users you need to handle to justify this expense.


问:
How mature is FreeBASIC?
A friend of mine is considering using FreeBASIC in a critical production environment. They currently use GWBasic, and they want to make a soft transition towards more modern languages. I am just worried that there might be undetected bugs in the software. I see that their version number is 0.22.0, which indicates, that it is not quite mature yet. I also read this discussion, without being able to conclude. Also on their Sourceforge pages there is no indication of whether it is Alpha or Beta (which anyways is not a very good indicator). Does anyone have own experience about the maturity, ideas on how to judge the maturity, or know of companies using FreeBASIC in a critical production environment?</p>

答:
These are the following basic-dialects which are good both as compiler and embeddable script:

1) gambas

These are the following basic-dialects which are good only as compiler but can embed other scripts:

2) jabaco

3) objectivebasic

4) freebasic

5) chipmunkbasic

These are the following embeddable basic-dialects which are good, and can be embedded into other basic dialects depending on the frameworks:

6) scriptbasic

7) maven-sb4j

8) ajbasic

All these can also be used for making gui applications which differ with each other, database connecting tools, and in the area of embeddable applications (webserver pages), scriptbasic and gambas-gbs3 are already there, whereas if you can get fb-curl and fb-simplewebserver and integrate them into freebasic framework, then also freebasic-server-pages (if they are not there then you may have to download and copy-paste the library and header files under the lib and include directory of freebasic respectively). Even jabaco can embed maven-sb4j, or objectivebasic and chipmunkbasic can embed applescript and scriptbasic respectively. So these are likely to have have solution for most of the requirements.

If you are very particular with gwbasic compatibility then choose bwbasic (gwbasic enhanced for freebsd and linux), but I don't think there is much of any difference with some others.

However for graphics with bwbasic you have to contend with x11 based options or wait until it adds support for tk, fox, and other well known toolkits.

If you are willing to look for:

Robust vb-like development environment + basic server pages, then choose gambas or jabaco with maven-sb4j.

Robust interpreter supported with a thin but good ide: freebasic, and if you can get fb-curl and fb-simplewebserver and integrate them into freebasic framework, then also freebasic-server-pages.

Robust web-engine for basic server pages, then scriptbasic, and thinbasic.

So, these are all robust and may become usable at least after adding some few modules.

Borrowed some minor features from python/perl/ruby: scriptbasic (and also yabasic3)

Easy and very standard syntax: would be obasic (openbasic) in future, currently freebasic and scriptbasic are two varied flavors or traditional basic, whereas gambas and jabaco are a varied vb6 dialects.

Title: How mature is FreeBASIC?


答:
When doing test driven development you create testcode that tests your modules in isolation (= as independant of other modules as possible )

To ease the creation of testingcode you introduce interfaces to other moduls that can be easily mocked away.

This way as a side affect you automatically get an architecture where the coupling between the modules is as small as possible.

In my opinion tdd is also architectural work.


答:
Then there is java-api support or japi for scriptbasic, yabasic2 and jabaco, which is cross-platform.

But of course now a days many basic-dialects have other cross platform toolkits too, which can soon pave way for quality applications in the future.

Title: How mature is FreeBASIC?

Body: A friend of mine is considering using FreeBASIC in a critical production environment. They currently use GWBasic, and they want to make a soft transition towards more modern languages. I am just worried that there might be undetected bugs in the software. I see that their version number is 0.22.0, which indicates, that it is not quite mature yet. I also read this discussion, without being able to conclude. Also on their Sourceforge pages there is no indication of whether it is Alpha or Beta (which anyways is not a very good indicator). Does anyone have own experience about the maturity, ideas on how to judge the maturity, or know of companies using FreeBASIC in a critical production environment?</p>