答:
It's not entirely sure what the tasks of a Senior+ in your case would involve. Always keep in mind that it is much more important to know what your job's tasks are rather than what your position is called. While having a Senior in front of your job title may have an impact on your financial outcome it does not in any way tell anything about what you actually do in your work. There are however two different types of senior level "developers".

System Architect

If you were interviewed for such a position, then indeed something is amiss. I agree with gahooa that such an interview should focus on the big picture thinking of the candidate, which seems to have been missing in yours.

There is, however, also the kind of evil perspective on this: in everyday work you will always be overwhelmed by those little detail things and it'll be your responsibility to keep track of the big picture despite all of these minor disturbances. If you want to test whether a candidate is able to not lose him/her-self in the small details one way might just be to try to sink him/her in those details. If you did not remind them that the envisioned architecture position is about the big picture - you might have just failed that test. Though I doubt that, as this sort of interviewing certainly isn't on the friendly side of things.

Technical Expert

In this case you may not be able to influence the overall system architecture and company direction much. Instead you will focus on the design level. Do note that all the questions you gave as examples fit perfectly into this category. From a senior developer responsible for SW designs I do expect him/her to know stuff like JIT, GC, data structures, etc. in and out - without needing to look up anything but the most intricate details. If you're supposed to make a software design, yet do not know the difference between an array and a list you're in the wrong position.

From reading your question I suspect that your job position (the current and the proposed one) focuses on software design. In that case, you may want to rethink what you actually should know/remember and what not. Given that you work with these things day by day there should be little need to look something up for answering elementary questions like those.

On a side note: a former professor of mine had the interesting habit of asking questions about elementary subjects in oral exams on advanced courses. While these subjects were never explicitly covered in the advanced course a student was supposed to know them from their elementary education. In interviews (of any sort) I adhere to this behavior as well, because over the past years I have witnessed over and over how students/candidates for something "advanced" have a severe lack w.r.t. the foundations. Given that reasoning, I for one have no qualms about asking a candidate for a senior position what a listener pattern is, or what the pros/cons are of keeping the listeners in an array vs list vs set.

Title: What's the point of those technique detailed interview question for Senior dev?

Body:
I've had an internal promotion interview for gain a higher level programmer title, something like Senior plus.
And I've been interviewed by around 7 people using different technology, and people using the same technology with me(.Net) tend to ask very technique detailed question which can actually easily been found via Google, like what is JIT, how GC works, difference between List and Array, abstract class and interface, delegate and event, even what is the class name when you process Upload file, etc. And I've got only one question asked about one of my design idea in my project and just simple discussion. But for most other my design choice they seems just not interested.

I didn't get the result yet and it would be about late this week, but here is my concern:

I personally think when I play as a senior programmer, I mainly solving problems, and I just need to know there are some certain way can make it happen but I may not remember every detailed thing, and that's should be why we have those detailed reference documentation like MSDN.

I feel it fine if you found I've not too much experiences around this area like Junior to Intermediate level, but when tend to interview higher level guy, isn't you should more focus to see how this guy logical thinking is and how good is he/she at solving problems? Does everybody just think if you know every detailed small point tech stuff then you are a Senior+. And by checking those interview question books I found there are more those kind of questions.

If I spend 5 days go through those interview question list book I can easily make those guys feel a wow, but does that really mean anything? This kind of interview can easily let those guys good at remember things gain higher salary even they have no idea how to solve difficulty problem.

So why is this happening on the world, is that just cause problem solving skills, design skills are hard to measure? I've serve this company for years and only had few interview with other companies so I wonder is that every company doing the same thing?

Or is this actually just my own problem that I should try harder to remember everything in MSDN in my mind so that I can work even without it and internet?

EDIT

For better explain my situation regarding Frank's concern about job tasks.
Sorry it's my bad didn't clarify those background.

There actually will be no specifically job's task changes, I personally think what I've done already played as a senior, like code review, mentor members, review BA's doc and give technique opinions, design architecture of new projects, it's just my title still stayed without senior and I asked to get one to reflect pay slip and lead to such an interview. This is a Saas company so people stay in one project as long as that product is still alive, this leads they need people be able to design more new features based on current product, fixing technique difficulty on live servers, design/code review/mentoring members And higher level title based on technique would be Architect and we do not have any job similar with Technical Expert. And I agree if you want to play Technical Expert role you should know more detail about the tech you use. Sorry it's my bad didn't clarify those background.


问:
NoSQL use cases
I am developing an application for my universities student research symposium around the idea of polyglot persistence. I have read Martin Fowlers book and done some other research online about the verious different types of NoSQL db's. I am curious as to what the different use cases are for the different NoSQL databases?

