答:
During an interview the interviewr is more interested in seeing your

Approach to the problem

Skill used to solve the problem and the

Time taken to effectively give an proper solution

Syntax though is not so important but it does hold a prominent place while solving a problem,
with major mistakes in the syntax you cannot expect to get the interviewer impressed.

The proper logic and syntax combined together can do the trick for you in an interview.

A small or minor mistake would never cost you much if logic is good enough.

More over there are may IDE available that could easily make syntax of even any in proper shape. But to use which method where and when and most importantly WHY, would only be known to a guy with the proper logic and knowledge of the actual subject.

I hope and urge you to provide something more than a white board or a notepad to write the code.

I would go with the second candidate...


问:
Why and for what reasons developers may not like "daily scrum"?
There are advantages in holding daily scrum, like:

Team get coordinated with each other

Everyone knows what amount of task has been done

Burndown chart gets more and more complete

Task board is updated

It doesn't last that much, 15 minutes won't kill anybody

However, recently (after 6 months of implementing and using scrum), I feel like that our developers don't like scrum daily that much anymore. People just update the task board, without explaining enough and it seems that  they're bored of it. I see that when for any reason, we don't hold it, they kind'of become extra-happy.

I just don't know what could be wrong with this. Are there any reasons mentioned somewhere for disadvantages the "daily scrum" can have for a team? What could be the reasons for developers getting tired of daily scrum?

答:
15 minutes.  Does that 15 minutes (plus the time to prepare for it) convey enough new and useful information between team members to improve the teams productivity for the coming day by more than 15 minutes worth?  If there's not that amount of useful scrum content each day, the team members are probably thinking that they'd make far more progress toward the goals if they got out of this meeting ASAP and got back to work.

If you just want to update the board and chart frequently, put draft copies on a wiki.

ContentLicense: CC BY-SA 3.0


问:
Are there technical reasons for an immediate update following a fresh download/install?
I've had this happen in all sorts of software products: You purchase a software product, download it, install it, and then after the install, the program immediately begins downloading an update or a patch.

Ideally, I would imagine that the download package would somehow be linked to the product's repository so that stable releases could be pushed to the product site rather than having to force the user to wait through an update after install.

Are there any technical reasons for the install/update process or is it just a case of poor deployment infrastructure on the part of a lot of companies?

答:
It's not poor, deployment of the main install image and downloadable update/patch are different things.

You cannot expect software providers chase all their downloadable images at all the mirrors to be updated with the latest nightly build, although some do that.

Usually, a cut-off is being made for a release image, and until the next cut-off, the updates are provided as patches one by one and are being downloaded by the product after it installs.


答:
In most cases, when software ships, it ships in stable form.  Once the software is installed, then at that time it phones home to check for an update.

More often than not, there are several factors that cause this...for example:

Operating Systems that come on disk probably already are behind the curve in updates, but the main goal is to get it installed first.

Another example is enterprise.  Big businesses want to install a product as-is, then slowly integrate the patches as-needed in controlled environments before just racing to the bleeding edge.

Being up-to-date isn't always a good thing.

Title: Are there technical reasons for an immediate update following a fresh download/install?

Body:
I've had this happen in all sorts of software products: You purchase a software product, download it, install it, and then after the install, the program immediately begins downloading an update or a patch.

Ideally, I would imagine that the download package would somehow be linked to the product's repository so that stable releases could be pushed to the product site rather than having to force the user to wait through an update after install.

Are there any technical reasons for the install/update process or is it just a case of poor deployment infrastructure on the part of a lot of companies?


问:
In simple words what are are the purposes of abstract classes and/or interfaces?
I have to explain to some students the use of abstract classes and interfaces, as I have a very tecnical background, I would like to know if you would help me to define an easy explanation for junior.

Simple definition:

What are the purposes of abstract classes, interfaces, and what is the difference between the two ?

When is it appropriate to use one instead of the other?

Thanks.

答:
An interface says to the user that this class will support these functions.

For example:

```<code>public interface IWorker
{
    void DoWork();
}
public class MyInformation : IWorker
{
    public void DoWork()
    {
        //Do your class-specific Work
    }
}

var info = new MyInformation();
info.DoWork();
</code>```

You might ask here - why not just add the method in MyInformation, instead of implementing an interface?

Here's a situation where it would be useful:

```<code>List<IWorker> workers = GetWorkers();
foreach(var worker in workers)
    worker.DoWork();
</code>```

Here we don't know what kind of objects we're recieving. All we know is that they will implement any of the methods defined in IWorker. We don't care how they do it - all we care about is that they support your call.

As for an abstract class:

```<code>public abstract class Serializer
{
    protected void GetAttributes()
    {
        //Some default implementation
    }
    public abstract void SaveObject(String outputPath);
}
</code>```

We have a serializer class, which has some basic default implementations - but by itself it does nothing. It does not know how to write the output - only how to get the attribute information.

Now you can have a concrete implementation such as :

```<code>public class XmlSerializer : Serializer
{
    public override void SaveObject(String outputPath)
    {
        //Do your xml serializing
    }
}
</code>```

Which will serialize it to XML.

Again, you don't care how they serialize, only that they do it;

```<code>List<Serializer> serializers = GetWorkers();
foreach(var serializer in serializers)
    serializer.SaveObject(@"C:\out.tmp");
</code>```

Body:
An interface says to the user that this class will support these functions.

For example:

public interface IWorker
{
    void DoWork();
}
public class MyInformation : IWorker
{
    public void DoWork()
    {
        //Do your class-specific Work
    }
}

var info = new MyInformation();
info.DoWork();

You might ask here - why not just add the method in MyInformation, instead of implementing an interface?

Here's a situation where it would be useful:

List<IWorker> workers = GetWorkers();
foreach(var worker in workers)
    worker.DoWork();

Here we don't know what kind of objects we're recieving. All we know is that they will implement any of the methods defined in IWorker. We don't care how they do it - all we care about is that they support your call.

As for an abstract class:

public abstract class Serializer
{
    protected void GetAttributes()
    {
        //Some default implementation
    }
    public abstract void SaveObject(String outputPath);
}

We have a serializer class, which has some basic default implementations - but by itself it does nothing. It does not know how to write the output - only how to get the attribute information.

Now you can have a concrete implementation such as :

public class XmlSerializer : Serializer
{
    public override void SaveObject(String outputPath)
    {
        //Do your xml serializing
    }
}

Which will serialize it to XML.

Again, you don't care how they serialize, only that they do it;

List<Serializer> serializers = GetWorkers();
foreach(var serializer in serializers)
    serializer.SaveObject(@"C:\out.tmp");


答:
I'd suggest if you hold the Retrospective meeting to see "What went well" and "What did not go well" and see if the developers list the daily Stand-up meeting itself as a waste of time. Then you would need to re-organise it a bit.

My personal experience:

The aim is to know what we are doing today and where we were
yesterday. Instead of sticking to the agenda, it gets down into a
technical discussion of blockers between 2 persons and the other 15
get bored. Identify the problem but discuss outside

People don't get into the meeting room on time, and this becomes a
cycle done by some on purpose. So the Scrum Master needs to have a
quiet discussion with them outside of the meeting to ensure they
start and end on time.

We already update burndown charts outside of the Scrum meeting so
that is not the main purpose of the daily stand-up.

Title: Why and for what reasons developers may not like "daily scrum"?

Body:
There are advantages in holding daily scrum, like:

Team get coordinated with each other

Everyone knows what amount of task has been done

Burndown chart gets more and more complete

Task board is updated

It doesn't last that much, 15 minutes won't kill anybody

However, recently (after 6 months of implementing and using scrum), I feel like that our developers don't like scrum daily that much anymore. People just update the task board, without explaining enough and it seems that  they're bored of it. I see that when for any reason, we don't hold it, they kind'of become extra-happy.

I just don't know what could be wrong with this. Are there any reasons mentioned somewhere for disadvantages the "daily scrum" can have for a team? What could be the reasons for developers getting tired of daily scrum?


答:
For software that is deployed through multiple channels, there can be different approval delays from submit to availability.

So as soon as you install it from channel X, it may check if there's a newer version and prompt to install again.

I've seen this several times with mobile software from app stores.


问:
How to Quantify the Value of Unit Testing
Our organization is considering integrating unit testing into our software development workflow. I've heard lots of anecdotal stories about how it encourages better, easy to maintain, and well-planned code. As a programmer, I understand the benefits.

However, in order to build consensus around using unit testing in projects that might affect customers, I would like to demonstrate its value quantitatively, in terms of saving hours of developer time.

Does anyone in the community have any historical data or experience they would be willing to share as quantitative evidence in my case for unit testing?

答:
Unit testing is invaluable.

I have many experiences with this.

When we first didn't adopt Unit testing, we spent the majority of the time solving bugs and dealing with mad customers because things didn't work as expected. Debugging code when you have no idea of where the bug may be is a hassle, especially because you first have to reproduce it in order to solve it.

When we decided it was time to start working with UT, it all changed. We got no more calls from mad customers at all. It may sound excessive but it went exactly like this.

With UT you find the bugs before your customers or QA. This is the big deal.


问:
What are the current problems involved in software engineering programming patterns?
can someone suggest me the current problems in software engineering and the research links for it?

i have some knowledge on MVVM being a pattern but i would like to know more about others and also current problems as to why people go for the patterns and how they help and what are still current problems involved and the research involved in this field

any help is greatly appreciated,

Thank you

答: Use of "dynamically" typed languages is a big problem. It creates maintenance nightmares in  form of lacking understandability because critical information (type informatione) is swept under the rug nor is it anywhere enforced that types match.</p>


