问:
To program in free time as a programmer, is to show that programming is passion. If not, is the programmer good?

Possible Duplicate:

  I don't program in my spare time. Does that make me a bad developer?

A lot of blogs and advice on the web seem to suggest that in order to become a great developer, doing just your day job is not enough. For example, you should contribute to open source projects in your spare time, write smartphone apps, etc. In fact a lot of this advice seems to suggest that if you don't love programming enough to do it all day long then you're probably in the wrong career.

That doesn't ring true with me. I enjoy my work, but when I come home from the office I'm not in the mood to jump straight back onto the computer and start coding away until bedtime. I only have a certain number of hours free time each day, and I'd rather spend them on other hobbies, seeing friends or going outside than in front of the computer.

I do get a kick out of programming, and do hack around outside of work occasionally. I'm committed to my personal development and spend time reading tech blogs and books as a way to keep learning and becoming better. But that doesn't extend so far as to my wanting to use all my spare time for coding.

Does this mean I'm not a 'true' software developer at heart? Is it possible to become a good software developer without doing extra outside your job? I'd be very interested to hear what you think.

答:
In my day job I don't necessarily get exposure to all the technologies I would like to know. Doing projects in my own time is a way of getting that knowledge and experience. For instance, I've never worked on a project that used Hibernate, but I recognise that this is a very widely used ORM framework, so I put some effort into learning it in my own time.
I also got myself a Mac and dabbled in iPhone programming. Although I admit some of the motivation behind that was to generate extra money. I do find it very interesting though.

On the other side of the fence, if I'm interviewing someone for a developer position in my company, I ask if the candidate has done any projects in their spare time. If they say yes, then I take that as a very good sign that the person has some degree of enthusiasm and passion for the work. It also shows initiative, and a willingness to learn. These are all good attributes to bring to a development role.


答:
There are plenty of developers that view programming as a 9-to-5 job, and that is perfectly fine. However, the people who put more time and effort into it, will usually become better. This is like any other task, the more you practice the better you become.

I think it is important that if you want to do this on your spare time, it should be enjoyable. Do not look at it as work, and do not force yourself to do it because someone else thinks a "true" developer should be involved in open source.

Personally, I really enjoy working on various open source projects. In these cases I can choose what to implement, how I want to implement it and so on.

ContentLicense: CC BY-SA 3.0

Title: To program in free time as a programmer, is to show that programming is passion. If not, is the programmer good?

Body:
Possible Duplicate:

  I don't program in my spare time. Does that make me a bad developer?

A lot of blogs and advice on the web seem to suggest that in order to become a great developer, doing just your day job is not enough. For example, you should contribute to open source projects in your spare time, write smartphone apps, etc. In fact a lot of this advice seems to suggest that if you don't love programming enough to do it all day long then you're probably in the wrong career.

That doesn't ring true with me. I enjoy my work, but when I come home from the office I'm not in the mood to jump straight back onto the computer and start coding away until bedtime. I only have a certain number of hours free time each day, and I'd rather spend them on other hobbies, seeing friends or going outside than in front of the computer.

I do get a kick out of programming, and do hack around outside of work occasionally. I'm committed to my personal development and spend time reading tech blogs and books as a way to keep learning and becoming better. But that doesn't extend so far as to my wanting to use all my spare time for coding.

Does this mean I'm not a 'true' software developer at heart? Is it possible to become a good software developer without doing extra outside your job? I'd be very interested to hear what you think.


问:
Is a company order to switch to a certain IDE a red flag?
I recently joined a rapidly growing startup. In the past 3 months the development team has grown from 4 to 12.  Until now they were very laissez-faire about what developers used to do their work. In fact one of the things I initially found attractive about the company is that most programmers used Linux, or whatever OS they felt best suited their efforts.

Now orders, without discussion, have come down that everyone is to switch to Eclipse. A fine editor. I prefer SublimeText2, but it's just my personal taste.

Just to be clear: we are a JS team using Backbone and Eclipse just isn't good at understanding Backbone code.  This means that those on the team who use a /good/ IDE (PHP Storm), have to go back to doing a lot of search-find-oh-wait-where-was-I-three-steps-ago kind of things instead of just ctrl+clicking and using back/ forward - probably diminishing productivity by say 15% and enjoyment by 50%...

Is this a red flag? It seems capricious and unreasonably controlling to tell developers (non-MS) what IDE or tool-sets to use if they are already settled in and productive.

答:
It is reasonable that when you working together on a common project, that on every workstation you have all the tools available to edit/build/debug your software, and that the core tools for doing about 90% of the development are known to everyone in the team. That goal is harder to achieve if your team is growing and everyone uses his personal favorite toolset - the more people, the more opinions. And the administrative work gets easier, too, if you don't let the number of tools grow more than necessary.

Of course, if one developer insists to use his personal favorite editor, that may be ok as long as he can make sure the source does not look or behave differently in the main editor of the team (in your case Eclipse), so if dev B has to to edit the source of dev A, dev B should not be forced to learn the personal favorite editor of A to be able to change the source effectively. But beware, if the two have to work together from time to time in front of the same display (or do some pair programming), things are often easier if the choosen editor is well-known by both.


问:
How are RDF and RDFS related?
I've been reading about Semantic Web technologies such as RDF/RDFS and "ontology", but was wondering how each of these are related? At the moment the terms all seem interchangeable, or I'm not understanding a fundamental concept here.</p>

答:
RDF is a data model, in a similar way to how JSON is a data model.

Notably RDF has a number of save formats (serialization formats), including RDF/XML, N3, Turtle, and others.

RDFS is a vocabulary of widely used terms (URIs) to define classes and relationships, etc.

Ontologies are generally written using RDFS terms or perhaps terms from something more powerful like OWL or OWL2.

Title: How are RDF and RDFS related?


问:
Need to test .properties one by one in every possibility?
For example, there are some key-value configuration in .properties file. Such like someFeatureEnable=true. It must be bool type value which will be parsed by framework, in my case it's typical Java Spring configuration. Spring will handle the configuration and throw Exception when users set someFeatureEnable=123.

My question is: if there many properties in .properties file, Is it worth testing them one by one? It's quite troublesome and low priority. The .properties file is always configured by tech administrator stuff. Limited chances that they will mess up the configuration.

Thanks!

答: I beleive that you should write tests for the accepted properties that you've defined (i.e.  The enum of properties that are valid).  However, as these can be changed on the fly at runtime a far mor eimportant test is an integration style test (perhaps unit depending on your design) that tests your property parsing code and how it deals with outright bad or perhaps invalid input.</p>


答:
For pair programming sake, it's nice if both parties infront of the screen has the same skills when using the keyboard. It's also nice to know that, if your project has special configuration needs in the IDE, then It's configured the same way for everybody. Getting a new developer started is easier when the tools are the same for everyone.

But if you compare that to just trying to be most effective, then it's not really worth it

Title: Is a company order to switch to a certain IDE a red flag?

Body:
I recently joined a rapidly growing startup. In the past 3 months the development team has grown from 4 to 12.  Until now they were very laissez-faire about what developers used to do their work. In fact one of the things I initially found attractive about the company is that most programmers used Linux, or whatever OS they felt best suited their efforts.

Now orders, without discussion, have come down that everyone is to switch to Eclipse. A fine editor. I prefer SublimeText2, but it's just my personal taste.

Just to be clear: we are a JS team using Backbone and Eclipse just isn't good at understanding Backbone code.  This means that those on the team who use a /good/ IDE (PHP Storm), have to go back to doing a lot of search-find-oh-wait-where-was-I-three-steps-ago kind of things instead of just ctrl+clicking and using back/ forward - probably diminishing productivity by say 15% and enjoyment by 50%...

Is this a red flag? It seems capricious and unreasonably controlling to tell developers (non-MS) what IDE or tool-sets to use if they are already settled in and productive.


答:
Someone who works on side-projects is not guaranteed to be a good programmer; they may be teaching themselves bad habits. Someone who doesn't work on side-projects is not guaranteed to be a bad programmer; indeed, in some, it helps them to focus harder while working.

But, there is certainly a correlation between time spent programming and skill level, even if it's not a straight line or a simple curve.

It makes sense. To be a master of anything, you must be willing to dedicate a significant time to learning the craft, especially a relatively new craft where the goalposts shift slightly over time.

But here's a thought: I don't think you have to code outside of work hours to learn. While I would never suggest that reading the theory of programming is a substitute for practising, I would suggest that if you're spending time reading blogs, etc., or just looking at new technologies, then applying what you learn at work then you can become a very good developer without having side-projects per se.


答:
I'd have the "corporate mandated" IDE installed, but would still do most of my work in whatever IDE I wanted--it's not like anybody can tell what IDE was used to edit a source file.

On the IDE vs. editor front... for almost all languages, I strongly prefer an IDE (IntelliJ) because there's just so much more it can do for you than an editor can. There are some things I revert to ST2 or Emacs for, but for day-to-day coding, despite how much I like both ST2/Emacs, the IDE almost always wins.


答:
In our Ruby shop there's a strong recommendation to use the IDE most of the team enjoys (RubyMine), because we know it does the job and we can teach each other shortcuts etc.

Developers are free to use a different IDE, but we require them to have solid skills in that editor should they choose so. If we see someone struggling to navigate their project or edit text in their custom FooEdit, RubyMine for them it is.


答:
If a programmer is an expert at a given IDE, then they should use it. If they aren't an expert at any IDE, there's probably one or two that are very common for your programming language, or within your team, and it probably makes sense for them to learn it.