Currently I have what Fowler has pointed out (other research was mostly done into API's).

Key/Value:

session data

 user profile

shopping cart

basically anything that has a single unique key that can be easily generated and replicated

Document:

event logging

CMS/blogging

e-commerce (after the transaction has been completed)

web analytics

Column Family:

event logging

CMS/blogging

counters

expiring usage

Graph:

connected data

location based services

recommendation engine

So what other use cases are there? More specifically what are the use cases for each type of NoSQL db that are better than a relational model?

答:
I think you have covered almost everything. I can offer you one more about Graph database I have seen people or researchers use graph database for semantic analysis or storing ontology for Natural Language Processing as well.

And as I have been using a lot of Graph db I think what Graph db offers is much more than relational model can offer. For example, if I have a web application and I to connect all my friends from Facebook and Twitter based on location or interests. I can do it in one query. However, you can do that in SQL as well if you really want to, but the SQL can be an A4 long or more than that if you want to do it properly.

ContentLicense: CC BY-SA 3.0

Title: NoSQL use cases


答:
Why not go about this more axiomatically?  For example, why is "CMS/blogging" better suited to document databases (or whatever)?  What are the common properties of these applications that make you think they're better suited to one or another technology?

Consider the strengths of each DBMS technology and, indeed, the theory each one is based on.  What data model do they implement?  (Does each one in fact have a data model?)  What are the properties of each data model, and how do the properties of the application map onto those of the data model?  If you develop such a map, you'll have a way of characterizing any application, even one you've never heard of or one that hasn't been invented yet.

Codd defined a data model as comprising three interlocking features: structure, operations, and constraints.  The relational model has all three in spades.  If you look closely at the alternatives, you'll find they're missing at least one and usually two of those.  Any technology not based on the relational model is ipso facto less functional.  For that reason it's safe to say every application can be supported the the relational model (if not by extant relational products).  The relational model is still more fully developed, more powerful, and yet simpler than any other yet devised.  It will be hard to improve on because it rests on predicate logic and set theory.

Perhaps you can identify applications for which, say, well defined operations don't matter.  But you want to be very sure you first understand why they matter in general before you can say with any certainty why they're not necessary (or even just useful) for a particular application.

Sooner or later, someone will tell you "relational doesn't scale" and that technology X is fast.  When they do, remember that they've implicitly given up features that technology X lacks relative to the relational model, features that might well matter.  Besides, a data model isn't fast or slow, only an implementation is.  Whenever there are more programmers than machines, it's cheaper to buy faster hardware than to hire more programmers.

Title: NoSQL use cases

Body:
I am developing an application for my universities student research symposium around the idea of polyglot persistence. I have read Martin Fowlers book and done some other research online about the verious different types of NoSQL db's. I am curious as to what the different use cases are for the different NoSQL databases?

Currently I have what Fowler has pointed out (other research was mostly done into API's).

Key/Value:

session data

 user profile

shopping cart

basically anything that has a single unique key that can be easily generated and replicated

Document:

event logging

CMS/blogging

e-commerce (after the transaction has been completed)

web analytics

Column Family:

event logging

CMS/blogging

counters

expiring usage

Graph:

connected data

location based services

recommendation engine

So what other use cases are there? More specifically what are the use cases for each type of NoSQL db that are better than a relational model?


问:
Referential integrity in a database where tuples are not physically deleted
Many modern Relational Database Management Systems automatically support referential integrity, i.e. when you try to delete a tuple which has a reference (in the form of foreign key, for example), the DBMS doesn't complete the operation and brings an error.

Consider a database where every table has an attribute, which indicates if a tuple is deleted or not. So no data is actually deleted from the database, but is marked as deleted instead. If a tuple is marked as deleted, all its references need to be marked as deleted too or an error should occur. How can this be supported?

Is performing additional checks (programmatically or with triggers) before deleting a tuple the only way to have referential integrity? Are there any accepted practices or algorithms?

Edit: This flag is mostly used for statistics, and partially for data recovery after a long period of time. It is filter with a special meaning, and right now when queries are made, referential integrity is checked right in the query, which is extremely error prone and not reliable at all.

答:
If you want to do this with just DRI, you can't just use a flag.  Or, you can, but you won't like it.

Let's define your "deleted flag" as a status flag Status CHECK IN ('OK', 'Deleted') because negative flags are confusing. Add STATUS to every table, and make it part of every FK constraint.  That way, every row has a status that must match the status of anything it's related to.  But you won't be able to "delete" rows on either end of the relationship while the FK constraint is in force!

You can get around that using triggers instead of DRI.  It's hard work, though, and tricky to get exactly right.

Instead of a flag column, define pairs of tables, one for active rows and one for inactive.  When a referent row is to be deleted, first copy it and the related rows to the inactive table, then delete per normal.  That gives you a chance to capture other aspects of deletion, such as when, why, and by whom.


问:
What to learn and how?
I am a Java (Web) Developer. Having knowledge about c#, PHP and Ruby. I am getting confused how to keep myself updated with very fast changing the programming language and their implementation.

Like, in the mobile, you can see around 7-8 OS. There are very much finer example of event-driven programming to make scalable application like node.js, Ember, Require etc.. Then WebSockets, Socket.io, HTML5.

Python and C once again climbing on the top. Scala and clojure are becoming very popular languages. Haskell and Erlang are also a great language too..

With so many programming language and platform, it is sometimes i feel very bad that i am missing some good things in my career.

I am just confused what to learn and how to co-op with this fast-changing world. Please suggest.

答:
Like, in the mobile, you can see around 7-8 OS. There are very much finer example of event-driven programming to make scalable application
  like node.js, Ember, Require etc.. Then WebSockets, Socket.io, HTML5.

Try to be a master of one trade (the trade you works with), then try to be a jack of others. How much you try to learn other things, there will always a sea of new technologies around you which you doesn't know. Don't get disheartened by thinking about what you doesn't know, but think about how good you are in the field you said you currently know. How much of a master you are in the technologies you know and working regularly.

With so many programming language and platform, it is sometimes i feel very bad that i am missing some good things in my career.

True, especially when you see others excellent programmers gives exemplary answers (in forums like this/SO) which you cannot even think about. You kind of think, how on earth they acquire that knowledge. But there is no short cut, they made effort to study them, or happened to work on that technology. With more experience you will get more opportunities to work with other technologies.

I am just confused what to learn and how to co-op with this fast-changing world. Please suggest.

Well, first make sure you are a master at field which you currently working. If you get more time to spent, then choose another language. Since you asked for suggestion and said you already know JAVA, just make an effort in Android. I said this because

Android uses JAVA

It is open source, takes no cost to setup.

From my understanding, you haven't worked in Mobility, which is
booming right now.

Well just some suggestions.

Title: What to learn and how?


问:
Can a table be both Fact and Dimension
Ok, I am a newbie and don't really think "dimensionally" yet, I have most of my initial schema roughed out but I keep flipping back and forth on one table.

I have a Contract table and it has a quantity column (tonnes), and a net price column,  which need to be summed up a bunch of different ways, and the contract has lots of foreign keys (producer, commodity, futures month etc.) and dates so it appears to be a fact table. Also the contract is never updated, if that makes a difference.

However, we create cash tickets which we use to pay out part or all of the contract and they have a contract ID on them so then the contract looks like a dimension in the cash ticket's star schema.

Is this a problem? Any ideas on the process to resolve this, because people don't seem to like the idea of joining two fact tables.

Should I put producerId and commodityId on the cash ticket? It would seem really weird not to have a contractID on it.

答:
You will simplify and amplify your thinking if you forget everything you know about "dimensionality".  The notion of Star Schema doesn't exist in relational theory.  The sooner you drop it, the sooner relations will stand alone clearly in your mind.

Your question, essentially, is: is a contract ID a property of a cash ticket?  It sounds like it is.  If adding it doesn't denormalize your table, if it's functionally dependent on the key, adding it is the right thing to do, full stop.  Any consideration of star-ness or fact/dimension duality can be safely discarded.

Title: Can a table be both Fact and Dimension


答:
Perhaps you should do the selection by domain and not by technology/prog language?

What is it that is of interest to you? Databases? Mobile applications? Search? Natural language processing? Big Data (hot right now)? Graphics? Web apps all around? Domain-specific web apps (like social)? GIS? Distributed programming for applications like say, ejabberd for chat? Enterprise middleware? Systems programming? System administration software?

Once you select domain, technology choice becomes natural, e.g. mobile => Java/Android + IOS/Objective-C. (You also have some flexibility re choice of tech there, e.g Scripting Layer 4 Android is becoming popular among some people who like dynamic languages.)

I also second advice of Krishnabhadra on becoming a master in 1 or at most few subjects.

Title: What to learn and how?

Body:
I am a Java (Web) Developer. Having knowledge about c#, PHP and Ruby. I am getting confused how to keep myself updated with very fast changing the programming language and their implementation.

Like, in the mobile, you can see around 7-8 OS. There are very much finer example of event-driven programming to make scalable application like node.js, Ember, Require etc.. Then WebSockets, Socket.io, HTML5.

Python and C once again climbing on the top. Scala and clojure are becoming very popular languages. Haskell and Erlang are also a great language too..

With so many programming language and platform, it is sometimes i feel very bad that i am missing some good things in my career.

I am just confused what to learn and how to co-op with this fast-changing world. Please suggest.


问:
Why do certain code elements (classes, methods etc.) in public APIs get deprecated over time?
Today our professor discussed with the class that what  "class X or method X get deprecated" means? From what I understood, it means, for example, that we are not going to get that method or class in the Java API in the future so we better use another method or class instead of this class. Then comes another question, why do they get deprecated?

My guess for this question was that it is because the Java API developers may find those classes or methods are using an algorithm which is not efficient and they replace them with another class(es) or method(s) which are more efficent. But the professor wasn't happy with my answer and told me to google. And I couldn't find anything. Can you please tell me why the classes get deprecated?

答:
The answer you might be looking for is that APIs can not get changed. Once you release an api, it's there. Changing it would break existing code relying on it.

So instead of changing an API, the developers mark it as deprecated and create a new class/method.

This way old code keeps working while on the other hand better methods become available for code you write now or in the future.

I think that's what your professor is hinting at: deprecating and creating new methods instead of changing.


问:
What is the most egregious waste of money you have seen, and what did you do about it?
Often we as programmers see large organisations wasting huge sums of money on bloated and inefficient solutions to problems. This pains me greatly because I like organisations to benefit from best of breed solutions. However, my abilities as a programmer are limited when it comes to influencing the key decision makers and often my perspective on the matter is constrained to my own little technical world.

So, my question is this. After encountering an egregious waste of money on some software and/or hardware that really got your goat, what did you do about it to get it fixed or were you doomed to bite the bullet and mutter forever under your breath? I'm interested in hearing your overall experiences and especially what lessons you learned about how to tackle this sort of thing in the future. Let's not name names, the experience of how to tackle the problem is more important than the actual offending product.

答:
There are two that I have experienced.

Cancelling a project that had a huge ROI for the business that was about 80% completed and then handing out 100 engraved and gold plated iPods to senior executives.

Laying-off several hundred people and then the following day announcing substantial pay raises and bonuses for the senior executives.

These are not totally programming related, but most certainly wasted a lot of money, plus provided a slap to the face for all those involved.

I didn't get laid off, but I also didn't get a raise or an iPod either...

ContentLicense: CC BY-SA 2.5


问:
What's the point of those technique detailed interview question for Senior dev?
I've had an internal promotion interview for gain a higher level programmer title, something like Senior plus.
And I've been interviewed by around 7 people using different technology, and people using the same technology with me(.Net) tend to ask very technique detailed question which can actually easily been found via Google, like what is JIT, how GC works, difference between List and Array, abstract class and interface, delegate and event, even what is the class name when you process Upload file, etc. And I've got only one question asked about one of my design idea in my project and just simple discussion. But for most other my design choice they seems just not interested.

I didn't get the result yet and it would be about late this week, but here is my concern:

I personally think when I play as a senior programmer, I mainly solving problems, and I just need to know there are some certain way can make it happen but I may not remember every detailed thing, and that's should be why we have those detailed reference documentation like MSDN.

I feel it fine if you found I've not too much experiences around this area like Junior to Intermediate level, but when tend to interview higher level guy, isn't you should more focus to see how this guy logical thinking is and how good is he/she at solving problems? Does everybody just think if you know every detailed small point tech stuff then you are a Senior+. And by checking those interview question books I found there are more those kind of questions.

If I spend 5 days go through those interview question list book I can easily make those guys feel a wow, but does that really mean anything? This kind of interview can easily let those guys good at remember things gain higher salary even they have no idea how to solve difficulty problem.

So why is this happening on the world, is that just cause problem solving skills, design skills are hard to measure? I've serve this company for years and only had few interview with other companies so I wonder is that every company doing the same thing?

Or is this actually just my own problem that I should try harder to remember everything in MSDN in my mind so that I can work even without it and internet?

EDIT

For better explain my situation regarding Frank's concern about job tasks.
Sorry it's my bad didn't clarify those background.

There actually will be no specifically job's task changes, I personally think what I've done already played as a senior, like code review, mentor members, review BA's doc and give technique opinions, design architecture of new projects, it's just my title still stayed without senior and I asked to get one to reflect pay slip and lead to such an interview. This is a Saas company so people stay in one project as long as that product is still alive, this leads they need people be able to design more new features based on current product, fixing technique difficulty on live servers, design/code review/mentoring members And higher level title based on technique would be Architect and we do not have any job similar with Technical Expert. And I agree if you want to play Technical Expert role you should know more detail about the tech you use. Sorry it's my bad didn't clarify those background.

答:
I am sorry, but I do not think that the kind of questions you were asked are trivia that should be Googled when needed. This may be true for the class name when you process Upload file, but:

what is JIT: This is a fundamental technological concern. A senior programmer should definitely know what this means at least high level. For instance, this affects the performance of different VM and runtimes, hence it should be at least considered when evaluating a new technology.

how GC works: similar to the above. The algorithms for GC are at the core pretty simple, and one should at least be familiar with generational GC versus mark & sweep, versus reference counting and the various tradeoffs

difference between List and Array: this is a basic question that I would expect a junior programmer to know

abstract class and interface: same as above. I do not understand how one is expected to architect a complex system without knowning at least interfaces

delegate and event: again, to design a robust and flexible system, event delegation is one of the basic patterns.

It seems to me that they have done a pretty good job of asking conceptual questions that are relevant to a senior programmer without getting lost in trivia.


问:
Can you claim that your product is fit for purpose when it uses OSS software which does not guarantee it?
I am working on a product for a client that must be valid and fit for purpose.

It's built on a LAMP stack (PHP/Cake), so there's GPL, MIT, PHP, APACHE licenses:

"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.

My rationale that my product is valid and fit for purposes:

The signed UAT doc proves validity and fitness for purpose.

The stack is so widely used by developers, industry and end users (netcraft, gartner etc. stats), that there is a consensus that it IS fit for purpose. (ie we can disregard the fitness for purpose statement in the warranty disclaimer to an extent)

Is this a valid point? Can I make claims that my software is fit for purpose?

答:
This is a standard disclaimer, that's often given for software, especially free software.

It just means that the provider of the software makes no guarantees about the fitness of the software. He may very well be convinced himself that the software is good for what it does, but he doesn't want to enter the legal minefield that is guaranteeing it.

The same applies to "consensus": "The community" (however you want to define it) might agree that a given piece of software is fit for its stated purpose, but they won't give you a guarantee.

In short: unless you pay for it, you will never get anyone to guarantee you any kind of fitness. And even if you pay someone, they might not guarantee it.


答:
Your reasoning is faulty for several reasons:

Nothing in the license gives you the ability to alter its terms.  If you accepted the license terms by using the work, you're bound by everything in it.  If you no longer like the terms, you're free to stop using the software.

There are no provisions in the license for wide adoption of the work changing the terms.

Your user acceptance test has no bearing on the agreement you made with the licensor.  If you warranted that your selection of the work for inclusion in your product makes it suitable for your customer's purpose, that's between you and your customer.  The licensor is an uninvolved third party.

The sentence following the one you highlighted ("You are solely responsible for determining...") puts the ramifications of having used it squarely in your lap.

Title: Can you claim that your product is fit for purpose when it uses OSS software which does not guarantee it?

Body:
I am working on a product for a client that must be valid and fit for purpose.

It's built on a LAMP stack (PHP/Cake), so there's GPL, MIT, PHP, APACHE licenses:

"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.

My rationale that my product is valid and fit for purposes:

The signed UAT doc proves validity and fitness for purpose.

The stack is so widely used by developers, industry and end users (netcraft, gartner etc. stats), that there is a consensus that it IS fit for purpose. (ie we can disregard the fitness for purpose statement in the warranty disclaimer to an extent)

Is this a valid point? Can I make claims that my software is fit for purpose?


答:
First of all, as others have said, there's a difference between software actually working versus software being sold with a legal guarantee that it works.

The disclaimer text you cite means that the original licensor you got the software from does not grant any kind of warranty. You can offer the software yourself with a warranty attached. The original authors don't offer a legal guarantee that the software works, but there's no reason why you can't make such a guarantee to your client. (Whether or not you think it's a good idea to attach a legal guarantee to something you didn't write is another matter entirely.)

Specifically, section 4 of the GPL states:

You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.

I'm not sure if a license must grant you the capability to add warranties explicitly (I'm not a lawyer, but I think the answer is no -- my intuition is that you should be able to offer guarantees on virtually whatever you want). In any case, the GPL unambiguously offers you the ability to add your own warranties while conveying the software to a client.

I'm not sure about BSD, since it requires you to preserve the disclaimer, but perhaps you can offer warranty protection notwithstanding the disclaimer in the license. In effect, you might say, "I assert a warranty that this work as a whole is fit for some purpose (even though some works this larger work is derived from do not carry such a warranty)." Always ensure, of course, that your warranty terms do not violate the licenses of any of your included works.

However, again, I'm not a lawyer, and if your client has requested a warranty of fitness of purpose, he's probably looking for some vetted legal protection. You should consult a lawyer to draft the text of such a warranty.


答:
I think the other answers are covering various aspects of your question, but I don't believe they are directly addressing your particulars.

Yes, you may issue a warranty for the software you have created including the software with the various OSS licenses that you mentioned.

You (and your company) will be the sole bearer of the liability generated by that warranty.  And that's all a warranty is - it's a liability.  You're guaranteeing that you are liable if the product fails to work.

You're not asking to do this, but you may not push that liability back "up-stream" to the other software components / publishers you mention as they have expressly denied accepting that liability coverage.

Whether or not you issue a license along with the software is a related but orthogonal question.  License provides terms of use.  Warranty guarantees a degree of functionality or operation.  I would recommend you license the product to your client in addition to providing the warranty that they require.  Having a license helps scope the applicability of the warranty you provide.  It also allows you to exclude non-clients from attempting to claim warranty support from you.

What means you use to determine fitness is solely your discretion.  It depends upon what amount of risk your organization is willing to accept.  It also depends upon the damages you may be exposed to should the product fail and your client makes a warranty claim against you.  A UAT is a standard approach and can be a pretty good for identifying fitness.  It's a positive verification for the expected functionality.  Consensus is a little more iffy since you don't know for certain how others are using those components.  Consensus is nice for generating a degree of confidence, but it is nowhere near as rigorous as defined and specific tests that validate the required functionality.


问:
What problem domain is LINQ made for?
Each time I see a question posted on Stack Overflow on C#, I see at least one or two answers posted that solve a problem with LINQ. Usually people with very high reputation seem to use LINQ like pros.

So my question is, what problem domain is LINQ supposed to be used for?

Also on side notes: Are there any purposes in which it should be avoided? Does the size of dataset affect the performance of LINQ queries?

答:
To answer the edited question: in short, it is beneficial to use LINQ whenever you have to implement "query" functionality (that's what the Q in LINQ stands for).  Defining an exact domain is difficult, but it greatly simplifies a variety of tasks associated with extracting and manipulating data from collections.

To elaborate slightly, a lot of query functionality has been brought directly into the language (or rather, the various LINQ-implementors), so things like aggregations, ordering, grouping, filtering, projections, joins (and many more) are all handled for you.  The LINQ-based solutions are also typically far shorter than if you were to implement them "by hand", and also communicate their intent far better.

A simple example which often helps convey the power of LINQ is to display the contents of a directory, grouped by extension.  Run through a typical imperative implementation in your head - there will be lots of implementation details already at the outset.  Perhaps we will use a Dictionary<String, List<String>> to index the files by extension.  Of course, we'll have to check if a key already exists, instantiate a list, add to it, etc.  It might go something like:

```<code>Dictionary<string, List<string>> fileGroups = new Dictionary<string, List<string>>();

foreach (string file in Directory.GetFiles(Environment.CurrentDirectory))
{
    string extension = Path.GetExtension(file).ToLower();

    if (!fileGroups.ContainsKey(extension))
    {
        fileGroups[extension] = new List<string>();
    }

    fileGroups[extension].Add(file);
}
</code>```

Consider the LINQ equivalent:

```<code>var query = from file in Directory.GetFiles(Environment.CurrentDirectory)
            group file by Path.GetExtension(file).ToLower();
</code>```

Notice that the query itself is only 2 lines, certainly shorter than any imperative solution we could have come up with.  It is also pretty readable; the signal-to-noise ratio is higher than it was with the first solution.  For those that are new to LINQ, you'd output the results of that query as follows:

```<code>foreach (var fileGroup in query)
{
    Console.WriteLine(String.Format("*** Files with extension: {0}", group.Key));

    foreach (string file in fileGroup)
    {
        Console.WriteLine(file);
    }
}
</code>```

With more complex examples, the differences normally become even more vast (consider simply grouping by multiple fields, for example).  So, to summarise, LINQ solves many "day to day" data querying problems in a way which is often shorter and more self-descriptive.  This comes at a mild cost of having to learn the syntax and the technology, but the benefits greatly outweigh the negatives.

Title: What problem domain is LINQ made for?

Body:
To answer the edited question: in short, it is beneficial to use LINQ whenever you have to implement "query" functionality (that's what the Q in LINQ stands for).  Defining an exact domain is difficult, but it greatly simplifies a variety of tasks associated with extracting and manipulating data from collections.

To elaborate slightly, a lot of query functionality has been brought directly into the language (or rather, the various LINQ-implementors), so things like aggregations, ordering, grouping, filtering, projections, joins (and many more) are all handled for you.  The LINQ-based solutions are also typically far shorter than if you were to implement them "by hand", and also communicate their intent far better.

A simple example which often helps convey the power of LINQ is to display the contents of a directory, grouped by extension.  Run through a typical imperative implementation in your head - there will be lots of implementation details already at the outset.  Perhaps we will use a Dictionary<String, List<String>> to index the files by extension.  Of course, we'll have to check if a key already exists, instantiate a list, add to it, etc.  It might go something like:

Dictionary<string, List<string>> fileGroups = new Dictionary<string, List<string>>();

foreach (string file in Directory.GetFiles(Environment.CurrentDirectory))
{
    string extension = Path.GetExtension(file).ToLower();

    if (!fileGroups.ContainsKey(extension))
    {
        fileGroups[extension] = new List<string>();
    }

    fileGroups[extension].Add(file);
}

Consider the LINQ equivalent:

var query = from file in Directory.GetFiles(Environment.CurrentDirectory)
            group file by Path.GetExtension(file).ToLower();

Notice that the query itself is only 2 lines, certainly shorter than any imperative solution we could have come up with.  It is also pretty readable; the signal-to-noise ratio is higher than it was with the first solution.  For those that are new to LINQ, you'd output the results of that query as follows:

foreach (var fileGroup in query)
{
    Console.WriteLine(String.Format("*** Files with extension: {0}", group.Key));

    foreach (string file in fileGroup)
    {
        Console.WriteLine(file);
    }
}

With more complex examples, the differences normally become even more vast (consider simply grouping by multiple fields, for example).  So, to summarise, LINQ solves many "day to day" data querying problems in a way which is often shorter and more self-descriptive.  This comes at a mild cost of having to learn the syntax and the technology, but the benefits greatly outweigh the negatives.


问:
What are the differences between abstract classes, interfaces, and when to use them
Recently I have started to wrap my head around OOP, and I am now to the point where the more I read about the differences between abstract classes and interfaces the more confused I become. So far, neither can be instantiated.  Interfaces are more or less structural blueprints that determine the skeleton and abstracts are different by being able to partially implement code.

I would like to learn more about these through my specific situation. Here is a link to my first question if you would like a little more background information: What is a good design model for my new class?

Here are two classes I created:

```<code>class Ad {
    $title;
    $description
    $price;

    function get_data($website){  }

    function validate_price(){  }
 }

class calendar_event {
    $title;
    $description

    $start_date;

    function get_data($website){ //guts }

    function validate_dates(){ //guts }
 }
</code>```

So, as you can see these classes are almost identical. Not shown here, but there are other functions, like get_zip(), save_to_database() that are common across my classes. I have also added other classes Cars and Pets which have all the common methods and of course properties specific to those classes (mileage, weight, for example).

Now I have violated the DRY principle and I am managing and changing the same code across multiple files. I intend on having more classes like boats, horses, or whatever.

So is this where I would use an interface or an abstract class? From what I understand about abstract classes, I would use a super class as a template with all of the common elements built into the abstract class, and then add only the items specifically needed in future classes. For example:

```<code>abstract class content {
    $title;
    $description

    function get_data($website){  }

    function common_function2() { }
    function common_function3() { }
 }

class calendar_event extends content {

    $start_date;

    function validate_dates(){  }
 }
</code>```

Or would I use an interface and, because these are so similar, create a structure that each of the subclasses are forced to use for integrity reasons, and leave it up to the end developer who fleshes out that class to be responsible for each of the details of even the common functions. my thinking there is that some 'common' functions may need to be tweaked in the future for the needs of their specific class.

Despite all that above, if you believe I am misunderstanding the what and the why of abstract classes and interfaces altogether, by all means let a valid answer to be stop thinking in this direction and suggest the proper way to move forward!

Thanks!

答:
Main difference is methods of a Java interface are implicitly abstract and cannot have implementations. A Java abstract class can have instance methods that implement a default behavior.

Variables declared in a Java interface is by default final. An abstract class may contain non-final variables.

Members of a Java interface are public by default. A Java abstract class can have the usual flavors of class members like private, protected, etc.

Java interface should be implemented using keyword “implements”; A Java abstract class should be extended using keyword “extends”.

An interface can extend another Java interface only an abstract class can extend another Java class and implement multiple Java interfaces.

A Java class can implement multiple interfaces but it can extend only one abstract class.

Interface is absolutely abstract and cannot be instantiated; A Java abstract class also cannot be instantiated, but can be invoked if a main() exists.

In comparison with java abstract classes, java interfaces are slow as it requires extra indirection.

Interface and abstract class in Java is that you cannot create non abstract method in interface, every method in interface is by default abstract, but you can create non abstract method in abstract class.

Abstract class vs. interface in Java is that, interfaces are better suited for Type declaration and abstract class is more suited for code reuse and evolution perspective.


答:
I have been working on a medical software project, where we were under the same kind of regulation, we have to both verify and validate the product.

And we could do that and live up to FDA requirements.

I did not take part in the actual validation of 3rd party tools, but as far as I could understand, what we had to do was specify which purpose that 3rd party software would serve us. Then we had to validate those products ourselves, meaning that we validated that the chosen 3rd party software packages did in deed serve that purpose.

As far as I understood, this type of validation did not have to be a lengthy process. Merely some sort of half page document describing the requirements and how that software met those requirements.

This validation would be for both components build into the actual software, but also for development environments, source control systems, etc.

Note: This is based on how I understood what we had to do. I may have misunderstood issues. And the company may have also been more excessive in the validation process than was actually required (I have a feeling this was the case to some degree).

But the software was validated.

But why do you require a validated product? Are you delivering to a regulated segment, e.g. medical or finance. Or is the client ISO 9001 (or similar) certified? If so, you should study the requirements for these kinds of regulations your self to find out exactly what is needed.


答:
Technical Debt

I've seen is the chronic "beating the dead horse" of legacy code. Or more to the point, from the viewpoint of the trenches, countless hours spent in maintenance mode when the whole team knows we should be in replacement mode.

What we've done.... is still on going. Trying to invoke positive change from within

Performance Testing

Simply, not doing it.  Again, still working on the positive change from within.

Title: What is the most egregious waste of money you have seen, and what did you do about it?

Body:
Often we as programmers see large organisations wasting huge sums of money on bloated and inefficient solutions to problems. This pains me greatly because I like organisations to benefit from best of breed solutions. However, my abilities as a programmer are limited when it comes to influencing the key decision makers and often my perspective on the matter is constrained to my own little technical world.

So, my question is this. After encountering an egregious waste of money on some software and/or hardware that really got your goat, what did you do about it to get it fixed or were you doomed to bite the bullet and mutter forever under your breath? I'm interested in hearing your overall experiences and especially what lessons you learned about how to tackle this sort of thing in the future. Let's not name names, the experience of how to tackle the problem is more important than the actual offending product.


问:
Managing SQL Stored Procedures' Version
I am working with a team of 5 persons. We are using SQL Server as our database.
Since long time I want to store the Stored Procedures in SVN so that the versions can be maintained. Is there any tool which can be used as a plugin with SQL Server Management Studio and allows checkin from there.</p>

答:
SSDT projects are great for this these days. </p>

<p>You keep all your db & proc & function definitions in script files (which define your model) and within Visual Studio sync the model with your database / publish to a database to update it. As all your object definitions are in script files you can have them under source control using SVN/Hg/whatever. </p>

Title: Managing SQL Stored Procedures' Version

Body:
SSDT projects are great for this these days.

You keep all your db & proc & function definitions in script files (which define your model) and within Visual Studio sync the model with your database / publish to a database to update it. As all your object definitions are in script files you can have them under source control using SVN/Hg/whatever.


问:
Functional reactive programming — is Fay expressive enough?
So I'm doing a fairly involved javascript/html client with lots of ajax calls and other involvements of callback-ism. I'm entertaining the thought of using Fay for this purpose. I'm aware of Elm. Tried it and liked the FRP elements. Now I'm looking to know if similar structure is possible in Fay.

Are there any concrete examples of FRP in Fay out there at this point?

Some relevant technologies:

Arrowlets, arrowised FRP in javascript

FlapJax, another javascript alternative

Bacon.js, FRP in javascript

One possible solution, using Bacon. With demo.

答:
The ReactiveMvc example among the fay-ide examples is probably the best bet at this moment. Although I'm not sure about the completeness or how it compares to other FRP solutions.

I suspect this does not fill the qualification of Functional Reactive Programming. I may be wrong.


问:
Help to simplify/model complex decision making (if, then, else scenarios)
I find my self in a situation, where I need to program a service, that can determine if two object in a huge database are the same. For simplicity, let's say it's used cars, and I want to determine if they are the exact same, based on various attributes e.g. brand, model name, year, milage, price, color etc. The problem is, that some of the attributes are obversely more significant/critical/important than others e.g. brand/model name HAS to be the same, where as the seller might wrongly have typed in the milage a slight bit differently. Additionally some times information such as the color might even have been left out, an hence I must fall back to less "unique identifying" information such as for an example the engine size. Apart from the direct weight/importance of each attribute there is another dimension of complexity involved - the attributes' importance vary with each other. So let's say e.g. that the car I'm comparing against the rest is very old, then suddenly the importance of the milage it self increases since it's way more likely to be unique among similar cars, than compared to a younger car. This is obviously due to the fact, that the dispersion of milage on older cars are much wider than the one on younger cars.

As you might imagine, modeling this as a lot of nested if-then terms easily ends up in a complete mess, and completely unreadable afterwards, and even hard to model in the first place.

So my questions are:

What might this kind of problem be called in programming, and how do I deal with it?
What solutions/algorithms might be good solutions? References, links?
Good reading on the topic?

答: Sounds like you're basically looking for an expert system.  An expert system is often used for classifying objects, by comparing them against specific criteria.  You could set your expert system up to classify cars based on your criteria (mileage, year, color and so on), and then verify whether there are any other cars in your collection with the same characteristics.  If not, then you make a new entry for it, otherwise you would either throw an error or simply ignore the new data.</p>


问:
What the right pattern to Use here
scenario:

I have an entity called Member. Members fall into multiple types. Some types are below.

Supporter

Volunteer

Sponsor

Player

I can create class for each type and inherit from the base Member entity. But when a Member has more than 1 type in a given time, it is not the right way.

can I use decorator pattern to achieve this intent? Or what the best pattern to get this work?

EDIT :

Language I use is C#

Also different Member types can have additional methods, for example, Sponsor can have its own methods as Donate(), Or the Volunteer can have a method Subscribe() and so on. these thing have to be considered.

答:
I would question the need to require a single "Member" class (and one only) to represent each person uniquely. Is it likely (or even possible) for a Member to be acting as a Volunteer and Sponsor and it matters that they are the same object instance in the code? In the example you are using, it is perfectly legitimate to have an instance of a Volunteer and a separate instance of a Sponsor, even if they are the same person in real life.

Also, you say the different roles have different method names/functionality. Thus, in order for the Liskov-Substitution principle to apply, the using code would only call methods on the "Member" interface. So either the Member class would have to have some generic method name like "DoYourBehavior" and the derived class knows to call "Play/Donate" OR inheritance doesn't really apply; other than for getting reuse of common code.

Thus, I would treat each role as a separately instantiated class instance and any common functionality can be shared either through inheritance, composition or neither. The key being that there is no reason that the design has to explicitly switch a single class instance between different roles.

Title: What the right pattern to Use here


问:
In agile development, should I try persistence in flat file before database?
Somebody explained to me that since in agile development, policy and the application logic should be more important than details such as persistence method, persistence decision should be taken at the end. So it might be a good idea to start with simpler persistence such as flat files, until we reach the point the weakness of this method become apparent, and only then we change the persistence, e.g. by using relational database.

Is this true, or did I misunderstood the concept? Is this how agile team usually build application? What are the rationales for it and when I should not take this approach?

答:
What are you persisting?

I am on an agile team and for one application, we persist almost everything to the database. Mind you, if we didn't then there wouldn't be much for this application to do - persisting things to a database is a large part of its raison d'être.

So: What are you persisting and what does your application do? If the application doesn't actually care where its data is persisted, then you can write a small layer that makes the decision (that decision can be stored in a config file somewhere) of flat-file vs. database. I think you need to evaluate your application and your data and decide if it makes sense in your specific case to invest time in database persistence, or just read/write flat files (which will probably be faster in terms of development time).


答:
It's an example, used to demonstrate a concept, rather than a concept in and of itself.

The concept is that you don't make an architectural decision until the last responsible moment, but no later. But, in reality, you often do have a decision on the database you're going to use very early on. That might not be perfect, but it's a fact.

Once that decision is made, you don't actively avoid it. Storing something in an existing database is often as easy as storing it in a flat file.

But changing from MySql on Linux to SQL Server on Windows might not be as simple as changing from a flat file anywhere to SQL Server on Windows. That's the real point. So, while there's doubt as to the final solution, take the simplest possible option, accounting for change. Once a decision is made, stick to it.

Title: In agile development, should I try persistence in flat file before database?

Body:
Somebody explained to me that since in agile development, policy and the application logic should be more important than details such as persistence method, persistence decision should be taken at the end. So it might be a good idea to start with simpler persistence such as flat files, until we reach the point the weakness of this method become apparent, and only then we change the persistence, e.g. by using relational database.

Is this true, or did I misunderstood the concept? Is this how agile team usually build application? What are the rationales for it and when I should not take this approach?


答:
It takes good judgement and experience to see what questions need answering first when embarking on a new project.

If the end product is still unknown then building/prototyping quickly well help you figure that out, and yes iterating in an agile way will help.  That of course will introduce risk such as finding out late in the process that the persistence implementation is going to take longer than you communicated to your stakeholders.

If the end product is well known then understanding how persistence will work in your application could be more important to know early on.  The risk there is that find problems with your product specification later in the development process.


答:
Since you know you will be using a DB, there's not much point in writing code to handle flat files.  You might get through a few iterations using some read-only CSVs but you'll quickly find yourself writing code that you know you will throw away.

One thing you can do to simplify the initial complexity by using something like SQLite (a library that gives you a serverless SQL database that's stored in a file).  It's got a flexible type system so you don't have to seriously commit to a schema, no server to configure/connect to & rebuilding your DB is as simple as deleting a file.  It also allows you to simply include the DB image along with the code in version control if needed.


答:
I think you are putting focus on the wrong values. In agile, business value is in focus. You create a product in order to deliver business value to some end users.

If you create the persistence layer late, or make it up along the way is your strategy for delivering business value to the customer. I don't believe that the term "agile" itself dictates if you should do one or the other.

The point of view about deferring data storage strategy is advocated in this presentation by Robert C. Martin (one of the authors of the agile manifesto).

It is a very good presentation, I can recommend that you watch it.

But I disagree with it! At least to a degree.

I do not believe that you can call a user story for "Done", if the user story involves data that should be persisted, and you don't actually have any type of persistence implemented.

If the product owner decides that now is the time to go live, you are unable to do that. And if you haven't started implementing persistence until late in the project, you also have no information about how long it would take to implement the persistence layer, leaving it a major project risk.

The agile projects I have worked on have not deferred the data access strategy. But it has been decoupled, allowing us to change it along the way. And the entire database schema is not designed up front. Tables and columns are created along the way as they are required in order to implement the user stored that, in the end, deliver business value.


问:
Anonymous software license
I am aware of some of the problems of the concept of "releasing a work to the public domain" (as mentioned here and here; I haven't listened to this specific discussion yet). IANAL, but the main problems seem to be as follows:

Releasing to the public domain doesn't exist in many jurisdictions; rather, a work becomes public domain after copyright expires.

Some moral rights are inalienable due to (certain ratifications of) article 6bis of the Berne Convention.

However, aren't you still allowed to publish a work anonymously? If you  anonymously publish a work, in such a way that authorship can't be proven or even distinguished, wouldn't that effectively "unlicense" your code? I would think so: since then any claim of authorship can't be validated, the rights implied by authorship can't be enforced, not even by the original author.

If so, I'd really like to know which permissive license (ISC/MIT/BSD-style) would be fit for such publications. (Especially when they've managed to get rid of the lengthy THIS SOFTWARE IS PROVIDED IN "SCREAMING CAPS"-style liability waiver.) If no such license exists yet, how would one modify an existing license to be suitable for an anonymous publication?

答:
I would have a read of FSF's thoughts on categories of software.  To give credit, the link is also included in the SO discussion you linked to.

Western world use of the term "public domain" correlates with what FSF terms noncopylefted free software.  In this case, free means no copyright associated to it as the author has disclaimed their copyright.  The noncopylefted aspect means there aren't any distribution restrictions.  So the software is truly Free as well as "free as in beer".  Editorial aside, copyleft software isn't truly Free since it has distribution restrictions.

Releasing the software anonymously may actually backfire for what you're intending to do.  Precisely because we don't know who wrote the anonymous software, we cannot ascertain that they have disclaimed their claim to copyright.  Just because it is "anonymous" doesn't mean that a future user would be protected from nuisance claims of "that's really my code that I was releasing under the pseudonym of 'anonymous'"  And yes, there's more than a few folk going around by the handle of anonymous.

Instead of following an anonymous route, I think you would be better off by saying I am Tinctorius and I wrote this code.  This code is free to use however you wish and I explicitly disclaim my copyright to this code.

Title: Anonymous software license


答:
The GNU license's disclaimer is there so that, by default, developers are disrobed of any liability arising from running the software.

Even if you feel that programmers should be liable for bad software, the fact is that the software is free.

The disclaimer simply says that what is being distributed is the software only, not any warranty protection.

The GNU model for making money from software is to sell services, or warranty protection.

A warranty is more then just a statement of confidence that the product is fit for a purpose. There has to be some money riding on it. At the very least "money back", or more: an obligation to perform work to bring the product to a condition such that it is fit for the covered purpose, or even to cover some losses and damages.

The presence or absence of a warranty doesn't change what the product is; it just a form of insurance which changes how the risk is distributed between vendor and customer.

This business of providing obligations over free software is actually quite common. Anyone who works commercially with free software will usually patch it if the customer has a problem. If you make some hardware box which runs an embedded Linux distro on it, and it has a problem because of a bug in the kernel, C library or anywhere else, you fix it for the customers. The situation is that your box has the issue, and you promised the customers a box that is reliable, 24/7.


答:
The concept being conveyed is something which is definitely part of agile and relevant, the idea of pushing things off to the last responsible moment.

However the example taken actually relies on a completely false assumption to begin with:

that it is easier/less work to implement a flat-file database than use an RDBMS. -- Often completely false

The example should be: The persistence layer is kept to the simplest possible implementation until a decision is made that it is inadequate.

For many development teams, getting a database stood up to do this is a matter of an hour or two (or 15 minutes for small database with ORM) while a flat-file database that they don't keep needing to meddle with may be an enormous pain and annoyance because they have to hand-write all the seek and data-table construction type code manually, when a database may be as simple as creating a table in a UI, adding a few columns, and then having an ORM generate everything else you need.

Furthermore, if you don't know your persistence layer to begin with it is an even more appropriate act to start with a common RDBMS that your team knows well, as to make the change later from flat-file to RDBMS is much larger than later changing from one RDBMS to another. There are many tools for converting from most any common RDBMS to other such ones, and tips and such because it is a well-travelled path. There are extremely few tools for converting from a flat-file to any given RDBMS where your flat-file has some proprietary format that tooling hasn't previously been written for aside from your own libraries.

In summary:
The concept is correct and accurate, but the example is based on a terribly large and often(almost always) inaccurate assumption.


问:
Hardware key removal on a test system
One of my company's applications still requires a hardware key to run, but we're currently in the process of removing that requirement and replacing it with an online check.  The issue we are having is that we allow our customers to set up test systems with copies of their live databases.  With the hardware keys, that isn't a problem as they get a special key that tells the software it is a test, but we're trying to figure a way to do this with a software only check.  Our only idea so far is to check the hardware against a registered list in the database, but before we implement this, I want to ask how others have solved similar problems?</p>

答:
Certificates are easy to set up on a per-machine basis. Create a doc containing the limiting criteria that the cert is good for: DB size, # clients, # processes, CPU time, expiration date, etc. Then add something unique to the machine (e.g. the MAC address of one of their ethernet interfaces, UUID of the root device, whatever), and then sign the cert with your private key. The software uses your public key to verify the signature, then does whatever.

Note that this only requires a one-time net/phone/email verification process to generate the signed certificate, something that was important to us when we were dealing with certain government agencies who have air-gap security requirements. They would email us the unique value (we were using MAC addresses), and we would email back a signed certificate, which was then hand-carried into the SCIF.

Since the signing / verification process is completely independent of the contents of the license, you can change the contents/uses over time without having to reengineer your entire license management process.

You can buy software to do this, but there are a lot of open source resources on this subject. Things to read and / or download:

Digital Signatures

Certificate Authorities

OpenCA

Title: Hardware key removal on a test system


问:
Distributed SCRUM team issues: The work environment
One interesting issue appeared for me today. In a distributed SCRUM team when do you start enforcing an unitary work environment in terms of code format, IDE plugins (checkstyle & co), VCS, CI? The team is in an exploratory phase and thegoal is not production quality code but rather proof-of-concept. Isn't it an overhead to enforce some common coding rules "a priori" - before the team members decide which are really relevant for their future work? Using this kind of tools is for sure a huge benefit because they act as an heuristic to minimize the technical debt but enforcing rules as "no trailng spaces" that really break the Jenkins build seems for me an overkill for a phase that should be focused rather on ice-beaking than on creating production code.

Mention 1: the prototypes create will be thrown away

Mention 2: although I wish that everything should be done right from the beginning - I m totally aware that it is not 100% possible.

答:
I guess this really depends on teams and how much do you care about checkstyle. I agree that we should have some kind of rules to prevent some unnecessary bugs. But some rules are rather annoying than productive. I guess you have to agree within the team what rules are necessary and unnecessary.

Setting Jenkins jobs for checkstyle or firebug is good as well, but again you have to agree how strict you want it to be. I have been in a situation where somebody broke some checkstyle rule and we prevent anyone from committing. In the long run, it'll just annoy people. Again, if you said people don't have to pay attention much they'll start ignoring them. So, in my team we kind of agree that as long as the quality job isn't badly broken. It has to be blue before the end of the sprint.

So my suggestion would be, timebox the meeting so you don't spend much time on creating rules and discussing about rules.

Some thoughts, modern IDEs have checkstyle plugin to alert people when some rules have been broken the team can agree just to check during the code review before they commit. That helps for my team as well.


答:
A lot of people misconstrue that aspect of agile as meaning they shouldn't plan ahead for future features.  Nothing could be further from the truth.  What you don't do is allow planning for future features to delay delivering value to your customers now.

How that applies to something like persistence depends very much on your application.  One of my current hobby projects is a calculator.  Eventually, I would like to be able to store user defined constants and functions, and save the state when I close the program.  That requires persistence, but I haven't even started to think about what form that would take.  My program will be very usable without persistence, and adding it now will add significant delay to my first release.  I would rather have a working calculator with fewer features than none at all while I wait for it to be perfect.

Another hobby project of mine is for video and photograph color correction.  This application will be completely unusable without being able to save my work in progress, and the code needed to do so is pervasive throughout the entire program.  If I don't get it right from the start, then changing it could be prohibitively difficult, so I've spent quite a bit of effort on persistence up front.

Most projects would fall somewhere between, but you should never feel bad about planning for future features if it adds little to no extra effort now.  Databases may be complex, but most of that complexity is hidden behind a solid, well-tested interface.  The work you will have to do in your application may very well be less for a database than a flat file, because of all the features a database gives you for free.  There are "hybrid" options like SQLite if you don't want to deal with the hassle of a database server yet.


问:
programming PID loops in C
I'm an electrical engineer that was kind of thrust into the digital world and learning as I go. I'm programming a TI processor to do a PID (proportional-integral-derivative) loop, illustrated by this diagram:

I'll also describe it:

Negative feedback op-amp, with non-inverting terminal grounded. Input through negative terminal. The feedback loop is an RE series circuit in parallel with a resistor and all that in parallel with a cap.

Anyone have any idea how to convert this circuit to C code? I'm a bit out of my element on this and could use the help.

答:
The Circuit

Ok i just created an account in here when i saw this question. Am not able to edit your question so that i could correct the typo you did. I believe you meant RC series circuit in parallel instead of RE ( if it is, I don't have a single clue what it means)

Seems like the analog circuit you want to simulate using C looks something like this

```<code>                         Ci
                  |------| |--------------|
                  |           Rp          |
                  |----/\/\/\/\-----------|
                  |          Rd    Cd     |
           Rf     |----/\/\/\---| |-------|
Vin o----/\/\/\---|                       |
                  |    |\                 |
                  |    | \                |
                  |----|- \               |
                       |   \              |
                       |    \-------------|---------o  Vout
                       |    /
                       |   /
                       |+ /
                   ----| /
                  |    |/
                  |
                  |
               ___|___ GND
                _____
                 ___
                  _

LEGEND:
  Vin is the input signal.
  Vout is the Output.
  Rp controls the propotional term ( P in PID)
  Ci controls the Integral term ( I id PID)
  Rd and Cd controls the differential term ( D in PID)
  Rf is the gain control, which is common to all of the above controllers.
</code>```

(I couldn't resist my urge to draw this since i wanted to tell you how electrical/electronics engineers used to communicate in forums and emails without images ... and why we just love courier, fixed width font)

I must confess that the circuit you are using is simple to setup but is very complex mathematically, when it comes to tune the Propotional, Integral and Derivative constants of the system to a desired value individually its not possible.

I strongly suggest you use the circuit from this source for studying.

Even though a little tedious to set up, mathematically its much simpler to analyse as you can directly relate it to the standard mathematical form instead of ideal one.

Lastly the Vout goes to control a motor or whatever needs to be controlled. And Vin is the Process variable voltage.

Before getting your feet wet in C (sea?)

I assume you are reading the signals from some kind of analogue to digital converter. If not then you would have to simulate the signal as an input.

If using Standard form we have,

Assuming the the loop running time is small enough (a slow process), we can use the following function for calculating output,

```<code>output = Kp * err + (Ki * int * dt) + (Kd * der /dt);
</code>```

where

```<code>Kp = Proptional Constant.
Ki = Integral Constant.
Kd = Derivative Constant.
err = Expected Output - Actual Output ie. error;
int  = int from previous loop + err; ( i.e. integral error )
der  = err - err from previous loop; ( i.e. differential error)
dt = execution time of loop.
</code>```

where initially 'der' and 'int' would be zero. If you use a delay function in code to tune the loop frequency to say 1 KHz then your dt would be 0.001 seconds.

Drawning in C

I found this excellent code for PID in C, though it doesn't cover every aspect of it, its a good one nonetheless.

```<code>//get value of setpoint from user
while(1){
  // reset Timer
  // write code to escape loop on receiving a keyboard interrupt.
  // read the value of Vin from ADC ( Analogue to digital converter).
  // Calculate the output using the formula discussed previously.
  // Apply the calculated outpout to DAC ( digital to analogue converter).
  // wait till the Timer reach 'dt' seconds.
}
</code>```

If we take a slow process, then we can use lower frequency such that dt >>> code execution time for single loop ( far far greater than ). In such cases we can do away with timer and use a delay function instead.

Title: programming PID loops in C

Body:
The Circuit

Ok i just created an account in here when i saw this question. Am not able to edit your question so that i could correct the typo you did. I believe you meant RC series circuit in parallel instead of RE ( if it is, I don't have a single clue what it means)

Seems like the analog circuit you want to simulate using C looks something like this

                         Ci
                  |------| |--------------|
                  |           Rp          |
                  |----/\/\/\/\-----------|
                  |          Rd    Cd     |
           Rf     |----/\/\/\---| |-------|
Vin o----/\/\/\---|                       |
                  |    |\                 |
                  |    | \                |
                  |----|- \               |
                       |   \              |
                       |    \-------------|---------o  Vout
                       |    /
                       |   /
                       |+ /
                   ----| /
                  |    |/
                  |
                  |
               ___|___ GND
                _____
                 ___
                  _

LEGEND:
  Vin is the input signal.
  Vout is the Output.
  Rp controls the propotional term ( P in PID)
  Ci controls the Integral term ( I id PID)
  Rd and Cd controls the differential term ( D in PID)
  Rf is the gain control, which is common to all of the above controllers.

(I couldn't resist my urge to draw this since i wanted to tell you how electrical/electronics engineers used to communicate in forums and emails without images ... and why we just love courier, fixed width font)

I must confess that the circuit you are using is simple to setup but is very complex mathematically, when it comes to tune the Propotional, Integral and Derivative constants of the system to a desired value individually its not possible.

I strongly suggest you use the circuit from this source for studying.

Even though a little tedious to set up, mathematically its much simpler to analyse as you can directly relate it to the standard mathematical form instead of ideal one.

Lastly the Vout goes to control a motor or whatever needs to be controlled. And Vin is the Process variable voltage.

Before getting your feet wet in C (sea?)

I assume you are reading the signals from some kind of analogue to digital converter. If not then you would have to simulate the signal as an input.

If using Standard form we have,

Assuming the the loop running time is small enough (a slow process), we can use the following function for calculating output,

output = Kp * err + (Ki * int * dt) + (Kd * der /dt);

where

Kp = Proptional Constant.
Ki = Integral Constant.
Kd = Derivative Constant.
err = Expected Output - Actual Output ie. error;
int  = int from previous loop + err; ( i.e. integral error )
der  = err - err from previous loop; ( i.e. differential error)
dt = execution time of loop.

where initially 'der' and 'int' would be zero. If you use a delay function in code to tune the loop frequency to say 1 KHz then your dt would be 0.001 seconds.

Drawning in C

I found this excellent code for PID in C, though it doesn't cover every aspect of it, its a good one nonetheless.

//get value of setpoint from user
while(1){
  // reset Timer
  // write code to escape loop on receiving a keyboard interrupt.
  // read the value of Vin from ADC ( Analogue to digital converter).
  // Calculate the output using the formula discussed previously.
  // Apply the calculated outpout to DAC ( digital to analogue converter).
  // wait till the Timer reach 'dt' seconds.
}

If we take a slow process, then we can use lower frequency such that dt >>> code execution time for single loop ( far far greater than ). In such cases we can do away with timer and use a delay function instead.

ContentLicense: CC BY-SA 4.0


问:
How important is it to reduce the number of lines in code?
I am a Software developer who works on J2SE (core java).

Often during our code reviews we are asked to reduce the number of lines in our code.

It's not about removing redundant code, it's about following a style that focuses on doing the same things with fewer lines in the code, while I believe in having clarity in code even if it means increasing the number of lines.

What do you think is the right way of doing things?

If LOC (lines of code) is a small number, how does it affect the code?
If LOC is a larger number, how does it affect the code?

example from the website : "javaranch"  -

```<code>public static void happyBirthday(int age)
{
    if ((age == 16) || (age == 21) || ((age > 21) && (((age % 10) == 0) || ((age % 25) == 0))))
    {
        System.out.println("Super special party, this year!");
    }
    else
    {
        System.out.println("One year older. Again.");
    }
}
</code>```

VS

```<code>public static void happyBirthday(int age)
{

    boolean sweet_sixteen = (age == 16);
    boolean majority = (age == 21);
    boolean adult = (age > 21);
    boolean decade = (age % 10) == 0;
    boolean quarter = (age % 25) == 0;

    if (sweet_sixteen || majority || (adult && (decade || quarter)))
    {
        System.out.println("Super special party, this year!");
    }
    else
    {
        System.out.println("One year older. Again.");
    }
}
</code>```

答:
I  wouldn't see the number of lines as an issue in normal circumstances, but it can point to issues. If some-one shows you a class with 1000 lines of code, then something must be wrong with the way the class was done or designed.

Your example does point to a case where a larger number of lines of code makes sense. But that is that example. Every day I see examples where the number of lines is attached to lack of planning


答:
There is a much bigger issue at play here.

Many companies have one goal - to increase shareholder wealth.
What they produce is irrelevant.
How they produce it is irrelevant.
How much waste they produce is irrelevant.
The cost to society and the planet is irrelevant.

So - go work for or start a company that does something of benefit for society / the planet.


问:
How can I deal with a team member who dislikes making comments in code?
One of my team members consistently avoids making comments in his code.

His code is not self-documenting, and other programmers have a difficult time understanding his code.

I have asked him several times to comment his code, however he just gives excuses or claims that he will do it later. His concern is that adding comments will take too much time and delay the projects.

What argument can I present to him to convince him to properly document his code?

On that note, am I wrong to focus on the code comments or is this indicative of a larger problem which should be addressed?

答:
Love the code review answers, but perhaps my process will help a little too.

I love comments, but I almost never add them into the code on the first pass.  Maybe it's just my style but I'll hit the same section of code 3 to 5 times during development (refactoring, writing tests, etc).

Whenever I get slightly confused or whenever someone asks me a question about a section of code I attempt to fix it so that it makes sense.

This can be as simple as adding a commento removing a confusing set of operations into their own function or it can trigger a larger refactor like extracting a new object.

I suggest that you encourage everyone in the group to "own" that their code is readable to others--this means that every time someone asks you a question about your code, you commit to making a change--or better yet pair with that person to make the change right then!

Seriously consider pushing for this as part of your "Team Contract" (And definitly create a contract if you don't have one)--that way everyone has agreed on it and you have it up on a wall somewhere so that there isn't any question about what you've agreed to do.


问:
Why use partial classes?
In my understanding, the partial keyword does nothing but allow a class to be split between several source files. Is there any reason to do this other than for code organization? I've seen it used for that in generated UI classes.

It seems a poor reason to create a whole keyword. If a class is big enough to require multiple files, it probably is doing too much. I thought that perhaps you could use it to partially define a class for another programmer somewhere to complete, but it would be better to make an abstract class.

答:
I've not seen it mentioned by anyone: I use partial to put nested classes in their own files.

All my code files contain only one class, struct, interface or enum. It makes it a lot easier to find the definition for an object when the file names show the name of the thing you're looking for. And since Visual Studio tries to match the project folders to the namespaces, the filenames should match the classes.

This also means that a class NestedClass nested inside MyClass will have it's own file in my projects: MyClass.NestedClass.cs.

```<code>partial class MyClass
{
    private class NestedClass
    {
        // ...
    }
}
</code>```

Title: Why use partial classes?

Body:
I've not seen it mentioned by anyone: I use partial to put nested classes in their own files.

All my code files contain only one class, struct, interface or enum. It makes it a lot easier to find the definition for an object when the file names show the name of the thing you're looking for. And since Visual Studio tries to match the project folders to the namespaces, the filenames should match the classes.

This also means that a class NestedClass nested inside MyClass will have it's own file in my projects: MyClass.NestedClass.cs.

partial class MyClass
{
    private class NestedClass
    {
        // ...
    }
}


答:
I think there are 3 parts to the issue:

You want to save technical debt/headaches down the road by enforcing good rules now.

You don't want to kill team velocity by bogging everyone down with unnecessary rules.

You don't know exactly the best rules to implement, because the project is in an exploratory phase.

I've tried both the extremes (from no rules, just use the same source control, to a 20 page coding style guideline + many other processes)

The only thing that's worked consistently is embracing the absolute minimum I know I need and can prove I need right now, and revising the process regularly.  (Every sprint in the retrospective is a good time to do it) This also includes removing any vestigial rules.

Title: Distributed SCRUM team issues: The work environment

Body:
One interesting issue appeared for me today. In a distributed SCRUM team when do you start enforcing an unitary work environment in terms of code format, IDE plugins (checkstyle & co), VCS, CI? The team is in an exploratory phase and thegoal is not production quality code but rather proof-of-concept. Isn't it an overhead to enforce some common coding rules "a priori" - before the team members decide which are really relevant for their future work? Using this kind of tools is for sure a huge benefit because they act as an heuristic to minimize the technical debt but enforcing rules as "no trailng spaces" that really break the Jenkins build seems for me an overkill for a phase that should be focused rather on ice-beaking than on creating production code.

Mention 1: the prototypes create will be thrown away

Mention 2: although I wish that everything should be done right from the beginning - I m totally aware that it is not 100% possible.


问:
Deliverables in a software development project
Following a standard framework of project management, for a software development project we will provide deliverables (documents and software) at the end of each month :

My question is:

From May to June, while software is in development, what would be the deliverable for each month?

Each document starts as version 1.0. Is it possible to deliver same document one or two months later as version 2.0? Because it could happen changes on the way.

Users and clients ask me they want to see something as deliverable for each month, so they won't feel that the project is going without direction.

答:
Based on the above you have a schedule of work. That work includes the specifications, technical requirements and a prototype.

Based on this I would expect that the deliverables in May->August would be a phased release of the application/project with each release building on the prototype so that in May the application/project would be 25% complete, June 50% complete etc.

Of course within that 25% complete in May some modules may be 100% complete and others 0% complete.

Before signing off on deliverables for May->August you should specify what aspects/modules of the application/project will be completed in each month.

Yes it is possible that based on delivered modules/changing requirements that the version could be move from 1.0 to 2.0 but it would be more normal for minor changes to be 1.0 to 1.1 or 1.2 etc.

If halfway through the project you are experiencing major version changes it is most likely that you will not be able to complete the project on time with the required functionality.


答:
Considering the often extreme views on commenting, I hesitate to weigh in. That being said...

What are some arguments that I can present that if you are going to
  write (unreadable) code that it should be properly documented?

Understanding how to write maintainable and readable code takes time, practice, and experience.  Inexperienced programmers (and sadly many experienced ones) often suffer from the Ikea Effect (PDF). That is because they built it and are intimately familiar with it, and they are sure the code is not only great, but readable as well.

If the person is a great programmer, then little if any documentation is required.  However, most programmers aren't great and a lot of their code will suffer in the "readablity" department. Asking the mediocre or developing programmer to "explain their code" is useful in that it forces them to view their code with a more critical eye.

Does this mean "documenting" their code? Not necessarily. Case in point, I had a similar programmer with this issue in the past.  I forced him to document.  Unfortunately his documentation was as indecipherable as his code, and didn't add anything.  In retrospect code reviews would have been more helpful.

You (or a delegate) should sit down with this programmer and pull up some of his older code. Not the new stuff he knows from just working on it.  You should ask him to walk you through his code with minimal interaction.  This could also be a separate "documenting" session, where he is to explain in writing his code.  Then he should get feedback on better approaches.

As an aside... some documentation is sometimes needed regardless of how good the "readablity" of the code is.  API's should have documentation, extremely technical and complex operations should have documentation to assist the programmer in understanding the processes involved (often outside of the programmers domain of knowledge), and some things like complex regex'es should really document what you are matching against.

Title: How can I deal with a team member who dislikes making comments in code?

Body:
One of my team members consistently avoids making comments in his code.

His code is not self-documenting, and other programmers have a difficult time understanding his code.

I have asked him several times to comment his code, however he just gives excuses or claims that he will do it later. His concern is that adding comments will take too much time and delay the projects.

What argument can I present to him to convince him to properly document his code?

On that note, am I wrong to focus on the code comments or is this indicative of a larger problem which should be addressed?


问:
Error checking in actor-based paradigm
I have an existing Scala application that I am trying to refactor in order to use Akka. One of the problems I have is how to manage error-checking in actor-based applications.

Usually error-checking is done through one of two mechanisms:

either one returns a value indicating an error condition, such as Option[A] or Failure[A], or

by the use of exceptions.

Neither of these style seems particulary useful here. On the one hand, actor messages are usually "fire and forget", hence there are no return values. [One can have a return value using Futures, but it certainly not customary to ask for futures on every message.] On the other hand, processing of the message usually happens on another thread, so that one cannot catch an exception arising from the processing of a message.

One could simulate the first mechanism by sending back error or confirmation messages, such as

```<code>class FooActor extends Actor {
  def receive = {
    case Foo => ...
      if (errorCondition) sender ! ErrorMessage
  }
}
</code>```

But if one has to do this for every actor, it becomes a lot of boilerplate and it seems a poor man's simulation of stack unwinding.

What is a good strategy to recover from errors in actor-based applications?

答: Based on your example with the database connection failing, I think you need to introduce another actor. This actor holds a queue of the messages that contain the data that needs to be written to the database. You then have the actor that holds the database connection request the next message to be saved to the database by sending a message to the queue actor. Then, a message containing the data to be saved is sent to the database actor and upon successful save, the database actor sends a message to the queue actor signifying a successful save. At this point, the message that was just saved can be removed from the queue and the next message sent to the database actor, if there is one. However, if the database actor crashes, the message signifying the successful save is never sent, and thus the message is still in the queue actor. When the database actor starts back up, it will simply tell the queue actor it is ready to process again, and the previous message that was not saved to the database will be sent again.</p>

Title: Error checking in actor-based paradigm


答:
Should you try persistence in a flat file before database?

Yes, you should try it. Especially if you've never tried it before. No matter how it turns out, you'll learn something.


问:
Whats the greatest most impressive programing feat you ever witnessed?
Everyone knows of the old adage that the best programmers can be orders of magnitude better than the average. I've personally seen good code and programmers, but never something so absurd. So the questions is, what is the most impressive feat of programming you ever witnessed or heard of?

You can define impressive by:

The scope of the task at hand e.g. John single handedly developed the framework for his company, a work comparable in scope to what the other 200 employed were doing combined.

Speed e.g. Stu programmed an entire real time multi-tasking app OS on an weekened including  its own C compiler and shell command line tools

Complexity e.g. Jane rearchitected our entire 10 millon LOC app to work in a cluster of servers. And she did it in an afternoon.

Quality e.g. Charles's code had a rate of defects per LOC 100 times lesser than the company average. Furthermore he code was clean and understandable by all.

Obviously, the more of these characteristics combined, and the more extreme each of them, the more impressive is the feat.

So, let me have it. What's the most absurd feat you can recount? Please provide as much detail as possible and try to avoid urban legends or exaggerations. Post only what you can actually vouch for.

Bonus questions:

Was the herculean task a one-of, or did the individual regularly amazed people?

How do you explain such impressive performance?

How was the programmer recognized for such awesome work?

答:
There is this one programmer where I work who has done the following on more than one occassion.

The most recent example was a project in our group that was assigned to 3 people.  It was a complex LOB app with a 6 month schedule (that was an extremely aggressive timeline).

The week coding was to begin, 1 of the 3 people quit (for personal reasons) and another left on a very sudden medical leave.  The lone remaining programmer went home to start programming and returned 3 months later with the completed application.

EDIT

Just to add some clarification.  The resulting code was nearly perfect, spot-on to the requirements and our QA group was only able to document 3 defects.