答:
If you have read the wiki article, then most of your questions should be clear. I will try to answer them in a simpler way here. Take a look at these 2 examples:

Part 1 - Examples

Code # 1 - Customer Registration - An example of process steps:

Customer goes to registeration screen

Customer enters his/her details.

If valid details entered save customer information in database

Else show dialog box with error message 100.

Code # 2 - Validate Customer Name - An example of programming function

```<code>Function ValidateCustomerName(Name1)

If (Name1 is entered and Name2 is entered) then return 1

If (Name1 is not entered)

   Send Error Message

   return 0

Endif

...

End Function
</code>```

Part 2 - Now to your questions

What is Pseudocode?

It is a way to write steps of an algorithm or a process.

Why was it made/is it used?

It is used to show the process or algorithm steps without being dependent on a specific programming language or special notations.

Is it considered a Programming Language?

It is not compilable and this is because it has no specific syntax and hence it is not a programming language.

If so, is it as capable as, let's say, Python?

It can be made as capable as you want it to be. You can write statements like : If Age is Valid...

Is it commonly known/used?

Yes. It is helpful when thinking about algorithms and for business analysts to provide specifications.

Title: What is pseudocode?

Body:
If you have read the wiki article, then most of your questions should be clear. I will try to answer them in a simpler way here. Take a look at these 2 examples:

Part 1 - Examples

Code # 1 - Customer Registration - An example of process steps:

Customer goes to registeration screen

Customer enters his/her details.

If valid details entered save customer information in database

Else show dialog box with error message 100.

Code # 2 - Validate Customer Name - An example of programming function

Function ValidateCustomerName(Name1)

If (Name1 is entered and Name2 is entered) then return 1

If (Name1 is not entered)

   Send Error Message

   return 0

Endif

...

End Function

Part 2 - Now to your questions

What is Pseudocode?

It is a way to write steps of an algorithm or a process.

Why was it made/is it used?

It is used to show the process or algorithm steps without being dependent on a specific programming language or special notations.

Is it considered a Programming Language?

It is not compilable and this is because it has no specific syntax and hence it is not a programming language.

If so, is it as capable as, let's say, Python?

It can be made as capable as you want it to be. You can write statements like : If Age is Valid...

Is it commonly known/used?

Yes. It is helpful when thinking about algorithms and for business analysts to provide specifications.


问:
What is pseudocode?
I've seen a lot of mentions of Pseudocode lately, on this site and others. But I don't get it:

What is Pseudocode? For example, the Wikipedia article below says "It uses the structural conventions of a programming language, but is intended for human reading rather than machine reading." Does this mean that it isn't actually used to make programs?

Why is it used?

How is it used?

Is it considered a Programming Language? (See the above Wikipedia quote)

Is it commonly known/used?

I honestly don't know where to start with this. I have Googled it and I've seen the Wikipedia article on the topic, but I still don't fully understand what it is.

答:
What is Pseudocode? For example, the Wikipedia article below says "It uses the structural conventions of a programming language, but is intended for human reading rather than machine reading." Does this mean that it isn't actually used to make programs?

It is exactly that, it's code written in a human friendly form.
It cannot be used to make a working program.

Why was it made/is it used?

Because Pseudocode is quick to write and quick to read. As it doesn't have language specific parts its clearer to read. Its also language independent so anyone can read it (for that reason its used in a lot of text books)

Is it considered a Programming Language? See the above Wikipedia quote.

No. A programming language requires more than just structure.   It requires formal semantics, which pseudocode lacks.

Is it commonly known/used?

Yes. Anyone above a junior level should know how to read/write pseudocode. Its essential for reading a lot of text books and planning code in a team.

ContentLicense: CC BY-SA 3.0

Title: What is pseudocode?


答:
The best example of Pseudocode was when I shared an office with a FORTRAN programmer, while I was programming in Pascal. Anytime we helped each other we had to write it in Pseudocode.At the time I didn't know FORTRAN so there is no way for me me to get the syntax correct (especially all the indents required locations for specific marks). He never had to write with semicolons. On the whiteboard we wrote in a Pseudocode so that it could be understood, without getting bogged down on complex syntax rules.

The are no strict constructs for Pseudocode. If the writer knows a language that uses "{" after an if statement they put it on the board, if they know python they don't. The goal is to quickly sketch out the basic approach to the problem, not absolutely correct code.

Teachers can use it to give guidance to a student, without giving them the correct answer. Once you know more then one language Pseudocode should be natural to use while sketching out code fragments.

Title: What is pseudocode?

Body:
I've seen a lot of mentions of Pseudocode lately, on this site and others. But I don't get it:

What is Pseudocode? For example, the Wikipedia article below says "It uses the structural conventions of a programming language, but is intended for human reading rather than machine reading." Does this mean that it isn't actually used to make programs?

Why is it used?

How is it used?

Is it considered a Programming Language? (See the above Wikipedia quote)

Is it commonly known/used?

I honestly don't know where to start with this. I have Googled it and I've seen the Wikipedia article on the topic, but I still don't fully understand what it is.


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

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

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

答:
tl;dr answer

Optimisations should not kept in a permanent long term branch

They can be developed in a branch, and then merged back into the release branch once complete, but it should always be possible to test both versions side-by-side and it should be possible to easily switch between optimised and unoptimised versions of any given algorithm, ideally at run time.

Full answer

Remember that there is more than one form of optimisation.

Algorithmic optimisation (replacing an O(n^2) algorithm with an O(n log n) algorithm for instance) almost always has the potential to provide more significant savings than implementation optimisation (hand unrolling a loop or ensuring your inner loops data fits in a certain level of cache).

Unfortunately, when people are thinking about optimisation, they tend to think more about implementation optimisation, which is about specialising software in such a way that it runs more efficiently on one architecture, possibly at the expense of execution speed on another architecture.

I have already answered many other aspects related to your question in my answer to the question How to document and teach others “optimized beyond recognition” computationally intensive code?

Essentially though, it boils down to the golden rules of optimisation:

The First Rule of Program Optimisation: Don't do it.

The Second Rule of Program Optimisation (for experts only!): Don't do it yet."

— Michael A. Jackson

In order to know whether now is the time to optimise requires benchmarking and testing. You need to know where your code is being inefficient, so that you can target your optimisations.

In order to determine whether the optimised version of the code is actually better than the naive implementation at any given time, you need to benchmark them side-by-side with the same data.

Also, remember that just because a given implementation is more efficient on the current generation of CPU's, doesn't mean it will always be so. My answer to the question Is micro-optimisation important when coding? details an example from personal experience where an obsolete optimisation resulted in an order of magnitude slowdown.


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

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

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

答:
Honestly, it doesn't matter how much experience you have with a technology, my advice is the same: Do not enforce technology decisions on those who will have to live with them while you are busy managing.

Be honest with yourself. I'll bet the reason you hated those prior managers was not because they didn't have the knowledge-base from which to make decisions, it was because they enforced decisions and never dealt with the consequences.

That applies whether you've never touched .NET before or you're the most expert developer on the team. Your job is now to manage, not to make technical decisions.

Managing might, depending on the skill level of your developers, mean advising them when they ask for it. "Have you looked into Spring.NET?" (note the lack of instruction there) is a perfectly good thing to say. Also, "Google around, see what the rest of the world is doing, we're not the first to face this problem."

In some respects, as an experienced Java developer, you may be in a better position than most for this. Most Java frameworks and technologies have an analogous equivalent in .NET. So you don't have to say "Here's the best thing to use," you can say "I've used this in Java, do you know of a .NET equivalent?"

Also encourage a lot of conversation within the team. Arrange weekly technical discussion meetings. All you ever need is information, in the end; you need to know what decisions they made and why. You don't need to make those decisions for the team.


问:
Creating a line of business application with Visual Studio Isolated Shell
I ask this to the pros out there - Is it feasible to build a new LOB(Line Of Business) application with VS Shell as an stand alone application.

There are some points that I thought needs to changed, but I'm unaware how, like -

There will be no document. Instead there will be windows with controls where people enter data.
There will be no file menu(new,edit). Instead there will be a login box when the application opens(something like the SQL Server Management Studio).
There should be floating windows which hosts the control and some kind of window management where these windows can be minimized(obviously inside the shell)
These are some of the points which I thought of. Obviously there are many other points which needs to be changed and I ask you to populate the list.

Also please point me out how to start with it, best practices and possibly any other tips which you think should be mentioned.

答:
This question is very broad.  Probably too broad, but:

The answer is yes, you can create an MDI Parent window as the main application window and then have a variety of child forms with your different business forms.

Use a main menu on the MDI Parent to access the child forms.

You need to think about whether the application allows more than one instance to be running on one computer at one time.  If not, you need to write code to maintain a single instance.

The same is true for your child windows.  Is it OK for any one kind of child window to have multiple instances open?

Think about including a standard "Window" menu in your main menu so that your users can access various open windows.


