答:
Use transactions.

If you are using a database that supports transactions, then run each test in a transaction.  Rollback the transaction at the end of the test.  Then each test will leave the database unchanged.

Yes, to cancel an order you will first have to create one.  That's fine.  The test will first create an order, then cancel it, then verify that the order is cancelled.

Title: Creating Unit Tests on a CRUD layer of an Application, how can I make the tests independent?

Body:
So I'm trying to make my Unit Tests as by-the-book as possible, but it becomes troublesome when I'm testing some simple Add/Delete methods.

For the add method, I basically have to create a dummy object and add it, then after the test is successful, I have to delete the dummy object.

And for the delete test, I obviously have to create a dummy object so that I can delete it.

As you can see if one test fails, the other will fail too, as they're both kinda needed.

Same with a system where you would need to write a test that "Cancels an Order"...well some dummy order would be needed to cancel first, doesn't this go against the guidelines of unit testing?

How are cases like this meant to be handled?


问:
Creating Unit Tests on a CRUD layer of an Application, how can I make the tests independent?
So I'm trying to make my Unit Tests as by-the-book as possible, but it becomes troublesome when I'm testing some simple Add/Delete methods.

For the add method, I basically have to create a dummy object and add it, then after the test is successful, I have to delete the dummy object.

And for the delete test, I obviously have to create a dummy object so that I can delete it.

As you can see if one test fails, the other will fail too, as they're both kinda needed.

Same with a system where you would need to write a test that "Cancels an Order"...well some dummy order would be needed to cancel first, doesn't this go against the guidelines of unit testing?

How are cases like this meant to be handled?

答:
Well, there's nothing wrong with what you're doing. Multiple tests can cover the same code; it just means that one problem will cause several tests to fail. What you want to avoid is tests that depend on the results of other tests. I.e., your delete test depends on the add test having run, and thus if you run your delete test BEFORE your add test, it will fail. To avoid that problem, make sure that you have a "blank slate" at the start of each test, so that what happens in a given test can't affect subsequent tests.

A great way to do that is to run the tests against an in-memory database.

In your add test, create an empty database, add the object, and assert that it has indeed been added.

In your delete test, create the database with the object you'll be deleting already in it. Delete the object, and assert that it has been deleted.

Blow away the database in your tear-down code.

ContentLicense: CC BY-SA 3.0


答: You're doing it fine. The one and only fundamental principle of unit testing is to cover every code path you have, so you can be confident that your code is doing what it's supposed to do, and keeps doing it after changes and refactorings. Keeping unit tests small, simple and single-purpose is a worthwhile goal, but it is not fundamental. Having a test that calls two relate methods of your API is not in itself questionable, in fact, as you point out, it is often necessary. The drawback of having redundant tests is just that they take more time to write, but as almost everything in development, this is a trade-off you have to make all the time, and the best solution is almost never one of the extreme points.</p>


答:
As you can see if one test fails, the other will fail too, as they're both kinda needed.

So?

... doesn't this go against the guidelines of unit testing?

No.

How are cases like this meant to be handled?

Several tests can independent and all fail because of the same bug.  That's actually normal.  A lot of tests may -- indirectly -- test some common functionality.  And all fail when the common functionality is broken.  Nothing wrong with it.

Unit tests are defined as classes precisely so they can easily share code, like a common dummy record used to test update and delete.


答:
You can use a mock framework or use an 'environment' with an in-memory database. The last one is a class where you can create everything you need to make the test pass, before the test runs.

I prefer the last one - the users can help you input some data so your tests become closest to the real world.


问:
How serious is losing the source code?
If a software company loses the source code to one of the products they are selling, how serious would that be, in terms you could explain to a layman?  Would the term "gross negligence" be too strong?  Or "gross incompetence"?  Obviously no one got killed but isn't it as serious as some financial negligence that people get jail time for?

EDIT:
Let's say it's not a case of a disk drive crashing, natural disaster or anything like that.  Just they misplaced it.

答:
If they don't have to fix any bugs, then it's probably not that big of a deal.  For example, if the company makes custom ActiveX controls, and they lose the source to one of their legacy products, then who really cares?  The product probably isn't actively maintained, and likely isn't being aggressively marketed, either.  They'll sell it as long as people still use 32-bit ActiveX, and then forget about it.

That said, I'd still classify it as gross negligence.  Obviously there's no source code management system in place, which is professional incompetence for a software house.

ContentLicense: CC BY-SA 2.5

Title: How serious is losing the source code?


问:
Is mootools alternative of jquery + backbone / spine / sprouteCore
I was a full time java developer, now I'm also working with JavaScript and Android. A couple of years back when I started learning JavaScript, the first library I tried was jQuery. But it made my life harder, and after sometime I started writing fairly large a JavaScript app. It wasn't coming together for me using jQuery. I had huge a code base without much of a structure. Method blocks updating HTML blocks using selectors.

Then I tried MooTools and obviously as a Java developer it appealed to me a lot. And I was able to write managable web apps having huge code base.

As per my understanding MooTools is not considered a preferred way to write JavaScript because it mimics conventional OO over default prototype-based OO language. So now to really understand Javascript and desire of walking with the world, I decided to try other approaches, so again I turned back to jQuery, and realise that only jQueryis not enough.

So started looking at current trending frameworks like backbone, spine, ember.js, sprouteCore. Strangely I found that these frameworks mimic conventional OO like MooTools only by having constructors and creating a object of class and reusing this class object to create instance objects. So

Am I missing something?

Is MooTools really wrong?

MooTools project is very alive and releases new versions/features, but I don't
see many people talking about it on internet, also there are no
comparisons vs backbone/spine etc.

答:
If you are missing anything, I think that it is only that the large number of JS frameworks/libraries give you the option to choose the one that works best for you. I'm not personally a fan of techniques that try to force the round peg of JavaScript into the square hole of classic OOP, but my personal preference is well-served by the incredible set of alternatives to mooTools that are more prototypal.

Let's take a look at Google Web Toolkit: it allows you to write your code in Java and it translates that code into JavaScript to run in the browser. It's very unlikely that the resulting JavaScript has some quality of pureness or JavaScript correctness. It probably won't look good going through JSLint, but why would you care if your application runs the way that you want it to.

Similarly, the CoffeeScript language compiles to JavaScript and gives a completely different programming experience. Some people swear by it and couldn't go without it. Other people develop grand web apps and have not spent five minutes looking at it.

So if mooTools or some other framework presents a classic-OOP face to JavaScript, why would you care as long as you are productive and your application works?

Scott Hansleman called JavaScript the Assembly Language of the Web. After doing so, of course, he was immediately agreed with and reviled by large numbers of equally committed proponents and opponents, but there is a hard kernel of truth in it that any open-minded engineer is going to see. It is (in my opinion) to JavaScript's credit that it is flexible enough to be both a primary language and target for compilers.

As long as the approach works for you and whoever you are developing with and it makes your application work, go with it. Everything else is just some preacher shouting their special beliefs.


问:
What decent web-frameworks exists for functional programming?
I would like to do some web programming using functional programming. What decent web-frameworks exists for functional programming languages?</p>

答:
Snap is a nice and really fast web framework for Haskell.

a simple web development framework for unix systems, written in the Haskell programming language. Snap has a high level of test coverage and is well-documented. Features include:

A fast HTTP server library

A sensible and clean monad for web programming

An HTML-based templating system for generating pages...


问:
If I use multiple third party components, using several different open source licenses, how should I attribute them?
I'm developing a Java application that utilizes several third party open source libraries. I'm adding a section to my app's "About" dialog that lists the components and their license notices.

For those that use the same license, do I have to repeat the same license text for each one? For example, I use several components that are all released under the Apache 2 license. Do I have to list the Apache 2 license terms for each one, or just say "Foo, Bar, and Baz are used under the terms of the Apache 2 License" and list the actual terms once?

Thanks. Just want to do the right thing.

答: I'd say that a line per component saying "Built using foo, licensed under bar" (With bar being a link to the license), is enough.</p>


问:
Is Software Testing Really Needed?
I'm a student working on my B.E(CS) and my question is the following:

Is testing in the software field needed?

If we create a software with great care, then why should we test?

After testing can we be sure that we have achieved this goal (the product/software works as intended) because we have done the testing for it? Is it possible?

My question: Is testing of software needed?

答:
Smells like a homework question.

Is testing in the software field needed?

Yes.  Absolutely.  At all levels.  Outside of a few specialized domains, we're not yet at a stage where we can mathematically prove our code is correct against specific bugs (at least not in a reasonable time frame), so we have to throw rocks at it to see if and where it breaks.

If we create a software with great care, then why should we test?

Testing isn't just about finding coding errors.  It's also about making sure that you've met all your requirements, and that the overall system performs as expected.  If I have a requirement that a failed transaction must return a specific error code, then I need to write a test to verify both that the functionality exists and that it works correctly.

And all that assumes that the specification and the design are complete, correct, and internally consistent, which is often not the case.  Even if you meet the specification to the letter and follow the design down to the last dot and semicolon, if the spec or design is bad, then there are going to be problems at integration time.  Often, system or integration testing is when you find out that the specification itself is buggy and needs to be revised (see war story below).

After testing can we be sure that we have achieved this goal (the product/software works as intended) because we have done the testing for it? Is it possible?

