答:
Think of the List as an array and the Dictionary as a hash table. You would only use the Dictionary if you needed to map (or associate) meaningful keys to values, whereas a List only maps (or associates) positions (or indices) to values.

For example, say you wanted to store an association between a person's age and their height. You could use a Dictionary<int, int> to map the person's age (an int) to their height (an int):

```<code>Dictionary<int, int> personHeightMap = new Dictionary<int, int>();

personHeightMap.Add(21, 185);
personHeightMap.Add(31, 174);

int height = personHeightMap.ContainsKey(21) ? personHeightMap[21] : -1;
</code>```

Not a very useful example, but the point is you wouldn't be able to do this as elegantly with a List because it would need to store these values positionally.

Title: Dictionary vs List

Body: So I ran into a Dictionary<int, int> today at work. This just seemed weird to me because I would have probably just used a List<int> instead. Is there a difference and would there be a use case where one structure would be preferred over the other?

Body:
Think of the List as an array and the Dictionary as a hash table. You would only use the Dictionary if you needed to map (or associate) meaningful keys to values, whereas a List only maps (or associates) positions (or indices) to values.

For example, say you wanted to store an association between a person's age and their height. You could use a Dictionary<int, int> to map the person's age (an int) to their height (an int):

Dictionary<int, int> personHeightMap = new Dictionary<int, int>();

personHeightMap.Add(21, 185);
personHeightMap.Add(31, 174);

int height = personHeightMap.ContainsKey(21) ? personHeightMap[21] : -1;

Not a very useful example, but the point is you wouldn't be able to do this as elegantly with a List because it would need to store these values positionally.


问:
Protecting proprietary code linking with LGPL v3 code
I've been warned that LGPL v3 forbids any kind of modifications that would prevent reverse-engineering, including software protection such as obfuscation.

In practice, does this license make it illegal to use something like SecureSWF, or simply a JavaScript minifier, when linking a program with a LGPL-licensed library?

答:
GPL requires that you make any modifications to the GPL'ed work, or any derived work, available as GPL.

GPL v3 clarifies this to say you can't take GPL'ed work, modify it and make the source available but ban someone from actually using it - by patents or code signing etc.

LGPL allows you to link the LGPL'ed code to your propriety code without releasing your own code. But you have to allow someone to swap the LGPL'ed code for another version so that they can modify it.

If your app checked for a particular LGPL library (by code signing etc) then it would not be acceptable - somebody would be unable to take the LGPL lib that they had written and change it while continuing to use it with your app. You are taking their work and not allowing them the freedom they demanded in return.

You can of course do anything you want with your app's code - you just have to let them change their work in the LGPL lib

OwnerDisplayName: Warren Seine

ContentLicense: CC BY-SA 3.0


问:
Isn't open source bad for developers themselves?
Why do programmers even like the idea of open source? I am not talking about the creators of those projects, of course they get fame, but I am talking about the industry in general, why are we so fond of the open source concept when it brings so many bad impact to the industry?

First, projects like wordpress and other CMS, they take away a lot of freelance jobs where clients want a blog or a simple website. Secondly, projects like Rails and other libraries and API's, they put a lot of programmers out of work, and make the demand for programmers smaller, because now with these open source API's, one programmer can do things that 10 programmers used to do. And finally, with open source software such as Notepad++, now people just feel funny when you ask them to buy software.

So, the question is, why do we still like open source if it kind of making us poor? Probably, my life as a programmer would be harder, but at least I can make a living out of it. But now, it's more like machine replacing human, funny thing is, we are creating those "machines" that replace ourselves.

Let's say, if you invented a tool, you don't have to share it, it will still help you and your company. Even without these open source tools, other programmers will live because they still have a job that makes money.

答:
Why do we like commodity hardware?

Intel and Dell stopped me charging for assembling my own computers and making my own PCBs.

High level languages mean I can't bill for 2 weeks work for a simple printer function written in Assembly.

And finally the internet means people can just ask questions for free and someone will answer them rather than having to pay me to write books and teach classes.

I just spent a couple of days installing and learning scipy+numpy+skimage, which means that I managed to write an image processor in a day. That makes me more valuable to my company's shareholders than if I had spent weeks of work going through the  maths of all the original papers and then coding everything in C++.


答:
Above and beyond Martin's answer:

Open source means that you get the opportunity to work on projects that you most likely wouldn't have gotten the chance to work on if you just stuck to what you did professionally. In that, there's two huge benefits:

Keeps you interested.

You learn from others who you wouldn't have otherwise worked with.

Both of these also make you a better programmer and more valuable to your company.

Title: Isn't open source bad for developers themselves?

Body:
Why do programmers even like the idea of open source? I am not talking about the creators of those projects, of course they get fame, but I am talking about the industry in general, why are we so fond of the open source concept when it brings so many bad impact to the industry?

First, projects like wordpress and other CMS, they take away a lot of freelance jobs where clients want a blog or a simple website. Secondly, projects like Rails and other libraries and API's, they put a lot of programmers out of work, and make the demand for programmers smaller, because now with these open source API's, one programmer can do things that 10 programmers used to do. And finally, with open source software such as Notepad++, now people just feel funny when you ask them to buy software.

So, the question is, why do we still like open source if it kind of making us poor? Probably, my life as a programmer would be harder, but at least I can make a living out of it. But now, it's more like machine replacing human, funny thing is, we are creating those "machines" that replace ourselves.

Let's say, if you invented a tool, you don't have to share it, it will still help you and your company. Even without these open source tools, other programmers will live because they still have a job that makes money.


答:
projects like Rails and other libraries and APIs, they put a lot of programmers out of work, and make the demand for programmers smaller, because now with these open source APIs, one programmer can do things that 10 programmers used to do.

Do you have any statistics that show this? In fact, according to Jevons' Paradox they should actually cause more demand for programmers.

Also, there are many contributors to open source and free software that get paid for it.


问:
Scrum for specialists teams
Scrum is best for teams with generalists members, that is teams where 2 people at least can do the same tasks. My main concern is to find good solutions to adapt scrum (what to keep, what to remove, what to improve) for teams made of specialists?

Suppose you have a team of 5 developers (not real, just for the example):

One mathematician with strong skills in C;

One DB developer;

One Web Developer;

One UX/GUI developer;

One software architect;