答:
I've had some very good managers/team leaders who knew very little about the technology, and some of my worst managers have been those who thought they knew everything.

To be a leader, if you have reasonably competent people, the main thing is to be able to judge their competence and judgement, and give each as much latitude as he can handle, while keeping the "wild ducks" on task and the "barely competents" busy with "safe" but productive activities.  Make sure everyone's marching to the same drummer.

Your bigger challenge is likely keeping upper management at bay.  They will want reports and schedules and checkmarks, and you need to figure out what it is they want and how to fake them reasonably well.  (Well, not exactly "fake", but produce documentation that satisfies them without eating up your time or the time of your team.)

Title: How to lead a development project without technical expertise

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

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

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


答:
What is Pseudo code?

Pseudo code is basically written instructions of what a program should do to complete an operation. The pseudo code is written in your speaking language. You simply write down the steps of an algorithm or procedure to make it easier for you or someone else to read it and convert it to a real programming language.

Why was it made/is it used?

It was made to help you specify the steps of a procedure, process or an algorithm without using a programming language. One possible alternative is to use flowcharts.

Is it considered a Programming Language?

No, it’s not a programming language, since there are no formal rules.

Is it commonly known/used?

Personally, I always try to use pseudo code when writing algorithms or complex procedures.

Title: What is pseudocode?


问:
Should a view and a model communicate or not?
According to the wikipedia page for the MVC architecture, the view is free to be notified by the model, and is also free to query the model about its current state. However, according to Paul Hegarty's course on iOS 5 at Stanford, lecture 1, page 18 all interaction must go through the controller, with Model and View that are never supposed to know each other. It is not clear to me if Hegarty's statement must be intended as a simplification for the course, but I am tempted to say that he intends the design as such.

How do you explain these two opposite points of view ?

答:
For me, the basic goal of an architecture is that it not impede future attempts at refactoring.  Typically, views interacting directly with models jives with this requirement, and it's relatively clear when it doesn't.

When a view is becoming too intimate with a model, a ViewModel can be a beautiful thing, but it's usually the case for me that the instances where it's called for are in the minority.


问:
Should QA find reproducible scenarios?
Sometimes my QA team reports bugs, but neither I or them have any idea on how to reproduce them. This leads to very long and frustrating debugging sessions which sometimes do not even yield results.

My software is tied heavily with proprietary hardware so bugs can come from many directions at once.

Should I expect more from them than "your software crashed when I pressed a button" or should I figure myself what happened?

EDIT:

One of my coworker pointed out that we are probably all developers here so the results might suffer a little bias

答:
Money is at stake here. Why should any team member be able to create a poorly-defined, low-chances-of-success task that burdens a (hopefully) highly-paid developer?

This isn't about pecking order, hierarchy, arrogance, us vs. them, or anything like that. This is just about investing in activities that add value to the product.

When a problem can be demonstrated to negatively and measurably affect the value of the product, then it should be investigated, reproduced, and fixed. Fix your product defect pipeline to filter out the noise.

Title: Should QA find reproducible scenarios?


答:
On the web, everybody calls their decoupling MVC.

Some technologies, such as C#, use MVVM because there is no link between the View and any other, everything goes through the service locator, binding the variables.

On pure MVC, the View talks directly with the Model and vice-versa. The Controller is only there when any change arises.

And then, there is the one called PAC (Presentation Abstraction Control). In this architecture, the View and the Model don't talk to each other. The Controller is the only one allowed to do anything with either the View or the Model. People often confuse this with MVC.

You'll see a way better explanation here : http://www.garfieldtech.com/blog/mvc-vs-pac

Title: Should a view and a model communicate or not?

Body:
According to the wikipedia page for the MVC architecture, the view is free to be notified by the model, and is also free to query the model about its current state. However, according to Paul Hegarty's course on iOS 5 at Stanford, lecture 1, page 18 all interaction must go through the controller, with Model and View that are never supposed to know each other. It is not clear to me if Hegarty's statement must be intended as a simplification for the course, but I am tempted to say that he intends the design as such.

How do you explain these two opposite points of view ?


答:
Holy hell! Why on earth would you even want to do that? That is extending the VS Shell to something that it wasn't meant to be done with which means two things:

1.) You may run into quite a few snags

2.) You will probably find very little support out there when you do run into snags because I've never heard anybody doing this.

It could, feasibly, be done using Managed Extensibility Framework (MEF) but it would be at least 10x more work than just creating a WPF application.

Title: Creating a line of business application with Visual Studio Isolated Shell

Body:
I ask this to the pros out there - Is it feasible to build a new LOB(Line Of Business) application with VS Shell as an stand alone application.

There are some points that I thought needs to changed, but I'm unaware how, like -

There will be no document. Instead there will be windows with controls where people enter data.
There will be no file menu(new,edit). Instead there will be a login box when the application opens(something like the SQL Server Management Studio).
There should be floating windows which hosts the control and some kind of window management where these windows can be minimized(obviously inside the shell)
These are some of the points which I thought of. Obviously there are many other points which needs to be changed and I ask you to populate the list.

Also please point me out how to start with it, best practices and possibly any other tips which you think should be mentioned.


问:
How can I quantify the amount of technical debt that exists in a project?
Does anyone know if there is some kind of tool to put a number on technical debt of a code base, as a kind of code metric?  If not, is anyone aware of an algorithm or set of heuristics for it?

If neither of those things exists so far, I'd be interested in ideas for how to get started with such a thing.  That is, how can I quantify the technical debt incurred by a method, a class, a namespace, an assembly, etc.

I'm most interested in analyzing and assessing a C# code base, but please feel free to chime in for other languages as well, particularly if the concepts are language transcendent.

答:
In between developers a fairly reliable measure of technical debt seem to be WTFs/minute.

Issue with this "metric" is that it is typically rather difficult to communicate "outside".

Metric that worked for me in communicating technical debt to "outsiders" was amount of testing and bug fixing effort (especially for fixing regression bugs) needed for successful delivery.

A word of caution: although this approach is quite powerful, one would better double-check with good old WTFs/minute before resorting to it. Thing is, it is quite cumbersome: to get the data, one has to carefully track time and accurately log it per appropriate categories.

it is so much easier to state 3 weeks total spent on implementing feature A than

I spent 14 hours on draft implementation of feature A then 29 hours on smoke testing it then 11 hours on implementing fixes for regressions I discovered, then 18 hours testing the QA-ready feature implementation. After that, QA guys spent 17 hours on testing the initial candidate release. After that I spent 13 hours analyzing bugs submitted by QA for the initial candidate release and 3 hours implementing the fixes. After that, I spent 11 hours on smoke testing the changes I made to initial candidate release. After that...

Anyway data about testing and bug fixing effort has been quite easy to communicate in my experience.

For recent release, we spent about 90% time on testing and fixing regression bugs. For next release, suggest to allocate some effort on getting this value down to 60-70%.

Another word of caution. Data like 90% above could be interpreted not only as an indication of technical debt, but also (surprise surprise) as indication of one being not quite proficient in programming / particular technology. "You just make too much bugs in your code".

If there is a risk of data being misinterpreted that way, it helps to have an additional, reference data on something less WTF prone to compare against.

Say if there are two similar components / applications maintained by same developer(s), first releasing at "waste rate" about 50% and second at 80-90, this makes a pretty strong case in favor of second being subject of technical debt.

If there are dedicated testers in the project, they could also contribute to more objective evaluation of the data. As I mentioned in another answer,

With testers, you get someone to backup your understanding of design issues. When there are only developers complaining about code quality, this often sounds like subjective WTFs from behind the closed door.

  But when this is echoed by QA guy saying something like component A had 100 regression bugs for 10 new features, as opposed to component B which had 10 regression bugs per 20 new features, communication suddenly turns into whole another game.


问:
Why don't software libraries solve all our problems?
Modular programming and reusable software routines have been around since the early 1960's, if not earlier. They exist in every programming language. Conceptually, a software library is a list of programs, each with its own interface (entry points, exit points, function signatures) and state (if applicable). Libraries can be high quality because modules are focused on solving narrow problems, have well-defined interfaces, and the cost can be amortized across all future software programs that will ever use them. Libraries are purely additive: adding new modules does not introduce bugs or limitations in existing modules.

So why don't software libraries solve all our problems? Why can't we write software as merely a composition of high-quality software modules?

Can we fix these problems with software libraries and unleash the full potential of this incredibly powerful mechanism for writing high-quality programs faster? Or are these problems intrinsic to libraries and can never be solved?

Note: Several comments said that I have too many questions. Please treat the above questions as the real questions and everything that follows as points for discussion.

It is true that software libraries are widely used. Some programming languages such as C, Java and Python have enormous software libraries. But there are numerous problems.

Some well-known languages have less than ideal library support (e.g. C++, Lisp). To some extent this is mitigated by piggybacking on a virtual machine platform (e.g. JVM, CLR). A corollary question, should all future software be written for a virtual machine platform to increase library support? This is problematic for scripts that don't want to incur the cost of launching a virtual machine every time.