Being forced to standardize on an IDE sounds like a terrible idea.


答:
You can "use" Eclipse while still typing in SublimeText2.

This means having Eclipse installed and configured for your projects and getting up to speed with it so that you are equally comfortable using it if, say, pair programming. Nobody will (or at least should) care what editor you actually used to type in a piece of code you committed as long as maintaining your parallel setup doesn't take up an undue amount of time and you don't cut yourself off from the standard development environment.


答: Yes, it's a bit of a red flag that management considers itself a better judge of which tools you would be more efficient with than you are.</p>


问:
How much time do you spend actually developing vs. infrastructure activites?
When I'm working I feel like most of the time I'm not doing actual work. For example after making a change to the code in order to test it, I have to first build the project, and start the server(say JBoss). Upon testing, I find that there is another small issue. So I bring down the server, make the changes, build again and start up the server again.The building and bringing the server up/down is not very useful work.

Also, the IDE (let's say Eclipse) does things such as updating Maven indexes and building the workspace which take some more time to get things done.

Have you come across this kind of situation? Do you have tips on how to overcome/bypass this? Any features on the IDE/build tools that can be helpful? Any architecture/application design/technology that attempts to overcome this?

答:
Development always involve overhead like this, even without an IDE.  At the the end of the day "someone has to do it" and "whatever time it takes, it counts as development time".

In either case, what you describe is just the development cycle with an IDE (I use a variety of IDE's and editors).

Since you asked for tips, one thing I do find easy with an IDE is the visual ability to select and run one or a selected number of tests easily to avoid the time delay of running the whole suite.

Another thing that can help a lot is caching.  For example I develop in rails and it caches stuff in production more than development to make development changes easier.  However that be be changed as needs to help speed things up more for development (e.g. css/js assets don't change).

Sometimes it's better to use command line tools and a lighter-weight editor depending on the circumstance at hand.


答:
The reasons for a company to force a particular editor or software in general on their developers should be examined. The paranoid (maybe not the word I am looking for) part of me thinks there might be some sort of productivity tracking added to the eclipse they are asking developers to install. A much less paranoid (again) thought would be that they have spent time adding product build tools to this IDE that would make things much easier if everyone pressed the same button to test and build their code branch.

Anyway what I am trying to say is its probably more than just mere bureaucracy, or a method of messing with the developers heads.


答: This is a massive red flag. Every company has a few such stupid ideas, but if other red flags keep coming, just leave.</p>


问:
Protecting your interests as a freelance web designer
What is the best way to protect your interests as a freelance web designer when:

The client is unresponsive and takes a long time to make decisions

The client makes constant changes

Feature creep

答:
You must sit with the customer before the project begins and set guidelines on how the project will proceed and let the customer agree on the method by which you design and execute your project plan. If this planning step is not accomplished up-front, it is hard to make the customer happy at the end of the project. Of course this assumes that you have a plan and you can scope the work correctly and can make a good estimate on effort required.

Many customers don't appreciate the effort required in making change (or simply don't care). Some belive that they can ask for anything as long as they are paying, that is not quite their mistake unless they were warned.

Still, if you passed this chance, try this now. Try to create a basic set of requirements that won't change and identify others as nice to have in the next release. Log the changes that were requested so far and the deviations from original scope and invite them for a discussion. If you are sure of yourself, you could ask for independent arbitration or ask for extra time/money.

Remember that this customer may be needed in the future as a referral. So be careful.


答:
Surely this is a bad idea. It is inevitable that the team will become less productive since they have to learn to use new tools. And even then they won't be as effective as with the tools they already grok.

Since I've tried various tools myself I always had at some point that  feeling "gosh, this editor is annoying me with <insert some bug/difference from prefered tool>". So it'll be a moral drawback as well.

But of course there are also pros to have a whole team use the same tools. Sharing configs, skripts, plugins and all that sort of stuff. Which wouldn't be possible with a diversity of toolsets.

On the other hand… that last bit wouldn't be necessary if everyone used his or her preferred software. ;)


答:
It is easy for the motivation behind some decisions to get lost - especially with rapidly growing team. The motivation to move to Eclipse might just be the fact that most of the developers seem to be wasting a lot of time just configuring the IDE and that there is only limited expertise withing your company.

I would just take the order to move to Eclipse to mean that you should have Eclipse setup in case it is needed, but continue your work in your favorite editor. (You might have to move to Eclipse gradually if your company starts deploying cool tools within Eclipse.)

Red Flag: I would wait if there are a few more such irrational orders before being worried.


答:
Every team I've ever been on has had a multiplicity of IDE and editors: Eclipse, Netbeans, IDEA, VIM, Emacs, Textmate, RubyMine -- it's never been an issue. Never.

To me this speaks to a misunderstanding at the high levels of the organization, as to what really matters. What matters is letting good coders do what they need to do and use the tools that make them most comfortable. IDE uniformity has very little to do with the real communication that takes place about the essential questions of object architecture, unit testing, algorithms, etc.

Having the same IDE as the next guy just means that we both know how to browse the code with the same shortcuts, and how our compilation/configuration is set up. None of which will matter when talking about real code issues.

Look, it's livable, depending on other factors at the company. You can always use your own preferred editor for day-to-day stuff. And maybe your group is doing other great things that creates great culture. But mandated IDEs is a huge misstep IMO. For me, if I were interviewing with a company and they informed me which IDE I was allowed to use, I would thank them politely for their time.


答:
A startup is generally trying to stay agile long enough to figure out a sustainable business model. Once it figures out the money part, management moves in to scale up the business. That's generally when all the early tech employees start leaving, as engineering processes gets tightened up.

As you know, you don't know what code will actually do until you run it. Turing proved that in the early days of computing. This means that there is no such thing as any meaningful measure of productivity when it comes to writing software. However, for management to do its job, productivity must be legible. Since you can't measure code (and people have tried -- lines of code, for example), they will measure what they can see. Programmers are more legible than the software they develop. The typical management team attempts to control programmers in order to make these things legible to them (instead of doing their real jobs: getting out of the way). And because they measure the wrong things, it doesn't work very well.

Having said that, you can still go a long way with a loosely-coupled team. Github's development team has around 50 people and they break every rule in the business management textbooks. They seem to be doing all right. Bugs get fixed (eventually). Features get added. Fires get put out.

What is a big red flag is if they are trying to scale things up without having figured out how to make money. At that point, you got to wonder how much of your unvested options and grants are really worth.


答: If you're using Git and your branching is down, you shouldn't need to be using each other's editors anyway. You can just push a branch and have another dev pull it to get it working if he really can't figure your toolset out. Forcing everyone to use the same editor sounds like an order by some business head who wants to look smart but doesn't really understand the way you guys operate. </p>


答:
If you think about this from a management point of view, the reason they may be doing this is for legal compliance.  The company is responsible to ensure that every tool used is being used legally and will also not encumber the product that is being developed.  (Some editors are free for personal use, but not free for any other purposes, etc.)  To audit every tool that every developer may want to use can be expensive. I've seen that on projects where time lines are tight, management will be cautious about which tools/libraries/etc are used to minimize changes later in the project that are directed by the legal folks.

On higher security projects there is also the concern of where the IDEs store temporary files, and what information is stored between sessions.


答:
It all depends on the reasons they have to recommend Eclipse. If developers are having trouble setting up their environments because everyone organizes things differently, there may be a reason to recommend a straightjacket. If, however, everybody was happy and productive using whatever they wanted, there is little reason to impose a change on something so deeply involved in the creative process.

Eclipse is a lot more than an editor - you may keep using your favorite editor for editing your code and rely on Eclipse for source control, debugging and whatever else the corporate mandated workflow wants it used for.

One final thing - enforcing process in this level may indicate the company intends to expand the development team and wants to have a certain bit of structure in place so new teammates can get productive faster. If you think Rails (or Django) as an "opinionated" framework, you'll realize having structure helps to understand  new applications easier.


答:
If you look at it from a business perspective, you'd have to make a distinction between value-adding activities and non-value adding activities. What is a value-adding activity? One that the customer is willing to pay for.

Does the customer want to pay you to start up the server? No!
Does the customer want to pay you for a relevant change in the code? Yes!

If you'd want to work as productive as possible, you have to eliminate all these non value-adding activities or at least cut them to the absolute minimum. This is a crucial step towards lean manufacturing. This is becoming more and more important in service companies too.

Now suppose you have a machine that has a setup and shutdown time before you can start to produce another part. What you will do to maximize productivity is you will cluster the same products together, in order to minimize the setup and shutdown time. In that way maybe you could do more changes at the same time before restarting the system.

The are many books written about the subject which will give you general advice of how to recognize all the "waste" in your company or specifically what you do but also how to get rid of it. The advice is general, so you should think of yourself how you could apply this to your specific programming situation.

Maybe this book is something for you. It specifically handles services. Also the wikipedia page about lean service management is relevant.

Title: How much time do you spend actually developing vs. infrastructure activites?

Body:
When I'm working I feel like most of the time I'm not doing actual work. For example after making a change to the code in order to test it, I have to first build the project, and start the server(say JBoss). Upon testing, I find that there is another small issue. So I bring down the server, make the changes, build again and start up the server again.The building and bringing the server up/down is not very useful work.

Also, the IDE (let's say Eclipse) does things such as updating Maven indexes and building the workspace which take some more time to get things done.

Have you come across this kind of situation? Do you have tips on how to overcome/bypass this? Any features on the IDE/build tools that can be helpful? Any architecture/application design/technology that attempts to overcome this?


答:
"Now orders, without discussion, have come down that everyone is to switch to Eclipse."

I think that this is the real red flag. Your team is the expert on software development and the one to be affected by the decision, and yet you did not get to say a word in the discussion that resulted in this order?

It sounds like over-managing by pointy-haired bosses. Does the decision making person/team have relevant insight for that decision?

Given that the decision makers are qualified enough for such a decision, not asking for the dev team's opinion has at least two shortcomings:

The team does not feel involved. Involving the team should be a priority for management. I would not like to work as a dev somewhere where my opinion about such central issues as IDE is not valued enough to even be asked for. Granted that asking for someone's opinion and then deciding against it may be worse, but in that case I'd expect a solid rationale for that decision.

The management, however experienced, does not work 100% with development of this specific code. Assuming that the people who do don't have interesting insight at all would be naïve. Of course it may be so that the managers had thought of everything the devs come up with, but the only way to know is to ask.


问:
What is the difference between building and compiling ?
What's the difference between Building and Compiling. </p>

答:
Compiling is part of a build process.

A build process can include testing, packaging and other activities apart from compilation.


答:
These terms are often used interchangeably, but I would differentiate them in the following way:

Building is done when preparing an application for release, which includes compiling, packaging, testing, etc.

Compiling is done at any time the compiler is involved in translating programming language code to machine code.

Thus, compiling is really a subset of building.

Title: What is the difference between building and compiling ?

Body: What's the difference between Building and Compiling. </p>


问:
Is it OK to repeat code for unit tests?
I wrote some sorting algorithms for a class assignment and I also wrote a few tests to make sure the algorithms were implemented correctly.  My tests are only like 10 lines long and there are 3 of them but only 1 line changes between the 3 so there is a lot of repeated code.  Is it better to refactor this code into another method that is then called from each test?  Wouldn't I then need to write another test to test the refactoring?  Some of the variables can even be moved up to the class level.  Should testing classes and methods follow the same rules as regular classes/methods?

Here's an example:

```<code>    [TestMethod]
    public void MergeSortAssertArrayIsSorted()
    {
        int[] a = new int[1000];
        Random rand = new Random(DateTime.Now.Millisecond);
        for(int i = 0; i < a.Length; i++)
        {
            a[i] = rand.Next(Int16.MaxValue);
        }
        int[] b = new int[1000];
        a.CopyTo(b, 0);
        List<int> temp = b.ToList();
        temp.Sort();
        b = temp.ToArray();

        MergeSort merge = new MergeSort();
        merge.mergeSort(a, 0, a.Length - 1);
        CollectionAssert.AreEqual(a, b);
    }
    [TestMethod]
    public void InsertionSortAssertArrayIsSorted()
    {
        int[] a = new int[1000];
        Random rand = new Random(DateTime.Now.Millisecond);
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = rand.Next(Int16.MaxValue);
        }
        int[] b = new int[1000];
        a.CopyTo(b, 0);
        List<int> temp = b.ToList();
        temp.Sort();
        b = temp.ToArray();

        InsertionSort merge = new InsertionSort();
        merge.insertionSort(a);
        CollectionAssert.AreEqual(a, b);
    }
</code>```

答:
Test code is still code and also needs to be maintained.

If you need to change the copied logic, you need to do that in every place you copied it to, normally.

DRY still applies.

Wouldn't I then need to write another test to test the refactoring?

Would you? And how do you know the tests you currently have are correct?

You test the refactoring by running the tests. They should all have the same results.

Title: Is it OK to repeat code for unit tests?


答:
As Oded already said, test code still needs to be maintained. I'd add that repetition in test code makes it harder for maintainers to understand the structure of tests, and to add new tests.

In the two functions you posted, the following lines are absolutely identical except for one space difference at the start of the for loop:

```<code>        int[] a = new int[1000];
        Random rand = new Random(DateTime.Now.Millisecond);
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = rand.Next(Int16.MaxValue);
        }
        int[] b = new int[1000];
        a.CopyTo(b, 0);
        List<int> temp = b.ToList();
        temp.Sort();
        b = temp.ToArray();
</code>```

This would be a perfect candidate for moving in to some kind of helper function, whose name indicates that it is initialising data.

Title: Is it OK to repeat code for unit tests?

Body:
I wrote some sorting algorithms for a class assignment and I also wrote a few tests to make sure the algorithms were implemented correctly.  My tests are only like 10 lines long and there are 3 of them but only 1 line changes between the 3 so there is a lot of repeated code.  Is it better to refactor this code into another method that is then called from each test?  Wouldn't I then need to write another test to test the refactoring?  Some of the variables can even be moved up to the class level.  Should testing classes and methods follow the same rules as regular classes/methods?

Here's an example:

```<code>    [TestMethod]
    public void MergeSortAssertArrayIsSorted()
    {
        int[] a = new int[1000];
        Random rand = new Random(DateTime.Now.Millisecond);
        for(int i = 0; i < a.Length; i++)
        {
            a[i] = rand.Next(Int16.MaxValue);
        }
        int[] b = new int[1000];
        a.CopyTo(b, 0);
        List<int> temp = b.ToList();
        temp.Sort();
        b = temp.ToArray();

        MergeSort merge = new MergeSort();
        merge.mergeSort(a, 0, a.Length - 1);
        CollectionAssert.AreEqual(a, b);
    }
    [TestMethod]
    public void InsertionSortAssertArrayIsSorted()
    {
        int[] a = new int[1000];
        Random rand = new Random(DateTime.Now.Millisecond);
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = rand.Next(Int16.MaxValue);
        }
        int[] b = new int[1000];
        a.CopyTo(b, 0);
        List<int> temp = b.ToList();
        temp.Sort();
        b = temp.ToArray();

        InsertionSort merge = new InsertionSort();
        merge.insertionSort(a);
        CollectionAssert.AreEqual(a, b);
    }
</code>```

Body:
As Oded already said, test code still needs to be maintained. I'd add that repetition in test code makes it harder for maintainers to understand the structure of tests, and to add new tests.

In the two functions you posted, the following lines are absolutely identical except for one space difference at the start of the for loop:

        int[] a = new int[1000];
        Random rand = new Random(DateTime.Now.Millisecond);
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = rand.Next(Int16.MaxValue);
        }
        int[] b = new int[1000];
        a.CopyTo(b, 0);
        List<int> temp = b.ToList();
        temp.Sort();
        b = temp.ToArray();

This would be a perfect candidate for moving in to some kind of helper function, whose name indicates that it is initialising data.


问:
What is the difference from the push and pull development models?
I was reading Extreme Programming Explained, Second Edition and in the chapter 11 "The Theory of Constraints" the authors talk about the old and obsolete "push" development model and the XP way, the "pull" development model. It looks like a quite important concept, but it takes only a very small paragraph and two images that are mere illustrations of the "waterfall" and iterative process, nothing specific about these models except by the image caption. I searched and it doesn't go any further about it in the rest of the book. I couldn't find any further explanations or discussions about it in the Internet either.

If the only difference about those is that one is "waterfall" and the other is iterative, them why push and why pull?

Does anyone understand what is really the difference between those two and give some good examples?

答:
The difference between a push and a pull system is how the units of work are assigned to the person who will be carrying out that unit of work. The concept of push and pull aren't unique to software development - the idea originates from logistics and supply chain management.

In a push system, some kind of task is created and then assigned to a developer. A task could be anything from the implementation of a requirement (or a component needed to realize a requirement) to a bug fix to a document to write. Someone, usually some kind of manager or team leader, takes the units of work that need to be done and then allocate them to the members of the team to complete. Simply, work is pushed onto the people who will be doing it.

In a pull system, the tasks that must be done are stored in a queue, often a priority queue of sorts. An example might be Scrum's product and sprint backlogs, which contain user stories that are to be done. A developer who is currently not working on anything will go to the queue and take off the highest priority story that they are able to do and work on it. The people who are doing the work pull the work out of a list and do it.

The concept of push and pull aren't related to iterative/incremental versus sequential development. A team using iterative/incremental/agile techniques could use a push system, while a team using sequential development could use a pull system. However, typically, the agile methods (XP, Scrum) favor self-organizing teams and therefore pull systems.

For more information, you might be interested in this blog post on Push vs. Pull in Scrum. Kanban might also be of interest - Kanban is a methodology that comes from manufacturing, but can be applied to software development, which emphasizes just-in-time development and reducing overload on workers. Kanban is also related to and often used with Lean, another manufacturing concept which can be applied to software development.

ContentLicense: CC BY-SA 4.0


问:
Flowchart for solving programming problems
I noticed that every developer implements a somewhat different flowchart for solving programming problems.

By flowchart I mean a defined system of techniques that the developer goes through in a certain sequence, trying to solve the problem at hand.

Some examples for techniques:

Google "how to..." or "... tutorial".

Search the java/msdn/apple/etc API doc for the specific class or method.

Search in stack overflow the exact problem with some tags like [iphone]/[java] etc.

Take a nap and let the subconscious work.

Debug.

Draw the algorithm or system.

Google the logged error message.

Ask a colleague or manager.

Ask a new question in stack overflow.

From your experience, what is the best flowchart for solving a programming problem?

答:
Think: consider issues that might come up, what resources you need, etc.

Design: create the technical plans that will be implemented as the product. UML is an excellent lingua franca of software engineering.

Test: create tests that will pass when the product is complete; this let's you know when you can stop programming. When the tests pass, you're done.

Create: implement the design and run the tests. Any extra problems encountered require refactoring the design and tests.

This process minimizes bugs and typing time (typing is the least insightful part of software engineering).


答:
Duplicating code for tests is an easy trap to fall into.  Sure it's convenient, but what happens if you start to refactor your implementation code and your tests all start needing to change? You run the same risks that you do if you've duplicated your implementation code, in that you will most likely need to change your test code in many places also.  This all adds up to a great deal of wasted time, and an increasing number of failure points that need to be dealt with, which means that the cost to maintain your software becomes unnecessarily high, and therefore reduces the overall business value of the software you work on.

Consider also that what is easy to do in tests will become easy to do in the implementation.  When you are pressed for time and under a lot of stress, people tend to rely on learned patterns of behavior and generally try and do what seems easiest at the time. So, if you find you cut and paste a lot of your test code, it's likely you'll be doing the same in your implementation code, and this is a habit you want to avoid early on in your career, to save you a lot of difficulty later on when you find yourself having to maintain older code that you have written, and that your company can't necessarily afford to rewrite.

As others have said, you apply the DRY principal, and you look for opportunities to refactor any likely duplications to helper methods and helper classes, and yes, you should even be doing this in your tests in order to maximize the reuse of code and save yourself facing difficulties with maintenance later on. You may even find yourself slowly developing a testing API that you can use over and over again, possibly even in multiple projects - certainly that is how things have happened for me over the last several years.

Title: Is it OK to repeat code for unit tests?


答:
"Building" is a fairly general term, and it can refer to anything that is needed to go from editable source material (source code, scripts, raw data files, etc.) to a shippable software product. Building can (and usually does) involve several steps, such as pre-processing, compiling, linking, converting data files, running automated tests, packaging, etc.

"Compiling" is more specific, and almost invariably refers to a process that takes source code as its input, and outputs something runnable, typically machine code for either a physical or virtual machine, or source code in a different language.


答: Even more than production code, test code needs to be optimized for readability and maintainability, as it has to be maintained along the code being tested and also be read as part of the documentation. Consider how copied code may make test code maintenance harder and how that may become an incentive not to write tests for everything. Also, don't forget that when you write a function to DRY your tests, it also should be subject to tests.</p>

Title: Is it OK to repeat code for unit tests?


问:
How to prove a Dynamic programming strategy will work for an algorithm?
How can I prove that a dynamic programming (dp) strategy for a problem will work or not? For greedy algorithms, we can prove by showing the sub problems exhibits matroid property.
Is there any such methods for dp algorithms?  </p>

答:
In principle, any multi-stage optimization problem is solvable using dynamic programming, if you can come up with the right notion of the state. You do not mention which class of problems you are working on, so it hard to give general guidelines. I'll make the following assumptions here:

You are looking at deterministic optimization problems (as opposed to stochastic optimization problems).

You have to choose finite number of decisions, and in the end want to maximize rewards that depend on all your decisions (the argument also works if you are interested in minimizing costs).

You can decompose the total reward into sum of individual rewards, ideally, in such a way that decision n influences the total reward for the first time only from the n-th term onwards.

In order to solve such a problem by dynamic programming, you need to come up with a state staten that satisfies the following properties:

staten+1 = function(staten, decisionn)

and

rewardn = function(staten, decisionn)

If these conditions are satisfied, then dynamic programming gives an optimal solution. First you define value functions

Vn(staten) = maxdecisionn[ rewardn + Vn+1(staten+1)]

and recursively solve for these value functions in a backward manner.

NOTE: These are the simplest class of problems that can be solved using dynamic programming. For more details, see any standard book on dynamic programming, e.g., Berksekas.


问:
Ubuntu, OpenSuse, the world of linux for a web-developer
I'm learning web development. My main OS is windows 7 but I've used Linux and currently dual-booting with Ubuntu. My Linux knowledge however, is pretty limited. I can work with the command line on simple tasks but that's pretty much it. I don't do any shell scripting, don't know very well the most important commands, nor the system in general.

I am interested in web development. Should I get myself familiarized more with Linux ?  Is it a must for future job positions considering my field of interest?

答:
It certainly is a must since most of the web you see (stackexchange being one notable exception) runs on Linux and other Unix-like OSs. Most web development technologies and frameworks are Unix-native - despite the fact a couple of them also run on Windows, but few target Windows deployments.

A developer must thoroughly understand the environment the program runs. In most cases, it won't be Windows. You should learn Unix (and Linux) philosophy to be able to make your apps integrate more easily.

The good thing is that, with tools like Cygwin, you don't even need to leave Windows to get experienced with Unix-like environments - and you get a very capable command line you can use on Windows. With compilers and interpreters for a multitude of languages, source-control and text processing tools.


答:
No, it's not OK. You should use a TestDataBuilder instead. You should also take care about readability of your tests : a ? 1000 ? b ? If tomorrow one have to work on the implementation you are testing, tests are a great way to enter the logic : write your tests for you fellow programmers, not for the compiler :)

Here are your tests implementation, "revamped" :

```<code>/**
* Data your tests will exercice on
*/
public class MyTestData(){
    final int [] values;
    public MyTestData(int sampleSize){
        values = new int[sampleSize];
        //Out of scope of your question : Random IS a depencency you should manage
        Random rand = new Random(DateTime.Now.Millisecond);
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = rand.Next(Int16.MaxValue);
        }
    }
    public int [] values();
        return values;
    }

}

/**
* Data builder, with default value.
*/
public class MyTestDataBuilder {
    //1000 is actually your sample size : emphasis on the variable name
    private int sampleSize = 1000; //default value of the sample zie
    public MyTestDataBuilder(){
        //nope
    }
    //this is method if you need to test with another sample size
    public MyTestDataBuilder withSampleSizeOf(int size){
        sampleSize=size;
    }

    //call to get an actual MyTestData instance
    public MyTestData build(){
        return new MyTestData(sampleSize);
    }
}

public class MergeSortTest {

    /**
    * Helper method build your expected data
    */
    private int [] getExpectedData(int [] source){
        int[] expectedData =  Arrays.copyOf(source,source.length);
        Arrays.sort(expectedData);
        return expectedData;
    }
}

//revamped tests method Merge
    public void MergeSortAssertArrayIsSorted(){
        int [] actualData = new MyTestDataBuilder().build();
        int [] expected = getExpectedData(actualData);
        //Don't know what 0 is for. An option, that should have a explicit name for sure :)
        MergeSort merge = new MergeSort();
        merge.mergeSort(actualData,0,actualData.length-1);
        CollectionAssert.AreEqual(actualData, expected);
    }

 //revamped tests method Insertion
 public void InsertionSortAssertArrayIsSorted()
    {
        int [] actualData = new MyTestDataBuilder().build();
        int [] expected = getExpectedData(actualData);
        InsertionSort merge = new InsertionSort();
        merge.insertionSort(actualData);
        CollectionAssert.AreEqual(actualData, expectedData);
    }
//another Test, for which very small sample size matter
public void doNotCrashesWithEmptyArray()
    {
        int [] actualData = new MyTestDataBuilder().withSampleSizeOf(0).build();
        int [] expected = getExpectedData(actualData);
        //continue ...
    }
}
</code>```

Title: Is it OK to repeat code for unit tests?

Body:
No, it's not OK. You should use a TestDataBuilder instead. You should also take care about readability of your tests : a ? 1000 ? b ? If tomorrow one have to work on the implementation you are testing, tests are a great way to enter the logic : write your tests for you fellow programmers, not for the compiler :)

Here are your tests implementation, "revamped" :

/**
* Data your tests will exercice on
*/
public class MyTestData(){
    final int [] values;
    public MyTestData(int sampleSize){
        values = new int[sampleSize];
        //Out of scope of your question : Random IS a depencency you should manage
        Random rand = new Random(DateTime.Now.Millisecond);
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = rand.Next(Int16.MaxValue);
        }
    }
    public int [] values();
        return values;
    }

}