No, not to 100%.  We can't test every conceivable combination of inputs or paths of execution in any but the simplest code.  We can't account for all environmental factors.  We can't imagine all possible failure modes.

We can test to a point where we're reasonably sure there aren't any big problems.  Again, this is why we need to test at all levels.  Write a suite of tests to make sure your code handles edge conditions properly (bad input, unexpected results, exceptions, etc.).  Unit test to verify that your code meets its requirements.  System test to verify end-to-end processing.  Integration test to verify that all components speak to each other correctly.  Do usability testing to make sure that the whole thing works in such a way that customers don't want to shoot you.

Real-world scenario - I was working on a back-end system that occasionally sent updates to a GUI service for display in a table on the screen.  During the project, a requirement was added to add filtering to the display (e.g., the operator could choose do display a subset of the entries in the table).  Design mistake #1 - filtering should have been done by the GUI service (I have this quaint, antiquarian notion that display management functions should be the responsibility of the display management software), but due to politics and my inability to recognize problems before they become problems, that requirement was placed on the back-end service.  Well, okay, no problem, I can do that.  Filter state changes, I get a message, and then I send a create or delete message for each row in the table, because that's how the interface works (design mistake #2 - there's no way to send updates to multiple rows in a single message; we couldn't even send a single "clear" or "delete" message to clear the entire table).

Well, everthing works fine during development; unit, system, and integration testing show that I send the right information and handle the filter changes correctly.  Then we get to usability testing, and the whole thing falls down hard, because the volume of data was overwhelming.  The network latency between my backend service and the GUI was on the order of .15 to .25 seconds.  Not bad if you only have to send updates for a dozen rows or so.  Deadly when you have to send updates for several hundred.  We started getting bug reports that the GUI was freezing up after changing the filter state; well, no, what was happening was that it was taking on the order of several minutes to update the display because the bone-headed update-one-row-at-a-time message protocol couldn't handle a real-world scenario.

Note that all of that could have and should have been anticipated by everyone from the prime contractor all the way down to little old me if we had bothered to do even the most basic analysis beforehand.  The only defense I'll offer is that we were closing out the second year of a six-month project that was going to be junked almost immediately after delivery, and we were all just desperate to see the back of it.

Which brings us to the final reason to test - CYA.  Real-world projects fail for a variety of reasons, many of them political, and not everyone acts in good faith when things go wrong.  Fingers get pointed, accusations get made, and at the end of the day you need to be able to point to a record showing that at least your stuff worked as it was supposed to.

Title: Is Software Testing Really Needed?


问:
A progressive plan from vb6 to .net, sound?
We are about to start a new project using an existing SQL DB, but this project is going to need to reuse a number of core features from an existing vb6 app that uses the same database.

The approach I would like to try:

Have the existing vb6 application be the entry point, but immediately call a .net class to present the main screen and menu. If the user needs to use a feature/form that is in vb6 then raise an event to vb6 to load that form and hide the .net side of it until it's done.

The alternative:

Opposite of the above, create a .net exe to be the entry point and call a vb6 dll whenever I need a vb6 feature/form.

Because of initialization that goes on in the vb6 app that makes various features usable, it would be much less painful for me to try the first approach.  Moreover, there is some functionality that is very tightly coupled to the forms in the vb6 app and is vital to the application, but I will not be able to immediately port it to .net in the first phase.

I realize this is not the ideal approach but unfortunately there are real world concerns that make taking the idealistic approach near (if not entirely) impossible.

So my question is: are any specific pitfalls I should be aware of in doing this?

答:
I'd say the most viable approach is to use the Strangler Vine method. Martin Fowler does a great job at describing the approach (I also found an article on docstoc that goes into more detail.

Also it's hard to recommend which approach would work best for you, but I've always found that hosting VB forms in .NET is easier than the reverse.

OwnerDisplayName: Brandon Moore


答:
IANAL and questions like this are always best put to a lawyer but:

The best source of information regarding this would be the websites of the organisations for the licences. Sometimes they contain FAQs that answer these questions. If not you'll have to refer to the licences themselves e.g. http://www.apache.org/licenses/LICENSE-2.0.html which contains:

Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:

You must give any other recipients of the Work or Derivative Works a copy of this License; and

You must cause any modified files to carry prominent notices stating that You changed the files; and

You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and

If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.

Notice that there are more conditions than merely including the licence file. Sometimes these conditions can be quite strict e.g. for the GPL.

So, to answer your question more directly: In the About dialog you may want to mention which components (and licences) are included in your application, however I would be surprised if it is required (many applications would not even have an About dialog). Generally speaking, you just need to keep files like the licence file and in this case the 'NOTICE' file in your distribution (as well as meeting any the other conditions like those of modified files).

That being said, I also like to give credit to the giants whose shoulders I stand on by including their logos/names in the splash screen, About dialog etc.

Title: If I use multiple third party components, using several different open source licenses, how should I attribute them?

Body:
I'm developing a Java application that utilizes several third party open source libraries. I'm adding a section to my app's "About" dialog that lists the components and their license notices.

For those that use the same license, do I have to repeat the same license text for each one? For example, I use several components that are all released under the Apache 2 license. Do I have to list the Apache 2 license terms for each one, or just say "Foo, Bar, and Baz are used under the terms of the Apache 2 License" and list the actual terms once?

Thanks. Just want to do the right thing.


答:
You aren't missing anything.

The pseudo-classical method of Object Oriented JavaScript has been an accepted technique for a very long time. There's certainly no reason you can't use it.

There are a couple reasons some people eschew it, though (myself included):

It's a misdirection - the pseudo-classical pattern, by necessity, uses prototypal inheritance, but this is not obvious. People who like to know what's going on at a low level (read: me) don't like non-obvious abstractions.

Purism - honestly not that great of a reason, but knowing how JavaScript works is good.

There are also several reasons that people eschew frameworks in general:

Overhead

Misdirection (non-obvious abstractions)

Poor APIs (which obviously depends on the framework)