There is a lot of "reinventing the wheel". Have you ever written a linked-list module in C? Yes, of course you have. I don't enjoy writing linked lists in C, but what is the alternative?

Can a given library (e.g. libfoo-0.1.2) be trusted as as a basis to write your important software? Is the library tested, documented, and does it implement the features you need? How can you tell?

Learning a library's API can be as time consuming as learning a whole new programming language.

If a bug is discovered in a library, what is the proper procedure for fixing the bug in your software? How should the bugfix be distributed to all library users?

How should libraries be built and distributed? (For example, autotools obviously got it wrong.) Semantic Versioning is good, but how can this be verified and enforced?

How should library dependencies be handled? Can we download and install automatically? Will the versions and licenses be compatible?

Is the license for a given library compatible with your software? How can you tell?

What should you do if the library is abandoned before starting your software? What about after starting your software?

答:
So why don't software libraries solve all our problems? Why can't we write software as merely a composition of high-quality software modules?

People are trying to make this easier every day but there biggest hurdle I can think of is : Every 3rd party software library is still disjoint with how you store data.

How could a 3rd party PDF library know I want to create a PDF from my books table, author table and the sum of the prices for that author?

ORMs help tackle this but it's short of the sentient components you're hoping for.

Also, try to come up with a more concise question.  Discussion is difficult with so many questions.


答:
Depends on the language.  JRuby is performance-competitive with Ruby, but you would not want to run C on the JVM.

I'm not an expert in C, but if you google 'linked-list library C' you will find several results.

I trust libraries based on the backing (is it a library Google uses or an obscure one), how active is it (likely to be supported), and is it open-source (can I fix bugs/extend it myself).

Learning library APIs does take a lot of time.  Fortunately, you only need to learn what you need to solve a particular problem, and many of the paradigms are the same across libraries (data structure names, file IO, etc).

Fix the bug and submit the fix.  Hope it is included in the next release, then everyone will get it eventually.  In the meantime people googling the same problem will find your fix.

Not sure what you are asking on this one.

Many possible answers here, Apache Maven is interesting.  I don't think there is one 'correct' way to go about it.

Google the license.  If your software will be commercial or closed-source it may limit your options.

Before starting the software you probably can defer deciding which libraries to use, but try to choose ones with high levels of activity.  After starting software, hopefully you wrapped a risky library in a layer such that you can replace the implementation, otherwise you will have to start supporting it yourself.

Honestly, none of these are the reason software libraries don't solve all our problems.  The reason is that problems are always changing and evolving.   From moving to dynamic websites, mobile devices, or solving obscure problems in a domain, if there was a library to do it then companies wouldn't need to hire more than one programmer.

Title: Why don't software libraries solve all our problems?

Body:
Modular programming and reusable software routines have been around since the early 1960's, if not earlier. They exist in every programming language. Conceptually, a software library is a list of programs, each with its own interface (entry points, exit points, function signatures) and state (if applicable). Libraries can be high quality because modules are focused on solving narrow problems, have well-defined interfaces, and the cost can be amortized across all future software programs that will ever use them. Libraries are purely additive: adding new modules does not introduce bugs or limitations in existing modules.

So why don't software libraries solve all our problems? Why can't we write software as merely a composition of high-quality software modules?

Can we fix these problems with software libraries and unleash the full potential of this incredibly powerful mechanism for writing high-quality programs faster? Or are these problems intrinsic to libraries and can never be solved?

Note: Several comments said that I have too many questions. Please treat the above questions as the real questions and everything that follows as points for discussion.

It is true that software libraries are widely used. Some programming languages such as C, Java and Python have enormous software libraries. But there are numerous problems.

Some well-known languages have less than ideal library support (e.g. C++, Lisp). To some extent this is mitigated by piggybacking on a virtual machine platform (e.g. JVM, CLR). A corollary question, should all future software be written for a virtual machine platform to increase library support? This is problematic for scripts that don't want to incur the cost of launching a virtual machine every time.

There is a lot of "reinventing the wheel". Have you ever written a linked-list module in C? Yes, of course you have. I don't enjoy writing linked lists in C, but what is the alternative?

Can a given library (e.g. libfoo-0.1.2) be trusted as as a basis to write your important software? Is the library tested, documented, and does it implement the features you need? How can you tell?

Learning a library's API can be as time consuming as learning a whole new programming language.

If a bug is discovered in a library, what is the proper procedure for fixing the bug in your software? How should the bugfix be distributed to all library users?

How should libraries be built and distributed? (For example, autotools obviously got it wrong.) Semantic Versioning is good, but how can this be verified and enforced?

How should library dependencies be handled? Can we download and install automatically? Will the versions and licenses be compatible?

Is the license for a given library compatible with your software? How can you tell?

What should you do if the library is abandoned before starting your software? What about after starting your software?


答:
You weren't chosen for your C# coding skills, and unless you're going to be writing code from the outset, it doesn't matter whether you know C# or not. You need to start thinking at a higher level:

What skills does each person on your team bring to the table?

Which components are critical to the success of the project?

What do you have to produce in addition to the actual code? (Tests? Documentation?)

How will you gather requirements, if you haven't already?

How will you and your team approach the design process?

You know that having a coding standard is important, but you can rely on your team to figure out exactly what standard they want to follow.

How can you detect problems early?

Some of these things may cross over into project management territory, but as the lead developer you'll be working closely with the project manager on these and other issues.

By all means, learn to be effective working in C# as quickly as you can. Just remember that your role is to see past the syntax and the framework details and look at the bigger picture.


问:
What's the difference between implementing an Interface explicitly or implicitly?
In Visual Studio I can right-click on an interface and choose to Implement Interface, or Implement Interface Explicitly.

```<code>public class Test : ITest
{
    public string Id // Generated by Implement Interface
    {
        get { throw new NotImplementedException(); }
    }

    string ITest.Id // Generated by Implement Interface Explicitly
    {
        get { throw new NotImplementedException(); }
    }
}
</code>```

The only difference I see between the two is that the Interface name is added to the interface properties and methods when they're created if you choose to Implement Interface Explicitly.

I find it makes the code a bit more readable since I can see where that method/property comes from, however does this make any difference in how the class is used or compiled? And does it really matter if I implement my interfaces implicitly or explicitly?

答:
There is also a difference in how you call the method.

When using an explicit interface implementation, you must use the interface type in order to call that specific implementation.

So, in calling code you would need to use a variable of type ITest in order to access ITest.Id.