问:
How important is it to be syntactically correct during an interview?
When asking an interview candidate to write a program on the whiteboard, do you expect the candidate to write code that is syntactically correct?

I had two candidates, one of which wrote a syntactically correct program but the logic was not up to the mark, and the other had the logic better written but the syntax was crap.

I favor the first candidate.

答:
I've been writing SQL and CSS (the most simple and basic languages I know) for nearly 13 years, and I can't always remember the syntax.

My friend (also a developer) works for a hedge fund, he can never remember the syntax for an insert statement.

We both end up on W3CSchools, I guess we should be embarassed (he has a degree, and I have a PhD).

However, to be honest, I think we have our priorities correct. Syntax is not an important skill.


答:
I once did a statistic over a number of versions and various modules of a large system, measuring basically the number of unit test LOC per functional code LOC, plotted against the number of bugs found during manual testing per functional LOC. The result looked something like this:

```<code>More Bugs
^
|
| +
|+    +  +     +
|   +    +          +   +
|  +        +    +     +    + +
|+     + +         +      +  +  +   +
|    +        +        +    +    + +
---------------------------------------> More Unit tests
</code>```

A linear interpolation said that there were nearly 50% less bugs in the code with the most unit tests, compared to that with none. But as you see, there is a large variance,
most likely related to complexity of the modules, experience and competence of the developers and maturity of the code.

Title: How to Quantify the Value of Unit Testing

Body:
Our organization is considering integrating unit testing into our software development workflow. I've heard lots of anecdotal stories about how it encourages better, easy to maintain, and well-planned code. As a programmer, I understand the benefits.

However, in order to build consensus around using unit testing in projects that might affect customers, I would like to demonstrate its value quantitatively, in terms of saving hours of developer time.

Does anyone in the community have any historical data or experience they would be willing to share as quantitative evidence in my case for unit testing?

Body:
I once did a statistic over a number of versions and various modules of a large system, measuring basically the number of unit test LOC per functional code LOC, plotted against the number of bugs found during manual testing per functional LOC. The result looked something like this:

More Bugs
^
|
| +
|+    +  +     +
|   +    +          +   +
|  +        +    +     +    + +
|+     + +         +      +  +  +   +
|    +        +        +    +    + +
---------------------------------------> More Unit tests

A linear interpolation said that there were nearly 50% less bugs in the code with the most unit tests, compared to that with none. But as you see, there is a large variance,
most likely related to complexity of the modules, experience and competence of the developers and maturity of the code.


答:
In modern application development, there're various problems to be solved. Most patterns we apply (from a high level perspective) are meant to benefit maintainability and extensibility, or in short: To cope with change.

can someone suggest me the current problems in software engineering
  and the research links for it?

There're plenty problems to be solved in software engineering. The whole profession is about solving problems. I'll list a few of the current problems:

OOP brought up the object-relational impedance mismatch because we traditionally use relational databases. There're various solutions to this problem. Object relational mapping can be used to work around it, but there're object-relational databases as well (see Postgres).

Reuse/Extensibility/Maintainability: How to communicate between UI and logic? Traditional patterns to solve this problem are MVVM or MVC.

Scalability/Distribution problems

I'd argue that future problems/current research topics involve mostly concurrency problems, as our software routines need to be parallelized more and more to take advantage of the hardware.

In any case, if you want to learn about software architecture patterns, then I'd recommend to visit Martin Fowler's website and then buy his books (Patterns of Enterprise Architecture for example). He has assembled a nice catalogue of patterns which are all meant to solve specific problems that arise in software engineering, probably the best reference out there today.

However, these patterns mostly try to provide solutions for architectural and fundamental technical problems. If you want to know more about design patterns, which are meant to provide solutions for technical/structural problems then you should read Head First Design Patterns as an introduction.

Title: What are the current problems involved in software engineering programming patterns?

Body:
can someone suggest me the current problems in software engineering and the research links for it?

i have some knowledge on MVVM being a pattern but i would like to know more about others and also current problems as to why people go for the patterns and how they help and what are still current problems involved and the research involved in this field

any help is greatly appreciated,

Thank you


答:
Interfaces are like skeletons. If you want to build a human, you should use that skeleton.

Interfaces simply create a kind of structure for your classes to denote that your class should have a defined and agree-upon structure. For example, all animals pee, eat and make sounds. Thus you can have an interface, called IAnimal which only mentions that classes should Pee, Eat, and MakeSound.

Interfaces are just like simple checklists, which should either be implemented totally, or none. When you want to use IAnimal interface, it's just like your boss telling you "Hey, don't create a Cat class unless you write some methods for it to eat, pee, and make sound".

Abstract classes are like skeletons, but with some meat on them as well. It's just there to make your work easier.

You can consider an abstract class to be an interface, which already has some implementation.

That was the plain English answer. But after getting that, please study more, to get the real concept.

Title: In simple words what are are the purposes of abstract classes and/or interfaces?

Body:
I have to explain to some students the use of abstract classes and interfaces, as I have a very tecnical background, I would like to know if you would help me to define an easy explanation for junior.

Simple definition:

What are the purposes of abstract classes, interfaces, and what is the difference between the two ?

When is it appropriate to use one instead of the other?

Thanks.


答:
Depending on the actual syntactical errors, I guess I would prefer the second candidate, because checking syntax is usually better left to the machines.

Errors like missing semicolons, forgetting closing brackets, forgetting commas in argument lists, etc, even non-syntactical errors like switching the argument order when calling a function usually get caught by the syntax highlighter, the compiler or when the code is run the first time, all things one usually uses, but are not available on the whiteboard.

However, there are some errors, that, while technically only syntax errors, show a deeper missunderstanding.

As a somewhat artificial example to get the point across: consider a python programmer who prefixes all his variables with $, or writes the for-loop as for list as item. Technically, both are syntax errors, but even with only limited exposure to python one should know how about legal characters and the for loop. It would be a good guess that the candidate knows php (or perl?) and tries to bluff about his python skills

Title: How important is it to be syntactically correct during an interview?

Body:
When asking an interview candidate to write a program on the whiteboard, do you expect the candidate to write code that is syntactically correct?

I had two candidates, one of which wrote a syntactically correct program but the logic was not up to the mark, and the other had the logic better written but the syntax was crap.

I favor the first candidate.


答:
Make sure that no-one monopolises the meeting.

If 4 of the developers get their spiel out of the way in 5 minutes, and the next 10 minutes are spent listening to the team leader detailing all of the amazing, awesome new developments he's made, most of which are neither as amazing nor as awesome as he thinks they are, people will get very bored very quickly.

Stand back a moment and think about your team:

Are they working effectively?

Are tasks completed on time?

Is the code robust and well-written?

Does the team ensure that nothing falls through the cracks?

Does the team co-ordinate itself so that they don't duplicate work or tread on each other's toes?

If your answer to all of these things is "Yes", perhaps you should consider why you want to force busywork like daily meetings, burndown charts and task boards on your team.  What value does it add?  Do you want to generate bureaucratic data solely for your own enjoyment or are you trying to make the team more productive?

Has there been a decline in productivity since the daily scrums stopped, or is everything ticking over the same as before?  If nothing has changed, why continue the meetings?


答: Unless the problem is subtle, and most interview questions aren't, the first candidate is disqualified.  It's a lot easier to learn language syntax than algorithm design.  I will hire a programmer with a history of successful work in multiple languages, even if he has zero experience in my current technology.  This isn't the best strategy if I need something done today, but if I need a lot of things done over the next twelve months, then I will always pick general ability over specific experience.</p>


答:
Some of the problems encountered with daily SCRUM meetings :

those which last too long. You don't want any manager guy in those daily because they're the root cause of this kind of problems. See how they'll usually be the ones using a chair (yes, having to stand up for those is to entice people to be fast)

having to hear about someone (or 2 or 3 devs) describing whatever isolated problem he has at length instead of him deciding to schedule another real meeting later to discuss it with the ones concerned

stupid hours. Those meetings don't have to be in the morning: you're not speaking about what you've done yesterday and deciding what you'll do today; you're speaking about what you've done between last daily and this one and deciding what you'll be doing until next one.

lack of ownership of the app for the devs. SCRUM works if devs are not treated as code monkeys. The first sign of the process going wrong is when the devs are not the ones evaluating how much time something will take to be done.

stupid hours again. If part of the team has started working on some things and are "in the zone" when the daily happens, it becomes a bother. A good time to have those daily is when no one should be working (after lunch for example, or just before to start some discussions to have during lunch).


问:
Modern approaches to retrieve useful content from a web page?
What are the modern ways to (effectively) determine which part of page contains useful text, data tables, etc. and which are not (e.g. ads, navigation, etc.)?

What were the last valuable researches/result/papers in this field in latest years?

Thank you in advance!

答:
Semantic Web

"a web of data that can be processed directly and indirectly by
  machines."

Semantic Web is a system to let machines understands human data.

Tim Berners-Lee originally expressed the vision of the semantic web as follows:

"I have a dream for the Web [in which computers] become capable of
  analyzing all the data on the Web – the content, links, and
  transactions between people and computers. A ‘Semantic Web’, which
  should make this possible, has yet to emerge, but when it does, the
  day-to-day mechanisms of trade, bureaucracy and our daily lives will
  be handled by machines talking to machines. The ‘intelligent agents’
  people have touted for ages will finally materialize."

In order to do this, Semantic Web relies on languages specifically designed to store arbitrary data, such as RDF, OWL and XML.

Microformat

A web-based approach to semantic markup to gather metadata from documents.

This approach allows software to process information intended for end-users (such as contact information, geographic coordinates, calendar events, and the like) automatically.

