问:
Can I use GPL, LGPL, MPL licensed packages with my application and make it closed source?
I saw a company is using BusyBox and also using Gpl + Lgpl + Mpl packages on it, and then they have there own application running on it. Their application is a closed source package.

You buy the device but its closed source. How come GPL mixed with LGPL+MPL becomes closed source?

I thought the rule is?? Or I am wrong or this following info is wrong?:

GPL: If you use it in your application then you must release your application under the GPL. That doesn't mean you can't also sell it (like they sell Linux CD's) but you must also release the source code for free. That might work for you, but probably not.

LGPL: If you use it in your application then you can still have a closed source proprietary licensed application. But if you modify the LGPL library then you must release your modifications under the LGPL, even though your application can remain closed source.

答: GPL is NOT compatible with closed source. If they used GPL-licensed packeges/modules and closed the source, in the general case they would be in violation of the GPL conditions.</p>


问:
Will taking up a job in the enterpise s/w domain reduce my chances of later shifting to consumer software?
I have been offered a job from campus in the Enterprise s/w domain. I'm at loggerheads with myself deciding if I should take up the job, since I'm generally interested in consumer s/w esp in companies that encourage open source contributions. My question is if i'll find it difficult to later(maybe after a year or two) change my domain and move onto B2C (Business to Consumer) software companies. Will my past experience with enterprise software stand against me?  </p>

答: It depends a lot on the company you're applying to. Some only want people with a very specific background, such as specific work experience and a specific degree. Other, better, more open minded, companies understand that programming talent is programming talent and that innovative ideas and great work can come from people outside of a very narrow subset.</p>

ContentLicense: CC BY-SA 3.0


答:
IANAL, but this is what I've learned. I would be very interested to know if any of it is incorrect:

LGPL: If you statically link it it in your application and you distribute the compiled application then you must release the source under the GPL to anyone who receives the binary.

Title: Can I use GPL, LGPL, MPL licensed packages with my application and make it closed source?

Body:
I saw a company is using BusyBox and also using Gpl + Lgpl + Mpl packages on it, and then they have there own application running on it. Their application is a closed source package.

You buy the device but its closed source. How come GPL mixed with LGPL+MPL becomes closed source?

I thought the rule is?? Or I am wrong or this following info is wrong?:

GPL: If you use it in your application then you must release your application under the GPL. That doesn't mean you can't also sell it (like they sell Linux CD's) but you must also release the source code for free. That might work for you, but probably not.

LGPL: If you use it in your application then you can still have a closed source proprietary licensed application. But if you modify the LGPL library then you must release your modifications under the LGPL, even though your application can remain closed source.


问:
What are all these license types for applications?
I am thinking of making some applications for Linux (primarily Ubuntu) and I have an intention of selling some in the Ubuntu Software Center and offering a few applications for free.

These free applications will be minor programs mainly used for fun and/or for a little convenience in day-to-day tasks (say, a ToDo list). What is the suitable license I should use for this?

As for the paid applications, they will be more business-oriented (eg: a decision making software). For these, what is the suitable license type?

I really confused about all these licenses (I have heard of Creative Commons, GNU, etc but have no idea whatsoever). And I'm hoping to make these applications using PyGTK and Quickly and some with Java. So if anyone could provide some light on this subject, I'm really grateful.

答:
GPL: good if you want to make your project freely available to anyone who is willing to ship source code (which is usually "other free projects"), but also demand a payment if people want to ship without source (which roughly corresponds to "commercial projects").

MIT/BSD: good if you want anyone to be able to use your code in any way whatsoever, but you want to attach your name to it. Sort of an "hey, I did this!" mark. This essentially only requires people to preserve that mark. It also purportedly gives you some protection against frivolous lawsuits, but I don't know if the legal disclaimer is really necessary.

Public domain (availability varies by country): you want to disclaim ownership of the code. It's as if it had always existed, like air that nobody owns. Anyone can do anything they want in it, and if they pretend it's their work you have no recourse. Where disallowed by local laws, the WTFPL (nsfw) may be used instead.

Creative Commons: a set of licenses primarily targeted at artistic creations, like photos, drawings, music etc. You mix and match the conditions you like, such as "no commercial use" - it's up to you whether you allow or forbid this. Not very suitable for source code IMO.

So, if you want to release source code but think there's some commercial potential in it, use GPL. If you just want to give something to the world but have your name on it, use MIT/BSD. For small snippets of code, or if you have ideological reasons to do so, use "public domain" - copyright might not apply to small snippets anyway, and it makes you look very benevolent.

If you don't want to release source code at all, then none of these do you any good. You need something that describes the conditions of use for your program. I don't know of any ready-made licenses for this.


答:
It is perfectly all right to sell an "aggregrate" of closed-source and open-source software according to the GPL FAQ. If the company compiled a Linux, built their own program on top of it using only LGPL libraries, and sold the resulting product while publishing all GPL/LGPL sources with it, they are not violating the GPL.

The point here is: The GPL does not extend to programs simply running on the same computer and communicating/interacting with the closed-source program. An open-source window manager like BusyBox is of course allowed to manage closed-source windows. As a rule of thumb, the GPL reaches as far as the address space of the licensed code.


答:
That fact that you worked in an Enterprise domain won’t be counted as a negative BUT the fact that you haven’t been working in B2C will. “No recent experience with public facing web apps?“

The same thing will happen if you take a job doing B2C then want to switch to B2B. B2B companies will hold the lack of Client facing experience against you.

Title: Will taking up a job in the enterpise s/w domain reduce my chances of later shifting to consumer software?

Body: I have been offered a job from campus in the Enterprise s/w domain. I'm at loggerheads with myself deciding if I should take up the job, since I'm generally interested in consumer s/w esp in companies that encourage open source contributions. My question is if i'll find it difficult to later(maybe after a year or two) change my domain and move onto B2C (Business to Consumer) software companies. Will my past experience with enterprise software stand against me?  </p>


答:
There are clear cases and then some muddy one for which you'll get more opinion that lawyers you present the case.

Your rules match my understanding, but what will vary is the precise definition of "use".  The copyright system on which the license is based isn't about "use" but about "creating a derived work" and some will argue with good arguments that a system made of different programs may be such that the different programs are tied enough that the whole system is a derived work of any one of them while another single program dynamically linked to a library isn't a derived work of the library because the library implement a clearly defined protocol and could be replaced (I've seen libreadline used in such a way with a simple GPLed wrapper to match an application provided interface).  Ask your lawyer for advice specific to your case. See you before the judge if the one of the copyright holder isn't of the same opinion.


答: if you plan to switch early on in your career it wont matter much, in fact it would probably help you to list some relevant experience to software development. just don't expect to get a job that requires X years of experience in consumer software with X years of experience something else, though you would still likely be qualified for jobs that require X-Y experience</p>


问:
Is having your own website important?
How necessary or important is it? I try to keep a running list of blogs or sites to follow, but a lot of the time I pull up someone's profile and notice there isn't anything there. Is it really important?

I understand are different levels of programming (from C/C++ system programmers to Rails and even Haskell and J) and not everyone works in a language easily worked with for web based applications. Not everything is web-centric, however with the advent of many popular and sometimes free services I don't think it's unreasonable to expect a majority of programmers to have a personal site.

答: I would not say important, but, having your own website can be good. Posting some codes/snippets and sharing your views on different topics in a blogish way is nice. It can  lead to new contacts, sharing ideas and maybe you'll get spotted by a potential customer/employer who likes your work, and your personality. Who knows :)</p>

ContentLicense: CC BY-SA 2.5

Title: Is having your own website important?


问:
Ease the pains of unit testing C# when you are the only person on the team unit testing
I have ran into this a few times where you get put on a project and you want to do unit testing of some type, but the project isn't setup right to allow for this and you might not have buy-in from everyone.  The main issues tend to be code smells like issues with dependencies (especially the over use of statics) and seperation of concerns.  New code that you write can be setup easily, but anything that operates with other legacy code or even those not drinking the cool aide can become an issue.

Some things that I have found are that isolation frameworks like TypeMock can make this easier. What are some other tools/tricks/best practices that you have found that ease this sort of pain?

答:
Try asking Michael Feathers article Testable Java  or Testable C# or C# TUFs and TUCs

The gist is ti avoid putting test unfriendly feature inside a test unfriendly construct.


问:
How do you limit whitespace differences for developers using different IDEs/environments?
I've used UltraEdit for years and never had a problem with sharing code with fellow developers whether they worked on Windows, Mac, Linux, Eclipse, Visual Studio -- what have you...

But now I am in an office where some developers are using emacs and they complain profusely about the white space differences my code "introduces". I have UltraEdit set to write to files as UNIX-style (no Windows returns), but it seems the whitespace renders differently for the emacs developers.

Since I don't use emacs (or vi), its a pain for me to try to figure out why this is impacting them, but I more so just want them to shuttup! lol

This is even causing problems in SVN/Diff!

Any thoughts on how to fix this?

Forget about everyone using Emacs because thats not gonna happen lol.

答: You may consider using emacs solely for the indentation and formatting after you have done all of your other changes.  I've done this before myself, because I actually like how emacs indents.  I would make all changes in my IDE (Qt Creator, Kate, or KDevelop), then I would open it up in emacs and select all and put in some command to auto-indent everything.  I don't remember the commands, but if it is something you are willing to do, I'm sure your fellow emacs users would be glad to help you with the commands.</p>


答:
You could find yourself working with a technology that is not popular (You mentioned ABAP and how non-enterprise jobs won't use that), but you should be 90% what you'll be using during the hiring process.

The other concern is how your personality will fit in with the corporate cultures. There is a stereo-type that programmers working in non-software related industries and typically larger companies are not a fit for smaller, flexible, cutting-edge (younger) company cultures.

It will really depend on you.


问:
Programming language with native concurrency support for large graphs?
I'm currently looking for a new programming language to learn (currently working through some C++, know some C and Python), specifically one that has built-in concurrency support? I want to try to build a large graph library that can do processing across clusters or multiple cores.. I know C++'s Boost library has support for concurrency, but I also want to learn a new language and I'm guessing a language that was designed with concurrency in mind would also be more pleasant to do concurrent programming in. Overall I see this as a chance to learn a new language, learn about concurrent programming, and tackle a big project.

From looking around, Clojure and Scala seem to be the two popular candidates when looking for concurrent programming support.. though I'm not sure how these two compare in terms of

Speed (specifically for concurrent large graph processing)

Community (thinking about pushing this project onto somewhere like GitHub)

Ease of programming concurrently

Or are there other languages I should consider aside from Clojure or Scala?

I have never programmed in a functional language before, but I'm open to learning it.. I've seen one of my friends program in Haskell and Clojure and it looks daunting but I've heard good things about functional programming, esp. for data processing.

Thanks!

答:
D's flagship concurrency model is based on message passing with extremely limited, explicit sharing of mutable data across threads.  This model can be used via std.concurrency.  What makes this interesting is that it's done in the context of a C-style systems language that allows traditional, imperative programming in the parts of your code that don't deal with concurrency.

Since D is a systems language, the isolation guarantees that std.concurrency provides are enforced partly by the std.concurrency module.  The language provides the mechanisms for enforcing these guarantees, such as support for transitive immutability and the shared qualifier.  (Immutable data may be freely passed between std.concurrency threads.)  The std.concurrency module provides the policies for enforcing isolation, though.  Other threading-related modules such as std.parallelism and core.thread don't enforce isolation.

If you're interested primarily in multicore parallelism as a means of increasing performance, you should might want to use the std.parallelism module.  If you're more interested in concurrency as an inherent part of the problem (concurrency and parallelism aren't the same thing even though they are related), then std.concurrency may better suit your needs.  Additionally, std.concurrency will eventually be extended to work across networks, though it currently only works with threads on a single machine.


问:
Evaluating Software Maintenance
1. When to treat a software as deployed and when to start charging for maintenance ?

In most of the cases the software we make is deployed on the web at early stages to enhance the testing process from the client side. This means that bugs keep arising and we keep fixing them alongside development. Not just that, as the clients use it, they come to know of modifications required which creates a pile of extra work for us. Because of no demarcation line between development, deployment and maintenance stages its hard to understand when to charge for what.

2. How to charge for software maintenance ?

I read that vendors charge 15%-22% generally for softwares annually. That being a fixed fee what happens if the maintenance takes more time then expected ? What happens if the system runs fine or without issues for an year ? Does the client still pay maintenance ?

3. How to charge for non-application specific improvements ?

We use a core engine to build business applications. Improvement in that engine means improvements, new functions, etc can be made available to all clients without modifying their application layer. Should that be included in maintenance as free upgrades ?

4. How to charge for maintenance in case of hourly contracts ?

If we work on an hourly project most of the times the scope of the project keeps expanding but that doesn't require a revaluation of the project because the increase in scope equates to increase in hours and hence increase in budget. But most of the times due to increase in the scope the bug fixing and maintenance work also gets included in the development time. Is that good ? Or should there be a demarcation between deployement and maintenance even for hourly projects ?

答:
From your question I infer that you are not doing test driven development.

The best way to switch from development to maintenance mode is with a formal customer acceptance were they agree "Yes, the software does everything that we originally requested." Of course you need an objective way to determine if the software does in fact meet the objectives, that is a formal test plan. If you write the test before writing the software, (test driven development) then this should be a natural part of the process.

You talk about "come to know of modifications required which creates a pile of extra work for us". This should be part of a written "change work order" and priced accordingly. Of course part of the work (to support the change) includes modifying the formal tests. Don't take this too lightly, many firms (government contractors come to mind) make far more on the change work orders than they do on the original contract. (what does it cost to make a grey boat - $100,000....We're half done, could you paint it white instead? Sure that will be an extra $75,000) If you are too loose about not charging for (and adjusting delivery schedules) then "feature creep" will kill you.

As for "maintenance", once again you need to clearly define terms. Strictly speaking maintenance would be limited to items spelled out in the original statement of work but which the test plan failed to test. For example suppose that the original contract called for the About Us to be done in 14 pt New Times Roman font and for some reason it was done in 13 point font and the test plan did not check to see if the correct font was used. Then six months after delivery someone discovers the error and asks you to fix this latent defect; that is maintenance. If however you use the correct font and they call up and say "You know that About Us page with the 14 pt New Times Roman? Could you make it 16 pt Helvetica instead?" - well that is not maintenance, that is a change. This is what I would label "break/fix" and I would think the client should not be charged for it.

Title: Evaluating Software Maintenance


问:
Using Scrum/agile with multiple customers
I am a big believer in agile development. I just changed jobs, and I am now working for a company that coordinates big development projects for (rather large) groups of customer organizations. My job is to find the right contractors for the projects, and make sure that the customer organizations are as happy as possible, and control the process. There is nothing in the world that would make me happier, than if I could introduce Scrum or a similar agile method into this situation, making my company's main role the product owner. It would make sense on so many levels.

There are some issues though: Since Scrum is a rapid-response method, I wonder if Scrum is the right method for a place like this, where not one customer but a big group of customers have to be involved in prioritizing of the backlog from sprint to sprint. It takes place in a quite political environment. What pitfalls and possibilities do you see in a situation like this? Can this situation simply be handled by longer sprints?

There is a general understanding and empathy for the agile agenda in the company, but the issue I describe here seems to be a major obstacle.

I would really appreciate your input. I need good ammo for my agile preaching :o)

答:
Backlog prioritization is really more of an input to scrum than a result of it.  The only property of agile that might make backlog prioritization easier is that more frequent releases reduce pressure to include everything in a release.  If you only have one release per year, customers will fight tooth and nail to get their features included now, so they don't have to wait 2 years.  They are more amenable to compromise if they only have to deal with a delay measured in weeks.

Therefore, making your sprints longer will make the problem worse, not better.  If you think about it, you are probably sort of doing 6-12 month "sprints" now.  How's that working out for you?

You don't have to revisit the entire backlog every sprint.  You get it into a basic order once, then on each sprint you only need to take what has changed during the sprint into account:  an urgent bug that was just discovered, a new feature needed to respond to a competitor's release, etc.  The product owner's job then becomes mostly reminding people that they already hashed this all out, and asking if they have new considerations to bring to the table.


问:
Why is C++ predominant in programming contests and competitions?
I understand that C++ is a very fast language, but ain't C just as fast, or faster in some cases?

Then you might say that C++ has OOP, but the amount of OOP you need for most programming puzzles is not that big, and in my opinion C would be able handle that.

Here's why I am asking this: I am very interested in programming contests and competitions, and I am used to coding in C on those. However, I noticed that the vast majority of people use C++ (e.g., 17 out of 25 finalists on Google Code Jam 2011 used it, while no one used C), so I am wondering if I am at a disadvantage going with C.

Apart from the Object Orientation, what makes C++ a more suitable language for programming competitions? What are the features of the language I should learn and use to perform better on the competitions?

For background, I consider myself pretty proficient in C, but I am just starting to learn C++.

答: Contests like that are not so much about the speed of the program as the speed of the programmer.  C++ has standard library features, type safety, and help for memory management that makes developing and debugging faster, even if the executable ends up slightly slower.</p>


问:
Ext JS code review check list
Can any one share a code review check list for Ext JS in common and specially for Ext JS 3.4 ?</p>

答:
Does it match the requirements?

Is the code correct?

Is the code high quality?

Do the unit tests have 100% coverage

Does the code adhere to the style guides

OwnerDisplayName: hop

Title: Ext JS code review check list

OwnerDisplayName: Raynos


问:
What happens between sprints?
I'm working on a project loosely following the scrum model. We're doing two week sprints. Something I'm not clear on (and don't have a book to consult) is exactly what is supposed to happen between sprints: there should be some "wrap" process, where the product gets built and delivered, but:

how long does this typically take?

should the whole team be involved?

does it strictly have to finish before developers start working on the next sprint items?

is this when code review and testing take place?

There are three developers, adding up to about 1 FTE. So the sprints are indeed very short.

答:
I'm working on a project loosely following the scrum model.

To make it clear: Your managers probably told you about Scrum but what you perform is not Scrum.

How long does this typically take?

Sprint review meeting + Sprint retrospective meeting ends current sprint. In short sprints they should take something between 30 minutes - 1 hour together. Next working day starts a new sprint by performing Sprint planning meeting 1 and 2. Based on the team size and sprint length these meeting can takes 2 - 4 hours.

Should the whole team be involved?

Whole team must be involved in meetings mentioned in previous answer.

Does it strictly have to finish before developers start working on the next sprint items?

Yes because until review meeting is done you don't know if customer accepts result of previous sprint and you don't know what users stories will be committed in planning meetings.

Is this when code review and testing take place?

No. Code review and testing is part of sprint. Developers must do everything needed to deliver working code satisfying requirements. This can include code reviews and it always must include some sort of automated tests validating that code works and does what it is supposed to do otherwise the user story cannot be considered as done.

The main mental shift is with QA. Many developers think that QA is there to validate that code works and does what it is supposed to do. Definitely no. That is developer job.

QA should participate on product development. Their main responsibility in sprint should be communication with product owner and creation of automated acceptance tests for acceptance criteria (definition of done) which will validate that user story is really done and the application passes all new requirements. In small teams this can be responsibility of developers as well.

QA should also do some manual testing to keep product consistent and to discover missing features, validate user experience with UI, etc. QA is not there to hunt for bugs and regression testing - regression testing should be highly automated.

In my experience this is where most companies moving to agile fails.

Title: What happens between sprints?


答:
Do not be hung up on the form your unit tests take, because there are many non-standard ways of doing this. Heck, you can write a stand-alone app which massages the database and looks for inconsistencies (in case some key constraints are too slow). You can test things from within a main method without formal unit test libraries. You can put together a quick Python script.

What you want to do is look for low-hanging fruits - e.g. things that are easy to test, likely to contain bugs, and are important.

When you succeed, advertise the success. Once you can demonstrate that your scripts and stuff can catch many bad bugs quickly, then take it to the next level.

Ask for permission to re-factor some code. Remember, critics will still be skeptical and will want to see tangible results, so you need to keep finding bugs with it. If you have to, make it find bugs that you actually discovered manually. Do not over-engineer stuff just because you like cleaner code. Multiply your hourly salary by the number of hours you spent on this - now you need to justify this investment. That is how many others see it.

Also, try to generate a lot of buzz slowly, so that people will start thinking that these ideas are actually theirs and not yours.

Title: Ease the pains of unit testing C# when you are the only person on the team unit testing

Body:
I have ran into this a few times where you get put on a project and you want to do unit testing of some type, but the project isn't setup right to allow for this and you might not have buy-in from everyone.  The main issues tend to be code smells like issues with dependencies (especially the over use of statics) and seperation of concerns.  New code that you write can be setup easily, but anything that operates with other legacy code or even those not drinking the cool aide can become an issue.

Some things that I have found are that isolation frameworks like TypeMock can make this easier. What are some other tools/tricks/best practices that you have found that ease this sort of pain?


问:
Eclipse: on new projects, which mode: debug or release?
I'm asked to teach my students Eclipse.

The lectures are already done; I see that the teacher asks the students to always start a new project in "Release" mode.

Is this a good idea? If "yes", or if "no", why?

答:
Not sure if this is normal or not but in general it is a matter of preference for the teacher.

I am not sure that not letting students debug their programs is any good for learning but I would ask him the reason why he limits this.

One thing that I can think of is to teach the ability to add another build configuration if problems arise.


问:
Dynamically generating HTML and CSS
I find writing CSS by hand to be extremely tedious.

Coming across a concept such as fluid, makes me want to write all my websites so that the CSS resizes nicely and looks the same in different browsers.

My question to you is: Can my design be generated programmically?

e.g.:

```<code>#include <css>
#include <html>
#include <vector>
#include <string>

int main(void) {
    HTML::HTML page;
    page.title("my title");
    page.heading.font(15);
    std::vector<std::string> para = <vector of paragraphs>;

    CSS::CSS layout;
    layout.grid(2,2);
    layout.fill(xcoords_as_percentage, ycoords_as_percentage);

    page.use_css(layout);
    for(int i=0; i<para.size() && y!=grid.y.size()+1; i++, x++) {
        if(x==grid.x.size()) x=0, y++;
        page.grid[x][y]=para[i];
    }
    page.header1("I am header1");
    page.footer("I am page footer");
    layout.order(page.header1[0], page.grid.all(), page.footer());

    generate_html("index.html");
    generate_css("layout.css");
}
</code>```

This will allow me to concentrate on the actual contents, abstracting away from "Oh, IE7 doesn't support this option, so do this hack..."

FYI: I am coding the actual site in Django (Python), so the HTML/CSS generator doesn't have to be in C++. I am aware of work being done in this direction in the C++ Wt framework

答:
Adding to Magnus Wolffelt's answer, you should take a look at LESS:

LESS extends CSS with dynamic behavior such as variables, mixins, operations and functions. LESS runs on both the client-side (IE 6+, Webkit, Firefox) and server-side, with Node.js.

I prefer its syntax over Sass's, but that's a matter of opinion. Django Compressor works fine with LESS with the added bonus of producing minified scripts:

Django Compressor combines and compresses linked and inline Javascript or CSS in a Django templates into cacheable static files by using the compress template tag.

There's also a very handy Apache filter that provides on demand conversion of CSS LESS files to CSS using CSS::LESSp under mod_perl2., if you really want to go there. It should provide language & framework agnostic use of LESS, but I just played with it for a few minutes, I'm using a PHP solution similar to Django Compressor and never had much need for it.

Title: Dynamically generating HTML and CSS


答:
For Agile to work best, there must be a single "product owner", a single person or team that is responsible for the generation and prioritization of requirements.

On my last Agile project, we had two product owners; two different companies who came to us as a pair and said they wanted new software to replace an application they were literally paying their competitors to use (we're talking hundreds of thousands of dollars a month in licensing fees). It worked as well as three corporate entities can work, primarily because there was a spirit of cooperation among all participants. Even then, there were problems; the requirements responsibilities were split between POs, and yet both companies needed to contribute to many of them. This resulted in differing quality of requirements depending on the PO that generated them, and often a long back-and-forth between the POs and BAs to iron out inconsistencies. The two POs also used the licensed application differently, with different configurations, and thus they had different expectations of how the same piece of functionality was supposed to work, based on settings they had long ago forgotten about from the original software.

You and your company face an even more difficult situation, in which the various stakeholders may be flat-out competing with each other day-to-day, and are biting and clawing beneath the surface for any relative advantage they can get. For one company to get a company-specific piece of functionality placed above another company's bit in the backlog is just such an advantage, and I wouldn't be surprised if one member of the organization tried to use this process to bury another member.

I would approach this situation in one of two ways:

Be the product owner for the group of companies. This means being the mediator, and possibly arbitrator, of disputes between the stakeholders with regard to prioritizing the backlog and creation of requirements. This would have significant value to both the stakeholders and the development firms you worked with; you become a "buffer" between the two sides, taking on the unenviable position of insulating the development effort from the politics of the requirements generation. To the stakeholders, you're a consultant and guide through the Agile process, smoothing out the bumps in the road so they don't derail the whole effort.

Arrange the development effort according to the stakeholders themselves. If there is a "common" set of functionality that most or all of the stakeholders can agree on, set up a large "core" team to build the basic software. Then, if one company, or even two or three, need it to work a different way for them and the group as a whole is unwilling to support the effort, you can set up or spin off smaller teams that can attack these additional pieces of functionality according to a separate backlog. These customer-specific teams are still subject to the critical path of the core backlog; creating company-specific functionality that is a change to the core feature will always be dependent on the core feature being implemented first. Definitely make sure the additional functionality is integrated in such a way that the project still passes the core ATs; those are the ones for which you and the developers will be getting the lions' share of the contract price.

Title: Using Scrum/agile with multiple customers

Body:
I am a big believer in agile development. I just changed jobs, and I am now working for a company that coordinates big development projects for (rather large) groups of customer organizations. My job is to find the right contractors for the projects, and make sure that the customer organizations are as happy as possible, and control the process. There is nothing in the world that would make me happier, than if I could introduce Scrum or a similar agile method into this situation, making my company's main role the product owner. It would make sense on so many levels.

There are some issues though: Since Scrum is a rapid-response method, I wonder if Scrum is the right method for a place like this, where not one customer but a big group of customers have to be involved in prioritizing of the backlog from sprint to sprint. It takes place in a quite political environment. What pitfalls and possibilities do you see in a situation like this? Can this situation simply be handled by longer sprints?

There is a general understanding and empathy for the agile agenda in the company, but the issue I describe here seems to be a major obstacle.

I would really appreciate your input. I need good ammo for my agile preaching :o)


问:
Architecting a multi-technology solution
I am trying to solve an issue with reusing components. I have some UI components (a mix of JS, CSS, and HTML) that are not specific to any application.  These UI components need to be able to be used in multiple applications. One is a RoR application, the other is an ASP.NET MVC application. How can I maintain these components (e.g. with version control, distribution) and still make them accessible to the different platforms that need to consume them?

For example, ApplicationA and ApplicationB use UIComponentA, which is not natively a part of their projects or repositories, because UIComponentA lives in its own repository. How can these projects get the dependencies they need while keeping the components reusable and hosted in their own location? Does anyone have experience with a similar situation, and if so, how did you tackle it?

If you need further information, don't hesitate to ask, I will update this question.

答: I think you can look at any number of publicly available client-side frameworks like jQuery and YUI and see how they are deployed. Any particular project may be dependent on a specific version of the UI lib. It can either copy the relevant version to it's own repo or grab as part of the deployment process. Another option is CDN approach where the UI components are actually hosted independently and are just pulled in client-side.</p>


答: One option would be to host the packages (JS, CSS, Static Images, etc) on a publicly accessible URL and just reference them where needed by the url. This is how jQuery and all the big libraries do it.</p>

Title: Architecting a multi-technology solution

Body:
I am trying to solve an issue with reusing components. I have some UI components (a mix of JS, CSS, and HTML) that are not specific to any application.  These UI components need to be able to be used in multiple applications. One is a RoR application, the other is an ASP.NET MVC application. How can I maintain these components (e.g. with version control, distribution) and still make them accessible to the different platforms that need to consume them?

For example, ApplicationA and ApplicationB use UIComponentA, which is not natively a part of their projects or repositories, because UIComponentA lives in its own repository. How can these projects get the dependencies they need while keeping the components reusable and hosted in their own location? Does anyone have experience with a similar situation, and if so, how did you tackle it?

If you need further information, don't hesitate to ask, I will update this question.


问:
Custom heap allocators
Most programs can be quite casual about heap allocation, even to the extent that functional programming languages prefer to allocate new objects than modify old ones, and let the garbage collector worry about freeing things.

In embedded programming, the silent sector, however, there are many applications where you can't use heap allocation at all, due to memory and hard real-time constraints; the number of objects of each type that will be handled is part of the specification, and everything is statically allocated.

Games programming (at least with those games that are ambitious about pushing the hardware) sometimes falls in between: you can use dynamic allocation, but there are enough memory and soft real-time constraints that you can't treat the allocator as a black box, let alone use garbage collection, so you have to use custom allocators. This is one of the reasons C++ is still widely used in the games industry; it lets you do things like http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html

What other domains are in that in-between territory? Where, apart from games, are custom allocators heavily used?

答:
Another area where you might want a custom allocator is to prevent heap fragmentation. Over time your heap may allocate small objects fragmented throughout the heap. If your program can't keep heap memory together, when your program goes to allocate a larger object, it has to claim more memory from the system as it can't find a free block in between your existing, fragmented heap (too many small objects are in the way). Your program's total memory usage will increase over time, and you will consume additional pages of memory unnecessarily. So this is a pretty big issue for programs that are expected to run over long periods of time (think databases, servers, etc etc).

Where, apart from games, are custom allocators heavily used?

Facebook

Check out jemalloc that Facebook is starting to use to improve their heap performance and decrease fragmentation.

Title: Custom heap allocators


问:
Why does shared state degrade performance?
I've been working under the share-nothing principle of concurrent programming. Essentially, all my worker threads have immutable read-only copies of the same state which is never shared between them (even by reference). Generally speaking, this has worked really well.

Now, someone has introduced a no-lock singleton cache (e.g. a static dictionary) that all the threads are accessing concurrently. Since the dictionary is never altered after startup there are no locks. There haven't been any Thread-Safety issues, but now there is a performance degradation.

The question is... since there are no locks why does the introduction of this singleton create a performance hit? What exactly is going on under the covers that could explain this?

To confirm, accessing this new singleton is the only change and I can reliably recreate this simply by commenting out the call to the cache.

答:
I would make sure that the Equals() and GetHashCode() methods of the objects you use as keys to the dictionary do not have any unexpected non-threading-friendly side-effects. Profiling would greatly help here.

If by any chance your keys are strings, then perhaps there you have it: rumor has it that strings behave like immutable objects but for the sake of certain optimizations they are internally implemented in a mutable fashion, with everything that this entails with respect to multithreading.

I would try passing the dictionary to the threads that use it as a regular reference instead of a singleton to see whether the problem lies with the sharedness or with the singletonness of the dictionary. (Eliminating the possible causes.)

I would also try with a ConcurrentDictionary instead of a regular Dictionary just in case its use yields some surprising results.  There are lots of things to be speculated about the problem at hand if a ConcurrentDictionary turns out to perform much better or much worse than your regular Dictionary.

If none of the above points to the problem, then I would guess that the degraded performance is caused by some weird sort of contention between the garbage-collecting thread and the rest of your threads, as the garbage-collector is trying to figure out whether the objects in your dictionary need to be disposed or not, while they are being accessed by your threads.


问:
How can I convince my managers to enforce documentation standards?
I'm trying to convince another group in my company— that's about to hand code off to my group—that they need to provide more documentation in their source code,  but they're treating it as a "nice to have".

In my view, it's a necessity. Of course, I also support intuitive naming conventions, but I think I'll have less difficulty getting the original authors to add comments than I would getting them to rename their functions and variables.

I've run a source code analysis tool and it's showing about 10% comment line, but looking at the source code, most of that is coming from entire functions that the author has commented out.

How can I convince my managers to enforce documentation standards on this other team? Have there been studies or work done to prove that code documentation increases profitability or productivity?

答:
If your goal is to somehow convince the other team to sit down and comment-up the code and provide documentation, I think you'll be in for a big disappointment. There's no way a team is going to crack open the code base and start commenting stuff for your team en-masse. Even if they somehow get forced to do it, the value would be dubious at best.

I think a more pragmatic approach is to get the cooperation of some original key developers who can guide your team through the code base and who are willing to come back on an as-needed basis. Call it a "transition phase".

The documentation will have to be written by your team, but the good news is that they'll be vastly more motivated to get it right than a team that has to perform such a task before "throwing it over the wall".


答: From reading your question, the most significant issue seems to be "bolting down dependencies in a technology agnostic way". To be able to resolve this you could create a service facade that provides you with the reuasable elements as mentioned by @Mike Brown and also provide data and functionality by exposing some implementation of RestFull services. This introduces an extra layer in your system by which you isolate the top level(UI) components from the implementation of the components it depends on.</p>


答:
I don't want to sound too pessimistic here, but if on the same project you're the only one of quite a few who is unit testing, you might as well not do it at all. Compromise on integration tests, even if they're less accurate and slower.

The reason is that you're going to find yourself with a code base that's only partially-tested, inconsistent and hard to follow. And that's much worse in my book than a project without unit tests. Again, remember that integration tests are still possible.

The better alternative would be to persuade them that unit-testing will make their life easier and help them create a better product.

If you still choose (for some odd reason) to unit-test, what I do with legacy code goes pretty much like this:

I start developing my classes

When I need a legacy service, I create an interface for it, and then create an adapter that implements that interface and delegates all work to the actual legacy service.

That way I can work with legacy services and mock them in my classes' tests, without changing any legacy code.

And if you need to fix stuff in legacy code, slowly turn it to testable code - starting from integration tests and slowly and carefully turning them into unit-tests (only of the part you're fixing). Do that and you'll slowly have more and more parts of the code base that are testable (and tested).


问:
Software Development - Project, 1 Programmer - What if hit by bus?
The company I am currently working for has me developing a bunch of internal mission critical software. I have one other person that works for me but he's more of a testing guy and not really a developer. The company is concerned about some of these projects and what happens if I am hit by a bus. How does the company pick back up after something like that when there is only one person that knows the code base. One person that knows the current status of the project.

I explained that with my documentation and with the documentation with in the code that they would really only need to hire another programmer that understands the languages that were used and that they could be up to speed pretty quickly.

They suggested an outside firm that might be "kept up to date" on a monthly basis that could "take over" in the event something happened. I just don't see how this could be helpful beyond paying someone for the sake of paying them. Worse I envision a day a month being wasted discussing the project with this consulting firm. I see how this could be helpful I just don't see it as anymore helpful than hiring a programmer after my untimely demise.

Thoughts? Similar situation and how its currently being handled where you work?

答:
I hope you don't get hit by a bus! You are correct, I don't see the value of doing this. First, the other company will charge an amount closer to a full time developer and they will critique things and slow you down. They may ask for too much deliverable and explanation from you. Also, there is no real guarantee that they will be able to pick up, since there will be no chance for you to test them before they are required to take over.

I suggest that the company invests in another developer instead. This developer does not have to be on your level of expertise, but the time spent with him/her would be an investment to the project. You will get several opportunities to test his understanding since he will be working hands-on with you.

Make sure you don't ride the same car when you go to lunch :)


答:
Unfortunately what they're doing is "putting all of their eggs in one basket".

Working with an outside firm is quite likely to provide revenue for them, but I seriously doubt that it'll be worth the money. Documentation always looks nice and clear when you write it. The problem is that you only know how much it's worth when somebody else tries to read it - somebody that barely knows something (technical) about the (insides of the) project.

Anyway, reading a complete code base you don't know anything about is possible, it might just take a whole lot of time (way beyond most businesses can afford).

Their best honest bet is to hire someone to work with you (strictly not under any of your guidance) for a certain period of time, and to test how long it takes him to get to a point where he can understand and change important parts of the project.

If it takes more time than they could afford if you left, then they should seriously consider hiring one or more permanent programmers (full or part time), and never let them take the same bus. :)

Either way, good programmers suddenly leaving always makes matters worse than they were.

Title: Software Development - Project, 1 Programmer - What if hit by bus?

Body:
The company I am currently working for has me developing a bunch of internal mission critical software. I have one other person that works for me but he's more of a testing guy and not really a developer. The company is concerned about some of these projects and what happens if I am hit by a bus. How does the company pick back up after something like that when there is only one person that knows the code base. One person that knows the current status of the project.

I explained that with my documentation and with the documentation with in the code that they would really only need to hire another programmer that understands the languages that were used and that they could be up to speed pretty quickly.

They suggested an outside firm that might be "kept up to date" on a monthly basis that could "take over" in the event something happened. I just don't see how this could be helpful beyond paying someone for the sake of paying them. Worse I envision a day a month being wasted discussing the project with this consulting firm. I see how this could be helpful I just don't see it as anymore helpful than hiring a programmer after my untimely demise.

Thoughts? Similar situation and how its currently being handled where you work?


答:
How can I convince my managers to enforce documentation standards on this other team?

In case like that I'd appeal to effort estimation for hand-off. I'd do a preliminary study of available documentation and summarize my findings in a form that is readable for management.

"1. Source code analysis tool is showing about 10% comment line, but after trial removal of entirely commented functions that value dropped to about 0.5%. 2. Presence of intranet documentation: 1 confluence page with about 1 Kb of text and two sharepoint pages with 20 lines of text. 3. Feature specifications: not found. 4. Issue tracker: studying sample selection of 5 randomly picked issues (#17, #31, #98, #118, #234) has shown these to be completely worthless as a source of project knowledge. 5. VCS: studying sample selection of 5 randomly picked commits (#1017, #1031, #1098, #1118, #1234) has shown these to be completely worthless."

After that I'd present management two efforts estimates to complete hand-off - one for the case if things are as-is and another in case if "another team" provides docs and these docs pass a review from my team and let them choose.

"Hand off effort for as-is option: about 12 mythical man-months. For a documented-and-passed-review option: 1 month to review plus 1 month for hand-off."

I wouldn't wonder BTW if the management picks the as-is option (been there done that - their brain just sometimes operates on a different frequency if you catch my drift).

Have there been studies or work done to prove that code documentation increases profitability or productivity?

Even if there are such studies they might turn out worthless for you. I mean, even if you somehow will be able to enforce some standard on these guys, they will most likely find a way to quickly hack it through (you mentioned the group has smart guys didn't you?) and leave you with a few hundreds kilobytes of useless garbage that perfectly conforms to your standard whatever it will be.

Title: How can I convince my managers to enforce documentation standards?

Body:
I'm trying to convince another group in my company— that's about to hand code off to my group—that they need to provide more documentation in their source code,  but they're treating it as a "nice to have".

In my view, it's a necessity. Of course, I also support intuitive naming conventions, but I think I'll have less difficulty getting the original authors to add comments than I would getting them to rename their functions and variables.

I've run a source code analysis tool and it's showing about 10% comment line, but looking at the source code, most of that is coming from entire functions that the author has commented out.

How can I convince my managers to enforce documentation standards on this other team? Have there been studies or work done to prove that code documentation increases profitability or productivity?


问:
Non-OOP languages advantages and good uses
I'm a C# developer, but I also know Java, JavaScript, XSLT, a little of C and Perl, and some other that I may have forgotten. Still, the paradigm I'm most familiar with is OOP.

I have always thought that OOP was the natural evolution of procedural programming, but I wonder if OOP is that perfect. After reading some articles on the web and some questions here, I found that many people don't agree with this and some say that OOP is a bad option.

While developing, I really appreciate using lambdas, LINQ, anonymous types, and really enjoy JavaScript with its prototyping and dynamic nature.

But still, I can't think of any scenario where OOP is not an option, or where other paradigms fit better. The only thing I can think of is that sometimes programming with OOP is really boring and slow, like having to declare a class, import some other classes, declaring a method, specifying its parameters, return type and name just to show "Hello, World!" on the console screen. But still, for real-life programs, it seems like something that compensates its cost.

In what scenarios do other paradigms fit better than OOP? What are their advantages over OOP and where does OOP make things worse instead of helping? Especially, what are the advantages and in what scenarios do procedural and functional programming excel?

答: For instance, functional programming languages are very useful in a context where you are interested in provably correct programs. They have the property that you operate with expressions which always evaluate to the same value. There is no notion of "state" of your program (except possibly for some bootstrapping code), which facilitates proving correctness in a mathematically rigurous way.</p>

ContentLicense: CC BY-SA 4.0


答:
One solution that would actually have value is to hire you a mentor. This is a service I provide for software firms that are local to me. I visit for half a day a week or a day a week. Each visit provides immediate value like making sure the developers are using best practices, teaching them new things they need to learn, giving them a chance to be exposed to new things since they're usually busy coding and don't go to launches and the like, solving their immediate bugs and roadblocks, explaining things they don`t know how to do, and so on. At times, I handle coding tasks, especially for one-offs where the staff would need to learn a lot to do the task, and then would never need to do it again. I can also project manage things like getting a Disaster Recovery Plan written - it needs answers from devs and management, but I at least know the questions.

Such an arrangement is likely to be cheaper than what your boss is suggesting, and have value for you. It has a side effect that the mentor will learn your system and would probably be able to train your replacement if you were to be hit by a lottery.


问:
Is there something like Diaspora written in PHP?
I am looking for an open source social networking platform. Diaspora is perfect, except it is not written in PHP. Is there a project like Diaspora written in PHP?</p>

答:
Elgg fits that description. From their about page:

Elgg is an award-winning open source social networking engine that provides a robust framework on which to build all kinds of social environments, from a campus wide social network for your university, school or college or an internal collaborative platform for your organization through to a brand-building communications tool for your company and its clients.


答:
I don't think there is such a specific list for Ext JS, you will have to compile your own one. There are plenty of code review check lists to be found in the internet. Most likely you put together several lists depending on your needs:

general list on correctness (e.g. requirements, tests passed)

general list on coding (names, method length, e.g. see book "Code Complete")

general lists on JavaScript fundamentals (JSLint result, bug patterns, e.g. see book "JavaScript the good parts")

general lists on Object Orientation (SRP, sizes, APIs, coupling, e.g. see book "Clean Code")

add more general lists, depending on your environment

and the most important the special lists, you come up after being bitten by something in the past. These are your specific rules

coding standards

adherence to naming standards

adherence to architecture

etc.

For the ExtJS specific part, you might also ask on the mailing list of ExtJS developers/users for common pitfalls and problems when using ExtJS. I'm sure the ExtJS community likes to have an Anti-Pattern list of things to avoid (and most likely this was your original question...).

Title: Ext JS code review check list

Body: Can any one share a code review check list for Ext JS in common and specially for Ext JS 3.4 ?</p>


问:
Keep my classes and methods as small as possible?
A few days ago, I was talking to a Software Engineering PhD candidate and at some point she said to me:

Keep your classes and methods as small as possible

And I wonder if this is always a good practice.

I mean for example, is it worthy to have a class with only 2 attibutes in it? For instance, In  some methods I need pairs of integers to work with. Should i write a "PairOfIntgers" class?

Could this way of thinking "break" the code in too many pieces?

答:
Uncle Bob says you should refactor/split/extract your methods until it is impossible to make them smaller. This usually ends in having several methods with 3 or 4 lines each. When you get too many methods, you have to make more classes.

If you try to follow SRP and one level of abstraction per method, these rules serve you well. At least they serve me well. Aiming for "as small as possible" gives me reasonable small methods, as I usually fall short the aim.

And it's always easier to understand smaller classes. Go ahead, read "Clean Code"


问:
Should the deploy script be an artifact of the build?
This is a web project written in Java.

So, I'm writing the build and the deploy scripts. To create the build, I used ant. The continuous build is done with Jenkins.

The build generates 3 different artifacts:

The war file

A zip with layouts

A zip with images

So far, so good, but now I need to write the deploy script, which should:

Deploy the war (artifact 1) to the tomcat running at server 1

Place the artifact 2 at server 1 in a specific directory

Place the artifact 3 at server 2 in a specific directory

So I was talking with my colleague and he said that we should also generate an artifact (maybe deploy.xml) that deploys these artifacts when placed at the correct server.

So there would be another script, that would:

Download the jenkins artifacts

scp to each server and place the deploy.xml there

remotely invoke the deploy.xml

What makes me a little uncomfortable is the act of having the deploy.xml as a build artifact. The motivation behind this would be to be able to make a deploy without needing to have access to the VCS repositories, so a build would be self-contained, ie, any build could go into production only with what was generated by Jenkins.

Where should the deploy scripts be placed? Should they be only at the VCS or should they be build artifacts too?

答:
All that Peter Rowell wrote, is correct, in addition I would:

For the deploy script file

if it was written by someone, it needs to be in version control.

if it was generated and can be generated again, it usually does not go into version control.

For the deploy process:

If you like your artefacts to be self-contained and if it could be done easily, then the file could be a build artefact, meaning that it's packaged with the build result in such a manner that it's usable for deployment.

On the other hand, deployments get more and more complex so sooner or later you will need a dedicated program (read some code) that does the deployment and a Jenkins build artefact is not self contained any more.

This is rather depending on your process and how you like to handle deployments.


答:
ISO 9001 in this business is all about the getting hit by a bus scenario. Will getting services from that company allow your company to qualify for that certification? This may be an interesting question to ask them.

Or to make'em go around in circles searching for answer. (that would probably sound very similar to "no")


答:
It is more common than you think for companies to have a plan in place for if some critical employee is hit by a bus.

Usually though it's pairing up the key talent with someone internal (who isn't allowed to travel on the same flights... Or buses) to prevent competitive advantages and ideas from leaking outside to the competition.


问:
Ease the pains of unit testing C# when you are the only person on the team unit testing
I have ran into this a few times where you get put on a project and you want to do unit testing of some type, but the project isn't setup right to allow for this and you might not have buy-in from everyone.  The main issues tend to be code smells like issues with dependencies (especially the over use of statics) and seperation of concerns.  New code that you write can be setup easily, but anything that operates with other legacy code or even those not drinking the cool aide can become an issue.

Some things that I have found are that isolation frameworks like TypeMock can make this easier. What are some other tools/tricks/best practices that you have found that ease this sort of pain?

答:
Wow, this describes a recent situation of mine exactly on a large, existing project.  No unit tests at all, and reluctance toward/skepticism of the idea.  At the time of writing, I've been able to work with another person who favored it to get it more accepted (though he and I are largely the only ones that generally write tests).  The code base was (still is) heavily laden with procedural static code, but it's getting better.  Here are some of the things that I did to improve the situation:

Immediately interface all singletons, especially ones in heavy use.  Then, inject the interface into the new client classes you're writing to make them testable.

Write wrappers for static classes that implement interfaces and inject those into new clients ala (1).

Start gradually retrofitting your injected interfaces on former clients of static state/singletons and writing tests for them.

Starting pulling functionality out of behemoth classes and testing the extracted, single-responsibility classes.

Touched on earlier, but inject your dependencies!

Write or factor to small methods and classes.

Keep up the refactoring until you can finally kill the singletons/statics.

These are ways to make your code more testable (and, I would argue, better in general), but selling the process to others is a different matter.  I would offer the following advice for that:

Write tests and show people how to do it  (the biggest barrier being a literal lack of knowledge of how to write tests).

If you review people's code, write a unit test to expose a problem instead of telling them about it.  Show them the failing test and task them with making it pass.

Make sure your test runs execute quickly - long running test suites will rot and annoy people.

If the application is large, show people that the feedback loop is much faster for modify-test-refactor than it is for modify-build-run-maniulate-gui-observe-refactor.

Unit test a feature that you write and keep objective statistics (defects reported per LOC) to compare to non-tested code.  This is a win with management.

Along those same lines, run static analysis/metrics on the unit tested code which, in my experience, tends to score better than non-tested code.  Objective metrics are hard to argue with.

Point out to people that guarding their code with unit tests makes it harder for someone to come along and mess with their code in defiance of their original intentions.  Sounds petty, but this is often a selling point for people when they realize it.

Product implementation documents or writeups for consumption by stakeholders that emphasize code coverage or number of tests.  This creates the (accurate) impression that your code is demonstrably reliable and managers/analysts/PM types might start asking others where their coverage/test metrics are.

Finally, and this is the one that I've found to be most eye opening or other developers, demonstrate the power of unit testing (specifically TDD for this one).  Pull off a coup like a major refactoring of your work in less than a day or having your code execute perfectly the first time you put it all together and run the application.  Developers who code it up and then spend a few days in the debugger programming by coincidence will be sobered by this in a way that they won't be all the unit test proselytizing in the world.


问:
Best design for Windows forms that will share common functionality
In the past, I have used inheritance to allow the extension of Windows forms in my application. If all of my forms would have common controls, artwork, and functionality, I would create a base form implementing the common controls and functionality and then allow other controls to inherit from that base form. However, I have run into a few problems with that design.

Controls can only be in one container at a time, so any static controls you have will be tricky. For example: Suppose you had a base form called BaseForm which contained a TreeView which you make protected and static so that all of the other (derived) instances  of this class can modify and display the same TreeView. This would not work for multiple classes inheriting from BaseForm, because that TreeView can only be in one container at a time. It would likely be on the last form initialized. Though every instance could edit the control, it would only display in one at a given time. Of course, there are work-arounds, but they are all ugly. (This seems to be a really bad design to me. Why can't multiple containers store pointers to the same object? Anyhow, it is what it is.)

State between forms, that is, button states, label text, etc., I have to use global variables for and reset the states on Load.

This isn't really supported by Visual Studio's designer very well.

Is there a better, yet still easily maintainable design to use? Or is form inheritance still the best approach?

Update
I went from looking at MVC to MVP to the Observer Pattern to the Event Pattern. Here is what I am thinking for the moment, please critique:

My BaseForm class will only contain the controls, and events connected to those controls. All events that need any sort of logic to handle them will pass immediately to the BaseFormPresenter class. This class will handle the data from the UI, perform any logical operations, and then update the BaseFormModel. The Model will expose events, which will fire upon state changes, to the Presenter class, which it will subscribe (or observe) to. When the Presenter receives the event notification, it will perform any logic, and then the Presenter will modify the View accordingly.

There will only be one of each Model class in memory, but there could potentially be many instances of the BaseForm and therefore the BaseFormPresenter. This would solve my problem of synchronizing each instance of the BaseForm to the same data model.

Questions:

Which layer should store stuff like, the last pressed button, so that I can keep it highlighted for the user (like in a CSS menu) between forms?

Please criticize this design. Thanks for your help!

答:
I maintain a new WinForms/WPF application based on the MVVM pattern and Update Controls. It started as WinForms, then I created a WPF version because of the marketing importance of a UI that looks good. I thought it would be an interesting design constraint to maintain an application that supported two completely different UI technologies with the same backend code (viewmodels and models), and I have to say I'm quite satisfied with this approach.

In my app, whenever I need to share functionality between parts of the UI, I use custom controls or user controls (classes derived from WPF UserControl or WinForms UserControl). In the WinForms version there is a UserControl inside another UserControl inside a derived class of TabPage, which is finally inside a tab control on the main form. The WPF version actually has UserControls nested one level deeper. Using custom controls, you can easily compose a new UI out of UserControls that you created earlier.

Since I use the MVVM pattern, I put as much program logic as possible into the ViewModel (including the Presentation/Navigation Model) or the Model (depending on whether the code is related to the user interface or not), but since the same ViewModel is used by both a WinForms view and a WPF view, the ViewModel is not allowed to contain code that is designed for WinForms or WPF or that directly interacts with the UI; such code MUST go into the view.

Also in the MVVM pattern, UI objects should avoid interacting with each other! Instead they interact with the viewmodels. For instance a TextBox would not ask a nearby ListBox which item is selected; instead the listbox would save a reference to the currently selected item somewhere in the viewmodel layer, and the TextBox would query the viewmodel layer to find out what is selected right now. This solves your problem about finding out which button was pushed in one form from within a different form. You just share a Navigation Model object (which is part of the application's viewmodel layer) between the two forms and put a property in that object that represents which button was pushed.

WinForms itself doesn't support the MVVM pattern very well, but Update Controls provides its own unique approach MVVM as a library that sits on top of WinForms.

In my opinion, this approach to program design works very well and I plan to use it on future projects. The reasons it works so well are (1) that Update Controls manages dependencies automatically, and (2) that it is usually very clear how you should structure your code: all code that interacts with UI objects belongs in the View, all code that is UI-related but does not HAVE to interact with UI objects belongs in the ViewModel. Quite often you will split your code into two parts, one part for the View and another part for the ViewModel. I had some difficulty designing context menus in my system, but eventually I came up with a design for that too.

I have raving about Update Controls on my blog too. This approach does take a lot of getting used to, though, and in large-scale apps (e.g. if your listboxes contain thousands of items) you may encounter performance problems due to current limitations of automatic dependency management.


答:
I agree with the OP. Hiring another developer is better. If the knowledge base is in another company which they have no control over then the situation is just as risky.

To me it sounds like they want to replace you with off-shore labor where people can survive on $10 per month.


问:
How will C# 5 async support help UI thread synchronization issues?
I heard somewhere that C# 5 async-await will be so awesome that you will not have to worry about doing this:

```<code>if (InvokeRequired)
{
    BeginInvoke(...);
    return;
}
// do your stuff here
</code>```

It looks like the callback of a await operation will happen in the original thread of the caller. It has been stated several times by Eric Lippert and Anders Hejlsberg that this feature originated from the need to make UIs (particularly touch device UIs) more responsive.

I think a common usage of such feature would be something like this:

```<code>public class Form1 : Form
{
    // ...
    async void GetFurtherInfo()
    {
        var temperature = await GetCurrentTemperatureAsync();
        label1.Text = temperature;
    }
}
</code>```

If only a callback is used then setting the label text will raise an exception because it's not being executed in the UI's thread.

So far I couldn't find any resource confirming this is the case. Does anyone know about this? Are there any documents explaining technically how this will work?

Please provide a link from a reliable source, don't just answer "yes".

答:
Jon Skeet gave an excellent presentation covering Async methods in C#5 which you may find extremely useful:

http://skillsmatter.com/podcast/home/async-methods


答:
First, the person testing your code should not work 'under' you; it's a conflict of interest.

In your absence they need to assess the risk of falling behind in the areas of: debugging and adding new features. They can get someone up to speed to be a debugger quickly, unless you've written bad code. Usually, adding new features can wait until you get a new programmer ready. Not always the case when there are promises to existing clients or in a  market where you're trying to keep up with the competition.

I worked at a company where I was the sole developer. They didn't replace me with another programmer, but drastically changed directions and settled for a third-party application. Stranger business decisions have been made. This is preventing them from drastically separating themselves from the competition and having a tremendous amount of leverage to grow their business. Maybe that was no longer their goal?


问:
Which version of C should I learn?
It looks like K&R "C Programming Language (2nd Edition)" covers ANSI C, but another book that I'm starting (Stephen G. Kochan "Programming in C") says that it uses C99.

I'm coming from a C#/JavaScript/Python/PHP/Java background and looking to round out my skills.

I'm currently using GCC, but I'm curious about Clang. Which version is used more in new and existing code? Does it even matter, or should I learn both?

答: Use the C-subset of C++.   Being able to define variables close to where they are initialized and used is better than having C force you to declare a list of variables at the top.</p>

Title: Which version of C should I learn?


问:
Can I use Ruby to automate everything?
I face various types of applications (web-based, GUI-based, command-line, etc.) on various platforms (Windows, Linux, etc.) to operate everyday. There is a great opportunity for me to automate tasks by scripting. But almost every type of application and platform has its native scripting language or tools (such as VBScript and PowerShell for Windows, Bash scripts for Linux, Selenium for web applications, and AutoIt for GUI applications, etc.). It kills me to learn and maintain so many scripting languages.

I have a feeling that Ruby can interoperate with various platforms easily, and it is very expressive. So my question is:

It is possible to use Ruby to script everything?

If it is, what are the main disadvantages compared to the native scripting language of each platform?

答:
Ruby is a fine choice for a general purpose scripting language on Linux, OS X, etc. But I recently needed to write some scripts that would work on every version of Windows from 2000 through 7. VBScript didn't have the functionality I needed (talking to SOAP web services for example) and PowerShell isn't available for Windows 2000, so I looked outside the Microsoft toolkit and decided to give Ruby a shot (having used it on Linux in the past). I don't exactly regret the decision, but I do wonder if there might've been a better choice. My main complaints about Ruby on Windows were:

There's no 64-bit Ruby for Windows (as far as I know) which made trying to access virtualized areas of the system like c:\windows\system32 a drag. I ended up shelling out to VBScript for some of that stuff; maybe there's a better way I didn't figure out.

It's slow. I have a quad-core CPU and 6GB RAM and irb takes 2+ seconds to load.

While there are Windows-specific libraries for stuff like registry access and WMI, things definitely aren't always as easy as you think they might be and the relative lack of documentation does result in some trial and error.

Still, things basically work the way you'd expect and I like working with Ruby about a thousand times better than anything built into the OS, so at a minimum, I'd say you could do worse than Ruby for general purpose scripting on Windows.

Title: Can I use Ruby to automate everything?


问:
Internationalization : What things to think about?
I was listening to Jon Skeet's talk at the last StackOverflow Dev Days and he piqued my curiousity regarding internationalization.

Suppose I have a waffle-making program, either complete, or still in progress, and I want to distribute it to other countries. What kinds of things do I need to worry about regarding internationalization? What are some un-obvious but easy pitfalls?

答:
In addition to the above, consider date formats, spelling and screen orientation control. In reports where languages are read right to left, you need to worry about indentation direction.
Weekend vary across countries. If you are displaying calendars you need to make sure that the weekends show correctly. If you are not using MS-Windows, check about features in client OS regarding handling collating sequences for sorting and how does the OS. Error messages must be translated to users when the mode is not English. In the code. For the database side, you need to select the correct character codes. This varies from database to database and may affect date comparisons.</p>


问:
Default vs Impl when implementing interfaces in Java
After reading Should package names be singular or plural? it occurred to me that I've never seen a proper debate covering one of my pet peeves: naming implementations of interfaces.

Let's assume that you have a interface Order that is intended to be implemented in a variety of ways but there is only the initial implementation when the project is first created. Do you go for DefaultOrder or OrderImpl or some other variant to avoid the false dichotomy? And what do you do when more implementations come along?

And most important... why?

答: I think that while Default can make sense in some cases, it would be more helpful to describe the implementation. So if your interface is UserProfileDAO then your implementations can be UserProfileSQLDAO or UserProfileLDAPDAO or something like that.


问:
What should I learn from Scheme?
I was wondering what unique features I can learn from Scheme that would help me become a better programmer?

I have a lot experience in mainstream languages, and I am looking to expand my horizons and learn about functional aspects that are missing from other languages.  I am familiar with closures from javascript, lambda expressions from C#, and I was wondering what I can focus on that is lacking in other languages?  Aside from the Lisp syntax, I feel like what I have seen so far I've already encountered in other languages.

What is unique to Scheme/Lisp that will teach me something new?

答:
I can think of the following:

Real macros (using the full power of the language to generate code)

Homoiconicity (data as code, code as data)

Lazy evaluation

Continuations

I also think lisp languages should be awesome to define domain specific languages (DSL). That's something you might want to read about if you don't know about it already.

Title: What should I learn from Scheme?


答:
In fact there is a term called a projects bus number. If the bus number is one you have a big problem. FEMA in the US is asking companies to be better prepared for disasters.

It is not just the loss of a key developer. It is the impact of a natural disaster, or the lack of off site backups. There are many questions on this site asking if they need to use source control as a solo developer. The ability for a new developer to pull up the most recent version of the software and to see what parts are new will help them.

There is more info about PS-Prep at http://www.fema.gov/privatesector/preparedness, and http://readyrating.org/.


答:
It's not always that easy... There are lots of things to consider, depending on the complexity of the software you are developing, and where you are going to ship it. In fact it might end up just about anywhere, so the important thing is which locales are you going to officially support.

Obviously, there's the language of the interfaces. All text you use should relatively easy to change for its equivalent in an other language. Like someone pointed already, the length of labels will vary. Something written in Chinese won't take the same width as something written in German, for example. Lets add that non only the basic interface is to translate, but all info bubbles, help files if any, error messages, maybe not log files, but it depends on the application I guess. If your application supports languages, your website might want to catch up too.

Character encoding. It's good to provide many languages, but how are you going to do that? If everything is programmed with a narrow/basic character encoding, you will have problems with some accents and most languages which are not using our characters. Think of Korean, or Arabic. I guess someone would have to use Unicode as much as possible.

Widget disposition / window orientation. If you choose to support Arabic, for example, you will need to think about a way to more or less flip your interfaces. They're reading from right to left, so it would be normal to have labels on the right side of the element they describe (textbox for entry, for example).

Number formatting. In some locales, there is a comma instead of a dot to separate the fractional part from the integer part in a number. That one is pretty obvious, but depending on the application domain, there might be lots of other things to consider. Are negative numbers between parentheses or with a '-' in front of them? Are thousands separated or not, with a space or with a comma? Is the separation of digits always by 3, or is only the first group by 3 and the rest by 2? Are you using Arabic numbers or Indian, or others?

Date formatting. It's almost as complicated. You might have to store the full names of days of the week, of months of the year, and all of them abridged too. What ordering are they using (day, month, year? month, day, year? year, month, day? etc. etc.).

Time formatting. 24 hours or 12? ':' or 'h'? ':' or '.' for the seconds? I don't know much about time formatting, but I guess there are plenty of unknown to me ways to display time.

Graphics! If you have icons... You will want to verify not only that the letters or words on them are still meaningful for all locales, but that the symbols you use are also meaningful and still correctly oriented. If an arrow pointed left in the English version, you have chances it should point right in the Arabic version (but not necessarily!). If you put up a stop sign as a red octagon on your icon, people in some locales won't have a clue what that is for, or worse, they will be convinced it should be doing some other things than what you intended and programmed.

If you have to deal with addresses in your system, they get awkward in some places too. Great headaches if you have to validate them.

Etc.

Happily, there are libraries in many languages to take care of a good part of the work. When you don't have a good library to do that, you will probably want to define parameters for all your locales and define them in detail using XML files or other types of configuration files (or in a database if you ship one with the software, or if you don't mind adding a small footprint one).

Title: Internationalization : What things to think about?

Body:
I was listening to Jon Skeet's talk at the last StackOverflow Dev Days and he piqued my curiousity regarding internationalization.

Suppose I have a waffle-making program, either complete, or still in progress, and I want to distribute it to other countries. What kinds of things do I need to worry about regarding internationalization? What are some un-obvious but easy pitfalls?


答:
Any time you have an application which has a performance-intensive critical path, you should be concerned how you treat memory.  Most end-user client-side applications don't fall into this category because they are primary event-driven and most events come from interactions with the user, and that doesn't have that many (if any at all) performance constraints.

However, a lot of back-end software should have some focus on how the memory is handled because a lot of that software can scale up to handle higher number of client, larger number of transactions, more data sources....  Once you start pushing the limits, you can start analyzing how your software users memory and write custom allocation schemes tailored to your software rather than rely on a completely generic memory allocator that was written to handle any imaginable use case.

To give you few examples... in my first company I worked on a Historian package, software responsible for collecting/storing/archiving of process control data (think of a factory, nuclear power plant or oil refinery with 10's of millions of sensors, we'd store that data). Any time we analyzed any performance bottleneck that prevented the Historian from processing more data, most of the time the problem was in how the memory was handled.  We've gone through great lengths to make sure malloc/free were not called unless they were absolutely necessary.

In my current job, I work on surveillance video digital recorder and analysis package. At 30 fps, each channel receives a video frame every 33 milliseconds. On the hardware we sell, we can easily record a 100 channels of video. So that's another case to make sure that in the critical path (network call => capture components => recorder management software => storage components => disk) there isn't any dynamic memory allocations. We have a custom frame allocator, which contains fixed-size buckets of buffers and uses LIFO to reuse previously allocated buffers.  If you need 600Kb of storage, you might end up with 1024Kb buffer, which waste space, but because it is tailored specifically for our use where each allocation is very short-lived, it works out very well because the buffer is used, free and reused for next channel without any calls to heap API.

In the type of applications I described (moving lots of data from A to B and handling large numbers of client requests) going to the heap and back is a major source of CPU performance bottlenecks. Keeping heap fragmentation to a minimum is a secondary benefit, however as far as I can tell most modern OSes already implement low-fragmentation heaps (at a minimum I know Windows does, and I would hope others do as well). Personally, in 12+ years working in these types of environments, I've seen CPU usage issues related to heap quite frequently, while never once have I seen a system that actually suffered from fragmented heap.

Title: Custom heap allocators

Body:
Most programs can be quite casual about heap allocation, even to the extent that functional programming languages prefer to allocate new objects than modify old ones, and let the garbage collector worry about freeing things.

In embedded programming, the silent sector, however, there are many applications where you can't use heap allocation at all, due to memory and hard real-time constraints; the number of objects of each type that will be handled is part of the specification, and everything is statically allocated.

Games programming (at least with those games that are ambitious about pushing the hardware) sometimes falls in between: you can use dynamic allocation, but there are enough memory and soft real-time constraints that you can't treat the allocator as a black box, let alone use garbage collection, so you have to use custom allocators. This is one of the reasons C++ is still widely used in the games industry; it lets you do things like http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html

What other domains are in that in-between territory? Where, apart from games, are custom allocators heavily used?


问:
Would you see any use of a Trilean (True, False, ??)
Sometimes I have a function that should return true or false. But sometimes three possible values would make more sense.

In some language theses cases would be handled with integers or with exceptions.

For exemple you want to handle the age of a user if he is over 18 years old. And you have a function like this.

```<code>if(user.isAdult(country_code)){
     //Go On
}else{
     // Block access or do nothing
}
</code>```

But in some case depending how your app is built I could see case where the birthday field is incomplete. Then this function should return something undetermined.

```<code>switch(user.isAdult()){
    case true:
        // go on
        break;
    case undetermined:
        //Inform user birthday is incomplete
    case false:
        //Block access
}
</code>```

As I said we can handle that with Exceptions and Int, but I would find it quite sexy to have a true, false, undetermined embeded in the language instead of using some home defined constants.

答:
For C++, Boost actually implements a Tribool described as such :

The tribool class acts like the built-in bool type, but for 3-state
  boolean logic. The three states are true, false, and indeterminate,
  where the first two states are equivalent to those of the C++ bool
  type and the last state represents an unknown boolean value (that may
  be true or false, we don't know).


答:
They need an additional developer.  Its really that simple.  Both of you should work on the entire code base.  Or at least be familiar enough with each other's work to step in to fix problems in an emergency.  If budgets are tight, you could in theory even hire a part timer - that'd probably be sufficient.  Someone who could put in some hours every week learning the code by doing maintenance and fixes.  That would familiarize them enough.

Hiring an outside firm?  I'm with you there - they might as well flush that money down the toilet.  That they are thinking of hiring an external company to learn your system tells me they are either not actually concerned with the bus scenario (because, as noted, the solution is obvious) and just need a reason to toss the buzz phrase 'hit by a bus' around while playing golf with their fellow managers, or... that they are looking to outsource your job.  After all, if an external company can learn your entire code base for a lower price than an employee, at some point the pointy haired ones will ask then why do they need you?


问:
Why is the Unit of Work pattern considered fast and efficient when working with an ORM?
In working with Doctrine 2 I came across the following paragraph.

In fact, since Doctrine is aware of all your managed entities, when
  you call theflush() method, it calculates an overall changeset and
  executes the most efficient query/queries possible. For example, if
  you persist a total of 100 Product objects and then subsequently call
  flush(), Doctrine will create a single prepared statement and re-use
  it for each insert. This pattern is called Unit of Work, and it's used
  because it's fast and efficient

I am not up to speed on relational databases and ORM theory so I was wondering why is the Unit Of Work pattern  considered fast and efficient?

答:
One reason the Unit Of Work pattern can be efficient, as the paragraph states, is because it can batch several operations and reuse resources.

Using Unit of Work provides a context that can contain several operations into a single transaction that might otherwise be difficult to operate on together.

Also, not only can the Unit of Work use a single prepared statement for efficiency, but it may also be able to submit many inserts or updates to the database in a single call - if the database driver supports it - rather than executing each insert or update individually.

OwnerDisplayName: Peter Kelly


问:
Orthogonal design for product pricing and production planning with a NoSQL database
I am in the process of developing extensible software for the company I am working with for product pricing and production planning.

The Present Scenario

There are basically two types of products: manufactured and traded (simple buy and sell with no conversion). Manufactured can be regular or made-to-order with made-to-order mostly being a deviant of the regular model. There is only a finite number of products (around 2000) but each product has got multiple attributes such as size, color, shade and more. Presently, there is software for order management with inventory and a decent accounting package. Costing and pricing is now done on an arbitary basis via sampling a few models and adding overhead and margin percentages.

Required

To calculate product cost per unit

Convert them into a valid pricing model (pricing may differ upon quantity and other factors),

Calculate exact cost and profitability per product,

Proactively plan production for regular models and made-to-order units, based on existing order management system and inventory

Proposed Design

I have proposed the following design.

Store product information for each unique product in document-style based on the 5M's of production (Man, Material, Machines, Methods and Money)

A separate module of each of the four M's - Men, Machine, Material and Methods in terms of Money with primitive building blocks for each module that can be  merged and combined into a compound block

Store metadata and result set required along with each document

A separate layer to parse metadata, act upon data based on metadata and return result set as defined (similar to a DSL with both metadata and result set redefined at runtime)

A separate pricing model that works on the cost of the product

A separate production planning module that works on the data of the order management system and the product information

Using MapReduce to aggregate data and analyze it

Technologies: MongoDB, Python, Django, and NumPy

All data to be stored in JSON format with all business logic written to parse a JSON file (technically, in my case a Python dictionary) and produce output based on keys and values.

So why am I here?

The present software company has recommended a traditional out-of-the-box RDBMS system that could be customized. The main problem I find with the system is the duplication of data for products with varying attributes, lack of analytical tools, tight coupling with products and prices and too many joins for complex queries, but it is recommended for better robustness and better aggregate analysis and the XXXX always told market runs this approach. Since the entire software is not to be used in real-time and most of the real-time sytem links to unique products only.

Does my proposed design is truly orthogonal?

Does loose-coupling product, cost and pricing work?

What is the general approach for this kind of problem?

Do MapReduce provide a better way to analyze data for this kind of problems (along with NumPy) than the traditional SQL approach

Basically I work with numbers, and I am thinking of a generic model which I could extend in the future.

答:
You are likely to find better tools and (more important) expertize with RDBMS based solutions than the NoSQL based one. Typically, NoSQL based solution should be considered when you start hitting the performance limits (e.g. amount of storage, number of queries per second).

Almost every NoSQL solution would relax Consistency, Availability or Partition Tolerance requirement (see CAP Theorem) and you will have to handle that in your application logic. IMO, you should refrain from this complexity unless you are really hitting RDBMS limits.