/**
* Data builder, with default value.
*/
public class MyTestDataBuilder {
    //1000 is actually your sample size : emphasis on the variable name
    private int sampleSize = 1000; //default value of the sample zie
    public MyTestDataBuilder(){
        //nope
    }
    //this is method if you need to test with another sample size
    public MyTestDataBuilder withSampleSizeOf(int size){
        sampleSize=size;
    }

    //call to get an actual MyTestData instance
    public MyTestData build(){
        return new MyTestData(sampleSize);
    }
}

public class MergeSortTest {

    /**
    * Helper method build your expected data
    */
    private int [] getExpectedData(int [] source){
        int[] expectedData =  Arrays.copyOf(source,source.length);
        Arrays.sort(expectedData);
        return expectedData;
    }
}

//revamped tests method Merge
    public void MergeSortAssertArrayIsSorted(){
        int [] actualData = new MyTestDataBuilder().build();
        int [] expected = getExpectedData(actualData);
        //Don't know what 0 is for. An option, that should have a explicit name for sure :)
        MergeSort merge = new MergeSort();
        merge.mergeSort(actualData,0,actualData.length-1);
        CollectionAssert.AreEqual(actualData, expected);
    }

 //revamped tests method Insertion
 public void InsertionSortAssertArrayIsSorted()
    {
        int [] actualData = new MyTestDataBuilder().build();
        int [] expected = getExpectedData(actualData);
        InsertionSort merge = new InsertionSort();
        merge.insertionSort(actualData);
        CollectionAssert.AreEqual(actualData, expectedData);
    }