As of 2010 microformats allow the encoding and extraction of events,
  contact information, social relationships and so on. More are being
  developed.

You may also be interested in

Semantic Advertising

Website Parse Template

Ontology Learning


答: Syntax checking is what a compiler is for. A compiler can't make your logic better, but it can tell you how to fix your syntax. That means that any job where you write code using a compiler, the logic is inherently vastly more valuable than being syntactically correct.  </p>


答:
Interviews are always awkward situations - you can tell this because when you walk out, you immediately think of all the things you should have said, or the right answers to the questions and the things you wanted to ask them but forgot. So, given this, expecting perfectly written code with no syntax errors is being unrealistic.

Additionally, your expectations of perfect code (on a whiteboard!) may not match the interviewers - for example, at one interview I attended I was asked to write a class, which I did, only for the interviewer to pull me up on not putting in a copy constructor. So I wrote one in, which did nothing but set a = b, but that was enough to satisfy him. My expectations of the problem didn't require a copy ctor, so I left it out as extraneous to the problem being solved - I didn't expect to have to write fully compliant, compiling code (to his hidden coding standards), simply show my understanding of the solution. (this same interviewer didn't like my solution either, it wasn't how he would have done it so obviously I got it wrong, sigh).

If you want working code from an interviewee, give them a compiler. Then don't complain  when they invoice you :)

So go for the person who knows what he's doing, not the one that can parrot the words but doesn't understand the meaning.


答:
True story, I still forget the syntax of C# events when I have to write them out by hand. It happens in interviews sometimes. I don't have the issue when I code at a keyboard.

Choose the guy who can code, not the one who can't but can remember the syntax.


问:
In a 4 hour Powershell 101 class should I skip for/while/do and just teach ForEach-Object
I'm making a syllabus to teach non-programmer co-workers PowerShell. The first non-pilot group I will run the course with will be a team that deploys and configures one of our software products. They are bright intelligent motivated IT workers, but not programmers.

I intend to cover the basics (variables, arrays, functions, and loops), and then move onto examples that are close to their problem domain. I'm not married to a 4 hour class, if necessary I can expand it to two four hour classes.

I'm toying with the idea of skipping for and while loops and simply teaching ForEach-Object. I've personally used traditional for and while loops in powershell scripts, but they can always be rewritten  as ForEach-Object loops with a bit of creativity. Part of me feels the good old for ($i=0 $i < foo; $i++) is a necessary fundamental before moving onto foreach, but the other part of me thinks that might be me clinging to my Model M and my K&R Bible.

To draw an analogy to SQL, I'd never teach a CURSORs or other loops in a 4 hour class there because you're supposed to be able to do everything in SQL as a SET operation. In theory you should stick to the pipeline in PowerShell. I use for and while loops in PowerShell more often than I do do cursors and while loops in SQL. However, PowerShell is a scripting language and conventions are less strictly enforced and I also push the boundaries of powershell with inline C# and excessive dependencies on calling native .NET APIs. My audience will not be ding this.

For those not adept at powershell, I'm pretty sure you don't actually need a for or while loop. I use them, but that's because I have experience with other languages. For example if you only want the first 10 members of an array of 20 members:

```<code>1..20 | Select-Object -First 10 | ForEach-Object { Write-Host $_ }
</code>```

答:
Why skip them? I appreciate you are time restricted, but include the syntax of each with a little example in the course notes at the very least. You don't have to spend more than 30 seconds describing them.

If they can't code a "display the first 10" easily I think you've missed a trick.


答:
The resistance comes when:
1) They are used to force people to rush in for 9am. It's extra stress when the train is late.
2) Poor scrum leadership. The leader should be telling people to take stuff off line rather than have people stand around listening to something that doesn't affect them.
3) Valueless content. This is again a scrum leadership issue. It is supposed to be a forum to address bottlenecks, trajectory issues and potential collaborations. What actually happens is everyone just says what they expect to work on that day which is of no use or interest to anyone else.
4) Standing. I won't stand for standing. The logic behind standing was that it encourages people to be brief. People actually just rattle on regardless. </p>


答:
I will try to be simple.

An abstract class is a class. It is special in that you cannot create object of abstract class. A non-abstract class in called concrete class.

An abstract class, being a class, can have usual elements in it like fields, properties, methods events, indexers etc. Note that, as it is guaranteed that abstract class will not be instantiated to create object, some of those elements cab be without implementations (e.g. methods without body).

An interface is description of members that some other class will have for sure. C# interface can describe methods, properties, indexers and events only.

If a class implements interface, then it must implement all members described by interface.

This means if a class, implementing an interface, does not implement all members described by that interface then such class must be abstract class!

An abstract class can be 'half-cooked' class meaning it has provided few methods with body but few methods are without body etc. An interface can never implement any member it describes.

Abstract class takes part in hierarchy of classes based on inheritance. Note that in C#, a class can have at most one parent class which may or may not be abstract.

A class can implement many interfaces at the same time.

There many use cases for both of them.

Following statements should give you more clarity:

Class must be either abstract or concrete.

Interface, by definition, is abstract.

Neither interface nor abstract class can be instantiated.

Class may inherit from zero or one (abstract or concrete) class.

Class may implement zero or more interfaces.

Interface may inherit from zero or more interfaces.

Interface cannot inherit a class.

Abstract class may have members with implementation.

Interface cannot have any member with implementation.

To be concrete, class must implement all members in interface.

I hope this helps.


问:
My boss wants a narrated line-by-line English explanation of our code
I have been specifically asked to give line by line (or as appropriate - for example, image by image, etc.) explanation or commentary which my boss wants to be able to read and follow.

Since he is not a programmer, he can not follow the code so wants it all translated into English.

Has anyone been asked to do this before?

I have commented on all of the source code and used JSDoc to generate full documentation of all functions, variables, etc... and included an implementation example, and full working demos with comments throughout.

Is there anything else I can do to comment the code for non-programmers?

This isn't a reasonable request, is it?

UPDATE

In the end, I managed to explain why it was not a good use of time to do what he was asking. He is a reasonable guy, and just did not have an understanding of what my job involves. Once he saw this post, I think he quickly understood that it was not a normal request.

I did provide documentation that is suitable for another programmer to follow (JSDoc and inline comments - as well as some extra notes on technical issues), and a very broad flow chart diagram of the main logic of the program for my boss to follow.

In the end, all parties were satisfied and we have moved on.

答: I would just show him the video Quick-sort with Hungarian (Küküllőmenti legényes) folk dance and then explain to him how long it would take to do this for all lines of code you have.

OwnerDisplayName: BIlly Moon


问:
What level of threat does selling an app on an app store present to a non-US company?
Can anyone point me to an article or an informed discussion about US software patents affecting a non-US company who is selling their products on an American app store/marketplace?

My company has several products on both Apple's App Store and Android's Marketplace, all of which are available for sale in the US. We are however based in Europe and have no assets registered in the US.

Assuming we had a product worth enough to attract patent trolls, should we be worried? We have not researched any relevant patents we might be infringing because such research would be too expensive for us. Reading articles about US patent law it seems that being able to catch all potential patents is unlikely anyhow.

I realise this site is frequented by programmers and not by lawyers, but a good external reference would be much appreciated.