Lack of modularity (they need one part of the framework, but don't want to load the whole thing)

The tendency, for people who want to avoid frameworks is to use micro-libraries, so they don't have to reinvent the wheel. Cross-browser XHR can be written in less than 20 lines (maybe far less than that). DOM interaction is similarly easy. Animations are less so, but there are still small libraries that can do animations. This is a modular approach that follows the concept of YAGNI, and keeps load times low.

jQuery in particular has a lot of issues. Some of which are solved by MooTools (which I'm just beginning to explore myself). Personally, I'm unfamiliar with many JS frameworks, but am exploring them simply for the sake of exploring them.

I find that since I know JavaScript fairly well, and how to properly construct object-oriented code in the language, I don't need a lot of what frameworks have to offer. I have no problem using the native DOM API. I have no problem using native prototypal inheritance patterns. And I have no problem using CSS for presentational bits (transitions in particular).

So, as I've become more well-versed in the ways of JavaScript, frameworks have become less of a nicety, and more of a burden. I keep my eye toward straightforward, modular code that is in line with YAGNI and DRY, and I think my applications are better for it.

Title: Is mootools alternative of jquery + backbone / spine / sprouteCore

Body:
I was a full time java developer, now I'm also working with JavaScript and Android. A couple of years back when I started learning JavaScript, the first library I tried was jQuery. But it made my life harder, and after sometime I started writing fairly large a JavaScript app. It wasn't coming together for me using jQuery. I had huge a code base without much of a structure. Method blocks updating HTML blocks using selectors.

Then I tried MooTools and obviously as a Java developer it appealed to me a lot. And I was able to write managable web apps having huge code base.

As per my understanding MooTools is not considered a preferred way to write JavaScript because it mimics conventional OO over default prototype-based OO language. So now to really understand Javascript and desire of walking with the world, I decided to try other approaches, so again I turned back to jQuery, and realise that only jQueryis not enough.

So started looking at current trending frameworks like backbone, spine, ember.js, sprouteCore. Strangely I found that these frameworks mimic conventional OO like MooTools only by having constructors and creating a object of class and reusing this class object to create instance objects. So

Am I missing something?

Is MooTools really wrong?

MooTools project is very alive and releases new versions/features, but I don't
see many people talking about it on internet, also there are no
comparisons vs backbone/spine etc.


问:
Enterprise scalable vs internet scalable, what is the meaning & differences?
While reading about Java EE applications, somewhere I have seen people saying they're enterprise scalable, I am confused as to what that really mean?

Are Java web applications mainly written & suitable for building enterprise management tools, not for the high traffic websites of today's world, that need to scaled to a large internet population?

答:
I see answers suggesting transactional isolation, language preferences or other hardware solutions to determine the difference.

Enterprise Scale = systems designed for usage in total employee &| customer populations.  Usually under a couple 100 thousand or so users.

Internet Scale = systems designed, or at least poised to handle everyone OTHER than your internal user population.

Online banking could be considered the edge of enterprise-internet scale, but do we think for a moment they don't value non-deferred transactions?  There are a few techniques used in architecting solutions between these, but there is no hard and fast rule.

Servlets/JSP is part of Java EE, but I would not hesitate to use 'em for an internet-scale system.  Conversely, I have seen near-internet-scale systems handled primary in the Unix shell (oh so taboo).  Go figure.


答:
Software testing techniques are extremely varied, and the more you educate yourself about them, you are going to begin seeing lots of different (and sometimes conflicting) guidance. There is no single 'book' to go by.

I think you are in a situation where you have seen some guidance for unit tests that say things like

Each test should be stand-alone, and not be affected by other tests

Each unit test should test one thing, and only one thing

Unit tests should not hit the database

and so on. And all of those are right, depending on how you define 'unit test'.

I would define a 'unit test' as something like: "a test that exercises one piece of functionality for one unit of code, isolated from other dependent components".

Under that definition, what you are doing (if it requires adding a record to a database before you can run the test) is not a 'unit test' at all, but more of what is commonly called an 'integration test'. (A true unit test, by my definition, won't hit the database, so you won't need to add a record before deleting it.)

An integration test will exercise functionality that uses multiple components (such as a user interface and a database), and the guidance that would apply to unit tests does not necessarily apply to integration tests.

As others have mentioned in their answers, what you are doing is not necessarily wrong even if you do things contrary to some unit test guidance. Instead, try to reason about what you are really testing in each test method, and if you find that you need multiple components to satisfy your test, and some components require pre-configuration, then go ahead and do it.

But most of all, understand that there are many kinds of software tests (unit tests, system tests, integration tests, exploratory tests, etc.), and don't try to apply the guidance of one type to all of the others.


问:
Optimization as a branch: is that a thing?
My company has highly optimized scientific application which has become so big and complicated that new versions are literally taking t = infinity to produce.  (E.G. I have an email which pre-announces a late 2007 release for something that has not been released yet.)  New feature requests from the scientific team to the development team  leads to a lot of arguing.  This got me to thinking..

The application should be clearly written with good design, clear names and lots of automated tests.  New features are added to this application.  Run and pass the tests.  Then this application is branched for optimization a.k.a. a release or production version.  Again, run and pass the tests.

Am I missing something?  Is this a 'thing'?  I guess my question is, if I bludgeon the VP of Product Development with this, would I be right (about the idea, not the bludgeoning)?

答: You could take a look at how Microsoft releases stuff. They alter their focus every release. Features, performance, features, performance, etc... Of course that's not the only thing they do but maybe you could take that as a basis.


答:
Code refactoring is really faster when you have unit tests. A unit test also show you simple use of concrete function, so you have a little "howto" which can be really useful in big projects where programmers dont know exactly the whole code.  </p>

<p>When you are Developing with TDD (test driven development) you dont have unnecessary getter/setters etc. You just create what you need. </p>

Title: Is Software Testing Really Needed?

Body:
I'm a student working on my B.E(CS) and my question is the following:

Is testing in the software field needed?

If we create a software with great care, then why should we test?

After testing can we be sure that we have achieved this goal (the product/software works as intended) because we have done the testing for it? Is it possible?

My question: Is testing of software needed?

Body:
Code refactoring is really faster when you have unit tests. A unit test also show you simple use of concrete function, so you have a little "howto" which can be really useful in big projects where programmers dont know exactly the whole code.

When you are Developing with TDD (test driven development) you dont have unnecessary getter/setters etc. You just create what you need.


问:
Right multi object dependance design
I need some help with a correct design.

I have a class called BufferManager. The push() method of this class reads data from a source and pushes it to a buffer repeatedly until there is no more data left in the source.

There are also consumer threads that read data from this buffer, as soon as new data arrives.

There is an option to sort the data before it comes to buffer. What I do right now is that BufferManager, instead of pushing data to the buffer, pushes it to another "sorting" buffer and starts a sorting thread. SorterManager class reads the data, sorts it in files and push()es the sorted data into the buffer.

There will be a bottleneck (I use merge sort with files) but this is something I can't avoid.

This is a bad design, because both BufferManager and SorterManager push data to a buffer (that consumers read from).  I think only BufferManager should do it.

How can I design it?

答:
Let's start from what we have?

A source of list exists somewhere.

The items of this list should be sorted.

There is a destination buffer which is consumed by others.

'It is a must's:

Sort process must precede source extraction.

Destination buffer flush must precede sort process.

All work must done asynchronously.

But steps of process must be preserved.

Process steps:

Get source list.

Sort it.

Write to buffer.

Design Steps:

SourceManager

SortingManager

BufferManager

Eventually here is your solution from my point of view:

When SourceManager finishes its work; it passes list to SortingManager

SortingManager sorts the list taken asynchronously.

When SortingManager finishes its work; it passes sorted list it produced to BufferManager.

BufferManager behaves like a data server to all other consumer threads by its buffer.

Warnings:

Do not give two responsibilities to a single class. All monads of a program must serve for only and only one responsibility.

While programming asynchronous tasks; make distinction between tasks which must not start unless another task finishes and task which
  starts and runs independently relying on none of other tasks.

Title: Right multi object dependance design


问:
Use of a profiler tool to aid in the analysis of a brute force algorithm in Java
I was asked to profile (using some tool, such as YourKit or JVisualVM) a couple of implementations of the Traveling Salesman Problem (find the minimum path that visits all the given set of cities), in the context of a Algorithms Analysis and Design graduate course.

Taking in consideration the brute force approach of the algorithm, I'm wondering, though, how to best use the tools (for instance, JVisualVM) to analyze the spatial and temporal complexities of the algorithm. If I'm not in error the algorithm has spatial complexity of O(n), as it basically grows linearly with the number of cities, while it is O(n!) in temporal complexity.

The math isn't the issue here.

After playing for a bit with both the referred tools, I'm having some hard time understanding how can they be of any use to my problem.

Sure I can see which methods are being used the most and which % of the time is being used in each one of them, and what is the actual memory footprint, so that can be all be regarded as hints where to optimize.

But other than that, and other than seeing the % of the CPU which is actually being used (or IO accesses, which never occur in this program), I can't see how can I actually learn something about the algorithm with these tools than the math before referred didn't.

What should be my main concerns when using profilers to the analysis of algorithms? Also, I've put basic time recording capabilities embedded in my program. Maybe I could use the profiling tools to better do that job?

Thanks

答:
I typically use the Performance Diagnostic Model (PDM) approach as taught by Kirk Pepperdine (he's a world leading expert on Java performance).  One of the things it teaches is that the profiler is a scalpel you use once you've diagnosed the general nature of the performance problem / analysis you want to do.  You typically start with looking at who the dominant consumer of the CPU is.  This can be:

System (i.e. Operating System/Hardware)

User (which in turn splits into JVM or the Application)

No dominator (which generally means CPU starvation)

So my question is - What question are you trying to answer in analysing these implementations?  Is it their performance?  If so then the profiler is actually the wrong place to start (starting with the profiler is common misconception that's taught).


问:
Question on design of current pagination implementations
I have checked pagination implementations on asp.net mvc specifically and i really feel that there is something less efficient in implementations.

First of all all implementations use pagination values like below.

```<code>public ActionResult MostPopulars(int pageIndex,int pageSize)
{

}
</code>```

The thing that i feel wrong is pageIndex and pageSize totally should be member of Pagination class otherwise this way looks so much functional way. Also it simplify unnecesary paramater pass in tiers of application.

Second thing is that they use below interface.

```<code>public interface IPagedList<T> : IList<T>
{
    int PageCount { get; }
    int TotalItemCount { get; }
    int PageIndex { get; }
    int PageNumber { get; }
    int PageSize { get; }
    bool HasPreviousPage { get; }
    bool HasNextPage { get; }
    bool IsFirstPage { get; }
    bool IsLastPage { get; }
}
</code>```

If i want to routing my pagination to different action so i have to create new view model for encapsulate action name in it or even controller name. Another solution can be that sending this interfaced model to view then specify action and controller hard coded in pager method as parameter but i am losing totally re-usability of my view because it is strictly depends on just one action.

Another thing is that they use below code in view

```<code>Html.Pager(Model.PageSize, Model.PageNumber, Model.TotalItemCount)
</code>```

If the model is IPagedList why they don't provide an overload method like @Html.Pager(Model) or even better one is @Html.Pager(). You know that we know model type in this way. Before i was doing mistake because i was using Model.PageIndex instead of Model.PageNumber.

Another big issue is they strongly rely on IQueryable interface. How they know that i use IQueryable in my data layer ? I would expected that they work simply with collections that is keep pagination implementation persistence ignorant.

What is wrong about my improvement ideas over their pagination implementations ?
What is their reason to not implement their paginations in this way ?

答:
Haven't used this IPagedList or helper thingy but this is my take:

The MostPopular(int pageIndex,int pageSize) is an explicit interface stating: I will only return pages of MostPopular things. You explicitly tell me which page and it's size.

If they had made a controller method MostPopular(IPagedList<T> page) the interface gets more confusing. Are you telling the controller the total amount of items or not?

When the controller retrieves your specific paged slice of the data it can typically discover various other data, like how many items there are total. At this point it makes sense to return such data to a view, so it can selectively use some of it.

This doesn't mean that IPagedList is the model, it could just as well be part of a model (a property on it). This is likely why there is no parameter-less overload.

They could have added IPagedList as an overload but then you would be passing a set (a paged chunk of data) to a little pager helper that doesn't need the actual data itself. It just needs to know how many pages/items and where you are at at the moment so it can highlight the page number and such. You would tell the helper far more then it needs to know to do it's job. The way it works now it has lower coupling, which is a good thing.


问:
Are testers considered low profile?
I happened to know some system admin and according to him, testing guys are not given preferences in an organization in comparison to developers. No doubt software releases are not possible without testers but I've never laid my hands on testing so not much aware of it. No offense intended. </p>

答:
In my experience, unfortunately, they are often treated like second class employees and even worse a frivolous perk for programmers.

It stems from a number of things:

When the testers are doing their jobs correctly, it is easy for everyone but the programmers to forget they even exist. Much like a network admin, you only notice them when they are not doing their jobs, or doing them badly. So from the perspective of the rest of the organization, they are remembered only for their mistakes.

It is mistakenly seen as an entry-level job for people who aspire to be programmers, but aren't qualified yet for those jobs. In fact, at one company I worked they were given Jr. Programmer job titles despite their pleas to get a Q&A job title. Even the fact that they were in a QA department wasn't enough to get HR to budge on that.

Because of #2, it is assumed that testers are all entry-level folks, and should be paid accordingly.

Nobody likes to be criticized, and it is all too common for defensive programmers to dislike testers because their jobs require them to point out programmer mistakes all day. As a manager, I was constantly on a PR mission to remind programmers that the QA team was there to make them look good, not narc them out.

It tends to be a job people get into by accident and not choice, at least initially. I don't remember any degree plan at any of the schools I attended that prepared people for software Q&A. They do exist, but usually at the lower-end vocational schools, which only contributes to the idea that they are less skilled professionals.

Testing jobs are much more likely than programming jobs to be sent offshore. At least the programmers can argue that it is more efficient to communicate design needs locally and that it is valuable to keep the knowledge of how the company's flagship app works inside the company. Testing, however, is much easier to modularize and thus easier to outsource.

For all of the reasons above, testers tend to see the writing on the wall and move into other jobs (like programming), especially the really good ones. This means that most testing jobs tend to get staffed with more entry level people who haven't burned out on it yet or moved on to other things, which unfortunately reinforces several of the above ideas.

Title: Are testers considered low profile?


答:
Good testers who can analyse problems efficiently and can do decent test automation are worth their weight in gold as there are so many cowboy testers out there (when interviewing one "tester" once he actually burst out laughing as he realised that we knew he was making stuff up on the spot whilst being quizzed on his CV).

In my team the tester is treated as an equal - which includes responsibility and salary. If you want a tester that clicks next all day - outsource them to somewhere cheap (we also do that).

Title: Are testers considered low profile?

Body: I happened to know some system admin and according to him, testing guys are not given preferences in an organization in comparison to developers. No doubt software releases are not possible without testers but I've never laid my hands on testing so not much aware of it. No offense intended. </p>


问:
Coming up with tokens for a lexer
I'm writing a parser for a markup language that I have created (writing in python, but that's not really relevant to this question -- in fact if this seems like a bad idea, I'd love a suggestion for a better path).

I'm reading about parsers here: http://www.ferg.org/parsing/index.html, and I'm working on writing the lexer which should, if I understand correctly, split the content into tokens.  What I'm having trouble understanding is what token types I should use or how to create them.  For example, the token types in the example I linked to are:

STRING

IDENTIFIER

NUMBER

WHITESPACE

COMMENT

EOF

Many symbols such as { and ( count as their own token type

The problem I'm having is that the more general token types seem a bit arbitrary to me.  For example, why is STRING its own separate token type vs. IDENTIFIER.  A string could be represented as STRING_START + (IDENTIFIER | WHITESPACE) + STRING_START.

This may also have to do with the difficulties of my language.  For example, variable declarations are written as {var-name var value} and deployed with {var-name}.  It seems like '{' and '}' should be their own tokens, but are VAR_NAME and VAR_VALUE eligible token types, or would these both fall under IDENTIFIER?  What's more is that the VAR_VALUE can actually contain whitespace.  The whitespace after var-name is used to signify the start of the value in the declaration .. any other whitespace is part of the value.  Does this whitespace become its own token?  Whitespace only has that meaning in this context.  Moreover, { may not be the start of a variable declaration .. it depends on the context (there's that word again!).  {: starts a name declaration, and { can even be used as part of some value.

My language is similar to Python in that blocks are created with indentation.  I was reading about how Python uses the lexer to create INDENT and DEDENT tokens (that serve more or less as what { and } would do in a lot of other languages).  Python claims to be context-free which means to me that at least the lexer shouldn't care about where it is in the stream while creating tokens.  How does Python's lexer know it's building an INDENT token of a specific length without knowing about previous characters (e.g. that the previous line was a newline, so start creating the spaces for INDENT)?  I ask because I need to know this too.

My final question is the stupidest one: why is a lexer even necessary?  It seems to me that the parser could go character-by-character and figure out where it is and what it expects.  Does the lexer add the benefit of simplicity?

答:
Your question (as your final paragraph hints) is not really about the lexer, it is about the correct design of the interface between the lexer and the parser.  As you might imagine there are many books about the design of lexers and parsers.  I happen to like the parser book by Dick Grune, but it may not be a good introductory book.  I happen to intensely dislike the C-based book by Appel, because the code is not usefully extensible into your own compiler (because of the memory management issues inherent in the decision to pretend C is like ML). My own introduction was the book by PJ Brown, but it's not a good general introduction (though quite good for interpreters specifically).  But back to your question.

The answer is, do as much as you can in the lexer without needing to use forward- or backward-looking constraints.

This means that (depending of course on the details of the language) you should recognise a string as a " character followed by a sequence of not-" and then another " character.   Return that to the parser as a single unit.   There are several reasons for this, but the important ones are

This reduces the amount of state the parser needs to maintain, limiting its memory consumption.

This allows the lexer implementation to concentrate on recognising the fundamental building blocks and frees the parser up to describe how the individual syntactic elements are used to build a program.

Very often parsers can take immediate actions on receiving a token from the lexer.   For example, as soon as IDENTIFIER is received, the parser can perform a symbol table lookup to find out if the symbol is already known.    If your parser also parses string constants as QUOTE (IDENTIFIER SPACES)* QUOTE you will perform a lot of irrelevant symbol table lookups, or you will end up hoisting the symbol table lookups higher up the parser's tree of syntax elements, because you can only do it at the point you're now sure you are not looking at a string.

To restate what I'm trying to say, but differently, the lexer should be concerned with the spelling of things, and the parser with the structure of things.

You might notice that my description of what a string looks like seems a lot like a regular expression.   This is no coincidence.  Lexical analysers are frequently implemented in little languages (in the sense of Jon Bentley's excellent Programming Pearls book) which use regular expressions.   I'm just used to thinking in terms of regular expressions when recognising text.

Regarding your question about whitespace, recognise it in the lexer.   If your language is intended to be pretty free-format, don't return WHITESPACE tokens to the parser, because it will only have to throw them away, so your parser's production rules will be spammed with noise essentially - things to recognise just to throw them away.

As for what that means about how you should handle whitespace when it is syntactically significant, I'm not sure I can make a judgment for you that will really work well without knowing more about your language.    My snap judgment is to avoid cases where whitespace is sometimes important and sometimes not, and use some kind of delimiter (like quotes).   But, if you can't design the language any which way you prefer, this option may not be available to you.

There are other ways to do design language parsing systems.  Certainly there are compiler construction systems that allow you to specify a combined lexer and parser system (I think the Java version of ANTLR does this) but I have never used one.

Last a historical note.   Decades ago, it was important for the lexer to do as much as possible before handing over to the parser, because the two programs would not fit in memory at the same time.   Doing more in the lexer left more memory available to make the parser smart.   I used to use the Whitesmiths C Compiler for a number of years, and if I understand correctly, it would operate in only 64KB of RAM (it was a small-model MS-DOS program) and even so it translated a variant of C that was very very close to ANSI C.

Title: Coming up with tokens for a lexer


答:
I'll take on your final question, which isn't in fact, stupid. Parsers can and do build up complex constructs on a character-by-character basis.  If I recall, the grammar in Harbison and Steele ("C - A reference manual") has productions that use single characters as terminals, and build up identifiers, strings, numbers, etc as non-terminals from the single characters.

From a formal languages standpoint, anything that a regular-expression based lexer can recognize and categorize as "string literal", "identifier", "number", "keyword", and so forth, even an LL(1) parser can recognize. So there's no theoretical problem with using a parser generator to recognize everything.

From an algorithmic standpoint, a regular expression recognizer can run far faster than any parser. From a cognitive standpoint, it's probably easier for a programmer to break up the work between a regular-expression-lexer and a parser-generator written parser.

I'd say that practical considerations cause people to make the decision to have separate lexers and parsers.

Title: Coming up with tokens for a lexer

Body:
I'm writing a parser for a markup language that I have created (writing in python, but that's not really relevant to this question -- in fact if this seems like a bad idea, I'd love a suggestion for a better path).

I'm reading about parsers here: http://www.ferg.org/parsing/index.html, and I'm working on writing the lexer which should, if I understand correctly, split the content into tokens.  What I'm having trouble understanding is what token types I should use or how to create them.  For example, the token types in the example I linked to are:

STRING

IDENTIFIER

NUMBER

WHITESPACE

COMMENT

EOF

Many symbols such as { and ( count as their own token type

The problem I'm having is that the more general token types seem a bit arbitrary to me.  For example, why is STRING its own separate token type vs. IDENTIFIER.  A string could be represented as STRING_START + (IDENTIFIER | WHITESPACE) + STRING_START.

This may also have to do with the difficulties of my language.  For example, variable declarations are written as {var-name var value} and deployed with {var-name}.  It seems like '{' and '}' should be their own tokens, but are VAR_NAME and VAR_VALUE eligible token types, or would these both fall under IDENTIFIER?  What's more is that the VAR_VALUE can actually contain whitespace.  The whitespace after var-name is used to signify the start of the value in the declaration .. any other whitespace is part of the value.  Does this whitespace become its own token?  Whitespace only has that meaning in this context.  Moreover, { may not be the start of a variable declaration .. it depends on the context (there's that word again!).  {: starts a name declaration, and { can even be used as part of some value.

My language is similar to Python in that blocks are created with indentation.  I was reading about how Python uses the lexer to create INDENT and DEDENT tokens (that serve more or less as what { and } would do in a lot of other languages).  Python claims to be context-free which means to me that at least the lexer shouldn't care about where it is in the stream while creating tokens.  How does Python's lexer know it's building an INDENT token of a specific length without knowing about previous characters (e.g. that the previous line was a newline, so start creating the spaces for INDENT)?  I ask because I need to know this too.

My final question is the stupidest one: why is a lexer even necessary?  It seems to me that the parser could go character-by-character and figure out where it is and what it expects.  Does the lexer add the benefit of simplicity?


答:
It looks like you're attempting to write a lexer/parser without really understanding grammars.  Typically, when people are writing a lexer and parser, they're writing them to conform to some grammar.  The lexer should return the tokens in the grammar while the parser uses those tokens to match rules/non-terminals.  If you could easily parse your input just going byte by byte, then a lexer and parser might be overkill.

Lexers make things simpler.

Grammar overview: A grammar is a set of rules for how some syntax or input should look.
For example, here's a toy grammar (simple_command is start symbol):

```<code>simple_command:
 WORD DIGIT AND_SYMBOL
simple_command:
     addition_expression

addition_expression:
    NUM '+' NUM
</code>```

This grammar means that -

A simple_command is composed of either

A) WORD followed by DIGIT followed by AND_SYMBOL (these are "tokens" that I define)

B) An "addition_expression" (this is a rule or "non-terminal")

An addition_expression is composed of:

NUM followed by a '+' followed by a NUM (NUM is a "token" that I define, '+' is a literal plus sign).

Therefore, since simple_command is the "start symbol" (the place I start), when I receive a token I check to see whether it fits into simple_command.  If the first token in the input is a WORD and the next token is a DIGIT and the next token is an AND_SYMBOL, then I've matched some simple_command and can take some action.  Otherwise, I'll try to match it to the other rule of simple_command which is addition_expression.  Thus, if the first token was a NUM followed by a '+' followed by a NUM, then I matched a simple_command and I take some action.  If it's neither of those things, then I have a syntax error.

That's a very, very basic intro to grammars.  For a more thorough understanding, check out this wiki article and search around the web for context-free grammar tutorials.

Using a lexer/parser arrangement, here's an example of how your parser might look:

```<code>bool simple_command(){
   if (peek_next_token() == WORD){
       get_next_token();
       if (get_next_token() == DIGIT){
           if (get_next_token() == AND_SYMBOL){
               return true;
           }
       }
   }
   else if (addition_expression()){
       return true;
   }

   return false;
}

bool addition_expression(){
    if (get_next_token() == NUM){
        if (get_next_token() == '+'){
             if (get_next_token() == NUM){
                  return true;
             }
        }
    }
    return false;
}
</code>```

Ok, so that code's kind of ugly and I would never recommend triple nested if statements.  But the point is, imagine trying to do that thing above character by character instead of using your nice modular "get_next_token" and "peek_next_token" functions.  Seriously, give it a shot.  You won't like the result.  Now keep in mind that that grammar above is about 30x less complex than almost any useful grammar.  Do you see the benefit of using a lexer?

Honestly, lexers and parsers aren't the most basic topics in the world.  I'd recommend first reading about and understanding grammars, then reading a bit about lexers/parsers, then diving in.

Title: Coming up with tokens for a lexer

Body:
It looks like you're attempting to write a lexer/parser without really understanding grammars.  Typically, when people are writing a lexer and parser, they're writing them to conform to some grammar.  The lexer should return the tokens in the grammar while the parser uses those tokens to match rules/non-terminals.  If you could easily parse your input just going byte by byte, then a lexer and parser might be overkill.

Lexers make things simpler.

Grammar overview: A grammar is a set of rules for how some syntax or input should look.
For example, here's a toy grammar (simple_command is start symbol):

simple_command:
 WORD DIGIT AND_SYMBOL
simple_command:
     addition_expression

addition_expression:
    NUM '+' NUM

This grammar means that -

A simple_command is composed of either

A) WORD followed by DIGIT followed by AND_SYMBOL (these are "tokens" that I define)

B) An "addition_expression" (this is a rule or "non-terminal")

An addition_expression is composed of:

NUM followed by a '+' followed by a NUM (NUM is a "token" that I define, '+' is a literal plus sign).

Therefore, since simple_command is the "start symbol" (the place I start), when I receive a token I check to see whether it fits into simple_command.  If the first token in the input is a WORD and the next token is a DIGIT and the next token is an AND_SYMBOL, then I've matched some simple_command and can take some action.  Otherwise, I'll try to match it to the other rule of simple_command which is addition_expression.  Thus, if the first token was a NUM followed by a '+' followed by a NUM, then I matched a simple_command and I take some action.  If it's neither of those things, then I have a syntax error.

That's a very, very basic intro to grammars.  For a more thorough understanding, check out this wiki article and search around the web for context-free grammar tutorials.

Using a lexer/parser arrangement, here's an example of how your parser might look:

bool simple_command(){
   if (peek_next_token() == WORD){
       get_next_token();
       if (get_next_token() == DIGIT){
           if (get_next_token() == AND_SYMBOL){
               return true;
           }
       }
   }
   else if (addition_expression()){
       return true;
   }

   return false;
}

bool addition_expression(){
    if (get_next_token() == NUM){
        if (get_next_token() == '+'){
             if (get_next_token() == NUM){
                  return true;
             }
        }
    }
    return false;
}

Ok, so that code's kind of ugly and I would never recommend triple nested if statements.  But the point is, imagine trying to do that thing above character by character instead of using your nice modular "get_next_token" and "peek_next_token" functions.  Seriously, give it a shot.  You won't like the result.  Now keep in mind that that grammar above is about 30x less complex than almost any useful grammar.  Do you see the benefit of using a lexer?

Honestly, lexers and parsers aren't the most basic topics in the world.  I'd recommend first reading about and understanding grammars, then reading a bit about lexers/parsers, then diving in.


答:
My final question is the stupidest one: why is a lexer even necessary? It seems to me that the parser could go character-by-character and figure out where it is and what it expects.

This is not stupid, it's just the truth.

But practicability somehow depends a bit on your tools and objectives. For example, if you use yacc without a lexer, and you want to allow unicode letters in identifiers, you'll have to write a big and ugly rule that explicity enumerates all the valid characters. While, in a lexer, you could maybe ask a library routine if a character is a member of the letter category.

Using or not using a lexer is a matter of having a level of abstraction between your language and the character level. Note that the character level, nowadays, is another abstraction above the byte level, which is an abstraction above the bit level.

So, finally, you could even parse on the bit level.

Title: Coming up with tokens for a lexer


答:
```<code>STRING_START + (IDENTIFIER | WHITESPACE) + STRING_START.
</code>```

No, it can't. What about "("? According to you, that's not a valid string. And escapes?

In general, the best way to treat whitespace is to ignore it, beyond delimiting tokens. Lots of people prefer very different whitespace and enforcing whitespace rules is controversial at best.

Title: Coming up with tokens for a lexer

Body:
STRING_START + (IDENTIFIER | WHITESPACE) + STRING_START.

No, it can't. What about "("? According to you, that's not a valid string. And escapes?

In general, the best way to treat whitespace is to ignore it, beyond delimiting tokens. Lots of people prefer very different whitespace and enforcing whitespace rules is controversial at best.


问:
Putting audit functionality into the database
Our database does not have any audit functionality.

It does not records who inserts the record or who who changes it

It does not keep a history of the changes made

Nothing can be restored if something goes wrong

There are many other short comings for example the database does not have any data integrity, anything an be thrown in, no check on different fields, duplicates etc

My question is, who's job it is to put this functionality in? An ASP Developer who knows basics of SQL and who interacts with the database regularly. Or an SQL Administrator who's sole job is to work with the databases, optimize it and maintain it?

At this point we do not have an SQL Administrator, but can hire one. How big of an undertaking this should be for a developer to fix the above issues?

答:
99% of this really depends upon the answer to the question "if I updated the database, what part of the application would know who I am?"

Typical web applications connect as a single user, the database server has no clue who is operating the keyboard and whom to assign the actions to.

On the other hand, many desktop apps connect using credentials per-user. In this case they know who is doing what so you can ride infrastructure into an great audit trail.


答:
All programs have bugs, at least to start with.

There have been some studies which converge on about 1 bug per every five lines of untested code.

A history lesson:

Back in the 1960s IBM needed a "NOP" program so they could execute some functionality in JCL without actually running a program. The developers came up with a one line assembler program in which the entire code was contained within its name "IEFBR14" the actual code being:

```<code>       BR 14 * brach to return address in register 14
</code>```

During its long liftime this one line program has been subject to 2 bug reports and five amendments.

Title: Is Software Testing Really Needed?

Body:
All programs have bugs, at least to start with.

There have been some studies which converge on about 1 bug per every five lines of untested code.

A history lesson:

Back in the 1960s IBM needed a "NOP" program so they could execute some functionality in JCL without actually running a program. The developers came up with a one line assembler program in which the entire code was contained within its name "IEFBR14" the actual code being:

       BR 14 * brach to return address in register 14

During its long liftime this one line program has been subject to 2 bug reports and five amendments.


问:
annual goal for programmers in IT company
As IT manager what goals would you set for your programmers in your team. These goals would be used in the annual performance review. Any recommendations?

How would you create goals that actually measure programmers technical abilities.

答: I'd try to dovetail this with the technical diretion of the company - are you trying to move all your GUI to WPF? Then learning WPF would be a good goal. I'd always emphasize learning the business - the more the programmers know about the business the better they can help automate.</p>


问:
Under which circumstances will development advance faster with many contributors compared to few?
I saw an interview with Joel Spolsky, where he says that Fog Creek Software intentionally keep their teams small (I believe as in four-five guys). The reason for this is to avoid a lot of the communication needed between the team members if the teams are larger. If one compares this to open source projects, where there can be hundreds (or thousands?) of contributors. Whether they are a team, is, though, arguable. There are probably also examples of something in between, with team sizes of 20 developers. </p>

<p>My question is: What kind of software is most suited for getting developed by small teams, and what kind of software is suited for large teams? </p>

答:
A few general thoughts on practices  I've seen work (regardless of team size & type of software):

continuous integration attitude

clean interfaces across tiers (e.g., SOA)

strong leadership

test-driven culture

automation

mature adults (not (necessarily) "old" but just not immature jerks)

I think Amazon.com has "2 pizza teams" - no bigger than can be fed with a couple of pizzas. They are also big into services (SOA) and own their services end-to-end (dev & ops). A page on Amazon.com pulls on dozens of these services (aggregating in the UI). Works for them. Enormous app made up of manageable bite-sized chunks.


问:
Dependency analysis for tests
Google built a testing system that can infer which tests need to be run after a change. In their own words:

... we built a
continuous integration system that
uses dependency analysis to determine
all the tests a change transitively
affects and then runs only those tests
for every change.

...

Inspired by that, I have created a tool for Python that also uses dependency analysis to detect which tests need to be run. The difference is that it is not tied to a CI system. It is meant to  be run locally and looks for file changes since the last time the tests passed, instead of looking at commits on the version control system.

Visual Studio 2010 has a featured called "Test impact analysis" that "inform the developer of what tests they should run to verify the code changes they are making".

My question is: Is there a name for this approach? I believe I read somewhere that this is called "Incremental Testing", but I cannot find the reference anymore.

答: I'm not sure if there's a canonical name but where I work we call this "automatic test selection."</p>

ContentLicense: CC BY-SA 4.0

Title: Dependency analysis for tests


答:
Some software projects are by their very nature so large that they could not be done in a reasonable amount of time by a small team. An example of this would be a large operating system or database product.

It is a question of math really. For example I remember a rather simple by today's standards operating system that had 2.5 million lines of code. Assuming a programmer could produce 100 lines of debugged, tested and production ready lines of code per day (very optimistic) then this would take one person 25,000 days or roughly 68.5 years working 7 days a week!

In project management there are methods to optimize team size vs project duration to minimize cost. Of course the need to get to market quickly will often cause firms to put more people on a project than is optimal from a cost prospective in order to attempt to get it done faster.

Where possible on small projects it is generally better to keep the team smaller rather than bigger. This way there is less time wasted in administration, meetings etc. and it is easier to insure that everyone understands the vision and remains on the same page.

A seminal work discussing these issues is the book The Mythical Man-Month: Essays on Software Engineering by Fredrick Brooks.

Title: Under which circumstances will development advance faster with many contributors compared to few?

Body:
I saw an interview with Joel Spolsky, where he says that Fog Creek Software intentionally keep their teams small (I believe as in four-five guys). The reason for this is to avoid a lot of the communication needed between the team members if the teams are larger. If one compares this to open source projects, where there can be hundreds (or thousands?) of contributors. Whether they are a team, is, though, arguable. There are probably also examples of something in between, with team sizes of 20 developers. </p>

<p>My question is: What kind of software is most suited for getting developed by small teams, and what kind of software is suited for large teams? </p>


问:
Asynchronous Java
I'm wondering if I wanted to implement a web service based on java that does web analytics, what sort of architecture should I use. The actualy processing of the Big Data would be done by Hadoop.

However I am not sure what I would need to do to make it asynchronous, or is Hadoop already asynchronous by nature? Could I do something with JMS? If so, how would that fit into the whole thing? Would it be something along the lines that upon receiving the web service request, I use JMS to send a message to Hadoop to handle a particular data, and then wait for it to come back to me? I am not too familiar with asynchronous java so I'm not sure where to start.

答:
" I use JMS to send a message to Hadoop to handle a particular data, and then wait for it to come back to me" -- this is using an asynchronous protocol to implement a synchronous interaction.

Is there any need for your program to wait for the reply? If there is couldn't you have another process handle the replies?

There are several asynchronous patterns you could use depending on your requirements:-

"Fire and Forget" simply put the request in a queue and trust the receiving process to apply the changes.

"Send and Poll" - loop around put all your requests on the queue, process all the replies.

"sender and receiver processes" -- have different processes, programs threads or whatever, one or more to send requests, one or more to handle replies.

Title: Asynchronous Java


答:
You might want to consider using something like the Mule ESB: http://www.mulesoft.com/mule-esb-open-source-esb

It's open source, pretty lightweight, can host web services and supports full asynchronous processing of incoming events.

You could start with just creating a lightwieght Mule web service that fires off requests to Hadoop (perhaps via JMS, but you could also just call Hadoop directly). But you'd have the flexibility to add lots more services and capabilities later.

Title: Asynchronous Java

Body:
I'm wondering if I wanted to implement a web service based on java that does web analytics, what sort of architecture should I use. The actualy processing of the Big Data would be done by Hadoop.

However I am not sure what I would need to do to make it asynchronous, or is Hadoop already asynchronous by nature? Could I do something with JMS? If so, how would that fit into the whole thing? Would it be something along the lines that upon receiving the web service request, I use JMS to send a message to Hadoop to handle a particular data, and then wait for it to come back to me? I am not too familiar with asynchronous java so I'm not sure where to start.


答:
I generally set goals that are product oriented so it's clear what we're working on.  However, I realize that those may change so I usually include goals that help the team while working on what I believe is a weakness of the team member.  For example, if the team member struggles writing English, I create a goal that requires them to write (they can't get better if they avoid doing it).

I also like to include goals that help them achieve their personal goals.  If they indicate they want to move from code-monkey to developer, then I'll set a goal or two that requires them to help write a spec document.

Title: annual goal for programmers in IT company

Body:
As IT manager what goals would you set for your programmers in your team. These goals would be used in the annual performance review. Any recommendations?

How would you create goals that actually measure programmers technical abilities.


问:
Our version of Agile isn't working. Tips?
I work on a small team of 4 developers. We are implementing a version of Agile that seems to continuously provide us with the same difficulties, week after week, and I'm looking for suggestions that can help us improve our process.

The background:

We generally do 2 week sprints, and each sprint we tend to underestimate our work, and we get in trouble with our manager because we're behind schedule.

We start off each sprint by tasking out the stories that our manager creates for us. Sometimes he throws in the tasks too and we estimate them. We don't use story points. We use the software Urban Turtle to "manage our sprints", which is essentially just stories and tasks, and the associated burn down. We don't plan for a release at the end of a sprint.

The most common issue that occurs is that we plan for a task in the beginning of a sprint only to discover it's much larger in scope, but still high in the priority, so we need to work additional hours on it. The second most common issue is that one of us runs into a technical problem that slows down the hours burned, causing a roadblock.

The only suggestion provided to us is to be more proactive in adjusting our estimates and providing updates during standups in the morning so we can adjust for the extra time needed.

However, there seems to be something fundamentally wrong with the way we're doing things. Perhaps there's a disconnect between the expectations of the manager on a project level and the expectations on a sprint level. Because we're making these sprint iterations according to a project plan, and therefore extending a sprint or deferring items screws up the project plan. So as developers we are being encouraged to perform Agile by extending estimates when necessary but also complete the sprint on time, which is confusing.

This can't be an uncommon problem, so I'm hoping those wiser than I out there have a suggestion or two on how we can stop running into this same problem every sprint. It's frustrating.

答:
Until you get your estimations in order shorten your sprints to one week, this way you will recognize the overage faster and be able to react in smaller increments.

Spend more time up front when designing tasks to get some breathing room to recognize side effects that are probably what's causing the scope to bleed all over.  It could also be that the tasks themselves are too long for a proper agile estimation, see if tasks can be broken down into shorter steps that will be easier to swallow.

Get everyone comfortable with sending up a red flag as soon as they hit a snag instead of getting stuck on a problem for a few hours.  Try and detach ego and blame from this process, that's easier for some than others =)

And like @Kevin brought up, you never really schedule 100% directly to tasks because there is always overhead like meetings and so on that you may not recognize as time eaters.

When everything is cool on the scheduling front then go back to two weeks, you'll magically pick up a little time from the fewer meetings again.

OwnerDisplayName: letsgetsilly


答:
In addition to the good suggestions by @Kevin and @Patrick ...

Agile approaches are not "one size fits all" but this comment got my attention:

We are implementing a version of Agile that seems to continuously provide us with the same difficulties

You are better off starting with a methodology "by the book" (Scrum is dominant these days it seems) - and do EXACTLY what some other successful team did ... Do that for a few sprints... And only then begin to consider changes needed to optimize for local conditions.

Renting an experienced Scrum coach (for a few iterations) may be a real difference maker. There is subtlety in getting agile right.

Title: Our version of Agile isn't working. Tips?

Body:
I work on a small team of 4 developers. We are implementing a version of Agile that seems to continuously provide us with the same difficulties, week after week, and I'm looking for suggestions that can help us improve our process.

The background:

We generally do 2 week sprints, and each sprint we tend to underestimate our work, and we get in trouble with our manager because we're behind schedule.

We start off each sprint by tasking out the stories that our manager creates for us. Sometimes he throws in the tasks too and we estimate them. We don't use story points. We use the software Urban Turtle to "manage our sprints", which is essentially just stories and tasks, and the associated burn down. We don't plan for a release at the end of a sprint.

The most common issue that occurs is that we plan for a task in the beginning of a sprint only to discover it's much larger in scope, but still high in the priority, so we need to work additional hours on it. The second most common issue is that one of us runs into a technical problem that slows down the hours burned, causing a roadblock.

The only suggestion provided to us is to be more proactive in adjusting our estimates and providing updates during standups in the morning so we can adjust for the extra time needed.

However, there seems to be something fundamentally wrong with the way we're doing things. Perhaps there's a disconnect between the expectations of the manager on a project level and the expectations on a sprint level. Because we're making these sprint iterations according to a project plan, and therefore extending a sprint or deferring items screws up the project plan. So as developers we are being encouraged to perform Agile by extending estimates when necessary but also complete the sprint on time, which is confusing.

This can't be an uncommon problem, so I'm hoping those wiser than I out there have a suggestion or two on how we can stop running into this same problem every sprint. It's frustrating.


问:
How should an administrating web application control a WCF service's entities?
We have a WCF Service (self-hosted) which can receive several types of calls from the outside, each call encapsulates a business logic procedure.

We need to construct a web application which will act as an administrating app, for all users of the service.

So we need to have access to all inner-entities of the service and not just the business calls.

How should this be done the most effective way?

EDIT:

I wasn't too specific because I see this as a general issue.
our Customers are retailers which have clients of their own, so when I say Customer, it's our client and when I say Client - it's our client's client.

Example:

Service X allows registered clients of Customers to commit
transactions.

there are several transaction types.

the service receives the transactions from several different devices.

The service is a WCF self hosted service.

The Customer, needs to register devices for use, register different configurations for different devices and many other registering and administrating which needs to be done.

All of this is done in a website.
The website users are the Customers, the Retailers, not the end clients

So as I see it I have these options

Reference the dll which holds all service-related entities - this is ok now because the website and the service are on the same machine, but what if this changes? is this a good approach?

Make service calls for all of this registering and administrating, which I'm not even sure how it should be done.

So, I need your help in understanding the best way to do this...

答:
Like @LachlanB I am a bit unsure what you are asking, but here is an attempt.

Sounds like two sets of services that share some code, classes, and database. Some are used ONLY by the admin console (secured or hosted elsewhere - doesn't matter).

Assuming the two sets of related services share a common storage / database, it should be clean. This is a fairly common pattern for what it (I think) you are trying to do.

Anything not workable with this model?


答: Use approach 1 and bundle the dll with each app (standard procedure).</p>

Title: How should an administrating web application control a WCF service's entities?

Body:
We have a WCF Service (self-hosted) which can receive several types of calls from the outside, each call encapsulates a business logic procedure.

We need to construct a web application which will act as an administrating app, for all users of the service.

So we need to have access to all inner-entities of the service and not just the business calls.

How should this be done the most effective way?

EDIT:

I wasn't too specific because I see this as a general issue.
our Customers are retailers which have clients of their own, so when I say Customer, it's our client and when I say Client - it's our client's client.

Example:

Service X allows registered clients of Customers to commit
transactions.

there are several transaction types.

the service receives the transactions from several different devices.

The service is a WCF self hosted service.

The Customer, needs to register devices for use, register different configurations for different devices and many other registering and administrating which needs to be done.

All of this is done in a website.
The website users are the Customers, the Retailers, not the end clients

So as I see it I have these options

Reference the dll which holds all service-related entities - this is ok now because the website and the service are on the same machine, but what if this changes? is this a good approach?

Make service calls for all of this registering and administrating, which I'm not even sure how it should be done.

So, I need your help in understanding the best way to do this...


答:
It seems like the problems are your team's inability to make accurate estimates, and inability to forsee the problems that inevitability arise.

Small tasks are much easier to estimate accurately than large tasks, so try and break your tasks into much smaller chunks.

Don't allow anyone to make an estimate for any task, unless they know EXACTLY how they're going to do it.  For any task that the developer doesn't know what to complete, put some time into THIS sprint's schedule for the developer to do some investigation and design, and come up with an accurate estimate.  Never less than half a day.  But move the task off to NEXT sprint.  Then, when you come to the planning for next sprint, you'll have a good estimate.  Note that this extra time isn't wasted, because it's time that the developer would end up spending in any case.

And don't be afraid of going back to the project manager and telling him/her that you'll need more sprints to get through the list of tasks.  It's better to do that, than to commit yourself to impossible targets.


答:
If you speak with the guys working on large projects such as the linux kernel (epic amount of work done by many devs) you will find that they are working in loosely knit small 'teams'. A known set of contributors works on a particular feature, usually under 5.

Out of that team one is the feature owner, and is part of the team for a larger feature, and so on and so on until you get to Linus who is the product owner.

Think of it as small commando teams. This is the organizational version of the 'divide et impera' pattern in software. You take a problem and split it up into smaller problems until it becomes manageable.

The number and size of the teams should always be dictated by the experience of the 'owner' of the feature/product. If you don't have enough experienced people for the features you are doing, either get some more so you can have more teams, or schedule your project so they have enough time to do the tasks.

Having a team that is too big causes serious problems in the long run (look up Vista development).


答:
This can be really difficult, because good goals for employees should be specific and quantifiable. As we know, quantifying a programmer's productivity is definitely a conundrum.

In my experience managing programmers, I try to create goals based on the long term goals of the individual employee. For example, if the programmer aspires to move into management I'll set a goal for them to seek out and take on leadership roles on teams or projects to help them build some informal authority that will be necessary for the transition.

Usually, however, to create measurable goals they tend to be fairly task oriented. For example getting a MCDBA certification for someone who wants to move into a DBA role. For someone who claims they want to improve/learn on a particular technology I'll usually pick a goal like reading x books on the topic or teaching a brown-bag class to the other developers on the technology.


问:
Why multiple calls to same classes' Constructor from within a Constructor wouldn't work?
Please have a look at following snippet:

```<code>public class Foo {
int digit;
String name;

Foo (int d, String n) {
    this(d);
    // cannot do following.
    //compile-time error: Constructor call must be first statement in a Constructor
    //this(n);
}

Foo (int p) {
    digit = p;
}

Foo (String q) {
    name = q;
}
</code>```

What would be the reason of this restriction? I understand why call to Constructor (both in a Constructor or in a method) has to be first statement - the object should be initialized properly before it is used. What I don't get is compiler not allowing calling multiple constructors of the same class from within a constructor. I don't see any problem with this construct - both regarding initialization and invarients.

It'd be great if someone can shed some light on what I am missing here...

Thanks!

答:
Constructors are not just "methods that are called when object is created", they are conceptually different.

Constructor's purpose is to constrain what states objects can be in initially. A freshly created object is zeroed on all fields (null/0/false) and that may be an invalid state in your program. For example, a Customer object in your application needs be constrained to always have a customerId > 0 — you then define a constructor that takes that id and checks it.

In this light there is no purpose in calling two constructors: after calling the first one the object is already in a consistent state. The second constructor will receive an initialized object which is a breach of its purpose (doing 0 => initialized).

What you want to do in this case is either introduce private methods that will do parts of that initialization and call them or make more specific constructors call the more general one (which is a very common pattern):

```<code>Foo (int d, String n) {
    digit = d;
    name = n;
}

Foo (int p) {
    this(p, null)
}

Foo (String q) {
    this(0, q)
}
</code>```

Body:
Constructors are not just "methods that are called when object is created", they are conceptually different.

Constructor's purpose is to constrain what states objects can be in initially. A freshly created object is zeroed on all fields (null/0/false) and that may be an invalid state in your program. For example, a Customer object in your application needs be constrained to always have a customerId > 0 — you then define a constructor that takes that id and checks it.

In this light there is no purpose in calling two constructors: after calling the first one the object is already in a consistent state. The second constructor will receive an initialized object which is a breach of its purpose (doing 0 => initialized).

What you want to do in this case is either introduce private methods that will do parts of that initialization and call them or make more specific constructors call the more general one (which is a very common pattern):

Foo (int d, String n) {
    digit = d;
    name = n;
}

Foo (int p) {
    this(p, null)
}

Foo (String q) {
    this(0, q)
}


问:
What parts of Java do I need to learn for specific software projects?
I'm starting a 12 week Java course next month through my local junior college. I'm starting from square 1. I have a basic understanding of OO and Java will be my first OO language. My Google-Fu returns way too much and I can't tell which is good, bad, etc.

As far as learning the language, is it best to use a plain editor, I use JEdit currently, or an IDE like Eclipse or Netbeans? I don't have experience with either IDE. Is there other IDEs I should consider?

My project goals are:

GUI programs to control different radios and test equipment, which means I/O via USB, sound card, and networking across *NIX, Windows, and Mac OS.

Programming for Android devices, both phone and tablets. Database backed apps for logging data. Quite possibly accessing radio/test gear over WiFi.

JBoss environment.

How should I setup a testing environment for different platforms?

答:
OK, here's my suggestions:

Get an IDE - in practice, most Java developers use an IDE nowadays and it will help you considerably with things like syntax checking, testing and debugging. I personally use the "Eclipse IDE for Java developers" which has served me very well. You can download Eclipse here. I also hear good things about Netbeans and IntelliJ - I don't think you could go wrong with any of these. Make sure you can create an run a simple "Hello World" application from scratch in your chosen IDE.

Do the Java tutorials - these are great tutorials that take you through many of the basics. I'd honestly recommend doing all of these (and learning how best to use your chosen IDE as you go along).

Pick an area to focus on. Even after you've mastered all the basics, you can't expect to become a expert at every advanced topic all at once. You might, for example, decide to focus on learning Android first. You'll be writing Java as before, but many of the APIs and tools are Android specific and you will need to learn them. Make sure that you actually build things that work - it's the best way to learn how to code in any language.


答:
You should learn how to run from console and plain-text editor for getting started, Once you understand packages/imports, how to run, building using console (Command line).

Then you can pickup Netbeans/Eclipse, based on your choice. I suggest you use Eclipse first, after that you can try Netbeans, and use whichever you find suitable to you.

Title: What parts of Java do I need to learn for specific software projects?

Body:
I'm starting a 12 week Java course next month through my local junior college. I'm starting from square 1. I have a basic understanding of OO and Java will be my first OO language. My Google-Fu returns way too much and I can't tell which is good, bad, etc.

As far as learning the language, is it best to use a plain editor, I use JEdit currently, or an IDE like Eclipse or Netbeans? I don't have experience with either IDE. Is there other IDEs I should consider?

My project goals are:

GUI programs to control different radios and test equipment, which means I/O via USB, sound card, and networking across *NIX, Windows, and Mac OS.

Programming for Android devices, both phone and tablets. Database backed apps for logging data. Quite possibly accessing radio/test gear over WiFi.

JBoss environment.

How should I setup a testing environment for different platforms?


答:
The reason is that the Java Language Specification says so. It could probably have been written to allow what you describe, but not for free: enforcing the order makes things simpler. Think about inheritance and calls to super(). If it wouldn't be the first statement in a constructor, then the subclass could do something with a superclass which is not yet constructed. At what point would this exist if the ubiquitous superclass Object wouldn't have yet been constructed?

Allowing arbitrary constructor call order would't have been very useful, but it would have complicated the language spec and compiler (a lot, I guess).

Title: Why multiple calls to same classes' Constructor from within a Constructor wouldn't work?

Body:
Please have a look at following snippet:

```<code>public class Foo {
int digit;
String name;

Foo (int d, String n) {
    this(d);
    // cannot do following.
    //compile-time error: Constructor call must be first statement in a Constructor
    //this(n);
}

Foo (int p) {
    digit = p;
}

Foo (String q) {
    name = q;
}
</code>```

What would be the reason of this restriction? I understand why call to Constructor (both in a Constructor or in a method) has to be first statement - the object should be initialized properly before it is used. What I don't get is compiler not allowing calling multiple constructors of the same class from within a constructor. I don't see any problem with this construct - both regarding initialization and invarients.

It'd be great if someone can shed some light on what I am missing here...

Thanks!


答:
because we're behind schedule

This type of thinking is your problem. You're not behind the schedule, the schedule is too tight. You should start estimating stories in abstract points as opposed to hours and then over the course of 2-3 iterations figure out your velocity. Your velocity is how many points you usually do every iteration, not how many points your manager wants to fit in.

After this it doesn't matter if you consistently underestimate tasks - your velocity already accounts for that.

Obviously, this is impossible if you use hours instead of points.


问:
How to lead a development project without technical expertise
I have been a hands-on developer for my entire career and love working with code.  I have always resented the team lead who has little or no expertise regarding a particular technology and yet insists on a certain implementation.

Now I find myself on the other side of the looking glass.  I am the lead developer of a fat client to be implemented in C#, however my expertise is in building Java web applications.  While I know that I can leverage design patterns and OO paradigms in any language, I am lost when it comes to coding standards, project life cycle tools and release/distribution procedures.  I have no doubt that I can pick up the basics within a month or two, but there are certain experiences one can only gather with time.

What should I do, and how do I avoid becoming the project lead that I hated when I was developing?

答:
It sounds like that are a few issues at play here.

The technology used in the project you are leading and the process that govern the development of that project.

Are you the team leader, or a lead developer? A lead developer also does quite a bit of the design and development work. So the only way around this is just to knuckle down and learn the new technology.

If you are actually leading the team, you will need to trust the team and let them steer the majority of the technical direction of the project. Of course, conceptually, you will be able to keep that steering in the right direction.

The processes that govern the development of the project should mostly be in place. It is just a matter of reading up on them, understand them and execute them.

If not, negotiate with your boss to get a mentor to help you to put some development process in place. This is pretty important. It will fail pretty quickly if the process is not in place, and is ad hoc.

Good luck!


问:
Not-for-profit universities that offer computer science undergraduate degree online?
There are many masters degree programs in computer science online offered by reputable organizations. However, I've found very few bachelors only degree programs offered by non for-profit institutions.

I am looking for a degree in computer science and also any programs for entrepreneurship/management or algorithmic trading.

I've found only 2 programs so far that fit:

http://www.regis.edu/regis.asp?sctn=cpcis&p1=ap&p2=cs&p3=ol

http://depaul.edu

Requirements:

100% online undergraduate non-profit

Options: Bachelor of Science Bachelor of Arts

Bonuses: accelerated recognized ABET cost effective

Update:
I've answered my question with a list. If anyone knows an online program that combines skills in entrepreneurship (getting capital, starting a business) or algorithmic trading with a computer program that would be ideal.. maybe too much to ask though

答:
I've found these non-for profit, accredited, online-only programs/colleges:

Uni Illinois, very tough/limited CS program, may have an information systems
http://www.uis.edu

private
http://www.regis.edu/

private, accelerated, flexible, quarter system, minor
http://depaul.edu

public, expensive, computer science and information system
http://umuc.edu

UMASS Online
http://www.umassonline.net/

Penn State World
http://www.worldcampus.psu.edu/

Troy website not working, a minus but cost is good.
http://www.troy.edu/ecampus/programs/ugdegreeprograms.htm

Eastern Carolina -- a business program, probably cheapest option
http://www.ecu.edu/business/undergraduateprograms.cfm

Since 1889
http://www.saintleo.edu/Academics/School-of-Business/Undergraduate-Degree-Programs/Computer-Information-Systems/Degree-Requirements

newer public school
http://www.rsu.edu/rsuonline/

Columbia College
http://www.ccis.edu/

Drexel Online (expensive)
http://www.drexel.com/

List of others that might fit
http://oedb.org/rankings

May be others in this list
http://www.forbes.com/bow/b2c/category.jhtml?id=147

very tough to find these


问:
How can I use Windows Workflow for validation of a Silverlight application?
I want to use Windows Workflow to provide a validation service. The validation that will be provided may have multiple tiers with chaining and redirecting to other stages of validation. The application that will generate the data for validation is a Silverlight app.

I imagine the validation will take longer than the blink of an eye, so I don't want to tie the user up. Instead, I would like the user to submit the current data for validation. If the validation happens quickly, the service will perform an asynchronous callback to the app. The viewmodel that made the call would receive the validation output and post into the view.

If the validation takes a long time, the user can move forward in the Silverlight app, disregarding the potential output of the validation. The viewmodel that made the call would be gone. I expect there would be another viewmodel that would contain the current validation output in its model. The validation value would change causing the user to get a notification in smaller notifcation area.

I can see how the current view's viewmodel would call the validation through the viewmodel that is containing the validation output, but I am concerned that the service call will timeout. Also, I think the user may have already changed the values from the original validation, invalidating the feedback.

I am sure asynchronous validation is a problem solved many times over, I am looking to glean from your experience in solving this kind of problem.

Is this the right approach to the problem, or is there a better way to approach this?

答:
First of all, I’d like to assume that you are using a WCF service that provides validation services written in Windows Workflow and the Silverlight client use the service to validate some sort of data or initiate a validation operation.

Under this scenario, you have to separate long running and short running validation operations and provide a different UI framework for each of them. Short running validation should be handled with the usual asynchronous request-reply model used by Silverlight, which means that the user will wait (without blocking) for the result of validation. This is the ordinary flow of most Silverlight applications. Long running validation should be handled in a different way. You can’t use force the user to wait for a result. It’s probably better to use a “notification mechanism” to notify user asynchronously with the results of validation and provide a way to “edit” or “resubmit” the operation in case the validation return an error or failure.

In other words, Windows Workflow is just a way to “glue” the validation steps. You should handle the design and implementation of the rest.