//another Test, for which very small sample size matter
public void doNotCrashesWithEmptyArray()
    {
        int [] actualData = new MyTestDataBuilder().withSampleSizeOf(0).build();
        int [] expected = getExpectedData(actualData);
        //continue ...
    }
}


问:
Where do I start in regards to making a Gnome/Unity Form Application
Ok so I am familiar with developing Form and Console applications on Windows using Visual Studio .Net with C#, but where do I start when it comes to Linux distro's like Ubuntu, is there an equivalent?

How would one go about matching what they can do in a Windows environment with .Net and C# in a Linux environment without .Net coding in something like Java or C/C++?

I am aware of Eclipse, does eclipse have a form designer or do you have to code the design of any Gnome/Unity forms manually? Can I use eclipse to write the Linux equivalent of a console application, that you just double click on to run?

I also know about Mono, but the idea is that I want to learn how to develop software without using anything in the Microsoft stack and am not sure where to start.

What is the standard language/framework used to develop these types of applications on Linux?

As I become more proficient with Visual Studio, C# and .Net, it has struck me that without these Microsoft tools, I am nothing. I am only capable of developing for the Microsoft OS and this scares me. This isn't some anti Microsoft thing, Microsoft makes some incredible Software/Hardware/Operating Systems/IDE's, but it is generally a bad idea to put all of your eggs in one basket so if I want to learn how to develop Terminal and Gnome/Unity form applications where in the world do I start?