答:
Naturally IANAL but Lodsys have gone after Rovio who are Finnish and have their principal place of business in in Espoo, Finland, and Square Enix who are British and headquartered in London (these are as listed on the amended complaint so they're not going after US subsidiaries of those companies).

Obviously it needs to be worth their while to go after you so if you're only turning over a few thousands of dollars a year (or a few tens of thousands of dollars even) they probably won't bother, but if you did hit it big your lack of presence in the US wouldn't protect you.


问:
Most efficient way to learn java if you already know how to code?

Possible Duplicate:

  Is there a canonical book for learning Java as an experienced developer?

I've been coding for close to 25 years now in basic, (C64 & Amiga), (Object) pascal, C, LPC and for the last few years, Python.
Python is definitely my favourite (and strongest) language. However, lately I've been forced to do stuff in Java - I have never written a single line of java code so far.

So I'm asking your advice - what is the fastest and most efficient crash course to learn java.

EDIT: I'm really looking for something along the lines teaching java to people who know how to code and what OOP is - not something that has with no previous programming experience in the synopsis.

答:
I started with Core Java.

This book is to the point, it has most of the basics covered, and you can read the second volume if you want to know more about Java.


问:
Does C99 make the K&R book outdated? If so what to recomend in its place?
C99 has been with us for a while now. It introduces a lot of features that are not in K&Rs The C Programming Language. None of them are particularly radical. However, even small features like being able to intermingle declarations and code change how one organizes code.

While I still consider the K&R book an invaluable reference, and like its writing style, is there a better book that takes into account the C99 standard? I'd buy a third edition of K&R in a heartbeat, but I don't think that is going to happen.

答: I'd recommend King's C Programming: A Modern Approach. It's thicker than K&R but still not particularly padded and the author points out what is and is not new to C99 as well as style tips and other such things. </p>


答:
It, as always, depends. If the syntax errors are relatively minor, I'd ignore them. If they're earth-shakingly huge, I'd pay attention to them and try to infer why they are there.

I think logic errors are worse than syntax errors, the latter can almost always be caught mechanically, the former less so (depends, to a degree, on what language you're writing, some classes of logic errors are caught by sufficiently-advanced type inference and checking).


答: I would recommend the book Thinking in Java. IMHO opinion it's one of the best books about object-oriented programming and Java. You can even download the previous edition of the book for free to make your own conclusions.</p>

Title: Most efficient way to learn java if you already know how to code?

Body:
Possible Duplicate:

  Is there a canonical book for learning Java as an experienced developer?

I've been coding for close to 25 years now in basic, (C64 & Amiga), (Object) pascal, C, LPC and for the last few years, Python.
Python is definitely my favourite (and strongest) language. However, lately I've been forced to do stuff in Java - I have never written a single line of java code so far.

So I'm asking your advice - what is the fastest and most efficient crash course to learn java.

EDIT: I'm really looking for something along the lines teaching java to people who know how to code and what OOP is - not something that has with no previous programming experience in the synopsis.


问:
Storing n-gram data
I was hoping to brainstorm a little bit on the subject of storing n-gram data.
In my project, I am trying to solve linguistic problems where I know all (n-1) data items and want to statistically guess my n using linear interpolation over all applicable n-grams. (Yes, there is a tagger that assigns tags to known words according to its lexicon and a suffix tree that tries to guess the word kind for unknown words; the n-gram component discussed here will be tasked with resolving ambuguity.)

My initial approach would be to simply store all observed n-grams (for n = 1..3, i.e. monogram, bigram, trigram) data in respective SQL databases and call it a day. But the requirements of my project may change to include other vector lengths (n), and I would like my application to adapt to 4-gram without a lot of work (updating schema, updating application code, etc.); ideally, I would simply tell my application to work with 4-grams now without having to change code much (or at all) and train its data from a given data source.

To sum up all requirements:

Ability to store n-gram data (initially for n = {1, 2, 3}

Ability to change what kinds of n-grams should be used (between application runs)

Ability to (re-)train n-gram data (between application runs)

Ability to query the data store (e.g. if I have observed A, B, C, I'd like to know the most frequently observed item for what might follow using my trained 4-, 3-, 2-, 1-gram data sets)

The application will most likely be read-heavy, data sets most likely won't be retrained that often

The solution employs the .NET Framework (up to 4.0)

Now what design would be better fit for such a task?

A fixed table managed by a SQL server (MSSQL, MySQL, ...) for each n (eg. dedicated tables for bi-grams, tri-grams, etc.)

Or a NoSQL document database solution that stores the first n-1 as the key of the document, and the document itself contains the n-th value and observed frequencies?

Or something different?

答:
Given that you won't know the optimal range of N, you definitely want to be able to change it. For example, if your application predicts the likelihood that a certain text is English, you would probably want to use character N-grams for N 3..5. (That's what we found experimentally.)

You haven't shared details about your application, but the problem is clear enough. You want to represent N-gram data in a relational database (or NoSQL document-based solution). Before suggesting a solution of my own, you may want to take a look at the following approaches:

How to best store Google ngrams in a database?

Storing n-grams in database in < n number of tables

Managing the Google Web 1T 5-gram with Relational Database

Now, having not read any of the above links, I suggest a simple, relational database approach using multiple tables, one for each size of N-gram. You could put all of the data in a single table with the maximum necessary columns (i.e. store bigrams and trigrams in ngram_4, leaving the final columns null), but I recommend partitioning the data. Depending on your database engine, a single table with a large number of rows can negatively impact performance.

```<code>  create table ngram_1 (
      word1 nvarchar(50),
      frequency FLOAT,
   primary key (word1));

  create table ngram_2 (
      word1 nvarchar(50),
      word2 nvarchar(50),
      frequency FLOAT,
   primary key (word1, word2));

  create table ngram_3 (
      word1 nvarchar(50),
      word2 nvarchar(50),
      word3 nvarchar(50),
      frequency FLOAT,
   primary key (word1, word2, word3));

  create table ngram_4 (
      word1 nvarchar(50),
      word2 nvarchar(50),
      word3 nvarchar(50),
      word4 nvarchar(50),
      frequency FLOAT,
   primary key (word1, word2, word3, word4));
</code>```

Next, I'll give you a query that will return the most probable next word given all your ngram tables. But first, here is some sample data that you should insert into the above tables:

```<code>  INSERT [ngram_2] ([word1], [word2], [frequency]) VALUES (N'building', N'with', 0.5)
  INSERT [ngram_2] ([word1], [word2], [frequency]) VALUES (N'hit', N'the', 0.1)
  INSERT [ngram_2] ([word1], [word2], [frequency]) VALUES (N'man', N'hit', 0.2)
  INSERT [ngram_2] ([word1], [word2], [frequency]) VALUES (N'the', N'bat', 0.7)
  INSERT [ngram_2] ([word1], [word2], [frequency]) VALUES (N'the', N'building', 0.3)
  INSERT [ngram_2] ([word1], [word2], [frequency]) VALUES (N'the', N'man', 0.4)
  INSERT [ngram_2] ([word1], [word2], [frequency]) VALUES (N'with', N'the', 0.6)
  INSERT [ngram_3] ([word1], [word2], [word3], [frequency]) VALUES (N'building', N'with', N'the', 0.5)
  INSERT [ngram_3] ([word1], [word2], [word3], [frequency]) VALUES (N'hit', N'the', N'building', 0.3)
  INSERT [ngram_3] ([word1], [word2], [word3], [frequency]) VALUES (N'man', N'hit', N'the', 0.2)
  INSERT [ngram_3] ([word1], [word2], [word3], [frequency]) VALUES (N'the', N'building', N'with', 0.4)
  INSERT [ngram_3] ([word1], [word2], [word3], [frequency]) VALUES (N'the', N'man', N'hit', 0.1)
  INSERT [ngram_3] ([word1], [word2], [word3], [frequency]) VALUES (N'with', N'the', N'bat', 0.6)
  INSERT [ngram_4] ([word1], [word2], [word3], [word4], [frequency]) VALUES (N'building', N'with', N'the', N'bat', 0.5)
  INSERT [ngram_4] ([word1], [word2], [word3], [word4], [frequency]) VALUES (N'hit', N'the', N'building', N'with', 0.3)
  INSERT [ngram_4] ([word1], [word2], [word3], [word4], [frequency]) VALUES (N'man', N'hit', N'the', N'building', 0.2)
  INSERT [ngram_4] ([word1], [word2], [word3], [word4], [frequency]) VALUES (N'the', N'building', N'with', N'the', 0.4)
  INSERT [ngram_4] ([word1], [word2], [word3], [word4], [frequency]) VALUES (N'the', N'man', N'hit', N'the', 0.1)
</code>```

To query the most probable next word, you would use a query like this.

```<code>  DECLARE @word1 NVARCHAR(50) = 'the'
  DECLARE @word2 NVARCHAR(50) = 'man'
  DECLARE @word3 NVARCHAR(50) = 'hit'
  DECLARE @bigramWeight FLOAT = 0.2;
  DECLARE @trigramWeight FLOAT = 0.3
  DECLARE @fourgramWeight FLOAT = 0.5

  SELECT next_word, SUM(frequency) AS frequency
  FROM (
    SELECT word2 AS next_word, frequency * @bigramWeight AS frequency
    FROM ngram_2
    WHERE word1 = @word3
    UNION
    SELECT word3 AS next_word, frequency * @trigramWeight AS frequency
    FROM ngram_3
    WHERE word1 = @word2
      AND word2 = @word3
    UNION
    SELECT word4 AS next_word, frequency * @fourgramWeight AS frequency
    FROM ngram_4
    WHERE word1 = @word1
      AND word2 = @word2
      AND word3 = @word3
    ) next_words
  GROUP BY next_word
  ORDER BY SUM(frequency) DESC
</code>```

If you add more ngram tables, you will need to add another UNION clause to the above query. You might notice that in the first query I used word1 = @word3. And in the second query, word1 = @word2 AND word2 = @word3. That's because we need to align the three words in the query for the ngram data. If we want the most likely next word for a sequence of three words, we'll need to check the first word in the bigram data against the last word of the words in the sequence.

You can tweak the weight parameters as you wish. In this example, I assumed that higher ordinal "n" grams will be more reliable.

P.S. I would structure the program code to handle any number of ngram_N tables via configuration. You could declaratively change the program to use N-gram range N(1..6) after creating the ngram_5 and ngram_6 tables.

Title: Storing n-gram data

Body:
Given that you won't know the optimal range of N, you definitely want to be able to change it. For example, if your application predicts the likelihood that a certain text is English, you would probably want to use character N-grams for N 3..5. (That's what we found experimentally.)

You haven't shared details about your application, but the problem is clear enough. You want to represent N-gram data in a relational database (or NoSQL document-based solution). Before suggesting a solution of my own, you may want to take a look at the following approaches:

How to best store Google ngrams in a database?

Storing n-grams in database in < n number of tables

Managing the Google Web 1T 5-gram with Relational Database

Now, having not read any of the above links, I suggest a simple, relational database approach using multiple tables, one for each size of N-gram. You could put all of the data in a single table with the maximum necessary columns (i.e. store bigrams and trigrams in ngram_4, leaving the final columns null), but I recommend partitioning the data. Depending on your database engine, a single table with a large number of rows can negatively impact performance.

  create table ngram_1 (
      word1 nvarchar(50),
      frequency FLOAT,
   primary key (word1));

  create table ngram_2 (
      word1 nvarchar(50),
      word2 nvarchar(50),
      frequency FLOAT,
   primary key (word1, word2));

  create table ngram_3 (
      word1 nvarchar(50),
      word2 nvarchar(50),
      word3 nvarchar(50),
      frequency FLOAT,
   primary key (word1, word2, word3));

  create table ngram_4 (
      word1 nvarchar(50),
      word2 nvarchar(50),
      word3 nvarchar(50),
      word4 nvarchar(50),
      frequency FLOAT,
   primary key (word1, word2, word3, word4));

Next, I'll give you a query that will return the most probable next word given all your ngram tables. But first, here is some sample data that you should insert into the above tables:

  INSERT [ngram_2] ([word1], [word2], [frequency]) VALUES (N'building', N'with', 0.5)
  INSERT [ngram_2] ([word1], [word2], [frequency]) VALUES (N'hit', N'the', 0.1)
  INSERT [ngram_2] ([word1], [word2], [frequency]) VALUES (N'man', N'hit', 0.2)
  INSERT [ngram_2] ([word1], [word2], [frequency]) VALUES (N'the', N'bat', 0.7)
  INSERT [ngram_2] ([word1], [word2], [frequency]) VALUES (N'the', N'building', 0.3)
  INSERT [ngram_2] ([word1], [word2], [frequency]) VALUES (N'the', N'man', 0.4)
  INSERT [ngram_2] ([word1], [word2], [frequency]) VALUES (N'with', N'the', 0.6)
  INSERT [ngram_3] ([word1], [word2], [word3], [frequency]) VALUES (N'building', N'with', N'the', 0.5)
  INSERT [ngram_3] ([word1], [word2], [word3], [frequency]) VALUES (N'hit', N'the', N'building', 0.3)
  INSERT [ngram_3] ([word1], [word2], [word3], [frequency]) VALUES (N'man', N'hit', N'the', 0.2)
  INSERT [ngram_3] ([word1], [word2], [word3], [frequency]) VALUES (N'the', N'building', N'with', 0.4)
  INSERT [ngram_3] ([word1], [word2], [word3], [frequency]) VALUES (N'the', N'man', N'hit', 0.1)
  INSERT [ngram_3] ([word1], [word2], [word3], [frequency]) VALUES (N'with', N'the', N'bat', 0.6)
  INSERT [ngram_4] ([word1], [word2], [word3], [word4], [frequency]) VALUES (N'building', N'with', N'the', N'bat', 0.5)
  INSERT [ngram_4] ([word1], [word2], [word3], [word4], [frequency]) VALUES (N'hit', N'the', N'building', N'with', 0.3)
  INSERT [ngram_4] ([word1], [word2], [word3], [word4], [frequency]) VALUES (N'man', N'hit', N'the', N'building', 0.2)
  INSERT [ngram_4] ([word1], [word2], [word3], [word4], [frequency]) VALUES (N'the', N'building', N'with', N'the', 0.4)
  INSERT [ngram_4] ([word1], [word2], [word3], [word4], [frequency]) VALUES (N'the', N'man', N'hit', N'the', 0.1)

To query the most probable next word, you would use a query like this.

  DECLARE @word1 NVARCHAR(50) = 'the'
  DECLARE @word2 NVARCHAR(50) = 'man'
  DECLARE @word3 NVARCHAR(50) = 'hit'
  DECLARE @bigramWeight FLOAT = 0.2;
  DECLARE @trigramWeight FLOAT = 0.3
  DECLARE @fourgramWeight FLOAT = 0.5

  SELECT next_word, SUM(frequency) AS frequency
  FROM (
    SELECT word2 AS next_word, frequency * @bigramWeight AS frequency
    FROM ngram_2
    WHERE word1 = @word3
    UNION
    SELECT word3 AS next_word, frequency * @trigramWeight AS frequency
    FROM ngram_3
    WHERE word1 = @word2
      AND word2 = @word3
    UNION
    SELECT word4 AS next_word, frequency * @fourgramWeight AS frequency
    FROM ngram_4
    WHERE word1 = @word1
      AND word2 = @word2
      AND word3 = @word3
    ) next_words
  GROUP BY next_word
  ORDER BY SUM(frequency) DESC

If you add more ngram tables, you will need to add another UNION clause to the above query. You might notice that in the first query I used word1 = @word3. And in the second query, word1 = @word2 AND word2 = @word3. That's because we need to align the three words in the query for the ngram data. If we want the most likely next word for a sequence of three words, we'll need to check the first word in the bigram data against the last word of the words in the sequence.

You can tweak the weight parameters as you wish. In this example, I assumed that higher ordinal "n" grams will be more reliable.

P.S. I would structure the program code to handle any number of ngram_N tables via configuration. You could declaratively change the program to use N-gram range N(1..6) after creating the ngram_5 and ngram_6 tables.


答: Touching on the basic loop constructs is very important -- if for nothing else than giving the students a fighting chance when they see the for/while constructs in the wild. </p>

Title: In a 4 hour Powershell 101 class should I skip for/while/do and just teach ForEach-Object

Body:
I'm making a syllabus to teach non-programmer co-workers PowerShell. The first non-pilot group I will run the course with will be a team that deploys and configures one of our software products. They are bright intelligent motivated IT workers, but not programmers.

I intend to cover the basics (variables, arrays, functions, and loops), and then move onto examples that are close to their problem domain. I'm not married to a 4 hour class, if necessary I can expand it to two four hour classes.

I'm toying with the idea of skipping for and while loops and simply teaching ForEach-Object. I've personally used traditional for and while loops in powershell scripts, but they can always be rewritten  as ForEach-Object loops with a bit of creativity. Part of me feels the good old for ($i=0 $i < foo; $i++) is a necessary fundamental before moving onto foreach, but the other part of me thinks that might be me clinging to my Model M and my K&R Bible.

To draw an analogy to SQL, I'd never teach a CURSORs or other loops in a 4 hour class there because you're supposed to be able to do everything in SQL as a SET operation. In theory you should stick to the pipeline in PowerShell. I use for and while loops in PowerShell more often than I do do cursors and while loops in SQL. However, PowerShell is a scripting language and conventions are less strictly enforced and I also push the boundaries of powershell with inline C# and excessive dependencies on calling native .NET APIs. My audience will not be ding this.

For those not adept at powershell, I'm pretty sure you don't actually need a for or while loop. I use them, but that's because I have experience with other languages. For example if you only want the first 10 members of an array of 20 members:

```<code>1..20 | Select-Object -First 10 | ForEach-Object { Write-Host $_ }
</code>```


问:
Which is best programming style to start learning to programm POP or OOP?
If somebody has to start learning to program, where should he/she start? Should he start to write procedure-oriented programs or jump to OOP?</p>

答:
I'd say go for learning both. If you don't know how to program yet, close your eyes and choose Python as your first language. It allows you to put in your procedural concepts while still being object oriented. Even using standard Python libraries/types will give you a feel of OOP and you will excel in the Science and Art of Programming. Then once you get the feel of the language itself, go for OO concepts.

Once you have the concepts right, you can give C++ or even Java a shot. But as a complete beginner, I'd recommend Python first.

OOP, Procedural programming, etc are just different ways to model and solve problems, and you should definitely have both under your belt.

regards,

Yati Sagade

PS: the second person in the above answer refers directly to the third person in your question :)


答:
I think what you begin with isn't really important. What is important is that you know both, and fail with both.

Because you will fail. Learn from it.

All xOP are here to solve problems devellopers encounter when coding, or maintaining software. The bigger the software is, the more important it is. You can learn OOP, or POP, but at the end, you'll not understand what it is good for unless you exprience problem you have not following those methodologies.

POP, OOP and others are not just coding techniques. This is a way to think about your code. New way to think are devellopped to solve problems devellopper had with previous way to think about what they do.

Acquiring that require time, way more than learning simple techniques.

Anyway, I'll advise you to start with POP. Because at the end, you cannot do something without it. If you do OOP, you'll have clases, methods, but with methods, you'll find plein old procedural programming.

POP and OOP are not think that should be thinked at instruction level. At this point, you are doing procedural, even if you do OOP, fucntionnal, or whatverer. But doing only POP, you'll encounter problems when your software grows. OOP, functionnals, and others way of thinking your software as a whole will help you to handle the incrasing complexity of the code.

Note that thos can be achieved in pure procedural, but kinda hard, and not the way broadly used in industry.

Title: Which is best programming style to start learning to programm POP or OOP?

Body: If somebody has to start learning to program, where should he/she start? Should he start to write procedure-oriented programs or jump to OOP?</p>


答: I think that before you start doing oop programming you should have a basic understanding of programming as it used to be done. It's important for a programmer to know why he/she is using oop and i think the fastest way to understand this is by starting without, begin with the basics of memory manipulation and math.</p>


答:
I know c# and recently learned Java. I got a couple of good Java books and just started doing the project. If you know the concept of programming then language specifics are easy to pick up as you go.

The best way of picking it up is on the fly while doing something.


答:
For a much cheaper and far more up-to-date alternative to the books mentioned, I recommend starting with Oracle's Java Tutorials. Since you have a programming background already, some of it is going to be easy that you can read and power through. When you get to a topic you aren't comfortable with, spend the time to read it, understand the sample code, and work through it. It might be a good idea to have the API documentation handy as well.

Just a note - the links I provided are for Java 7. Searching can find the documentation and tutorials for Java 6 as well. I know the API documentation is available, and the tutorials should be as well.

If you're going to be developing enterprise applications, you might also be interested in the Java EE Tutorial as well.


答: I would recommend Sams Teach Yourself Java in 24 Hours, that's what I learned on. then just give yourself a programming project with it. one of the great things about the book is that after every chapter, it has you build something, gives you the code, and explain each line.</p>


答:
You could use BlueJ to learn both Java and Object Oriented (OO) programming at the same time. The BlueJ environment provides class diagramming and object inspectors which would help you understand OO in an easier fashion.

I'm pretty sure that you might have an easy time learning Java with Head First Java as well, since they try to go over the class-based OO. It is quite verbose, so if you like reading a lot of pages that explain with figures and text then that book is for you.


答: Jump right into it with a good IDE (for syntaxctic support) and always have the standard API docs open. Then work through the tutorial that comes with the Oracle JDK distribution.


答:
I would reccomend OOP first, here's why:

First Language

You want to start off with OOP. The reason is that this is primarily what is used in the real word, and you it's always easier to learn a concept like that as a first language, instead of a second one. I always hear people saying they don't understand the concept of OOP, theses are usually POP programmers that are transitioning to OOP. My first language was Java, which is an OOP programming language, and I never had a problem understanding the concept, because I didn't know anything else.

OOP can do everything POP can do

The other thing is that you can always use an OOP language as a POP if you want to. for example, in java, you don't have to use more than one class if you don't want to, and it becomes fairly easy to understand what POP is like (OOP has all of the features of a POP language, but it is more dynamic and reusable, but if you don't want to, you don't necessarily have to take advantage of those features) the same should apply with something like C++ vs C


答:
We are in the same situation, and the best thing is indeed to ask to a specialized lawyer.

Meanwhile I found some recent articles about this topic, which my company is also worried about.

How the US patent mess affects European tech and startups - August 13, 2011

App Developers Withdraw From U.S. As Patent Fears Reach ‘Tipping Point’ - July 16, 2011

The situation it's still not clear to me, but it's also difficult to tell which patent you may have troubles with.

Meanwhile, beware of cross promotion too.

Title: What level of threat does selling an app on an app store present to a non-US company?

Body:
Can anyone point me to an article or an informed discussion about US software patents affecting a non-US company who is selling their products on an American app store/marketplace?

My company has several products on both Apple's App Store and Android's Marketplace, all of which are available for sale in the US. We are however based in Europe and have no assets registered in the US.

Assuming we had a product worth enough to attract patent trolls, should we be worried? We have not researched any relevant patents we might be infringing because such research would be too expensive for us. Reading articles about US patent law it seems that being able to catch all potential patents is unlikely anyhow.

I realise this site is frequented by programmers and not by lawyers, but a good external reference would be much appreciated.


答:
When I'm writing code on paper/whiteboard, even for a job interview, I basically skip a huge chunk of the syntax.  I don't use semi colons, I fudge method calls, etc.  I'm more likely to write a sentence explaining 4 lines of really basic code than the code itself.  Really, I use a php-like pseudocode, and talk through what I'm doing, while I'm doing it, and jot down quick comments to explain things I gloss over (which are, in theory, nothing that's actually important to the program)