Here, all are specialists and no one can replace someone else (I don't care about the risks of building such a team, I want to focus on scrum). So, in a scrum context, here are my thoughts:

Useless spring plannings: indeed, when the mathematician says that a specific task is worth 2 points, nobody can vote against him;

Useless team velocity metric: as everybody can allocate any number of points to his own tasks, computing velocity makes not sense;

Replace daily scrum meetings with weekly (longer) scrum meetings: as each member of the team is working on his own tasks, daily scrum meetings should be really important to keep a "team spirit". However, daily scrum meetings are supposed to last around 15 minutes. This is clearly not sufficient to understand what the others are doing and will do. Moreover, the mathematician will most of the time answer the same things: "I am still doing %&Lo( + ?$$+&)"... Weekly meetings would give more time. To keep the same meetings time between "initial" scrum meetings and "weekly" scrum meetings, each weekly scrum meeting should last (5 days a week, with 4 weeks sprints, with sprint meetings lasting 4 hours and daily meetings lasting 15 minutes): (4*60 + 20*15)/ 4 => 2h-2h30 which seems reasonable.

Or is scrum still usable? Maybe another agile technique should be used?

答:
Scrum is not a silver bullet. Not every project has to use Scrum in order to succeed. The situation you are describing however sounds like a great fit for Lean / Kanban. You may wish to check it out.

Kanban basically asks you to do only a few things, none of which are at odds with the kind of team you are describing:

Visualize the flow of value, i.e. the Kanban board. The Scrum board is a specific application of a Kanban board; It is possible to adapt it to allow for specialization.

Limit the Work In Progress (WIP), so that the amount of work assigned to the team is just enough to keep the work constantly flowing - i.e. no "blockage" on either the start of the stream (design) or the end (deployment).

You might want to check out some references about Kanban:

One day in Kanban Land

Priming Kanban (free EBook)

OwnerDisplayName: Korchkidu

Title: Scrum for specialists teams


答:
After reading the question I remembered a fear that was spreading in my place during 1990s that, the computer will take their jobs away!

The open source and the larger developer community is critical for many reasons;

It helps the new members in the community to learn.

You do not have start all over again; there is something which is already done. You can start over it or keep that as a reference and build your stuff.

Nobody, who are serious about the business, will think that only open source is enough. Just to take an example, there is blogger, word press and lot many providing free blogs(as you told), But how many corporations or companies use them? 90% of will have their own websites and blogs.

Any industry grows by mutual sharing and learning. Open source provides a great platform to learn and adapt.

It reduces the cost of building the software drastically their by forcing more and more companies to use it, which will intern result in more jobs for the developers.


答:
Some developers of open source are paid to do so. If they are paid to develop a product, the business model under which the company provides that product shouldn't really matter.

If they are not paid, having the open source project on their CV can make them more demanded by prospective employers.

The majority of open source projects are libraries/frameworks which still require developers in order to incorporate them into products.

As the amount of open source tools increases it doesn't reduce the amount of work we can get because the products we create are also becoming more and more advanced, requiring more and more of these tools to support them.


答:
But now, it's more like machine replacing human, funny thing is, we
  are creating those "machines" that replace ourselves.

You seem to be afraid that at some point all the software will be written and we'll run out of work. In reality, the opposite is true. Software is never really "done" until it's no longer being used. The more software there is, the more software there is to maintain, to improve, and to recombine in new and interesting ways.

Furthermore, increased availability of software creates more clients, not fewer. Tools like MySQL and PostgreSQL open up the power of databases to millions of people and organizations that might never use a database if they had to buy a license from Oracle. The web would surely be much smaller and less useful if not for tools like the Apache web server, and that would mean many fewer jobs for web developers.


答:
One thing about open source is sharing ideas/code.  From a developement prospective, it can be a good learning experience looking at someone else's code and learning how it works or contributing to a open source project.  I see plenty of opportunity of learning and growth.  So, I don't see how it could be a negative from a development prospective.

But from a business standpoint, there can definately be negative consequences.  If I am selling a product for X and then there is an open source project which is for free (let's just consider it equal) then I am out of business.

Nothing is ever free.  Even with open source project(s), people gave up there time to produce something, maybe they were willing to do that, but time was still spent.  So its a double edge sword.  Whenever something is free it will de-value the market which it is developed for.  Why pay for something when it is free?  This may put people out of jobs or cause some markets to dry up.

But is can also spurn innovation.  It can move the industry forward, it can spark growth and further innovation.

In the end, I tend to think there is a middle ground.  Certainly we do not want to give everything away for free as a form of programming socialism.   But a mix of open source plus business source will keep the industry healthy and innovative.


答:
A useful thought experiment here is to work backwards. Why stop at web frameworks, what if everything had to be hand-coded in assembly? How many programmer jobs would there be then? Not many, because developing most things would be too expensive and take too long.

Having lots of software to build upon for free expands the market you can reach. How big is the market for a C program that you write in a day? Not very big. How big is the market for a website that takes you a day to make with some free frameworks? Easily in the tens of millions.


问:
How do you find time to work on Open Source Projects?
A bit of background: I've got a small open source project that I've started on, a basic framework which provides an object oriented means of generating HTML code (since I don't really like HTML, and I do like PHP). It has some released source, and a few downloads, but primarily, the project is for me, with the Open Source portion just being a side benefit.

The original project which caused me to be able to develop on this project has mostly gone into hibernation for the time being, which means that all the development I get to sink into it at this point is personal time only. Unfortunately, I'm currently working toward my bachelor's degree, studying for certifications, and I have a three month old baby at home. In short, by the time I get around to "me time", I rarely feel like doing work, but rather usually feel like just chilling out.

So, if there's anyone else out there who feels like they're in a similar position, what strategies have you used to keep yourself motivated toward working on the project? I would really like to at least be able to work on this until I have 100% spec coverage, but I haven't committed source in months. Anyone out there who can help?

答: I'd say that by far your most interesting project and top of the top priority at the moment is your baby - you should kick all the non-work related programming out and just enjoy the baby growing up, first smiles and giggles. Use your available time to watch a good movie/soccer game/ read a book, or  whatever relaxes you.</p>

ContentLicense: CC BY-SA 2.5


答:
You are focusing a bit too much on the mechanics of scrum/agile without looking at what agile is supposed to deliver. You say that if the maths guy estimates 2 points no one can say he's wrong. This isn't the goal. The goal is to agree an achievable set of objectives for the upcoming sprint. As the expert on that task he will know best how long it will take.

"So what if he lies or just gets it wrong?" you say. In my experience people under estimate more because they fear they will be shot for giving an accurate guess. Others under estimate then add a safety margin which balances everything out and the odd lazy person will over estimate so they don't have to rush. Of the three the first will be picked up on the velocity tracking, the second while sounding wrong, is working and the third is something you have to deal with outside of scrum.

The daily meeting still provides benefits. There are dependencies between team members even if they are each specialists. The UI guy may be waiting on the server guy to fix a notification bug. The server guy may be waiting on the maths guy to figure out why a calculation is wrong. It also isn't just about how their work affects you. If a team member is constantly being delayed because of "Reason X" but they haven't taken time to mitigate future "Reason X" occurrences, that can be challenged.

Title: Scrum for specialists teams

Body:
Scrum is best for teams with generalists members, that is teams where 2 people at least can do the same tasks. My main concern is to find good solutions to adapt scrum (what to keep, what to remove, what to improve) for teams made of specialists?

Suppose you have a team of 5 developers (not real, just for the example):

One mathematician with strong skills in C;

One DB developer;

One Web Developer;

One UX/GUI developer;

One software architect;

Here, all are specialists and no one can replace someone else (I don't care about the risks of building such a team, I want to focus on scrum). So, in a scrum context, here are my thoughts:

Useless spring plannings: indeed, when the mathematician says that a specific task is worth 2 points, nobody can vote against him;

Useless team velocity metric: as everybody can allocate any number of points to his own tasks, computing velocity makes not sense;

Replace daily scrum meetings with weekly (longer) scrum meetings: as each member of the team is working on his own tasks, daily scrum meetings should be really important to keep a "team spirit". However, daily scrum meetings are supposed to last around 15 minutes. This is clearly not sufficient to understand what the others are doing and will do. Moreover, the mathematician will most of the time answer the same things: "I am still doing %&Lo( + ?$$+&)"... Weekly meetings would give more time. To keep the same meetings time between "initial" scrum meetings and "weekly" scrum meetings, each weekly scrum meeting should last (5 days a week, with 4 weeks sprints, with sprint meetings lasting 4 hours and daily meetings lasting 15 minutes): (4*60 + 20*15)/ 4 => 2h-2h30 which seems reasonable.

Or is scrum still usable? Maybe another agile technique should be used?


问:
Dictionary vs List
So I ran into a Dictionary<int, int> today at work. This just seemed weird to me because I would have probably just used a List<int> instead. Is there a difference and would there be a use case where one structure would be preferred over the other?

答:
Semantically, a Dictionary<int, T> and List<T> are very similar, both are random access containers of the .NET framework. To use a list as a replacement for a dictionary,  you need a special value in your type T (like null) to represent the empty slots in your list. If T is not a nullable type like int, you could use int? instead, or if you are just expecting to store positive values, you could also use a special value like -1 to represent empty slots.

Which one you will choose should depend on the range of the key values. If your keys in the Dictionary<int, T> are  within an integer interval, without many gaps between them (for example, 80 values out of [0,...100]),  then a List<T> will be more appropriate, since the accessing by index is  faster, and there is less memory and time overhead compared to a dictionary in this case.

If your key values are 100 int values from a range like [0,...,1000000], then a List<T> needs memory to hold 1000000 values of T, where your dictionary will just need memory in an order of magnitude around 100 values of T, 100 values of int (plus some overhead, in reality expect about 2 times the memory for storing those 100 keys and values). So in the latter case a dictionary will be more appropriate.

Title: Dictionary vs List


答:
I do not have any numbers, but I suspect there's an awful lot more programmers today than there were even 10 years ago. Having been in IT-related work for a few decades now, I'd say that Open Source seems to be here to stay and is more beneficial than harmful.

Open Source itself is no more harmful than (say) PHP or Ruby. Both, incidentally, Open Source languages. It used to be, if you go far enough back, taht compilers (and interpreters) was something you had to pay for, but these days you can get decent compilers for free. Doesn't seem to have stopped the "writing commercial compilers" business (but I do not know if it has grown, shrunk or stayed the same over any period of time).


答: It still takes a programmer to operate these open-source tools and libraries. Just like in other fields, the scale is bigger. It's not impossible to build skyscrapers anymore, but it still needs engineers and workers to do it. Similarly, installing wordpress is 5 minutes, but if you want something customized, it still takes a programmer (be it a simple CSS change, most non-programmers are far from being able to do that, because it's not their profession). Maybe no one will hire you to write a blog engine, but there is always other work to do. The tasks that these open-source projects simplify or eliminate don't take much time, so businesses will do other things, and hire you for actual jobs. Why? Because everyone wants to expand to compete with others. That means they will invest in IT because there is business value in it. If there comes a widespread open-source solution that e.g. solves the problem of custom CRM software, there will be another area where businesses will try to get ahead of others.</p>


答:
Your position reminds me of Brave New World. In that book, they artificially halted scientific and technological development, so that people wouldn't lose their jobs and the status wouldn't lose its quo.

Even so, one of your points attracted my attention:

First, projects like wordpress and other CMS, they take away a lot of freelance jobs where clients want a blog or a simple website.

This reasoning is flawed, in my opinion, and here's why:

These projects only take away freelance jobs where the freelancer is expected to build the entire blog from scratch. On the other hand, they actually create more freelance jobs of setting up the CMS. Most paying customers have no idea what a CMS is and don't really care if you built it from scratch or just configured something as long as it works as expected.

It may be true that in many cases configuring a CMS gets you less cache than writing a full blown application, however consider that your own investment is quite a lot lower since it takes less time, so in general you should have net profit.

Sometimes clients specifically want you not to use a widely used CMS or at least customize it heavily so that their site would stand out. Needless to say, this usually costs more. As you can see, supply and demand did their job even here - lower price for an industrial product actually increased the price of a hand-made one.

Then you expand that point to include other libraries and APIs:

Secondly, projects like Rails and other libraries and API's, they put a lot of programmers out of work, and make the demand for programmers smaller, because now with these open source API's, one programmer can do things that 10 programmers used to do.

Again, my response:

These libraries decrease the amount of work only on quantitative basis, not qualitative. In English: they only decrease the lines of code, not the amount of work needed. Now that these libraries are widely available, you're just expected to use them to write even cooler stuff. So, no more blogs and simple sites, now you're billing data mining, social web and other new things.

They don't effectively put programmers out of work. In the older days, you'd code for days just to have a software that sends some data to another computer. Then, you have to meet the programmer from the other side and decide what format to use for data exchange and only then to make the program do some work, etc. By the time you get a chance to do that, your company is broke and you jobless. Today, you find the libraries and do the same work in hours. Your company makes money, you still have your job and even more opportunities arise.

Do you really like the idea of you and another 9 programmers busily typing code for yet another blog over and over hundreds of times? Please excuse me if it sounds like elitist bs, code hamsters are not the kind of programmers I want to see developing in the following year. For their sake and for my sake if I ever get to maintain that code.


问:
How to organize a framework based project in Git
Ok, so I have what appears to be a complex situation, and I'm wondering how to best organize it. I have limited experience with Git so I might be missing system.

I have a framework developed internally. This framework is being used my ProjectX, ProjectY, and ProjectZ. If I update the core components of the framework (Located in /core and /resources) I want it updated for all of my projects. However I want to be able to update the custom components of each project and have that tracked in Git as well (All custom content is located in /app).

So I'm thinking on our central server we should have a Git repository just for the core framework. This will contain the following:

```<code>core/*
resources/*
.htaccess
index.php
</code>```

Then each of our projects will have their own repository on the server containing the app/ folder.

Would this work with Git locally however? Can we pull the contents of two repositories to one folder? We might have /home/brandon/projects/ProjectX.

Just looking for input on how to organize this. Also, how would we push to the live/test environments? Would SSHing into the production environment and pulling from the central repository be the way to go?

答:
Sounds like git submodules are exactly what you are looking for.

Put your framework in one repo. And each separate project into its own repo as well. Then include the framework as submodule in the project-repos:

```<code>git submodule add <clone path to framework repo>
</code>```

Body:
Sounds like git submodules are exactly what you are looking for.

Put your framework in one repo. And each separate project into its own repo as well. Then include the framework as submodule in the project-repos:

git submodule add <clone path to framework repo>


答:
It's not a stupid question. I could argue that there is little imperative for me to write a useful bit of software to sell because there is probably already a free open source alternative. If there isn't, there may soon be if my software was any good.

The reality isn't like that. I remember back in the late 80s' and early 90's there was already a large body of free software. Take a look at the wiki article on Fred Fish for just one example. I had my own distributions, but they clearly weren't important enough to warrant a wiki article ;)

But for money software continues to appear and turn a profit. I work as a developer and earn a reasonable crust doing so. Open source has helped me at times in my corporate development, it has never been a problem, so on balance it is beneficial.


答:
I think its 'BUSINESS LOGIC' that matters the most and fetches money.

So let the people build the open source world and you worry on how you are gonna make a good business out of it.


问:
Why do people use programming books?
I find that when someone asks what is the best way to learn how to program, people usually provide them with references to a bunch texts written by various authors.

However I don't believe many people at all learn to program from books. I find that they are usually faced with a challenge and then use programming as a tool to overcome it.

For example I 'got into' programming because I wanted to start a server for a game I was playing, so I googled and read through the support for that particular server and now I am a employed software engineer, using only the skills I developed (and then further developed) by coding C# scripts for a not very popular server package.

So my question is, do people generally find it easier to learn from these books? I know I have looked at a few of them and found them far too 'dry' to encourage me to finish it.

答: I think I go for reading books.Especially downloading ebooks.Reading each and every part of the chapter.Copy their code! paste to your programming editor and then see what the output is.Then try to change the logic of it.I mentioned downloadable ebooks because to work faster.Books are really superb.I am not lying but since last November till today.I have finished around 20 books.It all requires love to read.What the newbies do is that they solve specific problem taking the help form internet.But when a real complex task is given to them,they give up.Reason,no knowledge about the task and its solution.For example I have bounded the controls with datatable and don't know what datasets do and I have been provided with the task to make relation(s) between memory resident copies of database tables I can't do it.</p>

Title: Why do people use programming books?


答:
If you're interested in building a high quality software product, you will find free and open source software a dream. If your product is good, it will sell. Note that the product that you're selling can have any form, for example, Software As A Service (SAAS) or Platform As A Service (PAAS).

When developing a product, you want to spend your limited resources (time and money) on adding value to your product, not on writing (boilerplate) code. Open source projects usually produce high quality software because they are open. More programmers can review the source code and contribute patches containing bug fixes, optimizations or more features. You don't get this luxury when buying software to use in your products. I don't say that buying software is bad. It's bad when you are not allowed to look at it's source code to see how it works or to fix it. And many times this comes with an expensive and low quality support package and/or with dependencies on expensive third-party components (a nightmare when you are concerned about the total cost of ownership).

Now, a distinction must be made between copyleft licenses like GNU GPL and more permissive licenses such as the MIT license. They have different purposes. Copyleft licenses demand that if you distribute your product, you must provide full source code access and must allow others to modify it as they see fit. I think that this is a good thing, but it's more difficult to monetize your work. That's why most successful open source projects are licensed under a permissive license (MIT, BSD, Apache, MPL, etc) than copyleft licenses such as the GPL or the AGPL. With copyleft licenses it's usually harder to protect your commercial advantages, but this depends on your business model. Another thing that I observed is that components released under a copyleft license tend to be isolated when they are integrated in a system, so that they not "contaminate" the whole system. An example is, for example, when you run a GPLed program in a different process or when GPLed components are bundled in a operating system (as the Linux kernel).

I personally believe in all the models above because, as in nature, there is always more than one way to accomplish something and you must choose the model that serves your purpose well.


问:
Where to define view-specific data objects in Rails
Background: there are several places in our app where we want to display date-oriented information on a calendar. The event_calendar gem looks nice and has lots of reviews, so it's what I'm planning to use. However, it's designed to work with a model. I'm not going to update our existing models to meet its needs, so will create a DTO class and a helper function to construct an array of instances from our existing models.

My question is: where should that DTO class live? It seems like it should be defined inside ViewHelper, but that will violate DRY as soon as I use the calendar for two models (note: the helper functions will differ, it's just the DTO class that will remain the same).

So, is there a standard place in the Rails directory tree where non-model-related classes live?

Or is there a better/more idiomatic way to do this? One thought that I had was to make my helper function decorate the existing model instances with the methods that event_calendar wants to see.

答:
I ended up creating a base class in lib, that defines the attributes and a few helper methods. I kept a class inside the helper, but all it has is an initialize (that's where the interesting stuff happens). I also have a helper function that does the map to convert objects.

Reading Steve Klabnik's blog, I came across the following quote, which I think summed up my feelings going into this. I think I've gotten over it.

Maybe it's that lib/ feels like such a junk drawer


问:
How do you share your craft with non programmers?
Sometimes I feel like a musician who can't play live shows. Programming is a pretty cool skill, and a very broad world, but a lot of it happens "off camera"- in your head, in your office, away from spectators.

You can of course talk about programming with other programmers, and there is peer programming, and you do get to create something that you can show to people, but when it comes to explaining to non programmers what is it that you do, or how was your day at work, it's sort of tricky.

How do you get the non programmers in your life to understand what is it that you do?

NOTE: this is not a repeat of Getting non-programmers to understand the development process, because that question was about managing client expectations.

答:
Three Words:

dumb it down

Programming is complex.  It takes a lot of work to understand it.  And the joys of programming are even more subtle.

For me to communicate my successes and such to others (ie family) I have to communicate on a more common level.  Compare programming to normal real world things.

(ie an object to a car with a dash board and seats and ....)

It is even better if you know something about your audience because you can use things that they understand that are more complex than normal everyday concepts.

For example, my wife was a school teacher, so I can compare some of my software development processes to teaching processes she had to use.  It helps immensely.

But in the end you got to simplify, simplify and simplify some more.  And even then, it is hard to get someone to understand how cool a well crafted class with good unit tests is.  :)


答:
You start your question by writing:

"I am not talking about the creators of those projects, of course they get fame, but I am talking about the industry in general, why are we so fond of the open source concept when it brings so many bad impact to the industry?"

But of course, it is precisely the creators of the open source software that matter: if they didn't write and release the code, it wouldn't exist; and if they do, it does, no matter what anyone else may wish.  And many — I would say, if not all, then almost all — of them get more than fame out of it.

Of course, some people get money from writing open source, either directly (e.g. they write the software and then sell support for it) or indirectly because they work for a company that pays them to write it (which generally means the company is getting something more than fame out of it).  But a lot of open source software is written for the writer's own use, by people who just want to "scratch an itch": they derive utility just from the existence of the software, and any improvements to it made by others are just bonus on top of that.

For example, let's say I want a blog.  And let's say I want my blog to have some set of features that no existing free blog software provides out of the box (because then I could just download the software and install it and be done).

One thing I could do would be to buy a closed-source blogging platform, if there was a suitable one on the market, and maybe pay the people selling it extra to add the features I need.  However, since I happen to know some Perl and PHP myself, I have a few more options:

I could write my own blog software from scratch, and keep it to myself.

I could write my own blog software from scratch, and release it as open source.

I could download an open-source blogging platform and add the features I need myself (and, if I want and/or the license requires me to, release the additions as open source).

(Of course, if my own programming skills weren't good enough, or if I felt I was too busy to waste my time on such work, I could also choose to hire someone else to do any of these things.)

Obviously, the last option is likely to be the easiest of the three, if there's any existing open source software that even gets close to what I need.  But even if there isn't, why would I choose option 1 over option 2?

Keep in mind that I have no interest in selling blogs or blogging software to other people — that's tedious and boring work, and it's not the business I'm in.  All I want is a blog for myself that has the set of features I need.  Nor do I lose anything if someone else uses the same software to make their own blog; if anything, if their blog is interesting, I've just gained something to read.  So going with option 1 gains me nothing over option 2.

On the other hand, if I choose option 2 and someone else decides to use the software for their blog, they're likely to want some features I didn't bother to put in.  And, if they implement those features and release them (either because my license requires them to, or just because they reasoned the same way as I did), then I might find some of them useful for my blog too, after all.  And maybe they'll also find some bugs that I missed and fix them, which means I get the fix too for pretty much free.

So, that's why the open source economy works.  It's not about unpaid developers writing software they don't need and then giving it away "just for fame".  Rather, it's about people writing software that's useful for them and sharing it with others so that those others can in turn share their improvements to it with them.


问:
Is the Waterfall software development methodology still viable?
In my experience, it seems as though the Waterfall model has proven to be too inflexible and non-responsive to requirements changes to be considered a viable method in the modern world of software development. The growth and proven track record of more agile, iterative methods seems to indicate that there is no reason why anyone should be following a process of rigid blocks that assumes little to no changes from project inception to product delivery.

Is is the waterfall development methodology still viable for delivering software systems, with respect to time, cost, and quality?

答:
People don't use the text-book waterfall model and probably never have.

It is an idealized, theoretical construct whose purpose is to get you to think about the steps in systems development.  It's main point is that you want the bigger changes to happen as early as possible, because you'll never have the time or money to make a big change once there's a lot of code built.

Despite the fact that it is more of a way of thinking than a process, it is still very much the way that many - probably most organizations go about building software (or houses, or submarines, or whatever else...).

In the real world, you don't have totally strict cut-offs between phases, and you sometimes loop back to prior phases for small sub-projects.  What the methodology tells you is not that "these things are not allowed".  What it tells you is "these things cost you money and/or time" - so try to avoid that in the future.

It's all well and good for Agile Snobs(TM) to look down their noses at "old fashioned" developers and their quaint, unworkable waterfall methodology, but the fact of the matter is that Agile is no panacea either.  Some projects can't be built using Agile and a lot of teams that think they're Agile are actually just sloppy and unorganized.

The methodology is not the point.  The point is to think about what you're doing and why you're doing it that way - and to get the most value to the customer in the shortest reasonable time.


问:
What Are Some Advantages/Disadvantages of Using C over Assembly?
I'm currently studying engineering in Telecommunications and Electronics and we have migrated from assembler to C in microprocessor programming.  I have doubts that this is a good idea.  What are some advantages and disadvantages of C compared to assembly?

The advantages/disadvantages I see are:

Advantages:

I can tell that C syntax is a lot easier to learn
than Assembler syntax.

C is easier to use for making more complex programs.

Learning C is somehow more productive than learning assembler cause there is more developing stuff around C than Assembler.

Disadvantages:

Assembler is a lower level programming language than C,so this makes it a good for programming directly to hardware.

Is a lot more flexible alluding you to work with memory,interrupts,micro-registers,etc.

答:
Depending on how embedded you need to go, C is going to produce large, slow programs.  Which will noticeably increase the cost of that portion of the product.  It might be a drop in the ocean for the overall product or might radically change the product.   Yes, some might say that the software development and maintenance efforts are cheaper, again that can be true or false, if that deeply embedded and aiming for a part that low power, small, and inexpensive you are not talking about a lot of code.  That code is mostly specific to that vendor or that specific chip so being in C has zero portability benefits, you have to rewrite fore each target anyway.  With the cortex-m series from ARM we are just now starting to be able to have C compete with asm, not that folks havent been using C or other higher level languages in their embedded products, but they have done it at a cost.

The C vs ASM debate, professionally, always boils down to write it in C and use ASM where you can justify it.  And you can justify it.  In the embedded world there is performance and size.

You have to include the target in this discussion.  Although many have used C with Microchip (the older pics, not the pic32 which is mips) at a huge cost, it is a dreadful instruction set for compilers, very educational and interesting instruction set but compiler unfriendly.  msp430, avr, arm, thumb, mips, all good for compilers.  8051 also bad.

Even more than the language the tools.  Esp in those cases where worrying about code development and management are an argument, you need tools to be there today and tomorrow.  Having a single source tool, even including a single gcc mod, managed by one group, is risky from a business perspective.  You likely to find more than one assembler, and anyone worthy on being on that team could whip up an assembler in a weekend (so long as the assembly you write is not ghee whiz directive and macro happy).  For both asm and C you would want to use open source tools (or your own in house tools) where you stand a better chance, even if it means using a virtual machine to run a 10 year old linux distro, of having tools available for the life of the product.

The bottom line, again, use/learn/teach both C and asm, start with C and use asm where you can justify it.


答:
I think it's right that programming cannot be learned from books only (as most of the people mentioned), you need to practice a lot and there are many resources available on the internet (articles, videos, samples etc.).

But a good book fills the gaps in your knowledge. After reading a book cover to cover gives you confidence that you don't have any gaping holes in your knowledge of the subject. Though the challange is to find good books on the subject.

Title: Why do people use programming books?

Body:
I find that when someone asks what is the best way to learn how to program, people usually provide them with references to a bunch texts written by various authors.

However I don't believe many people at all learn to program from books. I find that they are usually faced with a challenge and then use programming as a tool to overcome it.

For example I 'got into' programming because I wanted to start a server for a game I was playing, so I googled and read through the support for that particular server and now I am a employed software engineer, using only the skills I developed (and then further developed) by coding C# scripts for a not very popular server package.

So my question is, do people generally find it easier to learn from these books? I know I have looked at a few of them and found them far too 'dry' to encourage me to finish it.


答:
Richard Stallman, the founder of the Free Software foundation, has been explaining for decades why you are wrong. Linux, Firefox, MySQL, and the very concept and culture of Open Software only exist because lots of people find these arguments persuasive. Read about it at the FSF website (scroll down to "Easily Rebutted Objections" for the answers to your question).

http://www.gnu.org/gnu/manifesto.html


答:
The waterfall model that you are referring to was never intended to be a process model used on a real project. Instead, it is a strawman. It identifies the key phases and activities that exist in software projects and the most basic flow between them. This oversimplification of how to develop software is a flawed one, and it was even presented that way.

From the Wikipedia article:

The first formal description of the waterfall model is often cited as a 1970 article by Winston W. Royce, though Royce did not use the term "waterfall" in this article. Royce presented this model as an example of a flawed, non-working model.

The paper discussed is titled Managing the Developement of Large Software Systems. In it, Royce does present that model on the second page. However, the text immediately below the pictoral representation goes on to read:

I believe in this concept, but the implementation described above is risky and invites failure.

He follows this with a discussion of the problems with testing following the "completion" of the development phase, and how failures here can lead to major redesigns and code changes, and how these can lead to major overruns in cost and schedule. Throughout the paper, he refines the original model to one that is indeed viable on a project. In the end, he ends up with a model that introduces prototyping, customer interaction, and refinement of artifacts - ideas that would eventually end up being critical to the agile movement that began in the late 1990s and early 2000s.

To answer your question: The Waterfall that you are asking about is not, and never was, a viable method to deliver software projects with a reasonable amount of quality on time and budget. However, there are other plan-driven methodologies that lie opposite of agile that can and do work on projects.

Title: Is the Waterfall software development methodology still viable?

Body:
In my experience, it seems as though the Waterfall model has proven to be too inflexible and non-responsive to requirements changes to be considered a viable method in the modern world of software development. The growth and proven track record of more agile, iterative methods seems to indicate that there is no reason why anyone should be following a process of rigid blocks that assumes little to no changes from project inception to product delivery.

Is is the waterfall development methodology still viable for delivering software systems, with respect to time, cost, and quality?


问:
Servicing background tasks on a large site
We're dealing with an interesting problem on StackOverflow.

We've got a whole bunch of little "needs to be done soon-ish" tasks.  An example is updating "Related Questions" lists.  What we've done in the past is to piggy-back those tasks onto some users' page loads.

This was never ideal, but it wasn't really noticeable.  Now that SO has passed the 1,000,000 question mark, those unlucky users are starting to feel it.

The natural solution is to actually push these tasks into the background.  There are two broad ways of doing this I'm considering.

1. In IIS as a custom Thread-Pool/Work-Queue

Basically, we spin up a few (non-ThreadPool, so as to not interfere with IIS) threads and have them services some collections we're shoving Funcs into.

The big pro here is simplicity.  We don't have to worry about marshaling anything, nor do we have to make sure some external service is up and responding.

We also get access to all of our common code.

The con is, well, that we shouldn't use background threads.  The objections I know of are all centered around starving IIS (if you use ThreadPool) and the threads dieing randomly (due to AppPool recycling).

We've got existing infrastructure to make the random thread death a non-issue (its possible to detect a task has been abandoned, basically), and limiting the number of threads (and using non-ThreadPool threads) isn't difficult either.

Am I missing any other objections to in IIS process thread-pooling/work-queues?

Moved to StackOverflow, as it wasn't really addressed here.

2. As a Service

Either some third-party solution, or a custom one.

Basically, we'd marshal a task across the process boundary to some service and just forget about it.  Presumably we're linking some code in, or restricted to raw SQL + a connection string.

The pro is that its the "right way" to do this.

The cons are that we're either very restricted in what we can do, or we're going to have to work out some system for keeping this service in sync with our code base.  We'll also need to hook all of our monitoring and error logging up somehow, which we get for free with the "In IIS" option.

Are there any other benefits or problems with the service approach?

In a nutshell, are there unforseen and insurmountable problems that make approach #1 unworkable and if so are there any good third-party services we should look into for approach #2?

答:
Task Queue Java API Overview

Task Concepts

In App Engine background processing, a task is a complete description of a small unit of work. This description consists of two parts:

A data payload which parameterizes
the task.

Code which implements the task.

Tasks as Offline Web Hooks

Fortunately, the Internet provides such a solution already, in the form of an HTTP request and its response. The data payload is the content of the HTTP request, such as web form variables, XML, JSON, or encoded binary data. The code reference is the URL itself; the actual code is whatever logic the server executes in preparing the response.


问:
Interception vs Injection: a framework architecture decision
There's this framework that I'm helping to design. There are some common tasks that should be done using some common components : Logging, Caching and raising events in particular.

I am not sure if it's better to use dependency injection and introduce all of these components to each service (as properties for example) or should I have some kind of meta data placed over each method of my services and use interception to do these common tasks?

Here's an example of both:

Injection:

```<code>public class MyService
{
    public ILoggingService Logger { get; set; }

    public IEventBroker EventBroker { get; set; }

    public ICacheService Cache { get; set; }

    public void DoSomething()
    {
        Logger.Log(myMessage);
        EventBroker.Publish<EventType>();
        Cache.Add(myObject);
    }
}
</code>```

and here's the other version:

Interception:

```<code>public class MyService
{
    [Log("My message")]
    [PublishEvent(typeof(EventType))]
    public void DoSomething()
    {

    }
}
</code>```

Here are my questions:

Which solution is best for a complicated framework?

If interception wins, what are my options to interact with internal values of a method (to use with cache service for example?)? Can I use other ways rather than attributes to implement this behavior?

Or maybe there can be other solutions to solve the problem?

答: I find the design of a framework to be largely orthogonal to this question--you should focus on the interface of your framework first, and perhaps as a background mental process consider how someone might actually consume it.  You don't want to do something that prevents it from being used in clever ways, but it should only be an input into your framework design; one among many.

OwnerDisplayName: sethcall


答:
Cross-cutting Concerns like logging, caching etc. are not dependencies, so shouldn't be injected into services. However, while most people then seem to reach for a full interleaving AOP framework, there's a nice design pattern for this: Decorator.

In the above example, let MyService implement the IMyService interface:

```<code>public interface IMyService
{
    void DoSomething();
}

public class MyService : IMyService
{
    public void DoSomething()
    {
        // Implementation goes here...
    }
}
</code>```

This keeps the MyService class completely free of Cross-cutting Concerns, thus following the Single Responsibility Principle (SRP).

To apply logging, you can add a logging Decorator:

```<code>public class MyLogger : IMyService
{
    private readonly IMyService myService;
    private readonly ILoggingService logger;

    public MyLogger(IMyService myService, ILoggingService logger)
    {
        this.myService = myService;
        this.logger = logger;
    }

    public void DoSomething()
    {
        this.myService.DoSomething();
        this.logger.Log("something");
    }
}
</code>```

You can implement caching, metering, eventing, etc. in the same way. Each Decorator does exactly one thing, so they also follow the SRP, and you can compose them in arbitrarily complex ways. E.g.

```<code>var service = new MyLogger(
    new LoggingService(),
    new CachingService(
        new Cache(),
        new MyService());
</code>```

Title: Interception vs Injection: a framework architecture decision

Body:
There's this framework that I'm helping to design. There are some common tasks that should be done using some common components : Logging, Caching and raising events in particular.

I am not sure if it's better to use dependency injection and introduce all of these components to each service (as properties for example) or should I have some kind of meta data placed over each method of my services and use interception to do these common tasks?

Here's an example of both:

Injection:

```<code>public class MyService
{
    public ILoggingService Logger { get; set; }

    public IEventBroker EventBroker { get; set; }

    public ICacheService Cache { get; set; }

    public void DoSomething()
    {
        Logger.Log(myMessage);
        EventBroker.Publish<EventType>();
        Cache.Add(myObject);
    }
}
</code>```

and here's the other version:

Interception:

```<code>public class MyService
{
    [Log("My message")]
    [PublishEvent(typeof(EventType))]
    public void DoSomething()
    {

    }
}
</code>```

Here are my questions:

Which solution is best for a complicated framework?

If interception wins, what are my options to interact with internal values of a method (to use with cache service for example?)? Can I use other ways rather than attributes to implement this behavior?

Or maybe there can be other solutions to solve the problem?

Body:
Cross-cutting Concerns like logging, caching etc. are not dependencies, so shouldn't be injected into services. However, while most people then seem to reach for a full interleaving AOP framework, there's a nice design pattern for this: Decorator.

In the above example, let MyService implement the IMyService interface:

public interface IMyService
{
    void DoSomething();
}

public class MyService : IMyService
{
    public void DoSomething()
    {
        // Implementation goes here...
    }
}

This keeps the MyService class completely free of Cross-cutting Concerns, thus following the Single Responsibility Principle (SRP).

To apply logging, you can add a logging Decorator:

public class MyLogger : IMyService
{
    private readonly IMyService myService;
    private readonly ILoggingService logger;

    public MyLogger(IMyService myService, ILoggingService logger)
    {
        this.myService = myService;
        this.logger = logger;
    }

    public void DoSomething()
    {
        this.myService.DoSomething();
        this.logger.Log("something");
    }
}

You can implement caching, metering, eventing, etc. in the same way. Each Decorator does exactly one thing, so they also follow the SRP, and you can compose them in arbitrarily complex ways. E.g.

var service = new MyLogger(
    new LoggingService(),
    new CachingService(
        new Cache(),
        new MyService());

OwnerDisplayName: Mark Seemann


答: It appears that the premise of this question is that the only reason to write code is for either fortune or fame; but there is in fact another reason to write code, make software, or for that matter invent any sort of new technology...namely to make people's lives better, more productive, and more efficient!</p>


问:
What are the most important OO skills to show off in the job hunt?
I am in the market for new employment, and found a position were they asked me to create a programming sample based off an assignment. I blew the sample trying to get it done quickly one night, and got declined - only to be given a second chance recently.

The concern was that I didn't really demonstrate object oriented knowledge. I've rethought my approach but I figure it's worth asking: if you were hiring someone for an OO position, what skills would you most want to see them demonstrate they had a firm grasp on?

I want to be sure that I'm missing anything important this time around.

答:
The ones that elegantly solve the problem they pose in the interview.

They don't care about your OO skills (well, they do care some).  What they do care about is that you can solve their problems.  If you've been putting in 105 hour work weeks, you should already know OO anyway.

The problem is not parsing out which OO skills they want to see, it's being disciplined enough to show them the kind of solutions they need (whatever that looks like).

In other words, don't show them inheritance if the programming sample they asked for doesn't require it.


答:
I guess some of the few things you need to demonstrate are:

Understand the problem

Good class design

Use proper class modifiers, prefer information hiding

Use features like inheritance, abstract classes, interfaces correctly if possible

Prefer Generics over untyped lists

Use exception handling

Create a good (and simple) architecture of at least 2 tiers

Use Constants instead of properties with literal values when applicable

Arrange your code well in namespaces and folders

Use good naming standards

Be sensible about your usage of static types

Code security

Validate inputs

Hide connection strings

Provide, if possible, configuration options

Provide help functionality even if not fully implemented in this version

Prepare a document for requirements, architecture, class diagram, and other documentation as much as possible

Include exceptions for not coded methods if any (in case you don't have time for them)

Design your database well

Attempt to create a good GUI

Title: What are the most important OO skills to show off in the job hunt?

Body:
I am in the market for new employment, and found a position were they asked me to create a programming sample based off an assignment. I blew the sample trying to get it done quickly one night, and got declined - only to be given a second chance recently.

The concern was that I didn't really demonstrate object oriented knowledge. I've rethought my approach but I figure it's worth asking: if you were hiring someone for an OO position, what skills would you most want to see them demonstrate they had a firm grasp on?

I want to be sure that I'm missing anything important this time around.


问:
How to handle encryption key conflicts when synchronizing data?
Assume that there is data that gets synchronized between several devices. The data is protected with a symmetric encryption algorithm and a key. The key is stored on each device and encrypted with a password. When a user changes the password only the key gets re-encrypted.

Under normal circumstances, when there is a good network connection to other peers, the current key gets synchronized and all data on the new device gets encrypted with the same key.

But how to handle situations where a new device doesn’t have a network connection and e.g. creates its own new, but incompatible key? How to keep the usability as high as possible under such circumstances?

The application could detect that there is no network and hence refuse to start. That’s very bad usability in my opinion, because the application isn’t functional at all in this case. I don’t consider this a solution.

The application could ignore the missing network connection and create a new key. But what to do when the application gains a network connection? There will be several incompatible keys and some parts of the underlying data could only be encrypted with one key and other parts with another key.

The situation would get worse if there would be more keys than just two and the application would’ve to ask every time for a password when another object that should get decrypted with another key would be needed.

It is very messy and time consuming to try to re-encrypt all data that is encrypted with another key with a main key. What should be the main key at all in this case? The oldest key? The key with the most encrypted objects? What if the key got synchronized but not all objects that got encrypted with this particular key? How should the user know for which particular password the application asks and why it takes probably very long to re-encrypt the data? It’s very hard to describe encryption “issues” to users.

So far I didn’t find an acceptable solution, nor some kind of generic strategy. Do you have some hints about a concrete strategy or some books / papers that describe synchronization of symmetrically encrypted data with keys that could cause conflicts?

答:
This is an interesting problem.

As I understand it, one of n devices is offline, the user launches your application for the first time. It randomly generates a new/fresh key & protects it with a password. It then uses that key in a symmetric algorithm to protect some data. Later the device is online and wishes to synchronize the encrypted data with the other devices.

If that understanding is correct, I don't see the requirement to synchronize the keys.

When the user launches the application, enters his password you now have access to the key on that device. Assuming the password is identical on other devices, and you have access to the password-protected key & encrypted data from those devices - you can obtain each device's key & decrypt the data. Once the data has been decrypted it can be synchronized.

Once synchronized, you could synchronize the keys to a random new value - or you could simply save the data on each device encrypted with the device-specific key.

Perhaps I'm missing a requirement?

If the above proposal is feasible, as ntziolis said, password changes while offline would be undesirable. To allow offline password changes, the prior password(s) must be kept alongside the key, protected by the new password. This would allow you to obtain the key from other devices that protected their key with one of the prior passwords. If this occurs, you would want to update each device's encrypted key to use the latest & greatest password to optimize for performance. (This also leads you down the road of keeping track of when password changes were made, and also protecting those dates from modification...)

OwnerDisplayName: Rafael

OwnerDisplayName: Tails


问:
One language to rule them all? (Them being platforms.)
I have been discussing a project with a client and they want to use a single language to deploy to as many platforms as possible.

(I am not sure that it's such a good idea, because each platform offers a different user experience and UI metaphor. In some cases, screen sizes vary as well. Also, iPhone is out of the running no matter what language we use. But, I digress...)

The project is going to display an arbitrary block of text each day and will track if the user has "read" it. Some other features on the table are "nags" and the ability to go to another days' text.

I know Flash from the CS3 days, and I think that translates into AIR, but I dont know if AIR can do what we want.

On the other hand, I have (a) little experience with Java or Python, but those seem like good contenders also.

Which language should I use here? Why?

Edit:

This is going to run on desktop platforms too.

答:
With C# .NET you can deploy to any major mobile platform natively (big difference from HTML 5 platforms like PhoneGap which are basically hybrid web apps) utilizing Mono (for Android), MonoTouch (for Apple), and BlackBerry.NET.

The language and platform is well supported by MicroSoft with many employers looking for that skill set. If your not completely sold, just go to your favorite tech job website and start plugging in different languages/platforms in the search box. You will get an idea of which direction you want to take.


问:
Is MongoDB the right choice in my case?
I'm going to build my first real project in Rails that consist in a web app made of 3 main parts:

The static part where no database is used

The User registration part which will require a database and I can use MySQL since each user's row will have the same fields

The "App" where users will be able to create, organize, edit... items in collections and share them with other users

There will be several item types and each one will have different options for example I may have "video" items with the following options:

id

user_id

collection_id

title

platform (if embedded)

url (if embedded)

file name (if hosted on my app)

file size (id hosted on my app)

and "map" items:

id

user_id

collection_id

title

platform (google maps, bing maps...)

location

url

map size

As you can while for users I may use MySQL for items the flexibility of MongoDB may be useful since each item may need different options then another item

Up to now I've always used PHP and MySQL (always on shared hosting for small projects) and scalability is a totally new word for me.

I have time to learn but I would like to be able to do something concrete in something like 1 month.

I've read a lot about MongoDB and NoSQL vs RDMS and MySQL and after trying it I have to say that I like how MongoDB works: no tables, no rows and its documents JSON like so:

In my situation what would you raccomend? why?

About scalability there may be problems with MongoDB? if yes when (in term of DB size) and may these problems slow down my app considerably?

Edit: how the app will work

Since many asked this is how I'd like the app to work:

A user sign up

He's logged in

He create his first collection iside which he can create infinite items

Items are of various type and each type need different data to be saved in the database and type of items may be added or modified

Users may create other collections and items inside it.

So we have CRUD for collections and items inside of them and each collection/item is referred to a specific user

The main problem with MySQL is that it hasn't a flexible schema, there is way to solve this (a workaround?)?

Thinking about NoSQL the only doubt I have is about join, for example given a certain colection I want to retrieve datas related to the User with id = user_id field in the collection

EDIT: Idea to keep using MySQL

Create a field in the "items" table with optional settings, each setting divided by a | or another symbol.

Then I will save somewhere a structure of each item optional settings, for example the "notes" item type need two optional settings "colour" and "strange_setting", when I get the data from MySQL i will split the field for optional settings into an array knowing that the first item in the array is for "colour" and so on.

What do you think? there are problem with that solution? do you have other ideas?

答:
I see this question a lot.  It always seems to be thought of as either/or.
MongoDB is a great new tool.  It's also sometimes seem as the shiny tool for everything and that can be a poor choice in my experience.

I think the best combination is definitely BOTH and I would like to commend you for your approach of using mylsql for some parts, such as users, but use MongoDB for other parts as I feel that authentication and authorization is best done with mySQL and there are a ton of examples and modules that do this really well.

For the 'large number of items' piece, that's where you would want to consider using mongoDB if your volume is high, and/or it's mostly reads and/or it's unstructured data.

I would advise not basing your decision on Mongo's schema-less flexibility.  SQL and sql-schemas arose from a need to have structured data and be able to perform calculations and transformations that are only possible with such a structure.  I learned this from 5 years of working in a data warehouse role.
I would only look to MongoBD for the performance issue.  If you are or are expecting a high volume of users and requests, say 100,000 users and 20 requests a second, I would use mongoDB, otherwise I would try and stay with sql.  In many cases I would use mySQL for low volume, and then, as volume, income and infrastructure support it, switch to Oracle, before mixing in mongoDB.  I agree that you should not try to deal with volume problems before you experience them, however if you have a fair idea of where you are heading and don't want to re-write things half-way there it makes a lot of sense to pick the right technologies at the outstart.  Just remember that if you really have that high volume there are a huge amount of options and technologies at all levels of the stack that you will look to use.

There are downside to loosely structured data.  I use the parking lot analogy here.  no dividing lines is great for the first 3 cars that enter, but as more cars enter, a lot of disorganizing starts to happen and trying to get parked or easily count cars and keep lanes free becomes a nightmare.  Organizing this takes work up front - marking out lines and dividers and traffic flows, etc. but it pays off.  Sometimes things change of course (cars get bigger) and you have to do some changes - repaint lines.  Plus just standard down-time for annual repaints and maintenance.

The schema design aspect will probably be the biggest hurdle for traditional mysql users.  I think the MongoDb page on schema design helps with that.
My final point is that every technology you add into the mix adds complexity.  There are often huge advocates for any given piece that will say you "have" to use it, but I have found that a really big factor is just how many pieces there are.  It implies more possible points of failure and most of all more of a knowledge base needed for anyone else to have to know to work on it.

fyi Rick Obsorne has a pretty amazing comparison diagram that's quite unique!

Title: Is MongoDB the right choice in my case?


答:
When I interview people I'm looking for people who will produce solutions that will be extensible and maintainable for the duration of its life time. How that maps to OO ties into the questions I ask when I interview.

I start with language questions. Are you familiar with all the constructs and subtleties of the language (C# primarily). If you pass that we move on to patterns.

It might seem like an odd choice to go to patterns before OO principles, but it gives me a chance to poke around in their experience around different areas. UI patterns, enterprise patterns, GoF patterns, etc. This will include some OO priniples as you can describe some, if not most as patterns. SOLID is important to me, D is dependency injection principle, that's a pattern. so its a nice segway to...

How to structure applications for maintainability, extensibility and testability. It's quite an open discussion, I know what I'm looking for and steer the discussion. I don't believe legacy code should become a millstone around the neck, so I want to know how you structure code in a way that makes that true.

Most importantly is that throughout I don't just ask HOW, I ask WHY. Why is a much under used question in interviews I find.


问:
How can I advocate a semi-strict release schedule in a risk-averse environment?
Recently I've been increasingly plagued by what I would have to describe as one of my most frustrating and morale-killing experiences in this profession: Having to sit on a release that has been tested, re-tested, staged, and for all intents and purposes is ready to ship/deploy.

As an all-around solutions guy and not just a hardcore coder, I do understand and have even advocated the need for proper change control. But lately, the tenuous balance between covering our bases and shipping on time has gone all lopsided, and I've had little to no success in restoring it to something sane.

I'm looking for compelling arguments to help convince risk-averse management that:

The dev team should (or must) be able to set its own release schedule - within reason of course (1-3 months should be conservative enough for all but the biggest Fortune 500 companies);

Software releases are important milestones and should not be treated cavalierly; in other words, unnecessary delays/stoppages are highly disruptive and should be considered only as a last resort to some critical business issue; and

External (non-dev/non-IT) entities who want (or demand) to be involved as stakeholders have a responsibility to cooperate with the dev team in order to meet the release schedule, especially in the last week or so before the planned ship date (i.e. user testing/staging).

The above are assertions that ring true for me based on experience, but it looks like I'm now in the position of having to prove it - so I'm asking for something a little meatier here, if such a thing exists.

Can anyone who has had to "sell" the idea of a fixed (or maybe semi-flexible) release cycle to management give some pointers on what arguments/strategies are effective or persuasive and what is not? Aside from the obvious schedule contention and sunk costs, is there any hard data/evidence that would be useful in making the case that shipping is actually important, even in a "corporate" setting?

Alternatively, I'm open to hearing constructive arguments about why schedule flexibility (even over a period of weeks/months) is more important than shipping on schedule; it's hard for me to believe right now but maybe they know something I don't.

Note we have staged releases, and this went through every stage except production. Issues are tracked using a commercial bug tracker and every issue - 100% of them - that was assigned to this release was closed out. I realize it's difficult to believe and that's really precisely the point - it makes no sense that a 100%, feature-complete, fully-tested, approved-by-stakeholders release would be delayed by management for unexplained reasons, but that's what happened, that's what's been happening, that's the problem to be solved.

答:
First, watch this video:

http://the99percent.com/videos/5822/Seth-Godin-Quieting-the-Lizard-Brain

Executive Summary:

The way you ship on time and on budget is this: when you run out of
time or run out of money, you ship.  That's it.

The reason most
projects don't ship on time is because someone comes along with "just
one more feature or fix" to insert into the release, right before you're
ready to ship, at a time in the development cycle when your resources are most scarce, and now you have to scramble.  This is called thrashing, and it happens because as
long as you don't ship, you don't have to worry about people telling
you your product sucks.

The way you cure thrashing is by forcing
people to do it at the beginning of the product development cycle,
not at the end.

Making product changes in the weeks just prior to the release date is very disruptive, for obvious reasons.  This is true whether the change is a new feature, a change to the software development process, or an attempt to fix a long-standing bug that's not in the development schedule.

When someone comes to me for a fix or change late in the development cycle, I always ask them this: "What do you want me to not get done so that I can get your thing done?"

If you need a money motivator, it is this: studies prove that the later you wait in the software life cycle to implement a feature or fix, the more expensive it is.  Exponentially.  It's not hard to prove this.


问:
How to find just starting OpenSource project and Join or find programmers for own?
Is there any place on the web where can I join a team when they are just starting their project?

Is there any place where developers can make groups for projects?

I know there are some /dev/forums where you can have luck to find something interesting in some topic ... but the chances there are really low.

I know that you can find some projects on CodePlex or GitHub but they will be already started projects and it's not so easy to understand and join it ...

I want to find some place where new ideas comes to new teams.

So ... maybe starting project must already have a good base, but not to big base and then project leader must Promote it and find developers who like the idea ?

Sometimes that is really hard to catch such promotions.

答:
Maybe you could try to start up a place like this. I see you already have a website. You could allow people to create profiles etc. I promise I will join!
Maybe a platform where everyone can

present what they are working on (if they already do),

talk about ideas & plans they have for the future

where or in what way they think other people could contribute and how much effort there would be to familiarize with the project before the fun can begin

You could start up with something simple, in the sense that it does not require you so much time to set up, and if people show some interest improve it.


问:
What's the best practice for async APIs that return futures on Scala?
I have started a project to write an async PostgreSQL driver on Scala and to be async, I need to accept callbacks and use futures, but then accepting a callback and a future makes the code cumbersome because you always have to send a callback even if it is useless.

Here's a test:

```<code>"insert a row in the database" in {

  withHandler {
    (handler, future) =>
      future.get(5, TimeUnit.SECONDS)
      handler.sendQuery( this.create ){ query =>  }.get( 5, TimeUnit.SECONDS )
      handler.sendQuery( this.insert ){ query =>  }.get( 5, TimeUnit.SECONDS ).rowsAffected === 1
  }

}
</code>```

Sending the empty callback is horrible but I couldn't find a way to make it optional or anything like that, so right now I don't have a lot of ideas on how this external API should look like.

It could be something like:

```<code>handler.sendQuery( this.create ).addListener { query => println(query) }
</code>```

But then again, I'm not sure how people are organizing API's in this regard. Providing examples in other projects would also be great.

答: No, you just use futures and don't call get on them unless absolutely necessary. Instead, you add callbacks to the futures and transform and compose futures with combinators. See Twitter Util futures and Akka futures.


问:
How does the MongoDb licence define "commercial" and "non-commercial" use?
I have a question about "commercial" and "non-commercial" usage, also with the usage of MongoDb.

Lets imagine we got a website without a business model, the site grows in popularity but still no incomming money. Are we talking about non-commercial at this point?

And once the website starts making money, is it allowed to decide at that point to get a commercial license?

Thanks for help.

答:
MongoDB licensing seems rather straight forward. It's an AGPL 3.0 license with Apache licensed drivers, which means you can use it commercially for free, as long as you contribute any improvements you do to the actual database back to the project.

For more detailed info and motivation behind it, see the linked page.

OwnerDisplayName: randomKek


答:
Perhaps a better way of asking what you're getting at is, "when is less iterative and more formal better?"

There are situations where this is the case:

When the requirements won't change.

When meeting new requirements is less important than hitting 100% of the original ones.

When all the technology components are mature and well understood.

In a sense you can take the opposite of what might drive you to be agile.

Very few techniques are applicable everywhere.  Very few have no use.


问:
JavaScript client for talking with WCF server with WebSockets binding
I'm excited about the possibilities for duplex communication with WebSockets between a web browser and web server.  I see that WCF for .NET 4.5 supports a WebSockets binding now, and I know there's a JavaScript API for using WebSockets.  However, what I don't understand is how these are supposed to interoperate.  Yes, you can deal with raw message passing with the JS API, but there doesn't seem to be any JS library for doing SOAP-based RPC compatible with WCF.

Do any of you know if there are any libraries to enable a web browser to call a WCF service using WebSockets?

答:
SignalR has a JavaScript API.  SignalR helps build asynchronous scalable web applications with real-time persistent long-running connections. Scott Hanselman wrote a great blog post about this.

If that's not your speed, you may be looking for something more like WCF Support for jQuery, which seems to have sprung up from the old WCF-RIA jQuery client. Looks like this will be part of ASP.NET MVC 4. The wiki page for this project seems to indicate that its flexible enough to plug in to WebSockets.

I'm a little concerned about WebSockets in the near term. There are some questions about just how Internet infrastructure (particularly in corporate environments where proxy servers are common) will handle WebSockets. I believe SignalR has strategies to help mitigate this by negotiating fallbacks when WebSockets don't work. Scott Hanselman has another blog post about this which makes some good points in this direction.


问:
Do all functional languages use garbage collection?
Is there a functional language which allows to use stack semantics - automatic deterministic destruction at the end of the scope?</p>

答: If you consider C++ to be a functional language (it has lambdas), then it is an example of a language that doesn't use a garbage collection.</p>


问:
Would you allow your programmers to use Messenger and social networks like Facebook?
I had many bosses, each one had a different approach about allowing or not use of Windows Live Messenger, Facebook, and many other Internet sites.

Of course Internet is really needed to research about the best way to solve a specific task. Sometimes you could have a friend online, also a programmer, who knows better about something.

For some managers, internet access would slow down project progress, and on the other hand, allow people to interact and find out brand new solutions.

What would you do?

答:
IMO, this question actually leads into the difference between people that must be managed vs. people that can manage themselves.

Much like managed code, people that must be managed require a runtime. They must have structure, office hours, scheduled meetings, a certain amount of vacation days so they know how much they've "used up", tasks/tickets handed to them, and a set of rules to play by. Without this structure, they will get lazy, push the boundaries, and require constant correction from you. There's a certain, usually "corporate" style of development that lends itself to these types of developers. If that's you, then you might consider ways to restrict distractions and social networks.

People that can manage themselves are the ones that only need a vision, and they're off with it, delivering stuff at 2pm Tuesday and midnight on Thursday or on the weekend, talking with customers, and moving things forward without your scheduling a status meeting. They will set their own limits with regard to social network time, StackExchange time (ahem), etc. These make good developers for creative and innovative products. Under no circumstances should you restrict their access to social networks or anything else; it's not necessary. A good trust relationship is a must, and web proxies / filters / timeclocks / forms are the enemy of trust.


问:
Senior Engineers: Go Back to Coding?
This is a question regarding engineers with 20+ years experience, but it is a question for everybody, as it has to do with career development.

I'm in a surprisingly long job hunt, and the problem seems to be that employers will not accept me as a coder.  Yes, I have done lots of things, had my own company, sold it too early, etc.  But the world always needs productive workers, and my skills are current and sharp.  The market I am in has fewer openings for senior people, and I don't mind taking a step or two back if I can find a place to contribute. What are your thoughts about career management that prepares the 40, 50 year-old for a sudden career disruption?

答:
Ageism is a very real problem.  The proble is people assume if you are any good, you don't need help finding a job.   Unfortunately anti-discrimination laws sometimes make the job search harder in some countries, since nobody wants to hire someone that they can't fire.

Some thoughts:

1) Go back to satisfied customers and prior employers.

2) Package yourself as an independent consultant.

3) Look for ways your non-programming experience can complement your tech skills.

4) Look for a place that can get value from your 20 plus years of contacts.

Title: Senior Engineers: Go Back to Coding?


答:
Not that I know of, though I'm no functional programming expert.

It seems pretty difficult in principle, because values returned from functions may contain references to other values that were created (on the stack) within the same function, or might just as easily have been passed in as a parameter, or referenced by something passed in as a parameter. In C, this issue is dealt with by allowing that dangling pointers (or more precisely, undefined behaviour) may occur if the programmer doesn't get things right. That's not the kind of solution that functional language designers approve of.

There are potential solutions, though. One idea is to make the lifetime of the value a part of the type of the value, along with references to it, and define type-based rules that prevent stack-allocated values from being returned from, or referenced by something returned from, a function. I've not worked through the implications, but I suspect it would be horrible.

For monadic code, there's another solution which is (actually or almost) monadic too, and could give a kind of automatically deterministically-destructed IORef. The principle is to define "nesting" actions. When combined (using an associative operator), these define a nesting control flow - I think "XML element", with the left-most of the values providing the outer begin-and-end-tag pair. These "XML tags" are just defining ordering of monadic actions at another level of abstraction.

At some point (at the right hand side of the chain of associative composition) you need some kind of terminator to end the nesting - something to fill the hole in the middle. The need for a terminator is what probably means the nesting composition operator isn't monadic, though again, I'm not entirely sure as I haven't worked through the details. As all applying the terminator does is convert a nesting action into effectively a composed normal monadic action, maybe not - it doesn't necessarily affect the nesting composition operator.

Many of these special actions would have a null "end-tag" step, and would equate the "begin-tag" step with some simple monadic action. But some would represent variable declarations. These would represent the constructor with the begin-tag, and the destructor with the end-tag. So you get something like...

```<code>act = terminate ((def-var "hello" ) >>>= \h ->
                 (def-var " world") >>>= \w ->
                 (use-val ((get h) ++ (get w)))
                )
</code>```

Translating to a monadic composition with the following execution order, each tag (not element) becoming a normal monadic action...

```<code><def-var val="hello">  --  construction
  <def-var val=" world>  --  construction
    <use-val ...>
      <terminator/>
    </use-val>  --  do nothing
  </def-val>  --  destruction
</def-val>  --  destruction
</code>```

Rules like this could allow C++-style RAII to be implemented. The IORef-like references cannot escape their scope, for similar reasons to why normal IORefs can't escape the monad - the rules of the associative composition provide no way for the reference to escape.

EDIT - I nearly forgot to say - there's a definite area I'm unsure about here. It's important to ensure that an outer variable can't reference an inner one, basically, so there must be restrictions one what you can do with these IORef-like references. Again, I haven't worked through all the details.

Therefore, construction could e.g. open a file which destruction closes. Construction could open a socket which destruction closes. Basically, as in C++, the variables become resource managers. But unlike C++, there are no heap-allocated objects that cannot be automatically destructed.

Although this structure supports RAII, you still need a garbage collector. Although a nesting action can allocate and free memory, treating it as a resource, there's still all the references to (potentially shared) functional values within that chunk of memory and elsewhere. Given that the memory could be simply allocated on the stack, avoiding the need for a heap free, the real significance (if there is any) is for other kinds of resource management.

So what this achieves is to separate RAII-style resource management from memory management, at least in the case where RAII is based on simple nesting scope. You still need a garbage collector for memory management, but you get safe and timely automatic deterministic cleanup of other resources.

Title: Do all functional languages use garbage collection?

Body: Is there a functional language which allows to use stack semantics - automatic deterministic destruction at the end of the scope?</p>

Body:
Not that I know of, though I'm no functional programming expert.

It seems pretty difficult in principle, because values returned from functions may contain references to other values that were created (on the stack) within the same function, or might just as easily have been passed in as a parameter, or referenced by something passed in as a parameter. In C, this issue is dealt with by allowing that dangling pointers (or more precisely, undefined behaviour) may occur if the programmer doesn't get things right. That's not the kind of solution that functional language designers approve of.

There are potential solutions, though. One idea is to make the lifetime of the value a part of the type of the value, along with references to it, and define type-based rules that prevent stack-allocated values from being returned from, or referenced by something returned from, a function. I've not worked through the implications, but I suspect it would be horrible.

For monadic code, there's another solution which is (actually or almost) monadic too, and could give a kind of automatically deterministically-destructed IORef. The principle is to define "nesting" actions. When combined (using an associative operator), these define a nesting control flow - I think "XML element", with the left-most of the values providing the outer begin-and-end-tag pair. These "XML tags" are just defining ordering of monadic actions at another level of abstraction.

At some point (at the right hand side of the chain of associative composition) you need some kind of terminator to end the nesting - something to fill the hole in the middle. The need for a terminator is what probably means the nesting composition operator isn't monadic, though again, I'm not entirely sure as I haven't worked through the details. As all applying the terminator does is convert a nesting action into effectively a composed normal monadic action, maybe not - it doesn't necessarily affect the nesting composition operator.

Many of these special actions would have a null "end-tag" step, and would equate the "begin-tag" step with some simple monadic action. But some would represent variable declarations. These would represent the constructor with the begin-tag, and the destructor with the end-tag. So you get something like...

act = terminate ((def-var "hello" ) >>>= \h ->
                 (def-var " world") >>>= \w ->
                 (use-val ((get h) ++ (get w)))
                )

Translating to a monadic composition with the following execution order, each tag (not element) becoming a normal monadic action...

<def-var val="hello">  --  construction
  <def-var val=" world>  --  construction
    <use-val ...>
      <terminator/>
    </use-val>  --  do nothing
  </def-val>  --  destruction
</def-val>  --  destruction

Rules like this could allow C++-style RAII to be implemented. The IORef-like references cannot escape their scope, for similar reasons to why normal IORefs can't escape the monad - the rules of the associative composition provide no way for the reference to escape.

EDIT - I nearly forgot to say - there's a definite area I'm unsure about here. It's important to ensure that an outer variable can't reference an inner one, basically, so there must be restrictions one what you can do with these IORef-like references. Again, I haven't worked through all the details.

Therefore, construction could e.g. open a file which destruction closes. Construction could open a socket which destruction closes. Basically, as in C++, the variables become resource managers. But unlike C++, there are no heap-allocated objects that cannot be automatically destructed.

Although this structure supports RAII, you still need a garbage collector. Although a nesting action can allocate and free memory, treating it as a resource, there's still all the references to (potentially shared) functional values within that chunk of memory and elsewhere. Given that the memory could be simply allocated on the stack, avoiding the need for a heap free, the real significance (if there is any) is for other kinds of resource management.

So what this achieves is to separate RAII-style resource management from memory management, at least in the case where RAII is based on simple nesting scope. You still need a garbage collector for memory management, but you get safe and timely automatic deterministic cleanup of other resources.


问:
What is a good alternative to the name variable for a language that only has immutable references or labels?
For example, in functional languages, variables are single assignment and their values are immutable once assigned. So they have two states unbound and bound, once bound they can't be changed.

Is there some mathematical term or other computer science term that is most appropriate for such as thing? Something that semantically doesn't imply variance or mutability.

If not there doesn't exist such as term and if you were designing a language that had such constructs, what other than the word variable would you use to for these?

I am not really looking to poll for ideas, I am trying to figure out if there is already an accepted industry ( any industry ) term for such a thing.

答:
What about "symbol"?

I saw a video on F# where the speaker said,

you do not assign a value to a variable, you bind a value to a
  symbol.

(Still looking for the reference for this.)

Whenever I encounter the word "variable" in places where such constructs are immutable, I silently think "bound symbol."