问:
What is the technique called in which you return a never ending http response to keep returning lines of javascript for dynamic update effect?
There is a technique in which you don't end the response and this allows you to send content to the client in chunks like pieces of javascript or maybe xml document that can be parsed on the client side and give an effect of updating something in real time instead of polling the server again and again.

Was there such a technique or am I dreaming?
Do you have reference to an online article explaining this?

答: You're definitely describing push technology, and it sounds like you're describing what's called "pushlet" on Wikipedia. I've heard of this technique, but I wasn't aware of its name until just now. It appears this name is more widespread, with a website dedicated to explaining how to use pushlets.</p>


问:
Is it possible to rewrite every line of an open source project in a slightly different way, and use it in a closed source project?
There is some code which is GPL or LGPL that I am considering using for an iPhone project.

If I took that code (JavaScript) and rewrote it in a different language for use on the iPhone would that be a legal issue?

In theory the process that has happened is that I have gone through each line of the project, learnt what it is doing, and then reimplemented the ideas in a new language.

To me it seems this is like learning how to implement something, but then reimplementing it separately from the original licence. Therefore you have only copied the algorithm, which arguably you could have learnt from somewhere else other than the original project.

Does the licence cover the specific implementation or the algorithm as well?

EDIT------

Really glad to see this topic create a good conversation. To give a bit more backing to the project, the code involved does some kind of audio analysis. I believe it is non-trivial to learn or implement, although I was prepared to embark on this task (I'm at the level where I can implement an FFT algorithm, and this was going to go beyond that.) It is a fairly low LOC script, so I didn't think it would be too hard to do a straight port.

I really like the idea of rereleasing my port as well as using it in the application. I don't see any problem with that, and it would be a great way to give something back to the community.

I was going to add a line about not wanting to discuss the moral issues, but I'm quite glad I didn't as it seems to have fired the debate a bit.

I still feel a bit odd about using open source code to learn from. Does this mean that anything one learns from an open source project is not allowed to be used in a closed source project? And how long after or different does an implementation have to be to not be considered violation of the licence? Murky!

EDIT 2 --------

Follow up question

答:
You cannot make derivative work of derivative work of derivative work ... and expect it to not be derivative work. It can become unrecognizable, but that's something else.
And you can start from any text and by serie of changes get any text (eg, remove first one, insert second one), so that its possible does not mean it was done.
So its not important whether something is possible, but whether it actualy happend (only impossible obviously did not happen)

Moraly speaking:
Learning from anything you can (legaly) get to is OK, but you should acknowladge sources.
rest is legality.

IANAL, but i would not think i made anything wrong, if:
1) I learned from open source implementation
2) Implement the same algorithm (even in same language)
by actualy doing this, large portions will naturally became totaly different, and
some will be realy similar.
If those similar parts are things where both sides followed same coding practice and thus
cannot be different, then these portions are imo not copyrightable. Eg. if class have two private String fields and they have getters and setters, only interesting thing is that this class have two read/write properties, not implementations of getters and setters.

OwnerDisplayName: optician

ContentLicense: CC BY-SA 3.0


问:
Should we attempt to review all our code?
We're currently modifying out development process and I'm wondering if we should try to keep a 100% of our commits peer reviewed.

What is your experience regarding code reviews?

Do you tend to spend "a lot" of time on them (say 1/2 hours per day), or just skim over for 5/10 minutes max?

Do you have a fixed amount of time to spend per day/week/sprint/project?

Most importantly do you think that the target should be for 100% of the code to be peer reviewed or that 100% is not necessary?

答:
We have a 'Code Review' task in each story.  Someone ideally not involved in the development of that story will review all code changes associated with that story.  It works well.

A lot of time?  Not very much, depends on how much code - we're looking for obvious errors, typos, basic logic sanity checking, uncaught exceptions, etc.

It's a quality step that does find bugs, therefore it has some value.  Allocating time may not be the best way of doing it - how about if something is fairly complex, it should be code-reviewed?

By the way, it's important that someone else does the code review..

OwnerDisplayName: Simeon

ContentLicense: CC BY-SA 4.0

OwnerDisplayName: Kieren Johnstone


问:
Why do so many programmers absolutely hate object prevalence layers?
Prevalence is a simple technique to provide ACID properties to an in-memory object model based on binary serialization and write-ahead logging.  It works like this:

Start with a snapshot.  Serialize the object model and write it to a file.

Create a journal file.  For every call into the object model, serialize the call and its arguments.

When the journal gets too big, you're shutting down, or it's otherwise convenient, perform a checkpoint: write a new snapshot and truncate the journal.

To roll back or recover from a crash or power hit, load the last snapshot and re-execute all the calls recorded in the journal.

The precautions needed to make this work are:

Don't let mutable object references escape or enter the prevalence layer.  You need some sort of proxy or OID scheme, as if you were doing RPC.  (This is such a common newbie mistake it's been nicknamed the 'baptism problem'.)

All the logic reachable from a call must be completely deterministic, and must not perform business-logic-meaningful I/O or OS calls.  Writing to a diagnostic log is probably OK, but getting the system time or launching an asynchronous delegate is generally not.  This is so that the journal replays identically even if it's restored on a different machine or at a different time.  (Most prevalence code provides an alternate time call to get the transaction timestamp.)

Writer concurrency introduces ambiguity in journal interpretation, so it is prohibited.

Is it because ...

people developed a bad taste for them after trying to use one on a project that wasn't well suited* to it?

Klaus Wuestefeld's strident advocacy turned people off?

people who like the imperative programming model dislike separating I/O from calculation, preferring instead to interleave computation with I/O and threading calls?

prevalence layers are so conceptually simple and so intimately bound to the characteristics of the framework they inhabit that they're usually custom-rolled for the project, which makes them too alien/nonstandard/risky?

it's just too hard to keep straight what you have to be careful not to do?

newbies' heads just seem to explode when faced with something that isn't the same kind of two-tier database-driven app they learned to write in school? ;)

*The entire data set fits in RAM, you don't need writer concurrency, and you don't need to do ad-hoc queries, reporting, or export to a data warehouse.  With apologies to SQLite, prevalence is an improvement on save-files, not a replacement for Oracle.

答: The pre requisites sound a bit onerous to code around, especially with most systems not needing ACID compliance when running in memory. Overhead sounds a bit nasty too -- there is alot of state tracking involved there. </p>


问:
What are the pros and cons of a language using whitespace vs. {}'s to indicate scope?
There seems to be a conflict over whether its better to use whitespace or tokens like brackets to indicate scope. I've seen many praise python's solution to the inconsistent indentation problem, but many disagree:

Any language that has whitespace as tokens needs to die.

posted later on the same answer:

I was sortof anti-whitespace-as-tokens, until I actually tried it. It probably helped that my personal white-space layout pretty much matches what everyone in python-land uses. Perhaps it's that I am a bit minimalist, but if you're going to indent anyways, why bother with the {}s?

I can see some clear arguments for each side:

using whitespace:

helps reduce inconsistent indentation in code

clears the screen by replace visible tokens with whitespace to serve the same purpose

using tokens:

much easier to cut and paste code to different levels (you don't have to fix the
indentation)

more consistent. Some text editors display whitespace differently.

more popular currently.

Are there any points I missed? Which do you prefer? Any words of wisdom after having worked with one or the other for a long time?

PS. I hate it when languages don't use the same token for each control structure. VB is really annoying with its End If and End While statements, most other languages just use {}'s for everything. But maybe that's a topic for a different question...

答:
{} adds redundancy. Too much redundancy is bad, too few is bad. And manualy entering it is bad, esp. if its hard to use it.

So in times of bad/no IDE, whitespace style could be slightly better. But with powerfull IDE, braces are better.

ContentLicense: CC BY-SA 2.5


问:
How to save images into files in a web application and avoid removing them with every build?
I am building a web application and users will be able to upload pics. And I want to store these images into files instead of storing them into the DB.

But if I saved these pics into relative paths to the web application, they will be removed with each build.

So how I can handle this and the best practices related to this issue.

答:
For simplicity of design and code it sometimes makes sense to store files as binary data in a database column, however RDBMS isn't efficient for this and I wouldn't recommend this if performance is a primary concern.

If you decide to store on filesystem then absolute paths are much better than relative paths as you have persistence.  Designate an absolute path to a folder to store files and make sure it is regularly backed up.

Another note of advice, when it comes to hosting, it is best that you NOT store files on the web server itself.  Most web server machines are configured to do one thing and one thing, receive and serve network communication.  Compared to a sophisticated file storage, backup, or other RAID array system the disk storage on most web servers is comparitively underpowered for large amounts of file I/O.  Webservers are just not intended for this purpose.

I recommend an absolute path to a network share to a dedicated file server or other system intended for large amounts of file I/O as well as backups and redundancy.


问:
Open Source Project and Revenue
I started an open source project in 2010 and the project is gaining some visibility. We are now 2 active committers and we hope to engage more contributors in the future.
We received today the second offer to "partner" with a company. This time is a hosting company that wants us to offer a hosting plan with a automatic installation of the software and receive a affiliate payout for each (the company is well-known).

The question is:
Is there a way we can share the revenue within the project contributors?

Our main goal for now is to have more contributors and make better software, not profitability...

PS: We are also in the process to assign the project to the Outercurve Foundation.

答:
Establishing in advance you will be paying contributors, and making it public, is likely to attract not-so-passionate-about-the-product fellows. I wouldn't.