I have used Linux on and off for years, but Windows has been my primary OS. However I have watched Linux get better and better and as much as I love Windows 7, I am dubious about Windows 8 (I for one will sorely miss my start menu)! Obviously MS aren't going anywhere anytime soon and I could spend the the next couple of decades developing for .Net without any issues but just because you can get away with something doesn't always mean it's a good idea.

Thanks

答: I'm a bit rusty with desktop apps. My first choice would be Glade and PyGlade. Since you come from a Windows background, I'd suggest MonoDevelop as a starting point, as it has a decent GUI designer and can target Gnome. I understand you want to distance yourself from Microsoft-related technologies and that the Mono runtime is not deployed on every Linux distro automatically, but you may want to start somewhere and this can bring you more immediate results. I never did GUI stuff on Eclipse, but NetBeans' GUI designer is excellent.</p>


答:
Although Mono can run certain Windows-built .NET apps, you can also grab MonoDevelop and make Gtk+ applications specifically for Linux using .NET - no Microsoft stack involved.

I don't know much about GUI applications in other languages for Linux, but for Terminal applications, you can use pretty much every language that exists, from C++ to JavaScript to Python to Perl.

Title: Where do I start in regards to making a Gnome/Unity Form Application

Body:
Ok so I am familiar with developing Form and Console applications on Windows using Visual Studio .Net with C#, but where do I start when it comes to Linux distro's like Ubuntu, is there an equivalent?

How would one go about matching what they can do in a Windows environment with .Net and C# in a Linux environment without .Net coding in something like Java or C/C++?

I am aware of Eclipse, does eclipse have a form designer or do you have to code the design of any Gnome/Unity forms manually? Can I use eclipse to write the Linux equivalent of a console application, that you just double click on to run?

I also know about Mono, but the idea is that I want to learn how to develop software without using anything in the Microsoft stack and am not sure where to start.

What is the standard language/framework used to develop these types of applications on Linux?

As I become more proficient with Visual Studio, C# and .Net, it has struck me that without these Microsoft tools, I am nothing. I am only capable of developing for the Microsoft OS and this scares me. This isn't some anti Microsoft thing, Microsoft makes some incredible Software/Hardware/Operating Systems/IDE's, but it is generally a bad idea to put all of your eggs in one basket so if I want to learn how to develop Terminal and Gnome/Unity form applications where in the world do I start?

I have used Linux on and off for years, but Windows has been my primary OS. However I have watched Linux get better and better and as much as I love Windows 7, I am dubious about Windows 8 (I for one will sorely miss my start menu)! Obviously MS aren't going anywhere anytime soon and I could spend the the next couple of decades developing for .Net without any issues but just because you can get away with something doesn't always mean it's a good idea.

Thanks


答:
Here is what I'd do (assuming that the task at hand is a one-man task and should be completed in short period of 1-4 days or so.)

Put a work plan to include the following:

Understand the problem carefully

Identify solution elements (math background, new tool, etc.)

Assess your current abilities vs. what seams to be required

Decide to solve the problem or not based on the above step.

If you decided that you can solve the problem given your skill set and time required, put an action plan to solve the problem, that would include:

A. Complete deficiency in background (Tutorials, books, etc.) - This may include going to a course, acquire books, download software, etc. The exact answer depends on the problem at hand. For example, there is no value in trying to learn HTML in a day to solve a design problem but you can search the net for how to convert a string date to a julian date using the internet.

B. Think about the solution given the current situation parameters now that you know the technology and produce a design with success scenarios and constraints (time, size, etc.). If you got stuck on a detail (e.g. how to write Regex to parse ISBN number, ask colleges if they are cooperative or go ask the net or look it up in a book).

C. Assess your solution and see if it is the best (Search, discuss, etc.)

D. Prototype

E. Build a working version and debug until it works as designed

If when run as designed you don't get what you want (as in B), Go TO B again Else Buy everyone lunch and call it a day :).

Title: Flowchart for solving programming problems

Body:
I noticed that every developer implements a somewhat different flowchart for solving programming problems.

By flowchart I mean a defined system of techniques that the developer goes through in a certain sequence, trying to solve the problem at hand.

Some examples for techniques:

Google "how to..." or "... tutorial".

Search the java/msdn/apple/etc API doc for the specific class or method.

Search in stack overflow the exact problem with some tags like [iphone]/[java] etc.

Take a nap and let the subconscious work.

Debug.

Draw the algorithm or system.

Google the logged error message.

Ask a colleague or manager.

Ask a new question in stack overflow.

From your experience, what is the best flowchart for solving a programming problem?


答:
Compiling is done by compiler, build can be more complex process.

Eg. in C++ to make a build of a project you need preprocessor (preprocessing of source files); compiler (compiling of source files); linker (merging everything into executable - compiled code, icons, strings, other resources together)

So generally compiling is translating code written in one language to another (eg. machine code).


问:
Should I be worried if I solve a lot of my problems the same way?
I really enjoy programming games and puzzle creators/games. I find myself engineering a lot of these problems the same way and ultimately using similar technique to program them that I'm really comfortable with.

To give you brief insight, I like to create graphs where nodes are represented with objects. These object hold data such as coordinates, positions and of course references to other neighboring objects. I'll place them all in a data structure and make decisions on this information in a "game loop".

While this is a brief example, its not exact in all situations. It's just one way I feel really comfortable with. Is this bad?

答:
"Developer Art" actually has the correct answer if your goal is to produce a product. And if your "factory" produces the products that satisfy then cool.

But...

If you ever want to learn new (and potentially better) ways of doing things you have to change things up. This will produce failures but only through failure does one actually learn. And through this new learning you may be able to produce even better and more compelling software.

This is actually backed up through neurological research. So there you go.


问:
Higher coding standards for dynamic languages?
Due to the inherent risks associated with using dynamic languages (e.g. Python, Ruby) carelessly, what (if any) standards should be imposed on production code written in these languages?</p>

答:
Not so much a coding standard as a good practice, I would say aggressive testing.

As you said, there are inherent risks with dynamic languages. Issues that would never even exist in a static language can and will crop up in poorly designed or written code in a dynamic language. Applying comprehensive, well-written unit tests as a part of your process will help ensure your code is correct and error free.


问:
Has Javascript developed beyond what it was originally designed to do?
I've been talking with a friend about the purpose of Javascript, when and how it should be used, etc. He quoted that:

JavaScript was designed to add interactivity to HTML pages

[...]

JavaScript gives HTML designers a programming tool

HTML authors are normally not programmers, but JavaScript is a scripting language with a very simple syntax! Almost anyone can put
  small "snippets" of code into their HTML pages JavaScript can react to
  events

A JavaScript can be set to execute when something happens, like when a page has finished loading or when a user clicks on an HTML element
  JavaScript can read and write HTML elements

A JavaScript can read and change the content of an HTML element JavaScript can be used to validate data

A JavaScript can be used to validate form data before it is submitted to a server. This saves the server from extra processing

JavaScript can be used to detect the visitor's browser - A JavaScript can be used to detect the visitor's browser, and -
  depending on the browser - load another page specifically designed for
  that browser.

JavaScript can be used to create cookies - A JavaScript can be used to store and retrieve information on the visitor's computer.

However, it seems like Javascript's getting used to do a lot more than these days. My friend also advocates against using Javascript's OOP functionality, claiming that "you shouldn't be processing data, merely validating." Is Javascript really limited to validating data and making flashy graphics on a web page?

He goes on to claim "you shouldn't be attempting to access databases through javascript" and also says " in general you don't want to be doing your heavy lifting in javascript". I can't say I agree with his opinion, but I'd like to get some more input on this.

So, my question: Has Javascript evolved from the definition above to something more powerful, has the way we use it changed, or am I just plain wrong? While I realize this is a subjective question, I can't find any more information on it, so a few links would be good, if nothing else. I'm not looking for a debate, just an answer.

答:
People who think JavaScript is not a programming language are people who's opinion on JavaScript you should not respect.