The article Explicit Interface Implementation (C# Programming Guide) on MSDN has a good example.


答:
It allows you to implement two interfaces that define the same method. However, if you explicitly implement the interface, the methods can only be accessed when the variable is typed to that explicit interface.

See: Explicit Interface Implementation Tutorial

Title: What's the difference between implementing an Interface explicitly or implicitly?

Body:
In Visual Studio I can right-click on an interface and choose to Implement Interface, or Implement Interface Explicitly.

```<code>public class Test : ITest
{
    public string Id // Generated by Implement Interface
    {
        get { throw new NotImplementedException(); }
    }

    string ITest.Id // Generated by Implement Interface Explicitly
    {
        get { throw new NotImplementedException(); }
    }
}
</code>```

The only difference I see between the two is that the Interface name is added to the interface properties and methods when they're created if you choose to Implement Interface Explicitly.

I find it makes the code a bit more readable since I can see where that method/property comes from, however does this make any difference in how the class is used or compiled? And does it really matter if I implement my interfaces implicitly or explicitly?


答:
Check out the top answer from Andrew Barrett for "implicit vs explicit interface implementation" on SO.

Basically:

Implicit: you access the interface methods and properties as if they were part of the class.

Explicit: you can only access methods and properties when treating the class as the implemented interface.

Code examples:

Implicit:

```<code>Test t = new Test();
t.Id; // OK
((ITest)t).Id; // OK
</code>```

Explicit:

```<code>Test t = new Test();
t.Id; // Not OK
((ITest)t).Id; // OK
</code>```

In terms of "when" you have to implement an interface explicitly, it is when your class already has a method with the same signature as one of the methods of your interface, or when your class implements several interfaces that share methods with the same signatures but incompatible contracts.

Body:
Check out the top answer from Andrew Barrett for "implicit vs explicit interface implementation" on SO.

Basically:

Implicit: you access the interface methods and properties as if they were part of the class.

Explicit: you can only access methods and properties when treating the class as the implemented interface.

Code examples:

Implicit:

Test t = new Test();
t.Id; // OK
((ITest)t).Id; // OK

Explicit:

Test t = new Test();
t.Id; // Not OK
((ITest)t).Id; // OK

In terms of "when" you have to implement an interface explicitly, it is when your class already has a method with the same signature as one of the methods of your interface, or when your class implements several interfaces that share methods with the same signatures but incompatible contracts.

ContentLicense: CC BY-SA 4.0


问:
How to Determine Frequency (In Hertz, Real Time) with Java Sound
I've been looking around and I've found some questions similar to mine but have never been quite satisfied with the answers. I'm more or less a Java n00b, although I am moderately proficient with C++ and I would consider myself intermediate to advanced, as a programmer in general. I'm looking to write a program in Java that functions similarly to a tuner - what I want to do is record an instrument's pitch over about a 3 second time frame, and to measure the average deviation. (This is for a band class.)

What I'm thinking is that I'll have a big array of numbers, and each entry in the array will be a number in terms of frequency. I want to be able to loop through the array, and calculate the average Hertz for displaying it on screen or something. So what I want to do is have some way of "polling" (for lack of a better word) the microphone to see what frequency is being inputted right that instant.

Is there a simple way to accept audio input from a microphone in terms of Hertz? This will be in Java, under a Windows platform.

答:
You will need to do some spectrum analysis. Take a short piece of audio data, maybe some 256 samples, then calculate a fast fourier transform (FFT) for each piece of data. However, a fourier transform itself is not enough since the process of cutting up sound in short samples introduces some distortion. This distortion will mainly be in the higher frequencies. For pitch detection, you can get away with simply filtering away this distortion using a low pass filter. Alternatively, you can window your sound sample, usually using hanning or blackman window functions (different sine-slopes, basically). In order to improve time resolution you should also overlap the individual samples you take. At last, you should average your individual spectra over as long a time as you want to analyze.

Doing all that will give you something called a Power Spectral Density function. This method of deriving it is called the Welch method. Hence, if you are lucky, Java Sound will include a method for calculating one of these. In many signal processing environments, this would be called "pwelch" or "psd".

Of course, the spectrum will use logarithmic frequencies (way more frequency points towards the high frequencies) and the amplitudes will most likely be denormalized and linear instead of simply dB values. Also, you will still have to find a good method to find your actual pitch frequency amongst all the harmonic noise etc.

What I want to say is this: Either your library has an easy function that does exactly what you want or this stuff is probably too complex to have an easy answer. Sorry.


答:
EDIT:
It shouldn't make a difference You shouldn't do it unless your class implements two interfaces with the same properties, as you'll have to cast to the relevant interface before you can access the member:

```<code>public interface ITest
{
    string Id { get; }
}

public interface IAlsoTest
{
    string Id { get; }
}

public interface ITestToo
{
    int Id { get; }
}

public class Test : ITest, IAlsoTest
{
    // Valid implicit implementation of BOTH interfaces
    public string Id
    {
        get { throw new NotImplementedException(); }
    }
}

public class TestSeparately : ITest, ITestToo
{
    // This way we can do different things depending
    // on which interface the callee called from.
    string ITest.Id
    {
        get { throw new NotImplementedException(); }
    }

    int ITestToo.Id
    {
        get { throw new NotImplementedException(); }
    }
}

public class TestOuch
{
    public void DoStuff()
    {
        var ts = new TestSeparately();

        // Works
        Console.WriteLine(((ITest)ts).Id);

        // Works
        Console.WriteLine(((ITestToo)ts).Id);

        // Not valid! Which one did we want to call?
        Console.WriteLine(ts.Id);
    }
}
</code>```

The example usage holds when you explicitly implement an interface member even if you are only using a single interface (which I always forget :S), so I would try and avoid the explicit implementation whenever possible, as it will hide class members if they're not cast to the right interface (which is fairly confusing).

Body:
EDIT:
It shouldn't make a difference You shouldn't do it unless your class implements two interfaces with the same properties, as you'll have to cast to the relevant interface before you can access the member:

public interface ITest
{
    string Id { get; }
}

public interface IAlsoTest
{
    string Id { get; }
}

public interface ITestToo
{
    int Id { get; }
}

public class Test : ITest, IAlsoTest
{
    // Valid implicit implementation of BOTH interfaces
    public string Id
    {
        get { throw new NotImplementedException(); }
    }
}

public class TestSeparately : ITest, ITestToo
{
    // This way we can do different things depending
    // on which interface the callee called from.
    string ITest.Id
    {
        get { throw new NotImplementedException(); }
    }

    int ITestToo.Id
    {
        get { throw new NotImplementedException(); }
    }
}

public class TestOuch
{
    public void DoStuff()
    {
        var ts = new TestSeparately();

        // Works
        Console.WriteLine(((ITest)ts).Id);

        // Works
        Console.WriteLine(((ITestToo)ts).Id);

        // Not valid! Which one did we want to call?
        Console.WriteLine(ts.Id);
    }
}

The example usage holds when you explicitly implement an interface member even if you are only using a single interface (which I always forget :S), so I would try and avoid the explicit implementation whenever possible, as it will hide class members if they're not cast to the right interface (which is fairly confusing).


答:
Libraries are great and certainly solve a lot of problems very quickly. However they never solve every problem and even gluing together many libraries isn't enough to solve many specific use cases.

Programmers are not typists. We've had that discussion before. Despite all the libraries, frameworks and out of the box solutions, there is always something your framework, library or SaaS product is not going to do for you. You're going to need to store your data in a different way, you're going to need to read your data faster, you're going to need to validate input in a way your libraries don't.

In any programming project of significant size, there is going to be some problem you need to solve that's so specific to your use case, so unusual, or so complex/simple that no library covers it properly. You're going to need to write your own code, your own objects or maybe even your own libraries or frameworks.

There's also lots of business reasons libraries aren't or can't be used. Maybe we can't use this library because of its license. Maybe we don't trust the source, or we'd have to modify it, and we don't trust an altered library. Maybe management believes all code needs to be purely owned, created and maintained by the company. But for various reasons, good, bad and spurious, many IT shops don't or can't use as many libraries as possible.

Some of these problems simply can't be fixed; some management types (or coder types!) are simply never going to trust code they don't own. The quality of libraries will never trump dogma.

Other problems are more solvable (quality of libraries, licensing) but the fact of the matter is that the legal and practical implications are often large and complex. Until all libraries are public domain and are 100% stable while containing all possible features (with perfect performance!) there's always going to be a reason to write your own code rather than use a library.

This isn't to say that libraries don't result in better programs; libraries solve a lot of problems and keep you from endlessly solving and debugging the same problems or working on hacked solutions. But the practical barriers mean they'll never be a panacea.


答:
Libraries were created by someone to fit some purpose they had. It might sound like a problem you want to use the library to solve, but it might not fit your exact usage. When considering a library you do have to evaluate it.

As a developer, one of your responsibilities is to think about how any library may fit into your software, and whether or not you can make your software and libraries work well together. Certainly as you gain more experience that becomes easier, but when you're a blank slate on libraries, there is a higher initial ramp-up time.

That said, I did find your questions interesting so I took my shot at answering them.

Some well-known languages have very poor library support (e.g. C++, Lisp). To some extent this is mitigated by piggybacking on a virtual machine platform (e.g. JVM, CLR). A corollary question, should all future software be written for a virtual machine platform to increase library support? This is problematic for scripts that don't want to incur the cost of launching a virtual machine every time.

Define "Very poor." C++ has boost, qt, Windows MFC and Win32 API, poco, WxWidgets, and those are just the general use frameworks and libraries similar to what you'd get with, say, the Java API. There are C++ libraries for many things, without having to factor in a CLR or JVM. Plus you can take advantage of the many C libraries out there (glib, curl, Apache Portable Runtime) and wrap them in C++ if you want to feel more C++-ey.

Lisp, though. There are many varieties of Lisp. You have modern Lisps like Clojure (on the CLR and JVM) and they can take advantage of their respective platforms. Common Lisp as a standard has many implementations, and I know there are companies out there building software in Common Lisp. I don't know enough about the kind of library support it has though.

Also, whether or not you should use a VM-based language. That's really up to you and what you want to use and what your company/employer/team are fine with. I will use what I think is a suitable tool for the job, as well as what I'm productive in for a given task.

I use Python and Ruby heavily because it's easy for other people to understand and I can quickly do a task in them.

There is a lot of "reinventing the wheel". Have you ever written a linked-list module in C? Yes, of course you have. I don't enjoy writing linked lists in C, but what is the alternative?

I have, but only as an academic exercise. There are several widely used libraries that provide data structures like linked lists for C, namely Apache Portable Runtime and glib.

The general alternative is to not leap before looking - you'll find reinvention in all languages, and much of that may be due to lack of knowledge about existing solutions.

Also, languages and libraries evolve over time. You're not going to find a library that fully suits your needs at some point in time, and in certain fields, algorithmic invention might be very commonplace.

Can a given library (e.g. libfoo-0.1.2) be trusted as as a basis to write your important software? Is the library tested, documented, and does it implement the features you need? How can you tell?

I base it on usage, community, maintenance activity, and if I must, I will check out its bug/task queue and see if it moves along smoothly. If it's commercially supported, I like to see if they actively update it. I also go by recommendations from developers I trust, as well as from communities like StackOverflow, where certain libraries are just mentioned significantly more than others.

There are libraries which I will trust without question, like boost and qt, and I will trust things from Google to perform correctly because I know Google eats their own food and uses their own code internally to process the bajillions of gigabytes of data they get every day.

For other things, I will evaluate it, read the code, and tailor it or scrap it if it's unsuitable.

Learning a library's API can be as time consuming as learning a whole new programming language.

Languages are easy to pick up, especially once you have experience in other languages and a similar paradigm. Ultimately they boil down to you expressing your logic in text, and being sure the compiler/interpreter knows what you mean.

This could be a factor of poor documentation, or you're using a framework that is significantly scoped (like the Java API). But the secret is, you don't necessarily have to learn 100% of a library to be effective using it. I consider myself a proficient Java developer, but I have not touched parts of the Java API because I have never had a need to.

Single purpose libraries are easier to learn in that regard - they have more limited functionality and hopefully documentation is simpler for it.

If a bug is discovered in a library, what is the proper procedure for fixing the bug in your software? How should the bugfix be distributed to all library users?

I have a lot of experience with this (making boost work on Solaris, making boost work on AIX, making tons of other things work on Solaris, like graphics libraries). Fixing it is the easy part.

If this is proprietary code, then my company would do something like patch releases if it was minor issues. Basically a bunch of fixes rolled into one, and then we notified customers via email that we had a new patch release.

For critical or per-customer issues, the fixes were put into a quick patch and we would either distribute just patched files to users, or release a quick patched release.

For open source projects - file a ticket with the project's bug tracker, and if you fixed it, submit your fix recommendation and a patch.

How should libraries be built and distributed? (For example, autotools obviously got it wrong.) Semantic Versioning is good, but how can this be verified and enforced?

autotools is a bear, but modern make systems are nicer, like cmake. There are more like Apache Maven, and you can use these systems to build and package distributables. I also like buildr, which is a Ruby alternative to Maven (compatible with maven).

How should library dependencies be handled? Can we download and install automatically? Will the versions and licenses be compatible?

Using cmake or maven can help you take care of dependencies, and maven can pull in remote dependencies or from a local server. cmake can do the same, but you do have to tell both these build systems what your dependencies are. Versioning and licensing is mostly your job, but if you were on a system like a Linux with a package manager, this could be mitigated.

Is the license for a given library compatible with your software? How can you tell?

You need due diligence here, because licensing is legal, not a software issue. You can see what the licenses are for various things in your system, and there are sites like FSF's License List and Comments which give FSF's interpretation of various licenses' compatibility with the GPL. Also, consult a lawyer.

What should you do if the library is abandoned before starting your software? What about after starting your software?

If it's abandoned before starting your software - evaluate to see if it's still useful to you, and check it's bug list. You could contact the maintainer and offer to take on the project.

If it's abandoned after - again, you can decide if it's worth it to continue, hopefully it's not so deeply embedded into your code that you couldn't switch it out with some effort. Of course, there are softwares where that is a problem and they get pegged to some old version. You can, though, also take the project under your wing and tailor it to your needs. Contact the maintainer.


答:
I think if you have a good bunch of .Net developers there is a lot of knowledge in the team that perhaps you need to tap into to get started. There are a lot of similarity between Java and .Net that what you already know may actually apply more of less directly. The importance is knowing what is important to get right for this project and the risks involved. Communicate with your team as often as necessary. Software engineering practice evolves throughout a project so it may be difficult to have a "best practice" very early on in the project.

I kinda had the reverse of your experience where I am given a very green team of grads who are not from software related field. While I have all the reason to stipulate what needs to be done (I was employed to) I instead looked for practice to get us moving and plenty of coaching and discussion to evolve our software engineering practice. I learnt heaps from the team on the way and we are almost there in delivering our first in house project after more than a year on the job!


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

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

答:
I think that the term "internet scalable" means one thing in particular: ready to grow to meet viral growth. The dream of every person who builds an internet application is that it will touch a nerve and grow through word of mouth, through passionate advocacy of its users. Twitter, Facebook, there are many examples, and virtually all of them struggle to grow their software and infrastructure to meet the demand. Down time is poisonous, and the lesson of internet scalability is be ready to grow fast or be ready to pack it in.

Enterprise scalability is a different beast. Businesses don't grow virally; each person hired generally does not then go and bring three or four more people into the organization, at least not over time periods of weeks or months. However, enterprises have other needs that are different than cool apps on the web, and building applications and supporting infrastructures to meet those needs is challenging, too.

All that being said, I do not believe that there is anything inherent to the nature of applications written in Java that either preclude them from achieving both kinds of scalability or predispose them towards either kind, either. Building truly scalable applications generally has more to do with good architectural principles and planning ahead of time, right from the beginning, to meet those scalability needs.


答:
Enterprise apps should be scalable enough that small to midsize shops can run them on the same server as their other apps, while large corporations can run them on dozens or possibly hundreds of servers with wide geographical dispersion, with thousands of users.  The challenges here are keeping data synchronized across data centers, automatic failover and recovery, and integration with other business systems.  Data integrity is a huge issue, and transaction design consumes a lot of development effort.

Internet-scale applications should be capable of running on hundreds or thousands of servers spread across the globe, with hundreds of thousands (or even millions) of users.  Challenges here are traffic routing and minimal state-keeping.  Shared data fidelity is often not a high concern (if you miss a status update it's not a big deal), and response time is the primary performance metric.

Title: Enterprise scalable vs internet scalable, what is the meaning & differences?

Body:
While reading about Java EE applications, somewhere I have seen people saying they're enterprise scalable, I am confused as to what that really mean?

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


问:
Windows OS design decisions
I've seen an interview with Richard Stallman some time ago, and he was asked a question about security and Windows OS which he answered saying that there are some relatively bad design decisions that were made when creating the Windows OS. These design decisions (according to R. Stallman) were known at the time for creating security vulnerabilities later on.

Can anyone explain what he's talking about ?

The video with the interview can be found here http://rt.com/news/richard-stallman-free-software-875/ - it starts at 8:30.

答:
I'm not Stallman, but here's my guesses:

Single-user, with no roles or permissions.  Yes, this has changed,
but only recently, and there's still a tradition of single-root-user.

Default opening files with exclusive read access.  This leads to
frequent rebooting to install new versions of DLLs and so forth.
Frequent reboots are the only way that a boot sector virus would
spread.

Default executable file attributes, with file extension determining what executes the file. How many phishing emails have succeeded because of something named "whatever.jpg.exe"?

Until Windows 2000, no address space protection. This allows one process to write into another process' address space and cause problems.

Not exactly an operating system issue, but allowing people to send emails that caused execution on the receiving machine was known to be insane. Sure it was cool and it let you do fun things, but it also let people create email worms like MELISSA and the LOVE BUG. When early versions of Outlook appeared, there was a lot of usenet commentary on how silly that was.  I recall someone writing that until Outlook came out, if you'd written an email client that executed incoming emails, people would have looked at you like you had a hole in your head.

Who knows what Stallman meant?  Those are only the ones that immediately pop into my mind.

Title: Windows OS design decisions


问:
Sprint Backlog Task Estimates - What Are the Hours Made Of?
For the sprint backlog, I read that the stories are broken into tasks, and estimated.  Are these estimates typically development hours only, or development + QA?  What are these hours typically consisting of?

Thanks.

答: In ideal Scrum the team is multi-functional in that the same people does both development and QA. If that is true for your team then your estimated hours are for any one person in your team to complete the task. I have been in company that the team consist of developers and QA which tasks are divided between them. We would then have "development hours" and "QA hours" on a task. Easily with more specialists in your team you can divide the "done criteria" to different type of tasks and complete with different type of hours. </p>


答:
I suggest you look into some tutorials or textbooks on digital signal processing.  What you are trying to do is actually quite complicated.  Some of the things that make it complicated are:

Audio samples will be coming to you from the sound card in PCM (Pulse Code Modulated) samples.  That is just a fancy term for time domain samples.  That is, the analog sound wave going into the microphone is sampled at a regular interval and you are given those samples as numbers.  This does not directly give you any frequency information, you will have to perform an FFT to transform the time domain data into the frequency domain.

Even after the FFT, you still do not have the array of frequencies you are looking for.  What you have is an array of magnitudes at each sampled frequency.  So you will have to do some kind of detection to determine which frequencies are actually present in your signal.  This could be a simple threshold and peak pick, or something more involved.

In addition to this difficulty, there is a tradeoff when performing spectral analysis with the FFT between time and frequency resolution.  If you want to get more frequency resolution, you must sacrifice time resolution.  For example, if you want to be able to detect a 1Hz change in a signal that is sampled at 44100 Hz, you will need to perform an FFT of 44100 samples.  Well, 44100 samples is an entire second of data, which means that even though you can detect a signal to 1Hz resolution, you don't know where in that second it occurred.  This is why many pitch detection algorithms use time-domain methods like auto-correlation to find the pitch.

Another difficulty is that an instrument does not produce a pure tone (single frequency), but produces a number of harmonics as well.  So you will not only have the true pitch frequency, but there will be other frequencies present in the signal that you will have to account for.

All of this is not to discourage you from doing this project, I am just trying to lay out some of the issues you might face when doing the project.  I worked on a similar project and ran into these issues.

Title: How to Determine Frequency (In Hertz, Real Time) with Java Sound

Body:
I've been looking around and I've found some questions similar to mine but have never been quite satisfied with the answers. I'm more or less a Java n00b, although I am moderately proficient with C++ and I would consider myself intermediate to advanced, as a programmer in general. I'm looking to write a program in Java that functions similarly to a tuner - what I want to do is record an instrument's pitch over about a 3 second time frame, and to measure the average deviation. (This is for a band class.)

What I'm thinking is that I'll have a big array of numbers, and each entry in the array will be a number in terms of frequency. I want to be able to loop through the array, and calculate the average Hertz for displaying it on screen or something. So what I want to do is have some way of "polling" (for lack of a better word) the microphone to see what frequency is being inputted right that instant.

Is there a simple way to accept audio input from a microphone in terms of Hertz? This will be in Java, under a Windows platform.


问:
Component Diagram, what's next?
I'm working on an iPhone application and I created a component diagram. I defined interfaces for each component. For example I have an AI component and I have made some interfaces for it.

How should I carry on? Should I create a class diagram to go into details, should I go into details of each interface or should I just start implementing my interfaces?

I am a bit confused on how to proceed.

答:
As rule of thumb, you start with the logic of your application and then continue with the implementation.

So you should first complete your interface declarations.

Continue to the class diagram to model your classes.

Finally write the code itself.

OwnerDisplayName: Eugene

Title: Component Diagram, what's next?

OwnerDisplayName: Avi Cohen


答:
For your class:

you should ask your instructor what is expected and do that

For the real world:

you should stop drawing pointless diagrams and implement something already

Title: Component Diagram, what's next?

Body:
I'm working on an iPhone application and I created a component diagram. I defined interfaces for each component. For example I have an AI component and I have made some interfaces for it.

How should I carry on? Should I create a class diagram to go into details, should I go into details of each interface or should I just start implementing my interfaces?

I am a bit confused on how to proceed.


答:
First of all, there's a lot more code reuse than most people give credit for, just not for every single application.  Have you tried making a website using a modern CMS?  "Merely a composition of high-quality software modules" is a perfect description.

There is an inherent coupling between the general applicability of an interface and its complexity.  Let's say you wanted to make the container to end all containers.  The interface couldn't be as simple as an array's because some people need O(1) insertions into the middle, some need fast lookup, some need persistent storage, some need space efficiency, etc. and they need a way to specify and operate upon those needs.

When you try to do too much in a library, your interface ends up with a complexity comparable to the programming language itself, so you may as well make narrowly-applicable interfaces and use the programming language as the glue, which is precisely what we have done.


问:
What is the best technology for a TRULY portable REST client
I develop a suite of productivity tools, for Mac, iOS and Windows. They all communicate with a sync server via a RESTful interface (using Protocol Buffers), but as we add new platforms, we realize the pain it is to recreate different versions of the same code just to communicate with the client, so we have thought of using a modular design:

The backend client module would be the same for all clients, so that changes to the protocol can be easily ported to all clients

Clients we need to support: Windows, Mac, iOS, Android, Web, possibly Windows Mobile

The only way I can think of is via a JavaScript module that's shared across all clients and handles communications with the server, but perhaps that's even more work because of the integration required with the JavaScript interpreter. Maybe we might be better off writing a couple of backend modules instead of just one.

答:
If you mean, write the code once and have it run on "Windows, Mac, iOS, Android, Web, possibly Windows Mobile": I don't think that's practical. You'll need to maintain several different clients.

But there are things you can do to make this less error-prone. You need to start with a rigorous and precise definition of what the server's inputs and outputs can be, then make sure that every one of the libraries obeys that definition. There are tools that can automatically generate client and/or server code from a WADL or WSDL document; those might be useful. At the very least, you'll need a unit test framework that runs all the clients against the same input data, and makes sure that they generate the same output.


答: IMO the biggest flaw is the frequent need for elevated privileges.  Installing the most trivial application requires access to the Registry and system folders and everything else.  This leads users to have administrator privileges enabled all the time, or else to routinely enable them whenever they are prompted to do so.  Combine this with a generally naive user community, and a barrage of malware via E-mail spam and the web, and it's no surprise Windows systems are so often compromised.  Other operating systems (e.g. Unix) were designed to protect the system from users, and protect users from each other.  Most tasks, including software installation, can be installed without elevated privileges, so the effect of user-installed malware is somewhat limited.  Malware can still do pretty bad things to the user's data, but it is much less likely to corrupt the operating system.

Title: Windows OS design decisions

Body:
I've seen an interview with Richard Stallman some time ago, and he was asked a question about security and Windows OS which he answered saying that there are some relatively bad design decisions that were made when creating the Windows OS. These design decisions (according to R. Stallman) were known at the time for creating security vulnerabilities later on.

Can anyone explain what he's talking about ?

The video with the interview can be found here http://rt.com/news/richard-stallman-free-software-875/ - it starts at 8:30.


答:
The reason that software libraries can't solve all our problems is because software libraries just solve many (not all) of the problems of software developers.  They don't solve the problems of software users!

Suppose your organization decides the world  needs a really good 3D visual interactive aerospace design application?  You, as the software developer, may well start with an existing 3D graphics library.  For this exacting application you're almost certain to find that there is no library that does everything you need, you'll have to extend what already exists.  And certainly there is no 'design a Boeing 747 or Airbus 380' library!   It will take years of work to develop this application.

Suppose you are a cabinet maker, a customer comes in with a hand drawn sketch of a cabinet she wants created.  You have a shelve full of woodworking books and a shop full of good woodworking tools.

The tools and books help, but you still have to make the cabinet!


答:
My personal definition of pseudocode is "the stuff I write in plain English on a sheet of paper when designing code"

Before coding from a pseudocode "design", I will add my pseudocode as comments. Then working through those comments I can add the "actual" code which performs the task described.

There may be a formal name, which I am unaware of, for this method of coding, and I only use it when doing something new/complicated.

Title: What is pseudocode?


答:
As how my programming lecturer said: </p>

<p>Pseudocode is the English version of any programming language. </p>

Title: What is pseudocode?

Body:
As how my programming lecturer said:

Pseudocode is the English version of any programming language.


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

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

答:
If word of that got out, well, any vendor that could lose its source code by any means other than a fairly widespread disaster is obviously not following anything like sound development practices, and is not to be trusted.  I'd consider that as very strong prima facie evidence of gross corporate incompetence.

How about "incredible stupidity"?

ContentLicense: CC BY-SA 2.5

Title: How serious is losing the source code?


答:
Since you're asking about the material in those Stanford lectures in particular, It's worth considering two things about Hegarty's stance:

As you've mentioned, he's teaching a l00-level Computer Sci course. There are plenty of places in his lectures where he simplifies, glosses over details, or says "just do it this way", as one probably has to when teaching the basics, i.e. you have to master the rules before you can break them.

My experience with the iOS SDK is that, where it doesn't enforce strict separation between View and Model, it is geared heavily towards that pattern. When writing iOS apps in particular, adhering to model-view separation helps you write code that's in line with the framework's expectations. I'd hesitate to generalize Hegarty's statements to development on other platforms or in general.


问:
Determining if language/framework/technology is 'Future-proof'
I'm a PHP developer and I recently started to work with CodeIgniter. It seems that whenever I search for something related to CodeIgniter, the blog posts and what not are usually from '09 or '10, so it got me thinking, is CodeIgniter still relevant and is it going to be in the future? Is there another framework that is taking it's place?

The same goes for other languages and frameworks as well. At what point do you abandon learning certain languages or frameworks? Is there any easy way to find those that are emerging and worth picking up?

答:
There is no way to know if something is going to be future proof I would rather focus on does the technology help me solve the problem I have today. You would abandon learning a certain language or framework when it no longer works to solve your problems.

Be involved in the community that represents what you are doing and you can get a good sense on whats coming and going but even then I would rather spend my time with the best tool for the job not whats hot or what i think will be hot a year or two from now.


答:
There is no way to determine definitively whether something is future proof. The closest that you can come is to determine the level of activity around a particular language or framework - if there's a lot of developer activity, it's usually a good sign that the language/framework is trending up in popularity and will be viable for a while. The inverse indicates that there is less excitement and that support (via developer forums) may be harder to come by.

So long as your language/framework of choice solves the problem that you're trying to solve, you shouldn't need to worry about future-proofing, unless you're clearly working with a dying technology. Technology keeps changing - one thing you can do is to keep track of industry trends. Learning new programming languages/frameworks, as noted in this thread, can help you keep up with trends and gives you an opportunity to continuously evaluate new tools.

Title: Determining if language/framework/technology is 'Future-proof'

Body:
I'm a PHP developer and I recently started to work with CodeIgniter. It seems that whenever I search for something related to CodeIgniter, the blog posts and what not are usually from '09 or '10, so it got me thinking, is CodeIgniter still relevant and is it going to be in the future? Is there another framework that is taking it's place?

The same goes for other languages and frameworks as well. At what point do you abandon learning certain languages or frameworks? Is there any easy way to find those that are emerging and worth picking up?


答:
It's not an exact science, so don't expect to be able to predict the future trends in the technology landscape more than 5 years out with any certainty.

But I would look for all of the following:

Installed base - a bigger installed base means lots of companies will contine to invest in the technology and its maintenance, which means developers will be needed to work with the technology. Positive cycle ensues. For example Java, like COBOL before it, is not going away for a very long time.

Broad-based Industry support - are there multiple big name industry players backing the technology? Only one committed backer is a warning sign - it could get dropped or sidelined any time with a single change of strategy.

Open source - major open source products have proven to be extremely good long-term bets (look at Linux, Apache, Red Hat, JBoss, Eclipse for example....). Proprietary products on the other hand are somewhat at the whim of a single vendor where you are at risk of discontinuation / ramped up prices / attempts to force to to migrate to their "next big thing".

Quality - high quality products will simply live longer because people will want to use them rather than switch to something else. Conversely, low quality products will get abandoned as soon as something better comes along.

Innovation - is the technology towards the cutting edge of innovation? If so, it is likely to gain adoption and support among the more innovative companies and users. This will ultimately start to become mainstream (I'd say new languages like Scala and Clojure for example are in this category)

Community - it there a positive, open-minded, pragmatic, committed, helpful community around the technology? These are the people who will ultimately guarantee it's future.....


答:
A difficulty that I don't see described clearly in other answers is how to find and exploit a relevant library efficiently. Even if all available libraries were searchable at http://code.google.com/hosting/ (and of course they are not) it would sometimes take longer for a programmer to complete that search process than to improvise an acceptable solution using the libraries that are already at hand.

Mathematicians have a similar problem to find math theorems that have already been proved. No one has yet perfected "mathematical knowledge management" software for that purpose. Aspects of the problem may be beyond the possibility of automating. The conceptual extreme case is Jorge Luis Borges's "Library of Babel" in which everything, as well as every possible variation on everything, is in the collection. Then the only unambiguous way to describe an item from the collection is to recreate it.

Edit: And where I just mentioned the possibility of having to choose between many variations on software libraries, a highly relevant example is different trade-offs between space (data storage) and time (CPU usage).

Edit 2: OK, my Library of Babel observation isn't mathematically correct. We can give names to the items in that catalog that interest us. But what I understand of Chaitin-Kolmogorov complexity leads me to believe that any such naming system leaves plenty of (perhaps unwanted) information resources whose most concise name is just as verbose as their complete content.


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

答:
Noir is beautiful, functional and simple (in the Rich Hickey "Simple Made Easy" sense):

```<code>(defpage "/welcome" []
    "Welcome to Noir!")

(server/start 8080)
</code>```

I particularly like the way that you can then build your entire web application just using function composition, supported with a few macros to enable a nice declarative DSL.

Body:
Noir is beautiful, functional and simple (in the Rich Hickey "Simple Made Easy" sense):

(defpage "/welcome" []
    "Welcome to Noir!")

(server/start 8080)

I particularly like the way that you can then build your entire web application just using function composition, supported with a few macros to enable a nice declarative DSL.


答:
"Futureproof-iness" is as much about will-power and stubbornness as it is about more pragmatic concerns.

An extreme example is this. Sparkle Filters IS STILL RUNNING an IBM 402 computer from the late 40's as their accounting system. This is a machine that is programmed using electrical plug-boards rather than "files".

I personally have had experience with a company that still maintain MS-DOS based machines inside specialized instruments that are designed to operate for decades. I've even scrapped an operational PDP as late as 1997.

I'd say that if your company gets a visit from the computer history museum, like Sparkle Filters did, that would be a sign that you (or your ancestors) have successfully "future-proofed" the system!


问:
Writing recursive functions
I am having a lot of trouble writing recursive functions related to trees. I can't just use google for these functions as they are not general and I won't be able to use google in an exam setting!

Is there some 'trick' to successfully coming up with an algorithm/writing psuedocode for recursive functions? Is there a certain way I should think about/approach this?

Example: Write a recursive function that determines whether a given binary tree has a
structure consistent with a valid AVL tree.

Solution Expected:

template <typename Type>
bool is_avl (const Binary_node<Type> * tree) {
    if (tree == NULL) {
        return true;
    }
    return is_bst (tree)
      && is_avl (tree->left())
      && is_avl (tree->right())
      && std::abs(height(tree->left()) - height(tree->right())) <= 1;
}
```

答:
Is there some 'trick' to successfully coming up with an algorithm/writing psuedocode for recursive functions?

Absolutely! When you're writing a recursive function, you're explicitly describing the induction you're preforming on the given datastructure. Therefore, when you write your function, the 'trick' is twofold:

Cover all the different forms your datastructure represents (IE, have cases for the leafs AND nodes of a tree, or the cells AND empty-lists in a linked list, or positive numbers AND zero if you're recurring on numbers.

When you're dealing with the containing case (cell in a list, node in a tree), reduce the problem into subproblems and find a way to combine them if need be.

For example, here's a recursive function to count all the nodes in a tree:

```<code>def TreeCount(Tree):
    if Tree.isLeaf: # we can't go down any further
        return 1
    else: # break the problem into sub-problems we can solve with this function
        return 1 + TreeCount(Tree.left) + TreeCount(Tree.right)
</code>```

As you can see, I split the function on the type of Tree we were looking at (Leaf vs Node) and in the case where I was dealing with a Node, I processed that in terms of recursions on it's subtrees.

Title: Writing recursive functions

Body:
Is there some 'trick' to successfully coming up with an algorithm/writing psuedocode for recursive functions?

Absolutely! When you're writing a recursive function, you're explicitly describing the induction you're preforming on the given datastructure. Therefore, when you write your function, the 'trick' is twofold:

Cover all the different forms your datastructure represents (IE, have cases for the leafs AND nodes of a tree, or the cells AND empty-lists in a linked list, or positive numbers AND zero if you're recurring on numbers.

When you're dealing with the containing case (cell in a list, node in a tree), reduce the problem into subproblems and find a way to combine them if need be.

For example, here's a recursive function to count all the nodes in a tree:

def TreeCount(Tree):
    if Tree.isLeaf: # we can't go down any further
        return 1
    else: # break the problem into sub-problems we can solve with this function
        return 1 + TreeCount(Tree.left) + TreeCount(Tree.right)

As you can see, I split the function on the type of Tree we were looking at (Leaf vs Node) and in the case where I was dealing with a Node, I processed that in terms of recursions on it's subtrees.


答:
You're in luck! There (sort-of) is!

What you often want to do is identify the 2/3 cases:

The base case

The recursive case

The exit case (sometimes optional)

That is:

What you want to do

Where you need to continue

When you're done

Think of an example (DFS over a binary search tree):

bool DFS(Node currentNode, T searchValue)
{
    // base case
    if (currentNode.Value == searchValue)
        return true;

    // recursive case and exit case
    if (curentNode.Left != null && DFS(currentNode.Left, searchValue))
        return true;

    // recursive case and exit case
    if (curentNode.Right != null && DFS(currentNode.Right, searchValue))
        return true;

    return false;
}
```

<p>So here we have:</p>

<ol>
<li>Base case: whether we have found our value</li>
<li>Recursive case(s): run DFS in the child nodes</li>
<li>Exit case: return true if DFS on the child nodes found the value</li>
</ol>

<hr>

<p>So now think of in-order traversal of the same tree:</p>

<ol>
<li>Base case: print out the node</li>
<li>Recursive case(s):

<ul>
<li>visit the left child</li>
<li>visit the right child</li>
</ul></li>
<li>Exit case(s): does the node exist?</li>
</ol>

<p>In the case of in-oder traversal it looks like:</p>

<pre class="lang-cpp prettyprint-override"><code>void InOrder (Node currentNode)
{
    // 3
    if (currentNode == null)
        return;

    // 2
    InOrder(currentNode.Left);
    // 1
    print(currentNode.Value);
    // 2
    InOrder(currentNode.Right);
}
</code>```

Almost all recursive functions will have these elements. Identifying them and putting them in the right order is key.

Title: Writing recursive functions

Body:
I am having a lot of trouble writing recursive functions related to trees. I can't just use google for these functions as they are not general and I won't be able to use google in an exam setting!

Is there some 'trick' to successfully coming up with an algorithm/writing psuedocode for recursive functions? Is there a certain way I should think about/approach this?

Example: Write a recursive function that determines whether a given binary tree has a
structure consistent with a valid AVL tree.

Solution Expected:

template <typename Type>
bool is_avl (const Binary_node<Type> * tree) {
    if (tree == NULL) {
        return true;
    }
    return is_bst (tree)
      && is_avl (tree->left())
      && is_avl (tree->right())
      && std::abs(height(tree->left()) - height(tree->right())) <= 1;
}
```

Body:
You're in luck! There (sort-of) is!

What you often want to do is identify the 2/3 cases:

The base case

The recursive case

The exit case (sometimes optional)

That is:

What you want to do

Where you need to continue

When you're done

Think of an example (DFS over a binary search tree):

bool DFS(Node currentNode, T searchValue)
{
    // base case
    if (currentNode.Value == searchValue)
        return true;

    // recursive case and exit case
    if (curentNode.Left != null && DFS(currentNode.Left, searchValue))
        return true;

    // recursive case and exit case
    if (curentNode.Right != null && DFS(currentNode.Right, searchValue))
        return true;

    return false;
}

So here we have:

Base case: whether we have found our value

Recursive case(s): run DFS in the child nodes

Exit case: return true if DFS on the child nodes found the value

So now think of in-order traversal of the same tree:

Base case: print out the node

Recursive case(s):

visit the left child

visit the right child

Exit case(s): does the node exist?

In the case of in-oder traversal it looks like:

void InOrder (Node currentNode)
{
    // 3
    if (currentNode == null)
        return;

    // 2
    InOrder(currentNode.Left);
    // 1
    print(currentNode.Value);
    // 2
    InOrder(currentNode.Right);
}

Almost all recursive functions will have these elements. Identifying them and putting them in the right order is key.


问:
When there are multiple scrum teams, how often should the 'scrum of scrums' meet and who should attend?
When there is too much work for one scrum team to manage, multiple teams are created. A scrum team has a stand up meeting everyday. How often should the intra-scrum team meeting occur and who should attend? What should they talk about?</p>

答:
We have Scrum-of-scrums daily. The typical day goes like this...

9:15 - individual teams have their stand-up meetings. The usual stuff: what you did yesterday, what you're doing today and (most importantly) any blocks
9:30 - Scrum Masters from each team have their Scrum-of-scrums. Same stuff: what the team did yesterday, what they're working on today and most importantly (even more so than for the individual team Scrums) any blocks and/or cross-team issues

Doing it this way requires a lot of discipline to stay focussed on the important stuff, but that's Agile in general for you.

For me, the most important thing, regardless of how or when or who is that blockages and cross-team issues are raised and resolved quickly.

Finally as Casey mentioned, don't be dogmatic. If it doesn't work - do something about it.


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

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

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

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

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

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

How can I design it?

答:
A lot of design problems go away when you use composition instead of inheritance.

For clarity, let's say the source you're reading from is a socket.

You can create an abstract Reader with read() method that reads a single string.

It will have 2 subclasses - SocketReader and FileReader.

Add a Reader data member to BufferManager initialized in the c'tor.

To create a 'regular' BufferManager, create a BufferManager and pass it a SocketReader instance in the c'tor.

Instead of creating a SorterManager, create a BufferManager and pass it a FileReader instance in the c'tor.

The push() method should be implemented as follows:

```<code>while (!mReader.eof()) {
  String s = mReader.read();
  writeToBuffer(s);
}
</code>```

For summary - you will have a single BufferManager class which will work with sockets or sorted files depending on the Reader you initialize it with.

Title: Right multi object dependance design

Body:
A lot of design problems go away when you use composition instead of inheritance.

For clarity, let's say the source you're reading from is a socket.

You can create an abstract Reader with read() method that reads a single string.

It will have 2 subclasses - SocketReader and FileReader.

Add a Reader data member to BufferManager initialized in the c'tor.

To create a 'regular' BufferManager, create a BufferManager and pass it a SocketReader instance in the c'tor.

Instead of creating a SorterManager, create a BufferManager and pass it a FileReader instance in the c'tor.

The push() method should be implemented as follows:

while (!mReader.eof()) {
  String s = mReader.read();
  writeToBuffer(s);
}

For summary - you will have a single BufferManager class which will work with sockets or sorted files depending on the Reader you initialize it with.


问:
Should a novice programmer learn several languages at once?

Possible Duplicate:

  Is it worth being computer languages polyglot?

I am half way through my first year at university studying computer science. I have been learning Java on the course and also have experience for Visual Basic from my A-Levels. To give you an idea of my level of understanding the most recent topic on my course was abstraction.

From reading around the site and similar places I am in no doubt that learning many languages is a good way to expand your knowledge and your programming toolkit. My question is should I be learning a new language now, or should I focus on gaining a better understanding of the Java toolkit. Keep in mind that I would be learning any new language in my own time alongside my studies in java and my other modules (shell scripting, SQL and basic Assembly).

If I should be learning a new language do you have any recommendations? From what I have read choosing a language with a very different paradigm seems like a good idea; but do you have any specific suggestions. My personally thought are possibly Assembly as an academic exercise or perhaps Ruby.

If I shouldn’t be learning a new language right now, when would be a good time? I know this is probably difficult to answer, but are there and indicators of when I have learnt as much as I should from java or generally what time is best to take on a new language.

答:
At your stage stick to trying to learn depth (one language well) rather than breath (lots of languages). it will serve you better in future and a uni course should expose you to several languages anyway.

Having said that if you want to try Ruby because it looks fun then go for it. Enjoying programming is the most important part of learning to do it well.


答:
The key is patience.  Patience, patience, patience.  There's no way for sure to predict the future. (did I even have to write that?)  But if you give the new technology a couple years and watch how its adopted you'll have a good idea of whether or not it will take roots and is suitable for long term projects/time investment.

So when the NextNewThing(tm) comes around, feel free to jump on the bandwagon... just not for anything important in the first couple of years.


答:
No. Don't learn multiple languages at once. Once you've got a solid foundation in a language, then learn another.

What you can do instead, is take a sampling or a nibble of a couple different languages (the book Seven Languages in Seven Weeks might be a good resource). Learn what the different styles are like, pick the style you like, pick the most popular language of that style, or one that a friend knows (reasoning: more/better resources for when you get stuck) and learn it really well.

Title: Should a novice programmer learn several languages at once?

Body:
Possible Duplicate:

  Is it worth being computer languages polyglot?

I am half way through my first year at university studying computer science. I have been learning Java on the course and also have experience for Visual Basic from my A-Levels. To give you an idea of my level of understanding the most recent topic on my course was abstraction.

From reading around the site and similar places I am in no doubt that learning many languages is a good way to expand your knowledge and your programming toolkit. My question is should I be learning a new language now, or should I focus on gaining a better understanding of the Java toolkit. Keep in mind that I would be learning any new language in my own time alongside my studies in java and my other modules (shell scripting, SQL and basic Assembly).

If I should be learning a new language do you have any recommendations? From what I have read choosing a language with a very different paradigm seems like a good idea; but do you have any specific suggestions. My personally thought are possibly Assembly as an academic exercise or perhaps Ruby.

If I shouldn’t be learning a new language right now, when would be a good time? I know this is probably difficult to answer, but are there and indicators of when I have learnt as much as I should from java or generally what time is best to take on a new language.


答:
No. Let me tell you why.

When you are first starting to learn how to program, there are tons of things you don't know, that will haunt you in every language. Stick with one language and learn those first. That includes:

Variables/Data Structures

Algorithms

Commenting practices

Other Best Practices

etc.

This may be a bit overwhelming at first, but you'll catch on and, eventually, will see that some things are the same in almost every language. Languages that are good for learning the above topics are:

Java

C#

Python

C(++)

as there aren't as many ways to do the same thing in these languages as there are in, lets say, Perl.

Since you have experience with Java, I would stay on that route. Once you think you have a good understanding of the language, test your knowledge. Start a semi-difficult project that uses everything you have learned, and some things you haven't. Then, during the project, if you have any questions, ask them here or on SO, depending on the question.

Finally, if you have successfully completed the project, let some people test it out, and even look at your code. Let them criticize what you've done, and make the changes.

If you feel you are ready, you can now move to a new language. If you want to keep working with Java (or whatever language you were using) even better!

Recommended Readings (assuming you are using Java)

Java Docs - Algorithms

Intorduction to Algorithms - Book

Data Structures in Java - Book

Data Structures and Algorithms - Book

If you decide not to use Java, leave a comment and I'll give you some recommendations. Until then, good luck!


答: This is a very good time to try other languages, time permitting.  You will never any quicker than you are now.  It doesn't much matter which one.  Just do whatever looks interesting.  Just pick one that looks interesting and play with it until you get bored.  </p>


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

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

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

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

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

How are cases like this meant to be handled?

答:
This is exactly why one of the other guidelines is to use interfaces. If you method takes an object that implements an interface instead of a specific class implementation, you can create a class that does not depend on the rest of the code base.

Another alternative is to use a mocking framework. These allow you to easily create these type of dummy objects that can be passed in to the method you are testing. It is possible that you might have to create some stub implementations for the dummy class, but it still creates a separation from the actual implementation and what the test is concerned with.