Depending on your jurisdiction, it could also need some authorizations.

(I can imagine with ease some thick bloke interpreting that as a contest of sorts)

Maybe writing a check, here and there, to a couple of professional programmers very involved in the process, people you end up considering precious to the project, let's say "premium contributors",  looks safer.

Get invoices for that, (you should be able to deduce those from your earnings) and make sure they are business entities. (or that, anyway, according to your local laws, you're not accidentally becoming their employer and should be paying them social security)

Title: Open Source Project and Revenue


答:
In a perfect world, everything would be explicitly read by the author and peer reviewed by at least one other person, from requirements specs to user manuals to the test cases. But reviews, even simple desk checks, take time and cost money. This means that you need to choose what you should review and when you should review it.

I recommend prioritizing things to review, choosing how you want to review them, and trying to review as much as you can with the appropriate level of detail. Prioritiziation could be based on the type of artifact, such as stating that requirements must be reviewed, design and production code should be reviewed, and test cases can be reviewed. Within that, you can also specify that high risk or high value components receive a priority in review, or perhaps a more formal review.

As far as time, it all goes back to how high of a priority the component is. There have been times where I've spent 10-15 minutes reviewing, and other times when multiple people have read the code individually then went into a room to do a more formal inspection process that lasts 30-45 minutes (depending on the size of the module).

In the end, it's a balance between time, cost, scope, and quality. You can't have them all, so you need to optimize where you can.

Title: Should we attempt to review all our code?

Body:
We're currently modifying out development process and I'm wondering if we should try to keep a 100% of our commits peer reviewed.

What is your experience regarding code reviews?

Do you tend to spend "a lot" of time on them (say 1/2 hours per day), or just skim over for 5/10 minutes max?

Do you have a fixed amount of time to spend per day/week/sprint/project?

Most importantly do you think that the target should be for 100% of the code to be peer reviewed or that 100% is not necessary?


答:
I reserve an hour per day for doing peer reviews, but don't always require it.  Our code base is shared among a couple dozen products.  Our policy is that a trivial change in code unique to one product is  okay to check in without review.  More complex one-product changes require a review, but it might be as informal as calling a colleague to your desk to give it a once over. Changes in shared code require a more formal review, including developers on other products. I think our policy strikes a fairly good balance compared to other companies I've worked for.

I spend more time per day on reviews than some of my colleagues with less central roles, but I don't consider it an unreasonable amount of time, because before the review policy I could easily waste more time than that tracking down bugs that a developer on another product introduced.


答:
It depends.

It depends on what your software is doing:

If it controls an electronic pacemaker or a space shuttle, then definitely yes.

If it is a throwaway prototype, then probably no.

It also depends on how well resourced you are, how experienced your developers are, and what you are looking for in code reviews.  (Bear in mind that the average developer reviewing someone else's code is probably going to notice style issues and miss subtle algorithmic bugs ... especially given that code reviewing is something of a chore.)

My advice would be to save your code-review effort for code where correctness is critical and the cost of undetected errors is high.


问:
How to handle 'external' dependencies in scrum?
If you've planned a number of user stories for a sprint and one candidate story is dependent on some external provider delivering something to your team. For example an online service provider adding a new API call to their system or enabling your test account on their system or suchlike.

You know it's coming 'soon'.

Do you go ahead and add the story to the sprint hoping they'll deliver what is required in time for you to complete your story or do you wait till the next sprint, when you know it will be ready and you can start immediately even if it means not starting the story as early as you could.

If the former how do you handle 'unearned' story points lost because of the dependency?
partial credit (eek!) or take it on the chin.

答:
The team is the one that makes the commitment.  In our team, if we feel we're waiting for (for example) an external developer, we have learned to say that we're not willing to pick up the story.  The story is not in a fit state to pick up.

Theres a very good chance that the late, unexpected, or different delivery from the external resource will mean your estimates and priorities might change.

Until you have all the info, the team shouldn't be so naive to think they can complete the story.  If they say they can, then it arrives late, in an expected format, or not at all, they've let everyone down.

Sounds harsh but I want to get my point across.


答:
Ultimately it depends on whether you are 100% confident that the external provider will deliver something you can use by the time you need to use it.

If you cannot be sure that they'll deliver in time then don't add the story to the sprint. However, just because they've always delivered in the past there's no guarantee they'll deliver this time.

You should let the customer know that this dependency exists and that you are going to have to wait for the API (or whatever) to become available before you can schedule the work.

On the plus side, there may be aspects of the story you can deliver - i.e. break it down further until you've isolated the dependencies as much as possible. This might allow you do some of the story before the supplier delivers their work.

One thing you could do is to create an interface between your code and the third party API. You code to your interface so the rest of the project can proceed and until you have the real API use a mock to return example data. Then when the real API arrives you just have to change the code behind the interface which won't affect the rest of the application. Only do this if you can agree with the the API's supplier that their interface won't change (at least not drastically).

Title: How to handle 'external' dependencies in scrum?

Body:
If you've planned a number of user stories for a sprint and one candidate story is dependent on some external provider delivering something to your team. For example an online service provider adding a new API call to their system or enabling your test account on their system or suchlike.

You know it's coming 'soon'.

Do you go ahead and add the story to the sprint hoping they'll deliver what is required in time for you to complete your story or do you wait till the next sprint, when you know it will be ready and you can start immediately even if it means not starting the story as early as you could.

If the former how do you handle 'unearned' story points lost because of the dependency?
partial credit (eek!) or take it on the chin.


答:
As a suggestion, if you plan to do any reviews at all, have some shared guidelines about the review scope and goal to make sure that reviews don't cause needless frictions between team members.

Coherent teams build better projects. People might loose relationships over nonsense or over perfection requests. There is always that one person who would complain about this or that and bug others just because he is like that...


答:
We've done 100% reviews for code. It's far cheaper than testing, especially 100% code coverage testing. We don't spend too much time on them, reviewing for more than an hour per day becomes less productive. (30 minutes is not a lot).

As you're zeroing in the process, keep notes. What did you find? What did QA find later? What did your customers find? Why did those bugs escape you?


问:
Is hooking Data access method on wrong object detrimental for a developer
In a simple application I am creating there are Admin and users where admin can create users. Right now I am creating Classes that encapsulate database CRUD calls with methods.

For example: adminStore.CreateUser(userObject)

will persist that user object into the Database and return the object. I am now confused as to which DataAccess entity I need to attach methods like these. Doing them on adminStore will make them sensible in sense developer would understand that admin is creating the user and has access role. But from another perspective the below to sounds logical.

like: userStore.CreateUser(userObject);.

So my questions would somewhat sound like a Api design,Class design question but I would like to know which if the below is the right one.

1 UserStore.CreateUser(userObject)

2 AdminStore.CreateUser(userObject)

Update:
Here is what i came up with later after viewing the answers.

User { Name ,Email, Password }

Admin:User,IImplementsAdmin { FlagPost() etc etc }

AdminStore { CreateUser(), SetUserStatus() }

答:
I am not sure about your object model, but I would create a user class and an 2 other classes inheriting from user. One class would be the admin class and the other is the regular user class. A method like CreateUser would be the responsibility of the admin class that inherits from the user class. Optionally, you could choose to make the super user class an abstract class.

A side note: You need to consider here what if an admin becomes a regular user and what if regular user becomes an admin? Your model should accommodate for this.


答: Have regular code reviews mostly for team building and sharing ideas on implementation.  You can learn a lot from your coworkers this way.</p>


问:
When are Getters and Setters Justified?
Getters and setters are often criticized as being not proper OO. On the other hand, most OO code I've seen has extensive getters and setters.

When are getters and setters justified? Do you try to avoid using them? Are they overused in general?

If your favorite language has properties (mine does) then such things are also considered getters and setters for this question. They are the same thing from an OO methodology perspective. They just have nicer syntax.

Sources for Getter/Setter Criticism (some taken from comments to give them better visibility):

http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html

http://typicalprogrammer.com/?p=23

http://c2.com/cgi/wiki?AccessorsAreEvil

http://www.darronschall.com/weblog/2005/03/no-brain-getter-and-setters.cfm

http://www.adam-bien.com/roller/abien/entry/encapsulation_violation_with_getters_and

http://www.yegor256.com/2014/09/16/getters-and-setters-are-evil.html

To state the criticism simply: Getters and Setters allow you to manipulate the internal state of objects from outside of the object. This violates encapsulation. Only the object itself should care about its internal state.

And an example

Procedural version of code:

```<code>struct Fridge
{
    int cheese;
}

void go_shopping(Fridge fridge)
{
     fridge.cheese += 5;
}
</code>```

Mutator version of code:

```<code>class Fridge
{
     int cheese;

     void set_cheese(int _cheese) { cheese = _cheese; }
     int get_cheese() { return cheese; }
 }

void go_shopping(Fridge fridge)
{
     fridge.set_cheese(fridge.get_cheese() + 5);
}
</code>```

The getters and setters made the code much more complicated without affording proper encapsulation. Because the internal state is accessible to other objects we don't gain a whole lot by adding these getters and setters.

The question has been previously discussed on Stack Overflow:

https://stackoverflow.com/questions/565095/java-are-getters-and-setters-evil

https://stackoverflow.com/questions/996179

答:
whether field is accesible directly or via method is not realy important.

Class invariants (usefull ones) is important.
And to preserve them, we sometimes need to not be able to change something from outside.
Eg. if we have class Square with separete width and height, changing one of them makes it become something else than square.
So we need method changeSide
If it was Rectangle, we could have setters/public field. But setter than would test whether its greater than zero would be better.

And in concrete languages (eg. java) are reasons why we need those methods (interfaces).
And another reason for method is compatibility (source and binary). So its easier to add them then think whether public field would suffice.

btw. I like to use simple immutable value holding classes with public final fields.

Title: When are Getters and Setters Justified?


问:
Does test-driven development force me to follow SOLID?
I hear a lot from TDD practitioners that one of TDD's advantages is that it forces developers to follow SOLID principles (Single responsibility, Open-closed, Liskov substitution, Interface segregation and Dependency inversion). But as for me it is enough to just write some tests (unit test primarily) to understand it is important to follow SOLID (and thus create testable architecture).

Does TDD force developers to follow SOLID more actively than just writing unit tests?

答:
My understanding of the SOLID Principles expanded by an order of magnitude when I started doing TDD.  As soon as I started thinking about how to mock dependencies I realized virtually every component in the code base had a potential alternate implementation.  And how much easier it is to test a simple public API.

It also provided a much stronger understanding of most design patterns.  Especially the Strategy Pattern.


答:
An issue more important that how much over your code is covered by reviews, is how effective are the reviews. If your reviews discover few or no issues, then reaching full coverage will be useless.

First work on making your reviews more effect, then decide on the coverage.

Reviews should be performed not only on code, but also on design.

Also, reviews are no replacement for tests and tools:

Reviews can dry run code

Reviews can include code analysis

Reviews examine reuse and readability

Reviews can examine some aspects of efficiency, however, this does not replace actual measurement of run time and finding of bottle necks

There are tools for static code analysis

There are tools for testing coding conventions, don't waste review time on this

Unit, system and integration tests wet run code

Unit, system and integration tests test can be repeated automatically, code reviews are usually one-offs

Unit tests should have high code coverage and test both main success scenarios and end conditions, code reviews can only partially do this

Integration tests test the ability of units or systems to work together, code review can not replace this

System tests test functionality of an entire system, code review can not replace this

Try dedicating a preset amount of time per month (or per sprint) for reviews.
Select the code you want to review at the next dedicated slot using a heuristic such as:

Code that may contain an unidentified bug that was reported

Code with that recently has had  bugs identified within it

Code with performance issues (bottle necks)

Code written by new developers

Legacy code that was recently updated by someone that was not previously familiar with it

Code in new areas

Existing code that you want new developers to learn about

Code that solves complex issues

Code that was identified as complex by analysis tools

And remember, you are reviewing code (or design or tests) and not authors.

I recommend the following reading materials:

Selective Homeworkless Reviews

Best Kept Secrets of Peer Code Review


问:
When can you call yourself good at language X?
This goes back to a conversation I've had with my girlfriend. I tried to tell her that I simply don't feel adequate enough in my programming language (C++) to call myself good. She then asked me, "Well, when do you consider yourself good enough?"

That's an interesting question. I didn't know what to tell her. So I'm asking you.

For any programming language, framework or the like, when do you reach a point were you sit back, look at what you've done and say, "Hey, I'm actually pretty good at this."? How do you define "good" so that you can tell others, honestly, "Yeah, I'm good at X".

Additionally, do you reach these conclusions by comparing what others can do?

Additional Info

I have read the canonical paper on how it takes ten-thousand hours before you are an expert on the field. (Props to anybody that knows what this paper is called again)

I have also read various articles from Coding Horror about interviewing people. Some people, it was said, "Cannot function outside of a framework." So they may be "good" for that framework, but not otherwise in the language. Is this true?

答:
Since there is no standardized programming test that you can take that will allow everyone to agree that you are a good programmer, it's up to you to determine whether you call your self that or not.

I find that it has to do with your confidence level.  If you FEEL you are good at something then you should be able to say it.  At somepoint you'll complete a project that pushed you and that feeling will change from 'not yet' to 'I am'.


问:
In C++, how much programmer time is spent doing memory management
People who are used to garbage collected languages are often scared of C++'s memory management. There are tools, like auto_ptr and shared_ptr which will handle many of the memory management tasks for you. Lots of C++ libraries predate those tools, and have their own way to handle the memory management tasks.

How much time do you spend on memory management tasks?

I suspect that it is highly dependent on the set of libraries you use, so please say which ones your answer applies to, and if they make it better or worse.

答: I use boost and TR1 libraries a lot, and they make memory management in the strict sense (new/delete) a non-issue. On the other hand, memory allocation in C++ is not cheap, and one must pay attention to where these fancy shared pointers are created. You end up using workspaces a lot, or working with stack-based memory. In general, I'd say that it's mostly a design problem, not an implementation problem.</p>


答:
Pretty much none. Even old technologies like COM, you can write custom deleters for the Standard pointers that will convert them in a very short time. For example, std::unique_ptr can be converted to uniquely hold a COM reference with five lines of a custom deleter. Even if you have to manually write your own resource handler, the prevalence of knowledge like SRP and copy-and-swap makes it relatively easy to write a resource managing class to use forever more.

The reality is that shared, unique, and non ownership all ship with your C++11 compiler, and you just have to write small adapters to make them work even with old code.

Title: In C++, how much programmer time is spent doing memory management

Body:
People who are used to garbage collected languages are often scared of C++'s memory management. There are tools, like auto_ptr and shared_ptr which will handle many of the memory management tasks for you. Lots of C++ libraries predate those tools, and have their own way to handle the memory management tasks.

How much time do you spend on memory management tasks?

I suspect that it is highly dependent on the set of libraries you use, so please say which ones your answer applies to, and if they make it better or worse.


答:
Modern C++ makes you not worry about memory management until you have to, that is until you need to organize your memory by hand, mostly for optimization purpose, or if the context forces you to do it (think big-constraints hardware). I've written whole games without manipulating raw memory, only worriing about using containers that are the right tool for the job, like in any language.

So it depends on the project but most of the time it's not memory management that you have to handle but only object life-time. That is solved using smart pointers, that is one of idiomatic C++ tool resulting from RAII.

Once you understand RAII, memory management will not be a problem.

Then when you'll need to access raw memory, you'll do it in very specific, localized and identifiable code, like in pool object implementations, not "everywhere".

Outside of this kind of code, you'll not need to manipulate memory, only objects lifetime.

The "hard" part is to understand RAII.


问:
What was SOAP invented for?
This question is inspired by this one. What was the initial goal of inventing SOAP? Why was it invented when we had old kind HTTP and REST?</p>

答:
From Wikipedia:

SOAP, originally defined as Simple Object Access Protocol, is a protocol specification for exchanging structured information in the implementation of Web Services in computer networks. ... SOAP has three major characteristics: Extensibility (security and WS-routing are among the extensions under development), Neutrality (SOAP can be used over any transport protocol such as HTTP, SMTP or even TCP), and Independence (SOAP allows for any programming model).

SOAP is not limited to HTTP and provides for security right out of the box.

If you're using HTTP and you don't need security (your web service is open to the public), then you don't need SOAP.

Title: What was SOAP invented for?


问:
What should I do if Scrum member leave half way?
Due to health condition of one of the scrum member, he has to leave the team.

My question is, do I need to start a sprint planning session again? or change the burn-down chart? or ask all the team members to bite the bullet and do extra work to meet the target?

Thanks

答:
As a team member or scrum master do nothing except informing product owner about the situation. Your team already made a commitment to some amount of user stories based on some expected capacity. Something bad happened and one of your team members cannot continue in sprint due to health condition. That can happen and nobody can blame him or you for that.

It is up to product owner to decide what to do next. It is obvious that you will most likely not deliver what you committed. Product owner can let the sprint continue as is so that you complete as many user stories as you can without missing team member and unreasonable overtime or she can decide to stop the sprint and start a new one - but it would be quite drastic.

Descoping is dangerous. Sprint should be a safe zone for the team. It is part of agile principles to empower people. Team is empowered to make a commitment. Once you allow commitment changing during sprint it can soon become a common practice and the whole point of commitment and safe zone will disappear. You will get chaos with continuously changing sprint target.


答:
Memory management is used to scare children, but it is only one kind of resource that a programmer has to look after. Think file handles, network connections, other resources that you obtain from the OS.

The languages that support garbage collection usually not only ignore the existence of these resources, but they also make it harder to handle these properly by not providing a destructor.

So, in short, I'd suggest not that much of a C++ developer's time is spent worrying about memory management. As klaim's answer indicates, once you get a handle on RAII, the rest is just reflex.


答:
If you are waiting for something you don't know yet than you cannot plan it even if you are 100% sure that it will be delivered tomorrow. Why? Because if you don't know it you cannot even estimate its complexity and if you cannot estimate it you cannot plan it.

If you defined some "interface" / "contract" upfront which must be followed by external company you can plan it and create service mock on your side. Your development will use the mocked service so they will not be dependent on external delivery. Still development with mock should be planned for sprint where real service will be delivered because feature developed and tested against mock is not completed - it must be tested with the real service to be considered as completed at the end of the sprint.


问:
Name for WS pattern where a generic object is returned?
Two part question:

I am working on a project where the webservices all return a generic object. On success, that object then contains the data returned from the webservice along with additional information such as status messages or qualifiers. On failure, the object contains no data and error messages. What is the name for this pattern?

When I think that something I am working on is a common pattern and has a name, what strategies can I use to learn what that name is? I frequently see things that look familiar or common and suspect they have a name and are a common pattern. How can I find those on my own without asking StackExchange?

答:
[...] What is the name for this pattern?

None. Returning value that have meaning for the rest of the code is what every function returning value does, in any language.

2, First, read the Design Patterns book to get the names commonly used. Most of the time any recurring solution you've seen will be an implementation of one or a combination of several of those patterns. After that, if you can't find what name should be used for a pattern, find an analogy to name it yourself. Use it until you discover the name commonly used, if it exists.


答:
how much time does it take as a client? very little, once you get the hang of it. when a container manages lifetime and references, it's really very easy. imo, it's far simpler than manual reference counting, and it's practically transparent if you consider the container you use as documentation which the compiler conveniently prevents you from performing invalid ownership transfers in a well designed typesafe system.

most of the time i spend (as a client) is spent containing types from other apis, so they function well within the context of your programs. example: this is my ThirdPartyFont container, and it supports these features, and implements destruction this way, and reference counting this way, and copying this way, and.... Many of those constructs need to be in place, and it's often the logical place to put them. whether you want to include that as time or not depends on your definition (the implementation needs to exist when interfacing with these apis, anyway, right?).

after that, you will need to take memory and ownership into consideration. in a lower level system, that's good and necessary, but it can take some time and scaffolding to implement how you should move things around. i don't see it as a pain since this is a requirement of a lower level system. ownership, control, and responsibility are evident.

so we can turn that towards c based apis which use opaque types: our containers allow us to abstract all the little implementation details of managing the lifetime and copying of those opaque types, which ultimately makes resource management very very simple and saves time, defects, and reduces implementations.

it's really very simple to use these - the problem (coming from GC) is that you have to now consider your resources' lifetimes. if you get it wrong, it can take a lot of time to solve. learning and integrating explicit lifetime management is understandably complex in comparison (not for all people) -- that's the real hurdle. once you are comfortable controlling lifetimes and using good solutions, then it's really very easy to manage resource lifetimes. it's not a significant part of my day (unless a difficult bug has crept in).

if you're not using containers (auto/shared pointer), then you're just pleading for pain.

i've implemented my own libraries. it takes me time to implement those things, but most people reuse (which is usually a good idea).


问:
Is there a pattern for subscribing to fired events/messages at specific intervals?
I'm not sure if this a common scenario or not, but I have a need along the following lines:

I have an object (I'll call it node) and this object has methods X, Y, and Z. I want to be able to have subscribers be notified if the methods are called in a specific order with specific timing (a range of time would be ideal). For instance:

Node.X() get called

Node.Z() is called 5 to 7 milliseconds  latter

Node.X() is called 1 to 2 milliseconds after that

Node.Y() is called 2 milliseconds seconds after that.

Finally, An event calling a subscriber to this sequence is fired.

Now, in this example I am simply using parameter-less methods, but in real life I'd need to be more specific about the contents of the parameters (I'd be looking for specific messages).

For reference I am using C# .net 4.

Are there any frameworks/patterns/libraries that exist out there that are built for doing this?

答:
I don't know of a framework or a library that can handle this out of the box, but one solution to your problem is implementing a finite state machine for event generation. As your example suggests, the FSM has 5 states. The transitions from i to i+1 are your conditions on your list. Every time a node function is called, you can pass in the event to the FSM, and it can check if the condition for state i is satisfied, and adjust state accordingly (condition holds => go to state i+1; else go to state 1). If you reach state 5, emit an event, and go back to state 1.

For example, if you are on state 3, and you receive EVENT_X_CALLED, then you check the current time, and compare it against transition time. If it is 1 to 2 ms apart, change state to 4. If not, go back to state 1.


答:
When I was a C++ programmer (a long time ago), I spent a long time worry about memory management bug when trying to fix hard to reproduce bugs.

With modem C++, memory management is a lot less of an issue, but can you trust everyone on a large team to get it right.   What is the cost/time of:

Training (not many programers arive with a good understanding of the issues)

Code reviews to find memory management issues

Debugging of memory management issues

Always having to keep in mind that a bug in one part of the app, may be due to a memory management issue in a unrelated part of the app.

So it is not just the time spending “doing”, this is more of an issue on large projects.


问:
Is it better to use pre-existing bad practices, or good practices that don't fit well with old code?
I was thinking of this because I was trying to write an extension for an existing 3rd party software, and their database is horribly denormalized. I needed to use their existing tables and add a bunch of new fields.

I had the option of either creating new tables in their design style (which consists of almost all the propeties being in one big table), or creating a new set of tables alltogether and using something extra such as Triggers to synchronize data between the new and old tables.

I ended up going with the first option of using the existing poor design style, but I was left with this question: Is it better to go with pre-existing bad practices, or to implement good practices that do not play nicely with existing code? Is there some situations where I should choose one over the other?

NOTE: Many answers so far have to do with slowly refactoring the bad code, however I am unable to do that. The code is not ours, and it frequently gets updated by the vendor. I can only build onto it.

答: Good practices always trump poor ones.  If your codebase is littered with code the wrong way, you shouldn't just cargo-cult your own stuff in the same fashion, you should write code properly and then try to educate everyone else on the correct way.


答:
I have used Microsoft PRISM's EventAggregator or MVVM Light's Messenger for message systems like this, and I would assume you'd have a class that subscribes to all 3 events and routes them to the same method.

In that method, check the message and see if it is the first type that handler is interested in. If yes, set a flag and a timer (optional) and wait for the next one. When you receive the 2nd event, check if the last received event was Event1 and if so set last received Event to Event2 and reset timer again. Repeat until you get all your events, and then process.

Here's a rough example:

```<code>public MyClassConstructor()
{
    eventAggregator.Subscribe<EventX>(ProcessEvents);
    eventAggregator.Subscribe<EventY>(ProcessEvents);
    eventAggregator.Subscribe<EventZ>(ProcessEvents);
}

private int eventCount = 0;
void ProcessEvents(object e)
{
    if ((e is EventX && eventCount == 0)
        || (e is EventZ && eventCount == 1)
        || (e is EventX && eventCount == 2)
    {
        eventCount++;
        // optionally start/reset timer which sets eventCount = 0
    }
    else if (e is EventY && eventCount == 3)
    {
        // Execute code
        eventCount = 0;
    }
}
</code>```

Each Node.Method would be responsible for firing off an event message with parameters based on which method got executed

```<code>eventAggregator.Publish<EventX>(new EventX(params));
</code>```

Title: Is there a pattern for subscribing to fired events/messages at specific intervals?

Body:
I'm not sure if this a common scenario or not, but I have a need along the following lines:

I have an object (I'll call it node) and this object has methods X, Y, and Z. I want to be able to have subscribers be notified if the methods are called in a specific order with specific timing (a range of time would be ideal). For instance:

Node.X() get called

Node.Z() is called 5 to 7 milliseconds  latter

Node.X() is called 1 to 2 milliseconds after that

Node.Y() is called 2 milliseconds seconds after that.

Finally, An event calling a subscriber to this sequence is fired.

Now, in this example I am simply using parameter-less methods, but in real life I'd need to be more specific about the contents of the parameters (I'd be looking for specific messages).

For reference I am using C# .net 4.

Are there any frameworks/patterns/libraries that exist out there that are built for doing this?

Body:
I have used Microsoft PRISM's EventAggregator or MVVM Light's Messenger for message systems like this, and I would assume you'd have a class that subscribes to all 3 events and routes them to the same method.

In that method, check the message and see if it is the first type that handler is interested in. If yes, set a flag and a timer (optional) and wait for the next one. When you receive the 2nd event, check if the last received event was Event1 and if so set last received Event to Event2 and reset timer again. Repeat until you get all your events, and then process.

Here's a rough example:

public MyClassConstructor()
{
    eventAggregator.Subscribe<EventX>(ProcessEvents);
    eventAggregator.Subscribe<EventY>(ProcessEvents);
    eventAggregator.Subscribe<EventZ>(ProcessEvents);
}

private int eventCount = 0;
void ProcessEvents(object e)
{
    if ((e is EventX && eventCount == 0)
        || (e is EventZ && eventCount == 1)
        || (e is EventX && eventCount == 2)
    {
        eventCount++;
        // optionally start/reset timer which sets eventCount = 0
    }
    else if (e is EventY && eventCount == 3)
    {
        // Execute code
        eventCount = 0;
    }
}

Each Node.Method would be responsible for firing off an event message with parameters based on which method got executed

eventAggregator.Publish<EventX>(new EventX(params));


答:
Realize that scrum has velocity to help manage that.

My understanding is that your velocity will adjust to the new team over time. Certain places even allow to estimate a decrease in velocity, to help better manage when team members either leave, or even just go on vacation.

Title: What should I do if Scrum member leave half way?

Body:
Due to health condition of one of the scrum member, he has to leave the team.

My question is, do I need to start a sprint planning session again? or change the burn-down chart? or ask all the team members to bite the bullet and do extra work to meet the target?

Thanks


问:
Should I use chained functions in Java?
From time to time, I'll have a class in Java that takes a multitude of parameters, however, sometimes when I am creating an object of this class, I don't need to use all the parameters.  As of now, I usually set the parameters to null or 0 depending on the type.  However, would it be easier if I just created chained methods to set certain fields in the class?

So, instead of:

MyClass someInstance = new MyClass(param0, null, null, 0, null, param5);

Have something like this:

MyClass someInstance = (new MyClass()).setParam0(param0).setParam5(param5);

Does this go against OOP or Java's usual paradigm?

答:
This is the perfect place for the Builder Pattern.</p>

```<code>MyClass someInstance = (new MyClassBuilder())
    .setParam0(param0)
    .setParam5(param5)
    .build();
</code>```

Title: Should I use chained functions in Java?

Body:
This is the perfect place for the Builder Pattern.

MyClass someInstance = (new MyClassBuilder())
    .setParam0(param0)
    .setParam5(param5)
    .build();


答:
Doing them on adminStore will make them sensible in sense developer would understand that admin is creating the user and has access role.

The business policy has little to do with these design decisions.  Policies change frequently.  Just avoid creating circular dependencies and it will work out.  For example, if createUser calls methods in AdminStore, and AdminStore is already dependent on UserStore, then put the method in AdminStore.  If createUser has no dependency on AdminStore, or if UserStore already depends on AdminStore, then put the method in UserStore.

I have found that writing the code test-first leads me to a workable design almost automatically.  If I wrote a unit test for createUser, and didn't need to instantiate AdminStore to define the test, that would be a strong sign that the createUser belongs in UserStore and not AdminStore.

Don't dwell too long on these little design decisions.  Just pick one, and get back to work.  Later you may see that it would be better the other way.  No problem.  It's just code.  Change it.

When you see a beautifully designed application or library, it is almost certainly the result of a lot of refactoring, and not the result of some brilliant initial design.

Title: Is hooking Data access method on wrong object detrimental for a developer

Body:
In a simple application I am creating there are Admin and users where admin can create users. Right now I am creating Classes that encapsulate database CRUD calls with methods.

For example: adminStore.CreateUser(userObject)

will persist that user object into the Database and return the object. I am now confused as to which DataAccess entity I need to attach methods like these. Doing them on adminStore will make them sensible in sense developer would understand that admin is creating the user and has access role. But from another perspective the below to sounds logical.

like: userStore.CreateUser(userObject);.

So my questions would somewhat sound like a Api design,Class design question but I would like to know which if the below is the right one.

1 UserStore.CreateUser(userObject)

2 AdminStore.CreateUser(userObject)

Update:
Here is what i came up with later after viewing the answers.

User { Name ,Email, Password }

Admin:User,IImplementsAdmin { FlagPost() etc etc }

AdminStore { CreateUser(), SetUserStatus() }


答:
while it's not particularly uncommon to see the chains...

the chained methods approach (to me) suggests that you are dealing with a class that is a data blob where all/most fields/members are publicly accessible and mutable, and that there really is no separation of members and interface (e.g. little substance beyond public accessors). these classes tend not to manage their dependencies correctly, and when they do, it is often quite costly compared to initialization proper. the abstractions are also likely to be weak.

at that point, the class has really meandered from good OOD because they have typically violated multiple OOD principles/concepts.

Title: Should I use chained functions in Java?

Body:
From time to time, I'll have a class in Java that takes a multitude of parameters, however, sometimes when I am creating an object of this class, I don't need to use all the parameters.  As of now, I usually set the parameters to null or 0 depending on the type.  However, would it be easier if I just created chained methods to set certain fields in the class?

So, instead of:

MyClass someInstance = new MyClass(param0, null, null, 0, null, param5);

Have something like this:

MyClass someInstance = (new MyClass()).setParam0(param0).setParam5(param5);

Does this go against OOP or Java's usual paradigm?


问:
Is @staticmethod proliferation a code smell?
Consider a Python class with a number of @staticmethod methods and few instance methods. The static methods don't accept an instance of the defining class as parameters.

Do you think that all these static methods don't belong to the class and should be factored out?

If yes, which approach would you take to clean up such code?

答: Sounds like a module masquerading as a class (which is common to see in a language like Java where there are no methods outside of classes, so the only way to make something that looks like a module is to make a static only class).  If the static methods are doing something that's actually related to the class as a whole, such as managing a pool of them, generating them (factories) or something along those lines then yes, they might be legitimate static methods.  Otherwise, they probably should just be module level methods.</p>


问:
Should we attempt to review all our code?
We're currently modifying out development process and I'm wondering if we should try to keep a 100% of our commits peer reviewed.

What is your experience regarding code reviews?

Do you tend to spend "a lot" of time on them (say 1/2 hours per day), or just skim over for 5/10 minutes max?

Do you have a fixed amount of time to spend per day/week/sprint/project?

Most importantly do you think that the target should be for 100% of the code to be peer reviewed or that 100% is not necessary?

答:
We require a peer code review for every check-in.  If no peer is available we arrange for a post check-in review. The reviewer is noted in the source control check-in comment.

These don't take a lot of time, and since they are done between peers there is no toxic adult-child aspect to them.


答:
This time is a hosting company that wants us to offer a hosting plan with a automatic installation of the software and receive a affiliate payout for each (the company is well-known).

Be careful.  Well-known is not the same as ethical.  Some well-known hosting companies have recently changed their business model, and are wrapping open-source downloads in adware installers.  If you object to adware, make sure you do not end up supporting it.

Title: Open Source Project and Revenue

Body:
I started an open source project in 2010 and the project is gaining some visibility. We are now 2 active committers and we hope to engage more contributors in the future.
We received today the second offer to "partner" with a company. This time is a hosting company that wants us to offer a hosting plan with a automatic installation of the software and receive a affiliate payout for each (the company is well-known).

The question is:
Is there a way we can share the revenue within the project contributors?

Our main goal for now is to have more contributors and make better software, not profitability...

PS: We are also in the process to assign the project to the Outercurve Foundation.


答:
.NET (and ultimately, out of the box Windows) may not be your best option for this.

All events are going to have a significant amount of wiggle room as to when they are addressed by the operating system this SO thread goes into a bit of the background.


答:
First, you need to answer this question:  Why do you review code?

With that answer in hand, you can figure out which code needs to be reviewed.

Some code reviews accomplishes exactly what testing does or would have done.  If that is the goal of your reviews, then getting closer to 100% is a good idea if you have little testing.  However, letting test tools do this would reduce the need for all of the code to be reviewed.

Most good reviews seem to be focused on sharing knowledge and increasing the capabilities of the developers in the review (either the one who wrote the code or the ones reviewing the code).  With this as a primary reason for reviews, making sure to review 100% of the code is probably overkill.


问:
Why is software still released with known bugs?
It seems that frequently in large projects the software is still released with the bug tracker full of bugs. Now I can understand feature requests, but several times I've seen large numbers of bugs still unresolved, not reviewed, or not finished but a release is still pushed out.

Why? Why would an open source project or a project in general be released with known bugs? Why wouldn't they wait until the bug tracker had 0 opened bugs?

答: Ultimately, it's a business decision, even for free and open source software. There's a point where the defects that exist are of a low impact that it's better to release, get your software into the hands of the user, and get feedback (including, but not limited to, feature requests and new bug reports of defects not found in testing). This decision is driven by the need to get traction in the market for the software among competitors. If you want your software to make an impact, you need to beat your competitors to market with new features or concepts.</p>


答: These bugs may be pretty minor. Remember that commercial software needs to be shipped, and pressed on discs, and such things. Meeting those release dates has serious financial implications, and delaying for some minor issues is not financial sense- not to mention the need to get to market for other reasons.</p>

Title: Why is software still released with known bugs?

Body:
It seems that frequently in large projects the software is still released with the bug tracker full of bugs. Now I can understand feature requests, but several times I've seen large numbers of bugs still unresolved, not reviewed, or not finished but a release is still pushed out.

Why? Why would an open source project or a project in general be released with known bugs? Why wouldn't they wait until the bug tracker had 0 opened bugs?


答:
Any number of reasons, including:

Company had made commitment to user base to release at a particular time

Bugs were not mission-critical, or even major

New feature development was viewed as more important (whether correctly or not)

To a small extent, this is like asking why you work as a programmer even though your programming knowledge isn't "complete". In most complex projects, there will be many, many bugs. Dealing with them while adding new features is a difficult, complex task.


答:
everything boils down to cost vs. benefit analysis. Each bug fix has some cost value associated with it (man hours to fix, risk of making more code changes X days before release...).  At the same time, each bug fix clearly brings additional value in terms of more features, usability, etc.

So this the question every development team faces when making a release: 1) is Bug #i is worth fixing given the cost and additional value and 2) repeat for all open bugs from i = 0 to N.

Keep in mind that a software product that is not released has NO value to anyone.  Software product that has 200 outstanding bugs but has 90% of its functionality working, has value to all the people who are happy with what works at the time of the release.

I've never in any company on any product that was released with 0 bugs and I think that's perfectly normal. At some point, you just cut your losses and capitalize on what works.  Otherwise, you'll never release anything.


答:
Potential answers:

It is highly unlikely for anyone to encounter the bug.

There are workarounds for the bugs.

The software needs to be released sometime, and perfection is unlikely to be achieved.


答:
I'm sure ideally most developers would like to see zero bugs in their applications, sadly conditions may not allow for such a state of utopia.

I would like to believe it's because the user base demands new features and are willing to take onboard the same or more bugs for added functionality.

If there's management involved, deadlines need to be met for a range of reasons - advertising schedules, additional staff availability issues, the "we-must-be-the-first-with-this-functionality" mindset.

Less optimistic in my mind, possibly because the developers are lazy?

Also remember that in open-source communities it's typically "whom" wants to take on what bug/feature/issue requests - perhaps no one wishes to deal with the problems that are present due to larger issues behind them.


答: In addition to the many good answers, sometimes there is a race to market with a new product. If you think you can gain the majority of market share even with 15% (or some other number) of non-critical defects open, it might be worth releasing the product to get an edge on the competitors.</p>


答:
In a large project, you never stop finding bugs.  If you had to wait until all bugs were fixed and the fixes regression tested, you would never release.

Also, note that not all bugs are internal.  Every program is part of a complex web of other software, and changes elsewhere can manifest themselves as "bugs" in your software.  You can't stop the world.


答:
Because a software with a bug is better than no software at all.

For the same reason:

Transportation companies bother making schedules, even though there's always delay.

Pharmaceutical companies sell medication with known (and mostly documented) side-effects.

Schools all over the world teach Newtonian physics, although it has known limitations.

Having a solution with known deficiencies is much better than having no solution, or having a solution with unknown deficiencies.

My favourite IDE has a lot of fresh features, that are far from stable. Let's just say: I prefer, having to do something by hand every twentieth time, because the feature fails, rather than having to do it all by hand.

Or to say it with the words of Voltaire: "Le mieux est l'ennemi du bien."


答:
In the simplest programmatic test:

```<code>if (management->perceived_cost_to_fix > management->perceived_benefit_release_now) {
    release;
}
</code>```

Everything is always a trade-off, whether it be fixing bugs, time / space / memory, or security / usability. Think about the tradeoff calculation that was done. You may disagree with it, but you're in trouble if you don't understand it.

Also, think about those calculations in a bell curve... some people will make really bad ones to either side. See Duke Nukem Forever for one end of the curve.

Body:
In the simplest programmatic test:

if (management->perceived_cost_to_fix > management->perceived_benefit_release_now) {
    release;
}

Everything is always a trade-off, whether it be fixing bugs, time / space / memory, or security / usability. Think about the tradeoff calculation that was done. You may disagree with it, but you're in trouble if you don't understand it.

Also, think about those calculations in a bell curve... some people will make really bad ones to either side. See Duke Nukem Forever for one end of the curve.


答:
SOAP is a messaging protocol, which was created for the same reason any other messaging protocol has been created; to standardize the way in which object information is passed around. As the Wikipedia page states, it originated at Microsoft, and is now an open standard maintained by the W3C.

The better question is why to choose between SOAP or some XML-flavored scheme or JSON or whatever, and the answer comes down to use whatever's easiest/most practical in your particular situation.

Title: What was SOAP invented for?

Body: This question is inspired by this one. What was the initial goal of inventing SOAP? Why was it invented when we had old kind HTTP and REST?</p>


问:
Alternatives to *documents* in the SDLC?
Since no one prints anything any more, the concept of actual project documents (meaning, a monolithic piece of formatted text) seems like it could be improved on. Problems with documents are things like Word version incompatibilities, endless messing around with templates, the fact people hate reading them...

I'm wondering if there are alternatives, like websites that would help manage the content, imposing some structure, but allowing things like linking to individual bits. But I guess the site would have to be able to spit out a "document" for the times it's needed (filing, showing sponsors who ask, etc)

For example, instead of a "project plan document", I'm imagining a project planning site where you can work on just the resourcing with relevant people, then you work on scheduling with other relevant people, and work packages with other relevant people.

Instead of an SRS document, some site that lets you manage requirements, assigning priorities, phases etc...but that could ultimately generate an actual SRS document if you needed it.

Thoughts? The context here is small, agile teams but with occasional need to produce documents to demonstrate progress. We're certainly not big enough to warrant anything like Rational or whatever they use these days in big companies.

答:
Since the target is small agile teams...

Favor formats which promote living documents.  Printed documents aren't going away, the trick is to identify what needs to be printed and what doesn't so you spend your energy formalizing the right artifacts.

There are several tools that help with this.  Two of the best are Wiki and SharePoint.  MediaWiki can even export a PDF created from specific pages which can be used with stakeholders or for archiving snapshots.  I've also had clients that preferred using hyperlinked reports that were exported directly from MediaWiki.  All we had to do was create an index.html title page which provided an entry point into the report.

You might also take advantage of lightweight "oral history" practices.  Some examples of these types of practices include...

Whiteboards - great for informal information radiators built on-the-fly

Sticky notes

Big sheets of paper

Also keep an eye out for practices such as the Refreshed System Metaphor and Architecture Haiku which encourage you to capture the essence of what is needed.

In each of these examples, you could take a picture or make a video to upload to your Wiki or hold in SharePoint.


问:
How to save images into files in a web application and avoid removing them with every build?
I am building a web application and users will be able to upload pics. And I want to store these images into files instead of storing them into the DB.

But if I saved these pics into relative paths to the web application, they will be removed with each build.

So how I can handle this and the best practices related to this issue.

答: Do both -- store them in a database initially. Cache them onto disk when requested. You get the best of both worlds -- easy transportable backup with scaleable distribution.</p>


问:
How much does/should your style imply about your skill in a language?
Two things I've noticed in the past week that make me wonder:

An interview where my Perl skills were reviewed. I always use C-style for loops and use map about once in every 10,000 lines of code, so I almost always have to reference it before using it. While I can interpret others code using that, it's not my style and that is for reasons involving readability and ease of changing between languages. I at least perceived that I was dinged for that.

This answer to my question in which the answerer proceeded to refactor and bullet-proof my tiny script. I admit I was a little bit offended and kind of annoyed at that, though I can understand how that as a habit may be helpful.

I understand that in a team, my style will need to adapt what the team has decided is correct -- this is necessary in every project and everybody has their own ideas. Yet I feel like I'm judged for what is syntactically fine and readable code.

How much does the style of your smaller snippet code weigh in? Does code like that imply to others that I don't have control of the language because I didn't use all the features? Does my code imply that I'm not familiar with unit testing and proper testing because I didn't fully error-protect a tiny script?

答:
I don't think the particular style matters in an interview code question, but it is good to see that you have one and are aware of why you do things the way you do it. </p>

<p>Based on your question, it sounds like you may not have reacted favorably to the criticism. You say you realize your style will need to adapt, but you may not have given that impression. Do you think you were defensive? That can be interpreted as unwilling to change. </p>

Body:
I don't think the particular style matters in an interview code question, but it is good to see that you have one and are aware of why you do things the way you do it.

Based on your question, it sounds like you may not have reacted favorably to the criticism. You say you realize your style will need to adapt, but you may not have given that impression. Do you think you were defensive? That can be interpreted as unwilling to change.


答:
Most popular modern languages have a similar syntax (with small tweaks here and there). But each language has its own very unique style of being used. This style has usually developed over many years and is result of how the language works underneath combined with the experience of users to avoid nasty problems in the language.

When most developers migrate from one language to another they take the style of their favorite language with them and try and apply it to the new language. Now this is fine while you are learning (as you have no other reference to go by). I am not good at perl so I write perl like C++ (with a few tweaks (but I recognize my perl is not good)). I see Java developers try and use C++ like Java and it makes a complete mess of the code (because it does not fit well).

But in the long term this is a bad approach. The language has a particular style for a reason and it is best to try and understand this and learn the style for that language. It makes the learning curve steeper (and you may fall back to your old style now and then to get things done) but in the long term it will definitely be advantageous to learn the correct style for the language.

Reason to learn the correct language style:

Integrate with existing code better

Avoid pitfalls of the language that are not obvious

Allow other users to easily understand your code

You can always work it out but reading code that is styled differently to what you expect is a lot harder work than reading it the style you expect.

Title: How much does/should your style imply about your skill in a language?

Body:
Two things I've noticed in the past week that make me wonder:

An interview where my Perl skills were reviewed. I always use C-style for loops and use map about once in every 10,000 lines of code, so I almost always have to reference it before using it. While I can interpret others code using that, it's not my style and that is for reasons involving readability and ease of changing between languages. I at least perceived that I was dinged for that.

This answer to my question in which the answerer proceeded to refactor and bullet-proof my tiny script. I admit I was a little bit offended and kind of annoyed at that, though I can understand how that as a habit may be helpful.

I understand that in a team, my style will need to adapt what the team has decided is correct -- this is necessary in every project and everybody has their own ideas. Yet I feel like I'm judged for what is syntactically fine and readable code.

How much does the style of your smaller snippet code weigh in? Does code like that imply to others that I don't have control of the language because I didn't use all the features? Does my code imply that I'm not familiar with unit testing and proper testing because I didn't fully error-protect a tiny script?


问:
Does teaching programming make you a better programmer
I consider myself an intermediate Python programmer and have been offered an opportunity to be a trainer for a beginner Python programming class.

I was wondering if this would really widen my programming repertoire. Has somebody had an enlightening experience after they successfully trained a group of people?

Does it also depend on those people -- whether they're programmers or noob students? (In my case they are intermediate .NET and Java programmers)

What should I expect from them?

One of my fears is -- what if I choked when one of them asked a tangled question. Is this normal?

答:
YES!

Louis E. Frenzel wrote about exactly this a few years ago:

Write a paper or article or teach what you have learned. You have to know it to write it or teach it. There's no better way to learn for yourself than to have to explain it to others.


问:
One-week release cycle: how do I make this feasible?
At my company (3-yr-old web industry startup), we have frequent problems with the product team saying "aaaah this is a crisis patch it now!" (doesn't everybody?)

This has an impact on the productivity (and morale) of engineering staff, self included.  Management has spent some time thinking about how to reduce the frequency of these same-day requests and has come up with the solution that we are going to have a release every week.  (Previously we'd been doing one every two weeks, which usually slipped by a couple of days or so.)

There are 13 developers and 6 local / 9 offshore testers; the theory is that only 4 developers (and all testers) will work on even-numbered releases, unless a piece of work comes up that really requires some specific expertise from one of the other devs.  Each cycle will contain two days of dev work and two days of QA work (plus 1 day of scoping / triage / ...).

My questions are:

(a) Does anyone have experience with this length of release cycle?

(b) Has anyone heard of this length of release cycle even being attempted?

(c) If (a) or (b), how on Earth do you make it work?  (Any pitfalls to avoid, etc., are also appreciated.)

(d) How can we minimize the damage if this effort fails?

答:
You can certainly deliver every week - or even more frequently. At the moment we generally release every two weeks, but it isn't unusual to deploy functionality when something has arrived with no notice from one of our partners that would be irrelevant if we waited for the next cycle. At some point in the next few months I'd like us to move to continuous delivery (items are released as soon as is practical once they're 'done') as standard, but we're not quite confident enough yet to go that far.

The critical thing is you need your website strongly covered by automated tests - both unit tests and end-to-end acceptance tests/executable specifications. By implication this also means that your build is fully automated. At the acceptance level we use Robot Framework which is excellent for quickly building up a maintainable test suite thanks to it's keyword approach. For look and feel our onsite tester makes some cursory checks, but we also have a couple of guys in India who do a more thorough check across different browsers (there are sites which help with this sort of thing by taking screenshots for you, e.g. BrowserLab).

We don't fully automate the deployment (the very final step requires manual intervention, this is a concious decision for us) - but we do automate all the things like ensuring that the correct database connections are being used, etc, with short deployment cycles it'd be too easy to make a mistake with this sort of thing.

There's a pretty good recentish book on continuous delivery that you might want to check out, I've skimmed it but not gone through it in detail yet. What I've read so far chimes well with our experiences though: Continuous Delivery: Reliable Software Releases through Build, Test, and Deployment Automation

In summary you need a highly disciplined team, a high level of automation and - most important of all - an extremely high degree of trust in that automation. To me it seems that moving to weekly cycles in your case may be a mistake - crisis patches hint at other issues and you should work to eliminate those. Upping the tempo could potential make the situation worse...


答: In my opinion SOAP is another take at RPC. Just take a look at how do you expose WebService these days. One party marks method as WebService and the other just fetches WSDL and uses remote methods as if they were local. I'm pretty aware of all the SOAP problems, but on some level of abstraction SOAP/WS delivers on its RPC promise. Of course you can come up with an API based on REST architecture, but it will still require other party to code some bits which somehow defy RPC definition.</p>

Title: What was SOAP invented for?


答:
Does code like that imply to others that I don't have control of the language because I didn't use all the features?

Yes, it does.  Good Perl programmers know Perl well, and use it effectively.

If you are writing five lines of Perl where one would do very nicely, do not expect a warm welcome from a team of Perl programmers.  Teams choose Perl and similar languages to get more done with less code.  It's not just a question of style, it's a matter of time and money.  It takes a lot longer to read and understand:

```<code>my @selectedThings
for (my $i = 0; $i <= $#things; ++$i) {
  my $t = $thing[$i]
  if ($t ... ) {
    @selectedThings.push $t
  }
}
</code>```

than:

```<code>my @selectedThings = @things.grep { ... }
</code>```

The grep call is clear to a Perl programmer.  The multi-line equivalent could say anything, and could easily contain a bug.

There is a huge difference in the cost to develop and maintain a 25,000 line application than a 5,000 line application, even if they do exactly the same thing.

I always use C-style for loops and use map about once in every 10,000 lines of code, so I almost always have to reference it before using it.

This is a form of what Larry Wall called "false laziness".  Each time you could use map, but instead write longer but more familiar code, you save a few seconds one time.  But taking a few minutes to really learn map would save you hundreds of lines of code and many hours in the future.

While I can interpret others code using that, it's not my style and that is for reasons involving readability and ease of changing between languages.

This attitude does not work well in a team.  The team knows Perl, and does not have time to wade through extra code because it's not your style.

Body:
Does code like that imply to others that I don't have control of the language because I didn't use all the features?

Yes, it does.  Good Perl programmers know Perl well, and use it effectively.

If you are writing five lines of Perl where one would do very nicely, do not expect a warm welcome from a team of Perl programmers.  Teams choose Perl and similar languages to get more done with less code.  It's not just a question of style, it's a matter of time and money.  It takes a lot longer to read and understand:

my @selectedThings
for (my $i = 0; $i <= $#things; ++$i) {
  my $t = $thing[$i]
  if ($t ... ) {
    @selectedThings.push $t
  }
}

than:

my @selectedThings = @things.grep { ... }

The grep call is clear to a Perl programmer.  The multi-line equivalent could say anything, and could easily contain a bug.

There is a huge difference in the cost to develop and maintain a 25,000 line application than a 5,000 line application, even if they do exactly the same thing.

I always use C-style for loops and use map about once in every 10,000 lines of code, so I almost always have to reference it before using it.

This is a form of what Larry Wall called "false laziness".  Each time you could use map, but instead write longer but more familiar code, you save a few seconds one time.  But taking a few minutes to really learn map would save you hundreds of lines of code and many hours in the future.

While I can interpret others code using that, it's not my style and that is for reasons involving readability and ease of changing between languages.

This attitude does not work well in a team.  The team knows Perl, and does not have time to wade through extra code because it's not your style.


答: Since good is very subjective, I would say you are good exactly when you are confident that you are great.</p>

Title: When can you call yourself good at language X?

Body:
This goes back to a conversation I've had with my girlfriend. I tried to tell her that I simply don't feel adequate enough in my programming language (C++) to call myself good. She then asked me, "Well, when do you consider yourself good enough?"

That's an interesting question. I didn't know what to tell her. So I'm asking you.

For any programming language, framework or the like, when do you reach a point were you sit back, look at what you've done and say, "Hey, I'm actually pretty good at this."? How do you define "good" so that you can tell others, honestly, "Yeah, I'm good at X".

Additionally, do you reach these conclusions by comparing what others can do?

Additional Info

I have read the canonical paper on how it takes ten-thousand hours before you are an expert on the field. (Props to anybody that knows what this paper is called again)

I have also read various articles from Coding Horror about interviewing people. Some people, it was said, "Cannot function outside of a framework." So they may be "good" for that framework, but not otherwise in the language. Is this true?


问:
Developing scalable applications using Agile methods
Maybe someone can share from his experience about developing an application that is meant to scale big time where just throwing more money at better hardware isn't a realistic option using development methodologies such as SCRUM and XP.

Did you need to rewrite substantial parts of your app
because of current framework couldn't scale enough to fit current sprint's
stories? how do you avoid that?

When do you do stress (or load) testing?

In what stage did you make your SMART(TM) design concerning bleeding edge requirements?

Did you add more stages to the dev-cycle of
write-a-test, code-to-pass-test, refactor?

Did you just refactor everything in the end to meet demands?

答:
Fast paced development that doesn't take into account all requirements
  (since they are added one by one) may lead to unsuitable design in the
  infrastructure level of the application.

That is not true. The design follows requirements. If your team commits to delivering feature it also commits to its acceptance criteria (definition of done). The acceptance criteria for the story can contain demands for scalability and performance and if these criteria are mentioned you must provide automated test to validate their passing to show that story is complete and to make sure that acceptance criteria will not be broken in future by regression.

Your product owner can even declare such acceptance criteria as a global so they will be part of every user story and team will be able to take it into consideration during estimation of stories (requirements).

If you ask about "tuning" application for global performance than it is similar as with any other. Premature optimization is source of evil so until you have solid code base with implemented features there is nothing to optimize and refactor toward performance.

As a side not if you want application to scale "big time" you need money and hardware - or even better you need to make application on cloud and pay for HW you will really use.


问:
Does C# experience translate well to C++?
My programming classes in school were C++, but I ended up working a job doing C# for the last few years. If there was a position that required say 1 or 2 years experience in C++, would my experience in C# be worthy of consideration? How effective could I be in such a position? So do I need to start out as an entry-level C++ programmer to gain the necessary experience?</p>

答:
It depends. If you can answer some basic interview questions about pointers and such, then you should be fine.

It's also beneficial if you can list the differences between C++ templates and .NET generics.

Other than that, it's pretty easy to catch up with the rest as you go along.


答:
I cant speak for every employer but I personally view programming as the skill and language specifics as a nice to have. Its still quite possible to get hired in another programming job that isn't your main skill.

Having said that its very very unlikely I would hire someone that had absolutely no experience  in the language I'm hiring them for. Spend a few weekends learning and have a couple of pet projects to bolster your CV. Even small ones prove you are capable of learning and keen.

Title: Does C# experience translate well to C++?

Body: My programming classes in school were C++, but I ended up working a job doing C# for the last few years. If there was a position that required say 1 or 2 years experience in C++, would my experience in C# be worthy of consideration? How effective could I be in such a position? So do I need to start out as an entry-level C++ programmer to gain the necessary experience?</p>


答:
You are exactly in the same situation I was in 4 years ago.

I did some C++ during my studies, but I hated it. I did a lot of web dev when I could on my spare time and got a job in that field.

When I moved I applied for a C++ job which had 2 years of C++ experience as a requirement.
Well I refreshed my C++ memories before the interview and when the time came for the tests I managed to get away with a few things I wasn't so sure I was doing right.

But most of the interview was about problem solving and creative solutions and C++ ended being just a minor factor.

So the chances really depend on the employer and the positions they have.

If you are going through a recruiting agency you will "probably" be told your profile doesn't match. But with a real employer your chances are way better as they really know what they need.


答:
If you are dealing with requirements one at a time with no knowledge of other requirements, you are doing agile wrong.

An agile project still has an up front design component - it is just far less than you have in a waterfall project, and there is no need to define all the details - just high level stuff like platform choice and overall system design that you can't handle at the individual feature level.

Since scaling issues usually aren't tied to individual features (the ones that are are easy to fix), the solution is in that initial design - no different from any other type of project.

If you do find you need to change the framework part way through a project, you did that first step wrong and will need to return to all the previously developed features. Most likely it will be quicker than the original development as you have some code you can reuse, but the process is the same as for a complete rewrite.

Title: Developing scalable applications using Agile methods

Body:
Maybe someone can share from his experience about developing an application that is meant to scale big time where just throwing more money at better hardware isn't a realistic option using development methodologies such as SCRUM and XP.

Did you need to rewrite substantial parts of your app
because of current framework couldn't scale enough to fit current sprint's
stories? how do you avoid that?

When do you do stress (or load) testing?

In what stage did you make your SMART(TM) design concerning bleeding edge requirements?

Did you add more stages to the dev-cycle of
write-a-test, code-to-pass-test, refactor?

Did you just refactor everything in the end to meet demands?


答:
The problem here is that C++ and C# are, fundamentally, extremely different languages with different approaches to many problems. It's easy to lump them in as "An OO language", but the simple fact is that many C# idioms are considered to be very bad code in C++ (and vice versa).

If you actually know the differences and what C++ idioms look like, then I see no reason that it shouldn't be fine.


答:
I wasn't in the room, but I'd generally say SOAP was a very, very good idea and a very reasonable response to the other RPC options that existed in the mid to late 90s. Such as CORBA, a beast which I can't say I've had to personally deal with, but the mere mention of which can make grown men soil themselves. Options beyond CORBA were actually scarier in many cases and there was little standardization and lots of custom messaging protocols going on. Integrated systems were very, very hard stuff. There were good reasons not to rely on HTTP as a transport. In the late 90s, typical LAN speeds were 10 megabits or less, WAN speeds were oftentimes measured in baud. The entire edge caching infrastructure that does so much for REST didn't exist.

Which gets us to SOAP -- which in and of itself doesn't specify a transport medium. I believe someone managed to implement a SOAP call over carrier pigeon. Or perhaps an african swallow. In any case, it is a vastly simpler to implement messaging option than what came before. And if you had a decent SOAP toolkit, it was much, much easier to consume than anything else that had come before. And easier to make tools for. So easy that they thought they needed to extend the protocol. And that is where WS-* comes in. Which is where the wheels fell off that truck . . .

Title: What was SOAP invented for?


问:
Using Node.js with Heroku to make a chat server?
I currently have a goal of creating a sort of chat website. I just finished trying with PHP and long polling, which hit a resource limit on my webhost's server. I was told that I should use Node.js and that it can be hosted with Heroku.

I honestly have very little understanding of what Node.js or Heroku are. From what I've been told and have read after looking this up is that you can install Node.js and run apps online with it. The tutorial here: http://www.jamesward.com/2011/06/21/getting-started-with-node-js-on-the-cloud/ goes over installing and executing a script on heroku with Node.js. I have NO experience with command line, and wouldn't be able to do anything but copy the exact commands in that tutorial. I also don't understand when he accesses the script with localhost if the app is supposed to be on Heroku.

Can anyone explain what Heroku is, and provide some resources on how to use it? How can I work my way up to knowing how to use it?

答:
Heroku is a company and eponymous server product, whose main feature is ease of use for Ruby developers (they've more recently added Node.js, Java & Clojure support)

The best place to get help with it is to go to http://devcenter.heroku.com/articles/quickstart and then start asking questions about things you don't understand.  (try asking very specific question on http://stackoverflow.com too.) - Rinse and repeat for nodejs.org.


答:
Not directly related, but...

I see this happen ALL the time at my grandson's Boy Scout troop.  The older Scouts think they "know" something until they try to teach it to their juniors.  I don't think that dynamic changes much no matter how old or experienced we get.

Title: Does teaching programming make you a better programmer

Body:
I consider myself an intermediate Python programmer and have been offered an opportunity to be a trainer for a beginner Python programming class.

I was wondering if this would really widen my programming repertoire. Has somebody had an enlightening experience after they successfully trained a group of people?

Does it also depend on those people -- whether they're programmers or noob students? (In my case they are intermediate .NET and Java programmers)

What should I expect from them?

One of my fears is -- what if I choked when one of them asked a tangled question. Is this normal?


答:
As for running a chat server, the chat example for socket.io can be up and running in about 5 minutes.  Basically, copy-paste and you have real time chat.

You should know that Heroku does not support Websockets at this time.  Socket.io will revert to xhr-polling or other techniques which really should work fine for chat, but it's not quite real time when using Heroku.

EDIT

Apparently I even did it to test at one point in the past.

Title: Using Node.js with Heroku to make a chat server?

Body:
I currently have a goal of creating a sort of chat website. I just finished trying with PHP and long polling, which hit a resource limit on my webhost's server. I was told that I should use Node.js and that it can be hosted with Heroku.

I honestly have very little understanding of what Node.js or Heroku are. From what I've been told and have read after looking this up is that you can install Node.js and run apps online with it. The tutorial here: http://www.jamesward.com/2011/06/21/getting-started-with-node-js-on-the-cloud/ goes over installing and executing a script on heroku with Node.js. I have NO experience with command line, and wouldn't be able to do anything but copy the exact commands in that tutorial. I also don't understand when he accesses the script with localhost if the app is supposed to be on Heroku.

Can anyone explain what Heroku is, and provide some resources on how to use it? How can I work my way up to knowing how to use it?


问:
How should I react to diminishing application performance?
Sometimes it comes to me that the biggest challenge for an engineer when he find his application getting worse in performance is lack of enough information.

Imagine that you go through the weekly performance report from your application's access log, and find you get much lower response times from July. All you can do is to pray for it not to get worse the next time.

答:
Although generating metrics is useful, I take the following approach:

1> Run perfmon/task manager (on win) of top (unix) to see if CPU, disk, network or memory are being used heavily/thrashing/flatlining and investigate as appropriate. Ideally disk/network/memory should not be using anywhere near all the available resources. CPU at 100% is ok where you are doing something CPU intensive. Check that you are not running more threads than CPU's (unless the application is light on CPU use and disk is not an issue).

2> Do an isolation test to see if there are competing processes on the hardware that are using resources that could affect performance.

3> Check to see if Concurrency (if applicable, eg web app) has increased. If it has you need to look at you application to find the bottle necks that need to be addressed. Usually these will be in the database (index and table locking issue, slow queries) but may be in the infrastructure set up (ie enough CPU, memory)

4> At this point you probably have a data volume issue. Now look to see what has changed. Are data files getting larger? are database tables getting larger? If data sizes are getting larger then you need to understand what the application is doing to determine what course of action to take. If you use a database, you should check that the appropriate indexes are used and that queries are optimized. A SQL profiler is handy here as well as visual inspection of the code (assuming you know or know someone competent in database optimization) You are looking for the longest running query and the most frequently run queries. Another option is to look at archiving or deleting old or irrelevant data, if possible. Also ask if all the data is really required to be processed/stored. You also need to look for locking situation, code inspection and SQL profilers will help.

5> If the application is CPU intensive, you may like to look at optimizing the CPU intensive portions of code. Visual inspection, trace statements while monitoring CPU usage and profiler tools will help identify code that could be changed. The solution may be to use a different algorithm of remove/reschedule processing tasks. A set of experience eyes may be of assistance here.

6> remove any needed debug/logging code. Remove anything that is not really needed to run.

Again, the key is to understand what and how the application is operating, and thinking about how these steps interact with the hardware/database.


答:
I was in the same boat about 2 years ago. Your c# experience would probably not be worth as much for a c++ job as c++ is for a c# job. That said, if you know how c# actually works (very few c# programmers actually do), and learned your c++ well then the c++ will not be the problem. What will be the problem is the way you have grown accustomed to certain design patterns which will be too high level for c++.

For instance, going from the nice ADO.NET data access model to using cppcon for mysql access, System.Collections.Generic to using stl, multiple-inheritence, garbage collection to cleaning up your memory in destructors and so on... all tend to be tough transitions. C++ isn't the problem, learning the libs, design patterns, and how to use them is the challenge. Most recruiters don't realize this. If you can do basic design and can use the actual commonly used features of c++ then you should be fine in the interview.

However, ready for the job is a different story. It is a fun challenge though, I hope all goes well.