JavaScript is a language that has grown organically inspired by semantics of Scheme and syntax of Java. It's original purpose was not general but it has now grown to be so.

JavaScript as a language is suitable to do just about any task if it's fit for it. Take a look at examples like node.js where JavaScript has access to host environment consisting of IO functionality which allows it to be used for generic server side programming

My friend also advocates against using Javascript's OOP functionality, claiming that "you shouldn't be processing data, merely validating." Is Javascript really limited to validating data and making flashy graphics on a web page?

No, JavaScript is a programming language, if you want to represent data structures, algorithms and logic then use the tools the language offers. Specifically 1st class functions and prototypes are powerful tools.

He goes on to claim "you shouldn't be attempting to access databases through javascript" and also says " in general you don't want to be doing your heavy lifting in javascript". I can't say I agree with his opinion, but I'd like to get some more input on this.

Wrong, In the browser we have a database called indexedDB which we access with JavaScript. It's a database baked right into the browser and if you want to use it (and you should) then you use JavaScript.

Also note that both mongodb and couchdb allow you to use javascript to run adhoc queries on the database directly.

As for heavy lifting, he's partly correct. If your doing heavy lifting you should be doing it in C or erlang. Although note that the term "heavy lifting" is vague, for example I wouldn't encode or decode videos in JavaScript, I wouldn't do image processing in JavaScript (use C). I wouldn't no number crunching in JavaScript (use fortran).

Has Javascript evolved from the definition above to something more powerful, has the way we use it changed, or am I just plain wrong

JavaScript was written in a period of 2 weeks just to slap minor scripting functionality into HTML. Since then it has grown severely. Since ES3 (1999) it has been a powerful general purpose programming language.


答:
The vision of your friend is effectively very obsolete, and misses everything which happened since Google released GMail.

Now, does this mean that Javascript developed beyond what it was originally designed to do? Sort of. But don't forget that the design changed meanwhile, and will change in the future according to the new needs from the developers. This is also valid for other popular languages. For example, when the first version of C# was released, no one would expect to allow dynamic code in the design. Now DLR is available for a few years.

Title: Has Javascript developed beyond what it was originally designed to do?

Body:
I've been talking with a friend about the purpose of Javascript, when and how it should be used, etc. He quoted that:

JavaScript was designed to add interactivity to HTML pages

[...]

JavaScript gives HTML designers a programming tool

HTML authors are normally not programmers, but JavaScript is a scripting language with a very simple syntax! Almost anyone can put
  small "snippets" of code into their HTML pages JavaScript can react to
  events

A JavaScript can be set to execute when something happens, like when a page has finished loading or when a user clicks on an HTML element
  JavaScript can read and write HTML elements

A JavaScript can read and change the content of an HTML element JavaScript can be used to validate data

A JavaScript can be used to validate form data before it is submitted to a server. This saves the server from extra processing

JavaScript can be used to detect the visitor's browser - A JavaScript can be used to detect the visitor's browser, and -
  depending on the browser - load another page specifically designed for
  that browser.

JavaScript can be used to create cookies - A JavaScript can be used to store and retrieve information on the visitor's computer.

However, it seems like Javascript's getting used to do a lot more than these days. My friend also advocates against using Javascript's OOP functionality, claiming that "you shouldn't be processing data, merely validating." Is Javascript really limited to validating data and making flashy graphics on a web page?

He goes on to claim "you shouldn't be attempting to access databases through javascript" and also says " in general you don't want to be doing your heavy lifting in javascript". I can't say I agree with his opinion, but I'd like to get some more input on this.

So, my question: Has Javascript evolved from the definition above to something more powerful, has the way we use it changed, or am I just plain wrong? While I realize this is a subjective question, I can't find any more information on it, so a few links would be good, if nothing else. I'm not looking for a debate, just an answer.


答:
What "inherent risks" are you thinking of?  I can't think of any run-time error that can occur in Python or Ruby that can't occur in C# or Java.  Null pointer exceptions, missing method exceptions, and type conversion errors are all possible in C# and Java.  In Java, we add back all the missing dynamic behavior through Spring and other packages layered on reflection.  This enables all the run-time errors inherent in dynamically typed languages, except that to fix them you have to sift through seventeen layers of XML configuration files.

Connecting strongly typed languages to the untyped HTTP protocol, and the differently-typed SQL database in any reasonable way requires type conversions that cannot be validated at compile time.  I don't believe that dynamically typed languages require special care.  No matter the language, delivering reliable code will require extensive testing.

Title: Higher coding standards for dynamic languages?

Body: Due to the inherent risks associated with using dynamic languages (e.g. Python, Ruby) carelessly, what (if any) standards should be imposed on production code written in these languages?</p>


问:
How common is prototyping as the first stage of development?
I've been taking some software design courses in the past few semesters, and while I see the benefit in a lot of the formalism, I feel like it doesn't tell me anything about the program itself:

You can't tell how the program is going to operate from the Use Case spec, even though it discusses what the program can do.

You can't tell anything about the user experience from the requirements document, even though it can include quality requirements.

Sequence diagrams are a good description of how the software works as the call stack, but are very limited, and give a highly partial view of the overall system.

Class diagrams are great for describing how the system is built, but are utterly useless in helping you figure out what the software needs to be.

Where in all this formalism is the bottom line: how the program looks, operates, and what experience it gives? Doesn't it make more sense to design off of that? Isn't it better to figure out how the program should work via a prototype and strive to implement it for real?

I know that I'm probably suffering from being taught engineering by theoreticians, but I need to ask, do they do this in the industry? How do people figure out what the program actually is, not what it should conform to? Do people prototype a lot, or do they mostly use the formal tools like UML and I just didn't get the hang of using them yet?

答:
A prototype can also be considered "iteration 0" of what you need to do.  It fulfills several things:

It proves that the concept can be done. This may be to your boss or to a paying client.

It allows you to identify things that may be hard to get to production strength, and give you a general idea of the amount of work needed.

You actually have code that does something.  This is immensely important!

All in all the prototype should with high probability be useful for building the final product, unless you've found that a completely different approach is necessary.


答:
Language always goes way over what we thought at the begin. Talk to anyone at the beginning of C (or C++), does someone thought that language will be found almost everywhere now. I don't think so.

Each language win to be learn more /  push further.

I agree that Javascript was/still a under-appreciate language, your friend isn't the only one. The problem isn't think that the language X or Y is bad/useless,  the problem is to keep this idea forever. In Computer Science / IT, everything change quickly, and it will still change a lot in the future.

That's why it's important to keep learn / think outside the box...


问:
Algorithm for perfect non-binary graph layout
I have a complex non-binary graph model.