My goal when coding in an interview is to show how I solve the problem, not to dictate something a typist could enter in to Notepad and have run.

Long story short: I think you should consider why the first programmer had crappy syntax.  He very well could know it but just considered it irrelevant for the interview, and preferred to focus on the parts of this job that are hard (logic and problem solving).


答:
The best thing you can do is to get a handle on all the paradigms.  I'd suggest the following order:

Simple procedural programming: just getting basic sequential programming techniques down.

Structured programming: Top-Down design, Abstract Data Types, Modules.

Functional Programming: Working without side-effects, functions as first-class objects

Object-Oriented Programming: Abstraction, Polymorphism

Very low-level programming, i.e. assembly language: working with the hardware, number of registers, cache, memory, SIMD instructions, optimization, and generally an appreciation of how much easier compilers and interpreters make our jobs.

Multiparadigm-programming:  Combine all of the above using the best tool for the job when appropriate

And then you can try some more esoteric styles, such as Logic Programming (Prolog), and Concurrent Programming (Communicating Synchronous Processes, OCCAM).

You can several steps in one language (Python would cover most of the bases), though it's probably better to do 3 in a relatively strict functional language (I'd suggest Lisp), and 4 in a relatively strict OO language (Java, C#).
You don't have to go extremely deep in any of the languages, just do a Code Kata or two in each to get a feeling for the paradigms.

Having all (or just several) of them under your belt will make you a more versatile programmer, even if you never really go deep into one specific paradigm again.


答:
Timing is the killer for many. Programmers like to code late, sleep late and come in after the morning rush. Having to be in office at a fixed time - way too early for them. And too late for others who may come in earlier and start working already.

Flow is another issue. A programmer in flow with some feature will work until late at night, go home and come back recharged and ready to continue. Having to sit through a meeting with mostly unrelated issues may distract him.


答: You already know how to code? Great! Pick something, that is relatively generic, that you've written in Python (or any of your existing languages) and write it in Java. You'll start off not knowing anything, but by the end of it, you would've learnt a huge amount.</p>


问:
What can you do about the quality of existing integration and unit tests while being the new guy in a team ?
A recurring theme that I came across in my career is being the new developer to arrive in a team, and quickly having an inherent distrust of the existing unit and integration test suites.

During the interview you are told by the management that they "strongly support unit testing" and that they openly encourage it. They do, but everything about the tests themselves is just plain wrong. Like the fact that they are claiming 100% coverage when there is 100% integration test coverage but less than 10% repeatable unit test coverage. Some other problems I have found:

No clear indication between what is a unit test and what is an integration test. Unit and integration tests are mixed together in the same class.

Integration tests that have undeclared explicit dependencies on very specific dynamic data on a specific environment's database.

Non-transactional integration tests, basically tests that may or may not bother to clean up after themselves, sometimes requiring manual database "scrubbing" to make the test repeatable.

No mocking whatsoever, and application code requires a major overhaul just for mocking to be possible. In other words, design without testing in mind.

No clear naming conventions to quickly look at a test name and determine roughly what tests are being done.

This is all not to say that ALL of the tests are useless or bad, a good deal of them are pretty good and worth keeping, but it feels like panning for gold sometimes. I would purposely avoid running tests just because I was afraid of screwing up the database for my black-box test cases.

This has essentially given me an inherent mistrust of unit and integration tests that I have not personally written or reviewed in some way.  At some level if you don't have faith in the quality of your test suite then it really brings no value to the team or the project whatsoever.

What do you do when you find yourself in this situation?  What do you feel the best plan of attack would be to tackle something like this?

Should all of the tests be refactored in a monumental effort spanning across releases?  Should you just abandon the idea that this legacy project may have one day solid unit test coverage?

答:
You will not be able to fix all the tests together. I think you should focus on the word improvement versus overhaul. Neither management not developers will agree on an overhaul but if you show that there is a way to improve things without affecting the project negatively, they will be more likely to listen.

First, you cannot 'fix' or refactor existing code unless you have quality test coverage, so I would focus on fixing your testing infrastructure first.

Make a list of things that need improvement and attempt to prioritize them. I think the ability to run tests independently and singly (so they do not effect each other) and the separation of unit and integration tests are some of the first things to work on. You need to make it easy for you and others to do the right thing.

As far as application code is concerned... You won't be able to do the complete overhaul of the application architecture just so it can be better unit tested. Instead, when you put in new code, try to apply principles that make it easier to unit test (like dependency injection). You might think that this is not big enough of a change, but it is amazing how fast developers catch on if they see the benefit. There just needs to be someone who starts making a change for the better.

Talk to your team and get them to buy-in. One of the most important things you can do is follow the 'Boy Scout Rule' and make small improvements to leave a class or test in a better shape then you found it. If the whole team applies this rule, things get better a lot faster.

After a while, you will have a lot of code that follows good principles and areas of the application that are in bad shape. At this point, you have a baseline of what good is and the team can decide if its beneficial to do a larger refactor for the older legacy stuff or it can just live on as it is.


答:
There are many ways to Rome, but one approach that strikes me as logical is to follow the evolution of programming languages and paradigms. So you'd start out with a close-to-the-metal imperative language (probably C). Then you'd build from there, discovering abstractions that people have invented to make managing complex code easier. So:

Imperative

Structured

Structured, but avoiding global state

Functional or OOP

OOP or Functional

ad libitum: Logic Programming, Aspect-oriented, Data-driven, Metaprogramming

And of course, taking the best of each in real-world programming situations.

At the bare minimum, I think a decent programmer should have had some exposure to at least one language in each of the following groups:

C

C++, Java, C#, Objective-C, ...

Python, PHP, Perl, javascript, ...

Lisp, Haskell, ML, Scheme, Clojure, F#, ...

brainfuck, malbolge, befunge, intercal, ...

(I'm serious about that last category: while you won't do any serious programming in any of them, looking into them definitely gives insights into the way computers and the human mind work)


答:
I suggest a simple, non-obstructive environment such as Squeak or Ruby with Shoes.

There's no reason to start programming in a procedural manner. Neither coding closer to the computer nor re-enacting the history of programming will help you find a good entry point to programming.

When you first learn, how to drive, you won't do it in a steam engine, although it's historically correct and will help you actually see on what basic principles engines are based.

First learn how to do it, gather some intuition and then push forward for an ever deeper understanding.


答:
You want Harbison and Steele: "C: A Reference Manual"

It explicitly covers C99 and compares/contrasts to other flavors of C. I have found it super useful.

Title: Does C99 make the K&R book outdated? If so what to recomend in its place?

Body:
C99 has been with us for a while now. It introduces a lot of features that are not in K&Rs The C Programming Language. None of them are particularly radical. However, even small features like being able to intermingle declarations and code change how one organizes code.

While I still consider the K&R book an invaluable reference, and like its writing style, is there a better book that takes into account the C99 standard? I'd buy a third edition of K&R in a heartbeat, but I don't think that is going to happen.


答:
I must admit I would take it as a rare gift to arrive at a project where they already have a significant number of unit/integration tests - I have never had that luck in my life so far. Even if not all of them are working as they should, there is already a great deal of effort put into it, and even if the team and management don't always follow best practices, still they already are committed to the cause, so you don't need to spend your time arguing about why unit tests are worth writing.

However, the tests as you describe them can indeed take some improvement. But you need to be careful with your tone when discussing the problems with your teammates. If you start by stating "everything about the tests themselves is just plain wrong", you may very quickly end up alienating the rest of the team. Instead, you should focus on how to improve the current state of affairs, which - I must repeat - is still significantly better than the average according to my experience so far.

IMO your first target should be to stop the team from producing more bad tests. So start by demonstrating the benefit of each specific improvement to your teammates. If they see the usefulness of a certain technique - be it cutting external dependencies, restoring the original state after each test, or separating unit and integration tests - they will start applying them. This in itself will slowly but surely improve the overall quality of the test base in the long run (if you have 1000 bad test cases now, and the team produces 1000 good tests by next year, you will have brought down the ratio of bad tests from 100% to 50%). Once that is secured, you can decide about refactoring existing tests on a case by case basis. Again, small improvements will add up to big changes over time.

As a side note, from the tone of your post I feel you might be in a place where I used to be too: not trusting in work done by others, unable to delegate tasks to anyone in fear of their work not being up to your own quality standards. In my experience, this is not a good place to be, because in the long run, it may easily lead to personal conflicts and burnout. You can't do everything alone, you must work together with the rest of the team. You can only succeed together.

Title: What can you do about the quality of existing integration and unit tests while being the new guy in a team ?

Body:
A recurring theme that I came across in my career is being the new developer to arrive in a team, and quickly having an inherent distrust of the existing unit and integration test suites.

During the interview you are told by the management that they "strongly support unit testing" and that they openly encourage it. They do, but everything about the tests themselves is just plain wrong. Like the fact that they are claiming 100% coverage when there is 100% integration test coverage but less than 10% repeatable unit test coverage. Some other problems I have found:

No clear indication between what is a unit test and what is an integration test. Unit and integration tests are mixed together in the same class.

Integration tests that have undeclared explicit dependencies on very specific dynamic data on a specific environment's database.

Non-transactional integration tests, basically tests that may or may not bother to clean up after themselves, sometimes requiring manual database "scrubbing" to make the test repeatable.

No mocking whatsoever, and application code requires a major overhaul just for mocking to be possible. In other words, design without testing in mind.

No clear naming conventions to quickly look at a test name and determine roughly what tests are being done.

This is all not to say that ALL of the tests are useless or bad, a good deal of them are pretty good and worth keeping, but it feels like panning for gold sometimes. I would purposely avoid running tests just because I was afraid of screwing up the database for my black-box test cases.

This has essentially given me an inherent mistrust of unit and integration tests that I have not personally written or reviewed in some way.  At some level if you don't have faith in the quality of your test suite then it really brings no value to the team or the project whatsoever.

What do you do when you find yourself in this situation?  What do you feel the best plan of attack would be to tackle something like this?

Should all of the tests be refactored in a monumental effort spanning across releases?  Should you just abandon the idea that this legacy project may have one day solid unit test coverage?


答:
This question is a bit like asking men if they think being circumcised is better than not being circumcised - there seems to be a remarkable correlation between whether or not they are circumcised and whether or not they think it's better. Of course, once you've been circumcised it's hard to go back. ;-)

As someone who first learned procedural programming, I (and quite a few of my peers) initially struggled at first with OOP. Having spoken to people whose first experience with programming was OOP, it seems they found it a much more natural way of working. This may be because they weren't trying to make it fit with their pre-existing procedural approach, trying to impose it, if you will. Or it may just be that they were smarter than me and my friends (very likely).


问:
What are the advantages of showing line numbers in a text editor?
I feel weird when I'm editing code in an IDE that does not have line numbers in the text editor.

The questions I have are:

Are line numbers visually excessive, particularly when a find by line function exists in your IDE of choice?

What are the uses of showing line numbers?

答:
For whatever reason (cross compiling comes to mind) your compiler may not be integrated into your IDE. Therefore you need an absolute reference for where errors are found. (When you compile outside of your IDE)

NWS


答:
Work towards test independence.  If test X modifies the test database in such a way that test Y fails, then change test Y.  In this little scenario the thing to focus on is not that X has messed up the database, but rather that Y has inappropriate dependencies.  Remove those dependencies (by stubbing out the database, by restructuring the test, or by initializing the database to a state where Y will pass) and now you have one more independent, working test.  That's progress (arguably, "fixing" X not to mess up the database would not be).

Be patient and respectful, as best you can, of the folks you're working with, despite the mess they've created.  They're trying to do the right thing, in all likelihood; keep that in mind and help them to do it.


问:
Best option for PDF viewer embedded in web app
I have a web app that needs to be able to display a PDF.  It needs to allow the user to page through the PDF, and my application needs to be able to know which page is currently being viewed, because other aspects of the web app will change based on the current page.  Ideally it would not be dependent on the client having Adobe Reader but I could probably support that dependency.

What are my best options for this?  My application stack consists of ASP.NET 4 along with optionally Silverlight 5.  Also, I could use something that is client-side based as well using JavaScript / HTML if such a thing exists.

I found ComponentOne's offering for this and that seems like the leading candidate at this point, but I want to know if there are other options I should consider.

Edit: Per Fosco's comment, converting the PDF to another format (such as HTML) might be an option, as long as I could tie back parts of the converted document to the original PDF page #s.

Another note: this has to run entirely on our servers.  It would not be acceptable to use a third-party service to view the PDFs.

答:
There's been a lot of buzz around pdf.js recently, a javascript PDF renderer for html 5.

It is a very young project, it is not yet suitable for real world usage, and it requires a recent browser. But in a long term, that may be a viable solution for your problem.

UPDATE

pdf.js is now integrated into Firefox as the default built in PDF viewer.


问:
Should a design document contain a discussion of the pros/cons to a given design or should it focus on facts and rationale?
I'm currently in the process of updating a design document so that it is correct and up-to-date for future developers.

Currently, the document focuses on only the facts, presenting how the design is. There is no rationale for any decisions presented. I believe that it's important to capture rationale so that developers know why something is the way it is, as that will probably affect future decisions. It's not possible for me to add rationale for all of the design decisions, especially those made before I started working on the project, but I'm doing what I can in this department.

However, some of the design decisions are, respectfully, very poor decisions given the requirements of the project. There are some good ones, though, as well.

My initial thought was that I should include a discussion of design problems and potential solutions or workarounds to these problems to focus the attention of future maintainers, but I'm not sure if the design document is a place for this type of discussion and information. I don't want a design "critique" to snowball into "ripping this design a new one" as other people work on this system and update the document, as that is clearly inappropriate.

My manager would support either decision, so it's up to me. Regardless of the approach that I take, the document produced would be officially versioned and provided to developers working on the system, typically before they are tasked with development work. It's expected that a new developer familiarize themself with the documents associated with a given software system prior to beginning development work.

Questions:

Should a design document stick to raw facts ("this is the design") and rationale ("here is why this is the design") or should it also be used to point out non-defective issues with the design that could be problematic for future developers?

If the design document should not be used to capture this information, what type of document should capture it, and what else should be captured with a discussion of design rationales, tradeoffs, and known issues (that aren't defects, as defects are tracked using other tools)?

答:
Should a design document stick to raw facts ("this is the design") and rationale ("here is why this is the design") or should it also be used to point out non-defective issues with the design that could be problematic for future developers?

It's not "either-or".

No one reads documentation in the first place.  They skim -- at best.  Therefore, write as few documents as possible.  One document is all anyone has patience for.  A second "non-desgin" document with "other issues" is unlikely to get read at all.

Advantages of one document?  People might read it.

Disadvantages of one document?  Few.  Mostly it gets out of date.

Advantages of multiple documents?  None.

Disadvantages of multiple documents?   Please read up on the DRY principle and literate programming.  Multiple documents means multiple sources of errors.  Each document disagrees with the other and disagrees with the code.  This is pretty obvious.  This is the path of madness.

Avoid hand-wringing.

A pros-and-cons document can drag on into indefinite depths of what-if and attractive nuisance discussions.

If you feel that it's necessary to present pros and cons, keep it short and to the point.

Focus on what is.

Keep what is not down to the bare bones.

If you have done benchmarks, studies, or actually explored alternatives, document that.  But if you're just considering alternatives, minimize it.

This should not be your personal history of trial and tribulation.

Had a problem?  Fixed it?  Took weeks?  Really struggled?  Barely an interesting anecdote.  It's fixed in the code.  The previous versions, wrong versions, buggy versions and low-performance versions don't matter.  They're blog-fodder at best.

Still have a problem?  Not fixed?  That means there are alternatives.  Document this.


答: Yes, I agree that it's not a reasonable request for us, but maybe he is curious to know how it all works. So for a non-programmer, I would say use flowchart. So that your boss can see the big picture or you can also go into as much details as you want in flowcharts as per his requirements. There are many flowchart applications available. I found Balsamiq Mockups helpful. I hope that helps.</p>

Title: My boss wants a narrated line-by-line English explanation of our code

Body:
I have been specifically asked to give line by line (or as appropriate - for example, image by image, etc.) explanation or commentary which my boss wants to be able to read and follow.

Since he is not a programmer, he can not follow the code so wants it all translated into English.

Has anyone been asked to do this before?

I have commented on all of the source code and used JSDoc to generate full documentation of all functions, variables, etc... and included an implementation example, and full working demos with comments throughout.

Is there anything else I can do to comment the code for non-programmers?

This isn't a reasonable request, is it?

UPDATE

In the end, I managed to explain why it was not a good use of time to do what he was asking. He is a reasonable guy, and just did not have an understanding of what my job involves. Once he saw this post, I think he quickly understood that it was not a normal request.

I did provide documentation that is suitable for another programmer to follow (JSDoc and inline comments - as well as some extra notes on technical issues), and a very broad flow chart diagram of the main logic of the program for my boss to follow.

In the end, all parties were satisfied and we have moved on.


问:
Is Silverlight only for eye-candy, or does it have a use in business?
Granted that Silverlight may make eye-popping websites of great beauty, is there any justification for using it to make practical web applications that have serious business purposes?  I'd like to use it (to learn it) for a new assignment I have, which is to build a web-based application that keeps track of the data interfaces used in our organization, but I'm not sure how to justify it, even to myself.

Any thoughts on this?  If I can't justify it then I will have to build the app using the same old tired straight ASP.NET approach I've used (it seems) a hundred times already.

答:
Silverlight is a great platform for doing line-of-business applications.  You can get the rich UI experience that users really like, while not having to go through the development pain of getting ASP.NET MVC, JavaScript, jQuery, Modernizr, etc. to all play nice together.   My experience has been that you can get much richer UX with Silverlight with a lot less development cost.  It is possible to create equivalent UX with HTML and friends, but it requires a LOT more libraries and a lot more headaches.

I recently have been involved in a couple large projects to create internal LOB apps with Silverlight and they were smashing successes.  We created great UIs that the users loved, and the developers all love the platform.

The downside of Silverlight at the moment is that Microsoft has been ambiguous lately about its future compared to their HTML 5 endeavors.  My guess (hope) is that Silverlight will continue to be invested in by MS and will stay ahead of the curve of HTML 5 in terms of features and ease of development.  But Microsoft needs to come out and tell us what their plans are.

I have a blog post that relates to this topic if you care to get more detail.

ContentLicense: CC BY-SA 2.5


答:
If the pros and cons can be summarized in a sentence or two, then it's OK to put them in a design document. Anything longer should be separated out.

Where I currently work, there is usually a separate "Design decicions" document to track all Big and Important decisions. Often formatted with a paragraph describing the problem (such as "Some files need to get moved from a server to certain users at the end of each processing cycle, there are many ways to do this..."), a table with columns "solution description" (such as "move files via FTP"), "pros" (such as "Easy for users to manage"), "cons" (such as "not secure enough for ABC-XYZ compliance") and a conclusion that explains why a particular decision was chosen (such as "FTP will not be used because it will not be able to meet certain compliance requirements"). The design document usually only references the chosen decision, and may recommend readers to read the decicion document for a full description of other options.

Title: Should a design document contain a discussion of the pros/cons to a given design or should it focus on facts and rationale?

Body:
I'm currently in the process of updating a design document so that it is correct and up-to-date for future developers.

Currently, the document focuses on only the facts, presenting how the design is. There is no rationale for any decisions presented. I believe that it's important to capture rationale so that developers know why something is the way it is, as that will probably affect future decisions. It's not possible for me to add rationale for all of the design decisions, especially those made before I started working on the project, but I'm doing what I can in this department.

However, some of the design decisions are, respectfully, very poor decisions given the requirements of the project. There are some good ones, though, as well.

My initial thought was that I should include a discussion of design problems and potential solutions or workarounds to these problems to focus the attention of future maintainers, but I'm not sure if the design document is a place for this type of discussion and information. I don't want a design "critique" to snowball into "ripping this design a new one" as other people work on this system and update the document, as that is clearly inappropriate.

My manager would support either decision, so it's up to me. Regardless of the approach that I take, the document produced would be officially versioned and provided to developers working on the system, typically before they are tasked with development work. It's expected that a new developer familiarize themself with the documents associated with a given software system prior to beginning development work.

Questions:

Should a design document stick to raw facts ("this is the design") and rationale ("here is why this is the design") or should it also be used to point out non-defective issues with the design that could be problematic for future developers?

If the design document should not be used to capture this information, what type of document should capture it, and what else should be captured with a discussion of design rationales, tradeoffs, and known issues (that aren't defects, as defects are tracked using other tools)?


答:
If there were valid reasons for avoiding more obvious or standard solutions, those should be noted. You'll save someone a lot of trouble. However, a particular technology may improve over time, so your reasons may not be applicable. A future developer can then use their own judgement.

I don't know if there is much benefit to pointing out all the short-comings. It may not be practical to make the changes or other priorities will take place. You may fix some of them in the near future and this will just be one more thing to update.


答:
I personally wouldn't put it in the design document. A design document should outline how it is, not why it is. </p>

<p>If you feel there is a good need for a back story as to why the design is the way it is, perhaps you should put that in a wiki article (or whatever knowledge base your company uses) so that there can be a history of the evolution of the design. People can go and read it, edit it, and add suggestions. That way it's more of a open discussion instead of a brow beating in a document. </p>

Body:
I personally wouldn't put it in the design document. A design document should outline how it is, not why it is.

If you feel there is a good need for a back story as to why the design is the way it is, perhaps you should put that in a wiki article (or whatever knowledge base your company uses) so that there can be a history of the evolution of the design. People can go and read it, edit it, and add suggestions. That way it's more of a open discussion instead of a brow beating in a document.


问:
Constant database calls or store in objects?
I'm creating a pretty simple database driven application. Whenever I create a db app, I create classes that mimic the data in the db. Is this good practice?

Am I better off making one big call to the database and populating my objects and working with these objects, or should I retrieve data from the db only when needed?

答:
Is this good practice?

It's called Object-Relational Mapping.  ORM.  It's done all the time.

Am I better off making one big call to the database and populating my objects and working with these objects, or should I retrieve data from the db only when needed?

That's imponderable.  First, you haven't defined "better".  Second, it depends on the volatility of the data in the database, the nature of your application, and the performance of your ORM layer.


答:
I think the key part of your post rather spells out that you shouldn't skip them:

I've personally used traditional for and while loops in powershell scripts, but they can always be rewritten as ForEach-Object loops with a bit of creativity.

I feel that it's good to know how to do the basic for/while/do loops so that you can take the next step to realize that creativity. It really doesn't take long to teach loops to people, and it would be a good lead in for the foreach loop.

So why not make it for/while/do/foreach, and walk though each one? You can even say right in the training that the foreach-object loop will be the one they use most, and you could spend more time on it.


问:
How should I choose the right Android phone for testing my app?
I am looking to buy an Android phone to test my first Android app on.

What things should I pay attention to to make sure I pick the most suitable device?

答:
Unfortunately one device will not be enough to do testing. In companies developing Android apps you will have numerous devices, as there are some bugs that are limited to few models. </p>

<p>Your choice of phone depends on you target audience. For example if you're targeting early adopters, your choice will probably be one of the "lead devices". However things working on these might not work on older ones, like for example there are still enormous amounts of Android 1.6 devices out there, not to mention 2.1 devices. </p>

Body:
Unfortunately one device will not be enough to do testing. In companies developing Android apps you will have numerous devices, as there are some bugs that are limited to few models.

Your choice of phone depends on you target audience. For example if you're targeting early adopters, your choice will probably be one of the "lead devices". However things working on these might not work on older ones, like for example there are still enormous amounts of Android 1.6 devices out there, not to mention 2.1 devices.


答:
First of all, as other posters have already wrote, you should be happy unit/integration testing is understood (not in a technical way, I mean the reason why it should be done is understood) and pushed by the management.

Before you start doing everything you should expose the problems to the management, why something should be done, and very diplomatically so that they don't think you think you are the best programmer in the world (even if you are! :-). Maybe they will tell you that the application is going to be replaced by something completely new, and if so, why bother. And maybe they will realize that it would be nice and speed up the testing phase before each release. And be diplomatic with your teammates, there may be million reasons why it is as it is and there is just no reason to look for a culprit.

A better idea would be to try to talk to them so that they can participate in the effort, and you will have fewer chances to appear as a smart-ass, it would be more "we" than "I".

Now, put priorities on what you want to do. Prioritize the tasks, always knowing that your first priority will always be your current project assignment... As for your test problem, here is what I would do, in three phases:

How to make a difference between unit and integration tests? The following solutions may apply and are not exclusive:

Refactor the name of the test case methods (not the classes since the right behavior is to have the test case share the same name as the tested class)

Create two annotations, one named "UnitTest", the other "IntegrationTest". These annotations can be used on classes and on methods. If an entire class is composed of either unit or integration tests, you can mark the class with the right annotation. If not, you can mark each method with the right annotation. Also, these annotations could be useful to dynamically inject fixtures before launching the tests (phase 3)

For each integration test, list what is the "dataset" that is expected to be in the database at the beginning of each test, and what should be removed at the end of it (ex: table X, needs a record with "id" set to "1", and "name" set to "foo", etc.). Note that what you remove may be bigger/smaller than what you have at the beginning since the code itself may respectively add/remove objects from the persistence layer. You will most probably quickly notice that several of these test cases need the same dataset or part of the same dataset.

The first two phases can be done relatively quickly... compared to the rest. Now that you have your dataset, you use create dataset fixtures for each test case that needs it. But that will cost some time... So you could do one, see how much time it cost you and estimate how much more time you need to do everything. Also, you could use that test to demonstrate to your fellow colleagues what you did, and why life is so much easier when you don't need to have a database in a specific state juts to perform tests.

You may note that phase 1, 2 and 3 may be done on a single test class, if you quickly want to show colleagues/management how it can be done. This would also be useful, as Péter Török wrote, in order to immediately show the "good way" to your teammates so that they stop producing bad code. However I think that rest of the phase 2, identifying the entire test dataset, is best done in one big step.

As for the API/technology behind all that, you seem to know the subject.

Hope that helped a little bit.

Note: for my proposal, I am supposing you code either in Java/C# where I know annotations and AOP is possible. I'm sure this is also possible in other languages, but I won't write about something I don't know.