Each tree node can have multiple children&parents (a node can also have a connection to it's "brother").

A node is represented as square on screen with lines to the connected nodes.

For that I want to use Draw2D and GEF libraries.

The problem I am facing is the graph layout.

I need a nice algorithm that can reposition the square nodes and the connections with minimum intersections and also make it symmetric as possible.

答: Your parent-child relation probably creates a partial order.  Google "partial order graph layout" and top hits mention things like "Coffman–Graham algorithm" and "Hasse diagrams."  Maybe some research in those directions would be productive.</p>


问:
Is a company order to switch to a certain IDE a red flag?
I recently joined a rapidly growing startup. In the past 3 months the development team has grown from 4 to 12.  Until now they were very laissez-faire about what developers used to do their work. In fact one of the things I initially found attractive about the company is that most programmers used Linux, or whatever OS they felt best suited their efforts.

Now orders, without discussion, have come down that everyone is to switch to Eclipse. A fine editor. I prefer SublimeText2, but it's just my personal taste.

Just to be clear: we are a JS team using Backbone and Eclipse just isn't good at understanding Backbone code.  This means that those on the team who use a /good/ IDE (PHP Storm), have to go back to doing a lot of search-find-oh-wait-where-was-I-three-steps-ago kind of things instead of just ctrl+clicking and using back/ forward - probably diminishing productivity by say 15% and enjoyment by 50%...

Is this a red flag? It seems capricious and unreasonably controlling to tell developers (non-MS) what IDE or tool-sets to use if they are already settled in and productive.

答:
It's not a red flag in itself.

Sometimes management need to take decisions. Any issues that require standardisation on something tend to fall into that category. I once worked at a client who had allowed standards to drift for a few years and they had 20+ different SCM tools. What started as independent choice by different development teams turned into a logistical nightmare that severely hampered sharing of skills and collaboration on code across the organisation. Integrated build were..... er..... not very integrated.....

Furthermore, it's not practical or necessary to consult everyone for every decision. The extent to which this needs to be done depends on the culture of the organisation and the importance / complexity of the decision. Typically you'd take one of these less consultation-heavy options:

Make the decision yourself, if you have sufficient knowledge of the pros/cons and it's not an important enough decision to require wide consultation.

Consult with a few key individuals (who would probably be the senior developers most qualified to take the decision).

Raise the fact that you are making a decision to everyone who might be affected (email, town hall meeting, team meetings). Say what you think the right decision is but that you're willing to change this if new evidence emerges to the contrary. Invite people to come forward individually if they have some important views

Invite people to form a sub-team to review options and recommend a decision. Good option if it is genuinely a close call, you don't know the answer and you want those involved to be bought into the decision.

For something like developer tooling (which is a potentially contentious issue) I'd probably do 2 followed by either 3 or 4. i.e. there would definitely be some individuals I wouldn't talk to personally on the issue, but on the other hand most of the key people would get a chance to contribute to the decision making.

To me the real red flag would be around if you feel strongly that the wrong decision has been taken (wrong == it harms the company rather than just your favourite tool wan't chosen). How does management react when you raise this issue:

Good management will listen to your argument, thank you sincerely for the feedback and reconsider their position in the event that you have raised new insights. They may still not agree with you and may stick to their decision, but they will appreciate that you have raised it with them and do you the courtesy of saying why they are sticking with their decision. They might even change the way they make such decisions in the future, and if you made good points may include you on their list of "smart people to ask".

Bad management will get defensive, say that "the decision is made" and other such tactics to avoid facing the fact that they may have made a wrong decision. They may see you as a "troublemaker". The company suffers, as does your faith in management. This is a real red flag! Get out while you can!


答:
Coding standards should be a simple as possible and hopefully restricted to avoiding language features and idioms which are known to be problematic or broken.

Too many rules in program standards can lead programmers to code sub-optimal and unreadable code because the best solution has been declared "bad" in the standards doc.

What dynamic languages really require are higher testing standards. As there are more run time errors possible, and, the forgiving nature of the languages means simple coding errors can cause weird behavior in seemingly unrelated components. You really need a good set of unit tests for every single component, plus a comprehensive set of integration tests which should be run every-time any piece of code has changed.


答:
Your question contains two contradictory elements:

that someone would use the language carelessly, and

that they would follow standards for the production code.

Any programmer that is part of a team that has standards for production code should not use a language, dynamic or not, carelessly.  There is a lot of experience with writing code in dynamic language, starting with Lisp many, many years before Java was even thought of.

While non-dynamic languages can catch some errors at compile time, they would not catch mistakes like erroneous conversion from SI to English units, etc.   As far as I know (and I would love to be proven wrong...) there does not exist any study that has shown that using dynamic languages to write programs leads to more errors.

Many programmers writing on this, and other forums, express strong opinions one way or another but I suspect (no proof, sorry...) that there is a lot more variation in programmer's skills and proficiency in using good tests than there is coming from the use of language X over language Y.   (with the possible exception of Ada...)


答:
The red flag is not so much that a single IDE/editor is being forced upon every developer, but that this decision, and especially the decision on which IDE/editor was to be used was not made by all the developers, and perhaps none of them!?!

Certainly it would be best for the developers to reach a consensus, especially because they are obviously best qualified for the decision (at least on which editor/IDE). There may be good reason to conform and that decision should weigh-in the preference of management, but which editor/IDE should have been the decision of all the developers.

Getting 12 developers to cast some votes would be easy. Certainly there was time enough to do that! The conclusion would have been painful for some anyways and it might have even ended up being Eclipse in the end, but labeling the requirement as a "red flag" in that case would be much more debatable.


问:
Should devs, testers and business users have one unified test script?
In development, I would normally have my own test scripts that would document the data, scenarios and execution steps that I plan to test; this is my dev test plan. When the functionality has been deployed to Test, testers test it using their own test script that they wrote. In UAT, the business user then tests using their own test plan.

In retrospect, it looks like this provides a better coverage, with dev tests having a mix of black and white box testing, while testers and business users focus on black box testing. But on the other hand, this brings up distinct test cases that only are executed per stage (ie. some cases which testers thought of are only executed on Test stage) and it would like the dev missed it, which makes it a finding/bug.

Is it worth consolidating the test scripts from the start? Thus using one unified test script, or is it abit difficult to do this upfront?

答:
Firstly QA is not Test. If your QA department are not involved in the entire development process, they are Test, not QA. QA when doing it's job, provides quality assurance, at best Test shows the lack of quality, but cannot prove quality exists -  i.e. Test shows QA has failed, but cannot show they have succeeded, so Test and QA should not be the same department.

I believe the best way is to have each group manage their own tests, as it does provide better coverage. However, each team should start testing as soon as possible. This means that UAT starts as soon as there is something that Users might be able to use, Test starts as soon as a part that they have a test for is ready etc. This prevents the late find of distinct test cases. This may mean some rejigging of your work models, as often UAT and Test expect to be working on complete product and need trainning in testing partially complete outputs. It can be more expensive unless workflow is disiplined and a developers "Complete" means Complete.

QA should oversee this, along with other quality measures, to ensure the process not only delivers the desired quality output, but also at an approriate efficency level.

Edit: Original question reference to QA has been removed, hence this answer now appears OT.


答:
We use UATs from the start.

It acts as a universal reference and I think it works well. While there might be test scripts that are used only by the Devs or Testers for smaller components, the direction of the testing is always pointed towards one unified target. At the end of the day, the UAT is the only one that counts so you might as well make it the focus at the start.

Doing UATs from the start also has an added benefit. It really clears up any ambiguity between the customer expectations and your own.

Title: Should devs, testers and business users have one unified test script?

Body:
In development, I would normally have my own test scripts that would document the data, scenarios and execution steps that I plan to test; this is my dev test plan. When the functionality has been deployed to Test, testers test it using their own test script that they wrote. In UAT, the business user then tests using their own test plan.

In retrospect, it looks like this provides a better coverage, with dev tests having a mix of black and white box testing, while testers and business users focus on black box testing. But on the other hand, this brings up distinct test cases that only are executed per stage (ie. some cases which testers thought of are only executed on Test stage) and it would like the dev missed it, which makes it a finding/bug.

Is it worth consolidating the test scripts from the start? Thus using one unified test script, or is it abit difficult to do this upfront?


问:
Where Can I List My Opensource Project?

Possible Duplicate:

  How can I get the word out about a new (open-source) library I've developed?

I have hosted my latest project, a JVM-based MIDI processor/API called Mjdj MIDI Morph, on Github (here and here). Now I need to bring some interest to it, even if it's negative interest (so I can improve it). I've looked up open source list on Google and end up with such things as this page on Wikipedia, which makes it quite clear that they don't want your project if it's new. Where should I list my project? Short of adwords and talking it up in forums and trade shows, where should I submit my URLs?

答:
Post it on Hacker News - you'll get a lot of feedback.

Hacker News is a social news website about computer hacking and startup companies, run by Paul Graham's investment fund and startup incubator, Y Combinator. It is different from other social news websites in that there is no option to down vote submissions; submissions can either be voted up or not voted on at all, although spam submissions can be flagged. In contrast, comments can be down voted after a user accumulates sufficient "karma" or points gained when submissions or comments are voted up. In general, content that can be submitted is defined as "anything that gratifies one's intellectual curiosity"...

ContentLicense: CC BY-SA 2.5

Title: Where Can I List My Opensource Project?


问:
Variable naming conventions?
I've just started using ReSharper (for C#) and I kind of like its code smells finder, it shows me some things about my writing that I meant to fix a long time ago (mainly variable naming conventions).

It caused me to reconsider some of my naming conventions for methods and instance variables. ReSharper suggests that instance variable be lower camel case and begin with an underscore. For a while I meant to make all my local variables lower camel case but is the underscore necessary? Do you find it comfortable? I don't like this convention but I also haven't tried it yet, what is you opinion of it?

The second thing it prompted me to re-evaluate is my naming conventions for GUI event handlers. I usually use the VS standard of ControlName_Action and my controls usually use hungarian notation (as a suffix, to help clarify in code what is visible to the user and what isn't when dealing with similarly named variable) so I end up with OK_btn_Click(), what is your opinion of that? Should I succumb to the ReSharper convention or there are other equally valid options?

答:
I agree generally with whats being said by other, however when it comes to tools and tools chains, I am lazy and like an easy life. I find life is often easier to just do it they way They suggest.
The reasons are

It's easier to install (just go with defaults, even I can hit Enter 20 times and get it going)

The bugs have usually be worked out of the default settings, often its the esoteric configuration I set up that exposes a defect for the first time

The tool chain vendor probably knows more about it than me, therefore they made it that way for a reason. Who am I to decide the experts are wrong (I consider them experts, because I bought their tool)

You will never have to defend the vendors choice by a Manager - "It's what They recommend"

The new guy won't bug you with "why" and "It's better that way" - When every answer is "because They decided..."

So my take would be if you can find a valid reason to reconfigure the tools you just spent a fortune on, by all means do it. If you cannot justify making the change, don't.

Keep in mind that each and every change has an ongoing cost (real and hidden) to maintain. The less there are, the lower the cost. For instance - that new guy I mentioned - no changes means he can read their manual. Reconfigure - you have to write the addendum, store it away with otehr stuff, retireve it and get him to read it after reading their manual.  Maybe not a problem for a 2 man shop, but what about a 100 man shop?

Title: Variable naming conventions?


问:
Advantages of using business logic in model
In an MVC framework i have often heard that use business logic in a model. But i think using the business logic in controller would run faster as view is directly connected to controller. I want to know what are the advantages of using a business logic in model?</p>

答:
Testability.

Decoupling user interface from the model makes it easier to write tests against just the model. You just test against the core functionality, without having to worry about User Interface getting in the way (which you may test as well, and there are ways to do that, but this is not what you are asking :).


答:
First, it is almost every time a mistake to argue about the place of the business logic in terms of program speed (at least, when your model and controller layers are part of the same program with no network communication between them). If you have speed issues, you can optimize them in your model layer as well as in your controller layer.

Much more important than speed is typically the goal to give your program a good structure, where you know about the responsibility of each component, where you can test things in isolation, where you avoid code repetition when the same part of business logic is needed twice, and so on.

Thus, the question for the best place should be guided by the question "what kind of business logic?"

business logic controlling the user interactions of your views belong typically into a controller

small parts of business logic dealing with primarily one business object typically belong to that object and so are best placed in the model. Example: having an object "Person" with attributes "FirstName" and "LastName", and you need to get the "full name" as concatenation of FirstName and LastName, then a property "FullName" of "Person" may be a good idea.

for bigger parts of your logic, independent from your views, you should introduce separate controller classes.

Where exactly to draw the line is up to you. There is a long-lasting and open-ended discussion in the community about how much logic should be in the model and how much in controllers, see, for example, here: http://www.martinfowler.com/bliki/AnemicDomainModel.html

Title: Advantages of using business logic in model

Body: In an MVC framework i have often heard that use business logic in a model. But i think using the business logic in controller would run faster as view is directly connected to controller. I want to know what are the advantages of using a business logic in model?</p>


问:
Which one is a better practice a static factory method of the same class or a separate factory class with methods?
I have seen this at many places. a Parent class has a static method to create objects of the right subclass and at times we have a dedicated factory class with instance methods to create object of various subclasses.

Which one is used in which scenario ?

Like static factory methods of InetAddress  in java.net to create subclasses of InetAddress Vs BorderFactory class to create various Borders.

答: The second one; the separate class.  That separate class should also have an interface. The reason is that this is the option that allows swapping the factory most easily, which is good for lowering coupling and for testability.</p>


问:
How important is the ability to touch-type?
Did you learn to touch-type when you were already working as a programmer?  If so how did it affect your productivity?  Or are you still unable to touch type and do you think it holds you back?

According to Steve Yegge it is essential,

Personally I did not notice much difference, possibly because I was spending less than 25% of my work time actually typing (I was working on a large legacy project at the time and I was spending more time on reading and debugging existing code.)

答:
I think it completely depends on what kind of programming that you do. Most of my work is bug-fixes and so it's usually just changing a few chars at a time, and many times it requires no typing whatsoever: copy-paste a line from point A to point B. Not saying I'm a copy/paste coder, but sometimes the right code is already there, it's just in reverse order.

When I code something new, much of the code is generated from my modeling application -- including comments.

Also, the coders that I've witnessed who can type fast aren't necessarily good at typing. Sure, they can hit 20 wpm more than me, but they also have about 2x's as many bugs introduced by typos. Perhaps it's less of an issue in compiled langs, or maybe more of an issue since you have to compile more often than someone who gets it right the first time?


问:
Where can you find your first customers as a freelancer?
I want to start doing freelance work, but no matter how I look at it, it seems like the best way to get customers and to have work most of the time, you have to already be in the freelancing game.

Most freelancers I've talked to have had the same customers over the years or got new customers because their satisfied clients referred them. What I'd like to know from the successful people here that work as freelancers is how do you start doing business when you haven't yet set foot in freelancing?

I want to start small, creating websites that won't require me to hire other people other than maybe a designer I already know. (I'd like to create desktop applications as well, but I think I should keep that for later when I'm more experienced) .

I thought about localized Google ads or visiting companies and meeting the people in charge there, but I wouldn't know which kind of businesses to look for or if it's even a good way to approach this.

Anyone care to share their personal startup experiences / advice that can help future freelancers?

答:
Here is what has worked for me:

Give a talk at a user's group. I try to do about 1 a quarter to keep my name out there. Its a great way to get some free marketing and meet people.

Tweet and write about programming. Try to be a guest on a podcast, write a blog.

Use linked in. I have had a bunch of clients find me via linked in

Work with other freelancers where it makes sense. I do a lot of Javascript and HTML5, and partner with a guy who does Ruby and Python, so we can bid on jobs that use both our skills.

If there is something like The Hub near where you live hang out there and get to know people.

I also wrote out a marketing plan for my business, which I found helps a lot. And no its not 40 pages with graphs its about 1-2 pages of text.

Assume that as part of a freelance operation you will be spending some amount of time each week on marketing and sales.


问:
Odd company release cycle: Go Distributed Source Control?
Sorry about this long post, but I think it is worth it.

I have just started with a small .NET shop that operates quite a bit differently to other places that I have worked. Unlike any of my previous positions, the software written here is targeted at multiple customers and not every customer gets the latest release of the software at the same time. As such, there is no "current production version." When a customer does get an update, they also get all of the features added to the software since their last update, which could be a long time ago. The software is highly configurable and features can be turned on and off: so called "feature toggles." Release cycles are very tight here, in fact they are not on a schedule: when a feature is complete the software is deployed to the relevant customer.

The team only last year moved from Visual Source Safe to Team Foundation Server. The problem is they still use TFS as if it were VSS and enforce Checkout locks on a single code branch. Whenever a bug fix gets put out into the field (even for a single customer) they simply build whatever is in TFS, test the bug was fixed and deploy to the customer! (Myself coming from a pharma and medical devices software background this is unbelievable!). The result is that half baked dev code gets put into production without being even tested. Bugs are always slipping into release builds, but often a customer who just got a build will not see these bugs if they don't use the feature the bug is in. The director knows this is a problem as the company is starting to grow all of a sudden with some big clients coming on board and more smaller ones.

I have been asked to look at source control options in order to eliminate deploying of buggy or unfinished code but to not sacrifice the somewhat asynchronous nature of the teams releases.  I have used VSS, TFS, SVN and Bazaar in my career, but TFS is where most of my experience has been.

Previously most teams I have worked with use a two or three branch solution of Dev-Test-Prod, where for a month developers work directly in Dev and then changes are merged to Test then Prod, or promoted "when its done" rather than on a fixed cycle. Automated builds were used, using either Cruise Control or Team Build. In my previous job Bazaar was used sitting on top of SVN: devs worked in their own small feature branches then pushed their changes to SVN (which was tied into TeamCity). This was nice in that it was easy to isolate changes and share them with other peoples branches.

With both of these models there was a central dev and prod (and sometimes test) branch through which code was pushed (and labels were used to mark builds in prod from which releases were made...and these were made into branches for bug fixes to releases and merged back to dev). This doesn't really suit the way of working here, however: there is no order to when various features will be released, they get pushed when they are complete.

With this requirement the "continuous integration" approach as I see it breaks down. To get a new feature out with continuous integration it has to be pushed via dev-test-prod and that will capture any unfinished work in dev.

I am thinking that to overcome this we should go down a heavily feature branched model with NO dev-test-prod branches, rather the source should exist as a series of feature branches which when development work is complete are locked, tested, fixed, locked, tested and then released. Other feature branches can grab changes from other branches when they need/want, so eventually all changes get absorbed into everyone elses. This fits very much down a pure Bazaar model from what I experienced at my last job.

As flexible as this sounds it just seems odd to not have a dev trunk or prod branch somewhere, and I am worried about branches forking never to re-integrate, or small late changes made that never get pulled across to other branches and developers complaining about merge disasters...

What are peoples thoughts on this?

A second final question: I am somewhat confused about the exact definition of distributed source control: some people seem to suggest it is about just not having a central repository like TFS or SVN, some say it is about being disconnected (SVN is 90% disconnected and TFS has a perfectly functional offline mode) and others say it is about Feature Branching and ease of merging between branches with no parent-child relationship (TFS also has baseless merging!). Perhaps this is a second question!

答:
Second question is easier and shorter, so I'll try to start from it

DVCS is system, where no one "authoritative" source of code (except "on agreement", when used) and P2P-exchange of data is possible without additional tiers
(personal, non-canonical definition)

On the topic the first question

I'm afraid, company have to reconstruct workflow and rethink about style in order to get "somehow managed and predictable code". I can't say about TFS (except personal opinion and feeling, that it is weak system in Version Control part /baseless merge is evil/), but for any VCS in your situation ("Product" is set of independent "Modules", each "Customer" get different "Products" - is this assumption correct?) I'll prefer split development of modules into separate branches, have Product as "Supermodule" (also branch?), there each module tied to specific revision of module-branch, module-development uses branch-per-task paradigm (and module-branch consist only from mergesets).

This way you can always know, which "Collection" (i.e set of modules and their corresponding revisions) forms each "Product", have possibility to do CI (for finished and merged task-branches), Unit-testing and Builds


答:
Many freelancers I know, including my humble self, started as an employee and when they turned into a freelancer, the former employer was the first customer.

If your employer is an IT company, your employer's customers are potential customers for yourself (though your contract most likely prohibits that, I've seen that happening a lot of times).

Reading the newspaper ads for job openings sometimes lets you find a company willing to accept freelancers.

Title: Where can you find your first customers as a freelancer?

Body:
I want to start doing freelance work, but no matter how I look at it, it seems like the best way to get customers and to have work most of the time, you have to already be in the freelancing game.

Most freelancers I've talked to have had the same customers over the years or got new customers because their satisfied clients referred them. What I'd like to know from the successful people here that work as freelancers is how do you start doing business when you haven't yet set foot in freelancing?

I want to start small, creating websites that won't require me to hire other people other than maybe a designer I already know. (I'd like to create desktop applications as well, but I think I should keep that for later when I'm more experienced) .

I thought about localized Google ads or visiting companies and meeting the people in charge there, but I wouldn't know which kind of businesses to look for or if it's even a good way to approach this.

Anyone care to share their personal startup experiences / advice that can help future freelancers?


答: Having hired freelancers, it's all about references.  If I choose to take the risk of not going with a known firm, it is because someone vouched that the freelancer is both cheaper and much better.  The first is obvious because of less overhead.  I need someone to tell me the second, because it's more about getting stuff done than IQ.</p>