答:
The increase in number of projects has to do with enabling unit testing and simplifying the dependency graph to the point where things aren't so complex that changes in one part of the app break things in seemingly unrelated parts of the app.

It works out when I am doing some sort of dependency inversion, to put all the "contracts", interfaces, abstract classes, data transfer objects into one assembly.  In another assembly I put anything that talks to the database. Unit tests get their own assembly. If the UI is fundamentally untestable (e.g. ASP.NET winforms), then there is significant benefit to splitting the UI into testable code and untestable code-- an assembly each. Sometimes some code starts to show up that has nothing to do with the database, the UI or anything I've mentioned so far-- it's code I sort of wished was in the .NET framework. That code I will put into a utilities assembly, or at least put it in whatever the root assembly is (probably the one with the interfaces.

If all assemblies reference all assemblies, or nearly so, then they should be merged back into a single assembly.  If you or people on your team lack the discipline to keep from putting data tier code in the UI and UI in the data tier, then simplify things by merging it all back into a single layer.

Some editions of Visual Studio runs into performance problems at about 15 assemblies, sometimes it depends on what kind of project are there.  Strategically unloading project files can sometimes help though.


问:
Recommended ways for getting a good grasp of inherited software
So you've inherited a large codebase that you need to make substantial changes to and you wish to get a pretty complete understanding of the software before starting.

Would you diagram it?

If so, which tool do find most suited for a large codebase?

Ideally I'd want expandable nodes representing major concepts in the flow that could be drilled down into for a sub-concepts, and sub-sub-concepts.

Preferably UML based, but not essential.

Are there decent automatic source diagramming tools, in particular, PHP->UML?

答:
Diagramming can help because you need to actively engage in the code. Actually everything which requires you to read the code and synthesize something out of it helps. It can be some UML diagram or it can be just a sketch with some bubbles and arrows.

Another way to get grasp of inherited software is to poke at it. You can add logging messages or fool around with a debugger.

There is one technique I like most, because it combines both approaches where can synthesize something new and poke at it: Trying to fit the code into some test harness. If the code base comes along with some unit tests, then you are lucky. You can read the tests to understand the productive code and add some more tests to actively interact with the code basis without harm. If there are no tests, then you need to start somewhere. You need to poke at the code and synthesize something which is much more valuable than diagrams: Tests which are in sync with the actual code and gives you a safety net for the future changes.

Knowledge about unit testing, refactoring techniques and software design is quite handy for wrapping tests around the existing code basis. There a lot of books for each isolated topic, but there are very few which deal with all three topics in the context of an existing code base. I found following two books very helpful:

Working Effectively with Legacy Code by Feather

Brownfield Application Development in .Net by Belcham & Baley

OwnerDisplayName: stebbo

ContentLicense: CC BY-SA 3.0


问:
How to fit beta versions into a numeric versioning scheme?
Some tools force developers to adopt a version scheme of a certain form, form instance "major.minor.build.revision", where each field must be a number.

How do I fit in betas in there? For instance, what version should I choose for version "2.0 beta2"? Should it be of the form "1.99.x.y" (it's not yet 2.0 stable) or "2.0.x.y" (2.0 beta introduces breaking changes with 1.x).

答:
in the example of "major.minor.build.revision" we abandoned the revision number and use the latest to indicate a beta (where beta would mean "not fully tested"):

```<code>1.2.1.0 -> normal release
1.2.1.1 -> beta release
</code>```

Now I hear you say "what?? no revision number? how do you track bugs then", as I know people/companies sometimes tend to match the "revision" number with their VCS especially when using svn. At least two options: get rid of the build number instead and keep the revision (do you really need more than major.minor for the actual version?), or what we do is tag the repository with the version number for each release which is the other way around but has the same effect + we feel clients shouldn't need to know what the amount of commits in a VCS is.

Body:
in the example of "major.minor.build.revision" we abandoned the revision number and use the latest to indicate a beta (where beta would mean "not fully tested"):

1.2.1.0 -> normal release
1.2.1.1 -> beta release

Now I hear you say "what?? no revision number? how do you track bugs then", as I know people/companies sometimes tend to match the "revision" number with their VCS especially when using svn. At least two options: get rid of the build number instead and keep the revision (do you really need more than major.minor for the actual version?), or what we do is tag the repository with the version number for each release which is the other way around but has the same effect + we feel clients shouldn't need to know what the amount of commits in a VCS is.


问:
Are these signs of a bad developer?
I used to blame changing specifications from clients for code rot, not realising that business models do change and it's my job to develop in an adaptable way. I now see that as a sign of a bad developer (I've changed!).

But now I see other 'whinges' in myself. A few times recently I've found myself saying 'it's like trying to fit a square peg in a round hole', and also I find myself blaming client indecision for a project not progressing.

Are there signs I should look out for where I should change my attitude? Is the client always right, or am I sometimes justified in getting frustrated?

答:
In Emerson's quote, "A foolish consistency is the hobgoblin of little minds..." the most often overlooked word is foolish. Consistency is non-negotiable in certain settings, but it all to often substitutes for critical thinking and analysis.

On the one hand, many development models are designed specifically to help in the environment you're describing; so if you find yourself having to violate your model, then either you're not implementing it right in the first place, or you've got the wrong model.

But on the other hand, if you have a well-reasoned and supportable justification for violating your rules, and you can show that your rogue method produces cleaner more maintainable code, then you shouldn't be afraid to take the sensible route.

Title: Are these signs of a bad developer?


问:
Practical way to store a "reasonably large" amount of data that hardly ever changes?
Think in terms of pre-computed lookup tables or something.  At what point does it make more sense to use a database instead of hardcoding values in my application?  The values are not going to change, and they're nicely segregated away from maintenance developers.  100 values, 1k, 10k, 100k?  I'm wanting to store about 40k values.  Right now it's a machine-generated switch statement (which VS2010 is unhappy about).

edit:

If anyone is curious, here's how I approached this:  My data was storable in two 100k-element float arrays, so that's what I did.  It took about 20 seconds to generate the data, so I did that once, and serialized it to an embedded resource with a BinaryFormatter.  Unpacking the data takes about 5 milliseconds at application startup, and outperforms the database implementation I was replacing (these hard-coded values were stored there prior) by almost 45,000x.

答: I've had a requirement like this twice. The applications were designed to be standalone with no database setup/access required. In both cases I used XML files to store the data. In the first one, which was on the 2.0 Framework, I used the old style XML parsing calls to look up data. For the newer one, on the 3.5 Framework, I used LINQ to XML to find what I needed. In both cases, access to the data was encapsulated in classes.</p>


答:
If you are stuck with purely numeric revisions you could make odd minor revisions release betas for the corresponding major which has a even minor number, e.g.

Beta
  : 1.3.11.df41a

Release
  : 1.4.1.df41a

The beta for 2.0 could then be any of 1.9, 1.11, ...

Title: How to fit beta versions into a numeric versioning scheme?

Body:
Some tools force developers to adopt a version scheme of a certain form, form instance "major.minor.build.revision", where each field must be a number.

How do I fit in betas in there? For instance, what version should I choose for version "2.0 beta2"? Should it be of the form "1.99.x.y" (it's not yet 2.0 stable) or "2.0.x.y" (2.0 beta introduces breaking changes with 1.x).


答:
You could modify the practice of Major.Minor.Build.Revision to something more like Major.Minor.Release.Revision. See examples:

1.0.0.0 - First Release

1.0.0.123 - Beta build approaching second release

1.0.1.0 - Next release

1.0.1.234 - Beta build approaching third release

1.1.0.0 - Third release

etc..


答:
I think the key word here is 'hardly'

If the data never changes - for example, pre-calculated mathamatical values, color constants, and the like - then sure, as long as the size is managable for you, keep it in the code.  Just be aware that if performance is an issue, case/switch statements will be very slow compared to other options.

If the data hardly ever changes - for example, phone area codes, national boundaries, and the like - I'd probably look into keeping the data externally in some manner.  Particularly if it started getting to be more than a couple dozen values.

Title: Practical way to store a "reasonably large" amount of data that hardly ever changes?

Body:
Think in terms of pre-computed lookup tables or something.  At what point does it make more sense to use a database instead of hardcoding values in my application?  The values are not going to change, and they're nicely segregated away from maintenance developers.  100 values, 1k, 10k, 100k?  I'm wanting to store about 40k values.  Right now it's a machine-generated switch statement (which VS2010 is unhappy about).

edit:

If anyone is curious, here's how I approached this:  My data was storable in two 100k-element float arrays, so that's what I did.  It took about 20 seconds to generate the data, so I did that once, and serialized it to an embedded resource with a BinaryFormatter.  Unpacking the data takes about 5 milliseconds at application startup, and outperforms the database implementation I was replacing (these hard-coded values were stored there prior) by almost 45,000x.


问:
Effective methods for managing work tasks? (documenting/remembering/prioritizing)
I'm looking for suggestions on effective methods that I can use to document, remember and prioritize tasks at work.  Many of the these tasks belong to a primary project, but they also exist for independent initiatives.  The tasks themselves cover everything from development to documentation to discussions, with varying priorities, and deadlines ranging from right away to a few months from now.

Historically I have used a notepad to keep track of these tasks, with a star next to an item indicating it needs to be done and a check mark when it's completed.  However, as I gain more responsibilities and more things to manage:

it becomes harder to make sure I've done everything (because some things get lost 5 pages back)

it becomes harder to remember what's most important to do next

it becomes harder to keep track of dependencies between tasks

Has anyone found methods that have made their tasks easier to manage?  I've considered adding some meta-data to keep track of what's most important and dependencies, or possibly switching to an app that could automate this (if such a thing exists).  Something that's accessible anywhere would definitely be a plus.

答:
I have a JIRA instance set up on my own VPN(basic linode.com account), Atlassian sells it for 10$ for start-ups(or you can use whatever bugtracker you like).
This is not a mindmapping tool, so I use tags to keep dependencies between tasks .
Also it allows to create custom task types beyond basic ones(bug/feature).
It allows to set priorities, due dates and add some metadata(like photos of documents to correct).

So I wonder why not to use a bugtracker?

ContentLicense: CC BY-SA 2.5


问:
Static functions question
Something came to my mind today. I have been doing a lot of the following

```<code>new Object().doSomething();
</code>```

I create an object and call on of its functions, then forget about the object. I don't need it past this one instance. Does this signal a bad coding style. Is it best to convert these methods to a static function so a new object does not need to be created every time?

答:
This depends offcourse in what exactly you are doing in that function and If you can call it as static or not. (static variables inside, etc...)

But from the way you seem to use it, the answer is yes. Either declare a static class or use the Singleton Pattern. But don't keep doing what you are doing. You are just having the overhead off instantiating a new object every time.

If for whatever reason you must use a new instance of an object, make sure you dispose of it when you are done.

Title: Static functions question


问:
What do you consider to be the prime cause of software defects (and how to minimize them)
I define defect as :

"something within the application design or code which prevents it functioning as per requirements."

I'm looking for ideas about the causes of defects, eg the human factor, lack of testing, lack of prototyping, and possible ideas to mitigate these.

答: Being incomplet</p>

Body: Being incomplet


问:
Who should be responsible for writing/updating design specifications in an agile team
I work as part of a scrum-like Agile team and a while ago, one thing we identified that the team should do is maintain good set of design documents for our code base.  Because we are agile and do have good amount of discussion and communications, our designs are kept at a high level and are generally used for describing general layout of modules, including main classes and some of their interactions and. We also found them useful for discussion starting points since and also for reminding people that design needs to be considered before you jump into code.

So far, it was expected that everyone will update design specs on as needed basis.  Design leads for each team are responsible for giving people advice on design in general, on what to update in the SDSs and also for reviewing the specs to make sure everything stays consistent.

The issue I'm seeing is that while everyone, especially new members find design specs very helpful when learning new components or even going back to components they haven't touched for a while, most people only update the docs for the sake of updating them (i.e. they are told they must do it and so they do it).  So that we end up with one-liner descriptions which sometimes aren't even full sentences and when I tell them this needs to be updated and filled in, they add more but again, only because they are told.  So now one-liners become 1.5 lines and there's still nothing helpful written down.

Obviously different team member skills/strengths will be different. So the question is, should certain team members on an agile team simply not be responsible for design and be reduced to just a coder? Or should it be design leads role to go back to those team members and make them rewrite the specs as many times as necessary (and this is really becoming painful) until they pick up enough skills to produce what's expected?

My basic guideline that I suggest to everyone: if you were sitting in a meeting or making a presentation about class diagram X, what would you say if your audience needed to know how your code works. Instead, half the time they simply restate what I can already see in the class diagram.  "Class X implements interface Y". That would be entire class description.

Amendment:
I work for a large corporation with a very healthy appetite for outsourcing/contracting. The team I'm on has permanent members, it also has permanent members who are very new to the team (from recent merger).  And we have contractors from India and Poland who will most likely be reassigned to other project after the current release.  So different members have different buy-in at this point. Documentation is definitely important to those of us that have been on the project in the last release and will be on the project in the next release.

答:
Since you mention Agile, it would be natural if you experiment with different approaches and find out which works best for your team.

Given information provided so far you appear to be in a very good position for that:

It [design specs] is a deliverable, it is tracked in iteration and
  people are given tasks to both write specs and review specs.
  Acceptance criteria is team's consensus (with design lead having more
  weight) that the spec meets what's expected when the review is held...

We have a review meeting...

Above sounds as almost perfect tooling for collecting data and performing comparative analysis for various approaches. I would rather prefer to have QA verification as an acceptance criteria over team's consensus but even as is it feels good enough.

A word of caution: before starting experimenting, one would better clarify with management their understanding of Agile - because, you know, sometimes they happen to have their own, quite a special way of looking at it.


答:
In addition to what @AGC said, if the doSomething() belongs to say, a customer class, then you don't want to make that static. In other words, business classes are seldom made into static classes since their data is supposed to change in the scope of a single transaction and you don't want to keep them around all the time.
Static type classes are good for long lived data and utility/helper methods. If you are using automatic testing tools, then statics may cause problems: ref1</p>

Title: Static functions question

Body:
Something came to my mind today. I have been doing a lot of the following

```<code>new Object().doSomething();
</code>```

I create an object and call on of its functions, then forget about the object. I don't need it past this one instance. Does this signal a bad coding style. Is it best to convert these methods to a static function so a new object does not need to be created every time?


问:
What assumptions / disclaimers should be included with a software estimate?
I'm writing a lot of estimates lately and I'm finding that quite often, a client might argue scope, deliverables or (most often) cost.

In an effort to ensure that the breadth of coverage (of client requirements and mutually understood scope) for the estimate is clear (and given most clients will view an estimate as a fixed quote from Moses himself), what common assumptions do you include with your estimates such that expectations are clearly set with clients and disagreements around what is being delivered or charged are minimised?

答:
Agree on clear, specific requirements with the customer.

Agree on what constitutes meeting each requirement, in a way that is clear, measurable and unambiguous (i.e. it passes an acceptance test).

As part of your internal estimation process, break down all of the required work into smaller sub-tasks.  Keep doing that until you have tasks that are small enough to accurately estimate.  Add up all of the smaller estimates for a total time and money estimate.  Make sure that you include the time it will take to write unit tests, acceptance tests and refactoring.

Add at least 20% padding to your resulting time estimate calculation.

Make it clear in the estimate that work beyond the scope of #2 above is not part of the estimate, and will cost extra.


答:
Creating an object only to call some method on it and then discard after the call is generally a bad idea. So, one possible solution is to convert that instance method to a static method. You can also leave it as an instance method but use only one instance of that class throughout the code. The latter can be enforced using the Singleton Pattern, as @AJC suggests.

But your question hides a deeper problem. Suppose that method doSomething() is being used in the context of business logic. In that case, whether you create the object in that context, or call a static method, or get a reference to the object via a Singleton, you are making your code very hard to test. In those three scenarios, the method call can't be mocked out from a unit test because the test cannot control how the object is instantiated. So, you are stuck with that "version" of the method, which, in turn, may call other static methods or Singletons, which may instantiate their own dependencies and so on and so forth. Therefore, even if you try to write a unit test for that method, you will end up testing a whole bunch of classes of your application at once. Besides, you are mixing business logic with object creation, violating the Single Responsibility Principle and making your code harder to maintain.

Your code should very rarely "go get" the dependencies it needs. Instead, it should only declare what it needs and let the responsibility of creating those dependencies to another class (typically called factories). This design technique is often referred to as dependency injection.

Title: Static functions question


答:
Well, most clients will view an estimate with a host of disclaimers as an estimate from Moses himself plus a bunch of irrelevant noise, but I can give you some suggestions (and I'm sure there are lots of legal ones I don't know about):

You are assuming the client will give you what you need, depending on the project.  If they can't answer your questions promptly, give you needed network access, test system, test data - whatever, then at minimum the schedule slip is their fault.

Well, obviously you have some agreed on work that you are doing for that estimate.  You are assuming that work doesn't get changed or added to.

You are assuming that the product will not be bug free.  If it passes the agreed upon acceptance tests then you are done.

If there are pictures or mock-ups, you are assuming they don't require the product to look exactly like those pictures or mock-ups.

When you estimated there were probably lots of assumptions specific to the project that should be spelled out.  Like the user interface elements will be drawn from the .NET standard library and will not have to be customized or used outside of industry standard uses for the project.

Title: What assumptions / disclaimers should be included with a software estimate?

Body:
I'm writing a lot of estimates lately and I'm finding that quite often, a client might argue scope, deliverables or (most often) cost.

In an effort to ensure that the breadth of coverage (of client requirements and mutually understood scope) for the estimate is clear (and given most clients will view an estimate as a fixed quote from Moses himself), what common assumptions do you include with your estimates such that expectations are clearly set with clients and disagreements around what is being delivered or charged are minimised?


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

How much time do you spend on memory management tasks?

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

答: Depends on the senior technical leads in the team. In some companies ( including mine ), there is no concept called smart poiner. It is considered fancy. So, people simply put deletes all over the place and there is a drive for memory leak fixing for every 2 months. New wave of delete statements arrive everywhere. So, depends on the company and the kind of people who work there.</p>


答:
How about an estimate is an approximation and cannot be entirely accurate?

Or how about error range +%150/-%10? :p


问:
Do real-world algorithms that greatly outperform in the class below exist?
Last night I was discussing with another programmer that even though something may be O(1), an operation which is O(n) may outperform it if there are is a large constant in the O(1) algorithm. He disagreed, so I've brought it here.

Are there examples of algorithms which greatly outperform those in the class below it? For example, O(n) being faster than O(1) or O(n2) being faster than O(n).

Mathematically this can be demonstrated for a function with an asymptotic upper bounds, when you disregard constant factors, but do such algorithms exist in the wild? And where would I find examples of them? What types of situations are they used for?

答:
The Big-Oh notation is used to describe a function's growth-rate, so it is possible that an O(1) algorithm will be faster, but only up to a certain point (the constant factor).

Common notations:

O(1) - The number of iterations (sometimes you can refer to this as user-time spent by the function) is not dependent on the size of the input, and is in fact constant.

O(n) - The number of iterations grows in a linear proportion to the size of the input. Meaning - if the algorithm iterates through any input N, 2 * N times, it is still considered O(n).

O(n^2) (quadratic) - The number of iterations is the input size squared.


问:
What is the difference between skill level amongst programmers?
I am a beginning programmer and in 5-10 years I'd like to be an expert. I love programming because it is a distinct skill set that you can continually improve on. But then I thought, how can you continually improve? At a certain point, don't you just "know" how to program? I imagine, just like at most things one can be great at, that, at the top, the difference in skill is probably minimal. So what makes a better programmer? Clearer code? Faster understanding of concepts? Being able to write a post on SO without it being closed? (I feel like this post is doomed, but it really is a question I was wondering.)</p>

答:
Imagine what the responses would have been had you asked this question 30 or 40 years ago.

The world of development will never stop moving (if nothing else, Microsoft wants to sell new versions of C#).

Even if you somehow manage to learn all known development techniques (functional programming, coroutines, continuation passing style, lock-free data structures, ...), new ones will still arise.

New fields of development will also arise with improved hardware.  Multi-touch screens, 3D displays, motion tracking, biometric sensors, and other IO technologies all create new challenges of UI and functionality.

OwnerDisplayName: Kewigro


答:
The best assumption is, assume tne estimate is way off. Software development is too complicated to estimate more than about two or three weeks out. At least, if your're creating something new.

If you're estimating making your 100'th website off of the same template, perhaps you can extend that out a bit.


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

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

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

My questions are:

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

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

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

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

答:
If you are continually in "crisis release" mode, I'd say it would be more prudent to take a step back and reevaluate your code and your process.  Obviously, there is some kind of failure there that just keeps getting repeated.

While it may not be entirely possible to do this on a true production scale, but it would probably be worthwhile to have at least one senior member and some other subset of developers and testers be dedicated to this evaluation.

The "4 on at a time approach" doesn't sound like a clear-cut winner to me.  That means constant context switching, which means far less efficiency.

Remember, if you are constantly hurrying to make changes, you are much more likely to make mistakes in those changes, and break something else while you're doing it.


答:
A simple example is the difference between various sorting algorithms. Mergesort, Heapsort, and some others are O(n log n). Quicksort is O(n^2) worst case. But often Quicksort is faster, and in fact it performs on average like O(n log n). More info.

Another example is the generation of a single Fibonacci number. The iterative algorithm is O(n), whereas the matrix-based algorithm is O(log n). Still, for the first couple of thousand Fibonacci numbers, the iterative algorithm is probably faster. This also depends on the implementation of course!

Algorithms with a better asymptotic performance may contain costly operations that are not necessary with an algorithm with worse performance but simpler operations. In the end, the O-notation only tells us something about performance when the argument it operates on increases dramatically (approaches infinity).

Title: Do real-world algorithms that greatly outperform in the class below exist?

Body:
Last night I was discussing with another programmer that even though something may be O(1), an operation which is O(n) may outperform it if there are is a large constant in the O(1) algorithm. He disagreed, so I've brought it here.

Are there examples of algorithms which greatly outperform those in the class below it? For example, O(n) being faster than O(1) or O(n2) being faster than O(n).

Mathematically this can be demonstrated for a function with an asymptotic upper bounds, when you disregard constant factors, but do such algorithms exist in the wild? And where would I find examples of them? What types of situations are they used for?


答:
While the fundamentals of programming may not change, a lot of other things do change and this is part of I think what you missed.  Look at what kinds of architectures and hardware we have now that we didn't have 10 years ago.  What kinds of software ideas will the cloud and social media create as what a computer is becomes even more blurred.

Learning domain knowledge will help as you could pick a specific type of software like a CRM or ERP.  Even then there can be advances in platforms so there is usually new things to learn or changes in requirements that people will want.

There will always be room to improve as one shouldn't underestimate human creativity.  Consider how creative are hackers and those that write software in an attempt to capture or beat the hackers, assuming the general meaning of hacker as someone that breaks into systems without authorization and performs malicious acts.

Title: What is the difference between skill level amongst programmers?

Body: I am a beginning programmer and in 5-10 years I'd like to be an expert. I love programming because it is a distinct skill set that you can continually improve on. But then I thought, how can you continually improve? At a certain point, don't you just "know" how to program? I imagine, just like at most things one can be great at, that, at the top, the difference in skill is probably minimal. So what makes a better programmer? Clearer code? Faster understanding of concepts? Being able to write a post on SO without it being closed? (I feel like this post is doomed, but it really is a question I was wondering.)</p>


答:
Note:
Please read the comments by @back2dos below and other gurus, as they are in fact more helpful than what I have written - Thanks for all contributors.

I think from the chart below (taken from: Big O notation, search for "The Pessimistic Nature of Algorithms:"), you can see that O(log n) is not always better than say, O(n).
So, I guess your argument is valid.


答:
My suggestion is to keep the data in either a file or database table. If speed is not an issue, then query the file or database (database is better) at run time. If memory is not a problem, but you would like some speed, then load the data into memory when the program starts. In C# you could use and array, list or (best option) a hash-table and have a method to return the data you need at runtime ( ie getDataValue(string keyToValue) ).

I would recommend that you do not use the switch statement as it would be very difficult to maintain and would result in a large exe footprint.

Hash-table eg http://support.microsoft.com/kb/309357


答:
For practical values of n, yes. This comes up a lot in CS theory. Often there is a complicated algorithm that has technically better big-Oh performance, but the constant factors are so large as to make it impracticaly.

I once had my computational geometry professor describe an algorithm for triangulating a polygon in linear time, but he finished with "very complicated. I don't think anyone's actually implemented it" (!!).

Also, fibonacci heaps have better characteristics than normal heaps, but are not very popular because they don't perform as well in practice as regular heaps. This can cascade to other algorithms that use heaps - for instance, Dijkstra's shortest-paths is mathematically faster with a fibonacci heap, but usually not in practice.


答: Lookups in very small, fixed data tables.  An optimized hash table may be O(1) and yet slower than a binary search or even a linear search due to the cost of the hash calculation.</p>


答:
```<code>how can you continually improve?
</code>```

You continually improve by working hard and setting the bar a bit higher each time.

```<code>At a certain point, don't you just "know" how to program?
</code>```

At a certain point (around the age of 3-5 years), all world-class athletes learn the most basic skill of their career, namely running. But that does not mean that a six year old can break any athletics world records. Again constant practice and discipline are required.

```<code>at the top, the difference in skill is probably minimal
</code>```

Yes, no doubts about that. But take a closer look and you will see that the top is NOT quite a stationary thing. Every few years, the top domains change, and with it the skill sets to ride the change. You can either have your lunch, or be somebody's lunch.

```<code>So what makes a better programmer?
</code>```

Three words:

attitude: ability to stick to a problem when stuck.

attitude: ability to ask others (and help others too) when in doubt, and you are stuck for a long time. Being humble is important.

attitude: ability to stick around enough. (most important, imho)

Things like writing clearer code and a faster understanding of concepts come easily after you have been coding for some time, and gone through the cycle of understanding and implementing something for the first few times. And in the end, the code that you write today will look bad to in a few years' time. Hanging around programmers.stackexchange and stackoverflow for some time taught me that there is a lot of scope for improvement for me. Sometimes, just reading people's answers takes you to insights you would not have otherwise reached. Such things remind (at least) me that the more you improve, the more scope for improvement there is.

Body:
how can you continually improve?

You continually improve by working hard and setting the bar a bit higher each time.

At a certain point, don't you just "know" how to program?

At a certain point (around the age of 3-5 years), all world-class athletes learn the most basic skill of their career, namely running. But that does not mean that a six year old can break any athletics world records. Again constant practice and discipline are required.

at the top, the difference in skill is probably minimal

Yes, no doubts about that. But take a closer look and you will see that the top is NOT quite a stationary thing. Every few years, the top domains change, and with it the skill sets to ride the change. You can either have your lunch, or be somebody's lunch.

So what makes a better programmer?

Three words:

attitude: ability to stick to a problem when stuck.

attitude: ability to ask others (and help others too) when in doubt, and you are stuck for a long time. Being humble is important.

attitude: ability to stick around enough. (most important, imho)

Things like writing clearer code and a faster understanding of concepts come easily after you have been coding for some time, and gone through the cycle of understanding and implementing something for the first few times. And in the end, the code that you write today will look bad to in a few years' time. Hanging around programmers.stackexchange and stackoverflow for some time taught me that there is a lot of scope for improvement for me. Sometimes, just reading people's answers takes you to insights you would not have otherwise reached. Such things remind (at least) me that the more you improve, the more scope for improvement there is.


答:
As with any skill it is a little like a fractal picture. Looking from a distance it looks simple. The closer you get the more you realise how complex it is.

The better you are the more you realise how much there is to know and how little of it you know. As you get better (as long as you keep your desire to improve) you will find new ways of looking at programming and you will find ways of improving even old techniques.

You will get faster, better at conveying your intention through the layout of the source code, and better at problem solving.

Of course the law of diminishing returns applies. It will take you longer to improve by the same amount when you have done 10 years than when you have done 1.


问:
source code file system layout for 2 very similar projects (with git)
we're working on "two" android apps that are very similar; in fact, they're the same apps with different graphics and color schemes, slightly different configuration and one or two unique activities that are not in the other project - but the functionality is 95% the same.

the plan was to work on one app until it is as complete as possible and then change the images and the other /res(ource) files.

of course it's not that easy; we're still working on the shared code, and patching the same code in different projects (or repositories) is - in my opinion - out of the question.

we're all using git and eclipse.

is there the "definitive guide" about handling such a situation?

my thoughts about it:

three repositories

rep1 for the unique files of application1, rep2 for the unique files of application2, and rep3 for the shared files.

if there is a way to push files in one folder (the project folder) to different repositories ... i mean, cloning rep1 automatically pulls the files from rep1 AND rep3, and pushing automatically pushes files back into to the right rep?

my teammates are suspicious; no one of us knows git very well and we're afraid of spending too much time repairing our dcvs mistakes.

2 repositories

if the first option isn't possible, our plan was to have 2 repositories. rep1 for the complete app1 and rep2 only for the rep2-specific files. a build script would replace the files from app1 with those of app2. imo this is an "accidental overwrite" minefield, and i don't like it. but as long as we don't have a better solution, this is the way to go.

eclipse

maybe there is some kind of eclipse-specific hack that would make this painless?

(edit) branching!?

i don't have any experience with branching. but this be a possible solution?

note: these are android projects; android demands a specific file layout. e.g. the name and structure of the "res" folder is pretty much fixed. this means that there are directories which contain files both app-dependent and shared files. i don't know if git can handle this.

答:
There are two approaches you could take:
1> Maintain one code base. The code uses a parameter/config file (like app.confg in .net) to determine which which behaviors/colors/images to use at either run time or during build/compile

2> I've not used GIT, but if it like PVCS or (if you dare!) VSS, you could attach a labels to the configuration items that float with the current version and states which 'build' the item refers to. When it is time to work on application A, get where label = A, for application B, get when label = B. You need to be careful with that approach, particularly if you the applications begin to diverge or branch.


答:
If you store large volumes of data into your application, then your program may load slower and you may be exposing the code to risk in case some one could play with the binaries or executable.

Also, if the program is edited many times, who knows, may be you could introduce errors by mistyping a numbers by mistake or as a result of change command.

May be in the future some one asks for running queries on the data, say, someone may ask for the average, of a column, in which case you will have to change your application and add a method to calculate every query your user comes up with, then go with the all the steps to  promote your code to production. This is really not good.

Separating data and code is a good practice specially if the data is large.


问:
Is it unusual for a small company (15 developers) not to use managed source/version control?
It's not really a technical question, but there are several other questions here about source control and best practice.

The company I work for (which will remain anonymous) uses a network share to host its source code and released code.  It's the responsibility of the developer or manager to manually move source code to the correct folder depending on whether it's been released and what version it is and stuff.  We have various spreadsheets dotted around where we record file names and versions and what's changed, and some teams also put details of different versions at the top of each file.  Each team (2-3 teams) seems to do this differently within the company.  As you can imagine, it's an organised mess - organised, because the "right people" know where their stuff is, but a mess because it's all different and it relies on people remembering what to do at any one time.  One good thing is that everything is backed up on a nightly basis and kept indefinitely, so if mistakes are made, snapshots can be recovered.

I've been trying to push for some kind of managed source control for a while, but I can't seem to get enough support for it within the company.  My main arguments are:

We're currently vulnerable; at any point someone could forget to do
one of the many release actions we have to do, which could mean whole
versions are not stored correctly.  It could take hours or even days
to piece a version back together if necessary

We're developing new features along with bug fixes, and often have to delay the release
of one or the other because some work has not been completed yet.  We also have to force
customers to take versions that include new features even if they just want a bug fix,
because there's only really one version we're all working on

We're experiencing problems with Visual Studio because multiple
developers are using the same projects at the same time (not the same
files, but it's still causing problems)

There are only 15 developers, but we all do stuff differently; wouldn't
it be better to have a standard company-wide approach we all have to
follow?

My questions are:

Is it normal for a group of this size not to have source control?

I have so far been given only vague reasons for not having source control - what
reasons would you suggest could be valid for not
implementing source control, given the information above?

Are there any more reasons for source control that I could add to my
arsenal?

I'm asking mainly to get a feel for why I have had so much resistance, so please answer honestly.

I'll give the answer to the person I believe has taken the most balanced approach and has answered all three questions.

Thanks in advance

答:
Be a leader. Being a leader means doing what's right; proactively solving problems. Leadership is not doing nothing because there's not enough consensus. And a good leader learns to recognize situations when one should build consensus and when to do. This is clearly a doing situation. The lack of code control WILL blow up in your faces sooner or later.

Leaders often are not in official management positions. People will follow good, decisive leaders regardless of title.

If your decisive efforts get slammed down, especially if it's from management then it's a clear sign for you to get the hell out of there. It's a drag on your professional development; and Competent developers and incompetent management do not mix, and an incompetent with power will screw you.

OK, the flashbacks are getting to me. Signing off. Good luck.

OwnerDisplayName: LordScree


答:
Compare inserting into a linked list and inserting into a resizable array.

The amount of data has to be fairly large for the linked list O(1) insertion to be worthwhile.

A linked list has extra overhead for next pointers and dereferences. A resizable array has to copy data around. That copying is O(n), but in practice very fast.


问:
What should take precedence: YAGNI or Good Design?
At which point should YAGNI take precedence against good coding practices and vice versa?  I'm working on a project at work and want to slowly introduce good code standards to my co-workers (currently there are none and everything is just kind of hacked together without rhyme or reason), but after creating a series of classes (we don't do TDD, or sadly any kind of unit testing at all) I took a step back and thought it's violating YAGNI because I pretty much know with certainty that we don't require the need to extend some of these classes.

Here's a concrete example of what I mean: I have a data access layer wrapping a set of stored procedures, which uses a rudimentary Repository-style pattern with basic CRUD functions.  Since there are a handful of methods that all my repository classes need, I created a generic interface for my repositories, called IRepository.  However, I then created a "marker" interface (i.e. interface that doesn't add any new functionality) for each type of repository (e.g. ICustomerRepository) and the concrete class implements that.  I've done the same thing with a Factory implementation to build the business objects from DataReaders/DataSets returned by the Stored Procedure; the signature of my repository class tends to look something like this:

```<code>public class CustomerRepository : ICustomerRepository
{
    ICustomerFactory factory = null;

    public CustomerRepository() : this(new CustomerFactory() { }

    public CustomerRepository(ICustomerFactory factory) {
        this.factory = factory;
    }

    public Customer Find(int customerID)
    {
        // data access stuff here
        return factory.Build(ds.Tables[0].Rows[0]);
    }
}
</code>```

My concern here is that I'm violating YAGNI because I know with 99% certainty that there is never going to be a reason to give anything other than a concrete CustomerFactory to this repository; since we don't have unit tests I don't need a MockCustomerFactory or similar things, and having so many interfaces might confuse my co-workers.  On the other hand, using a concrete implementation of the factory seems like a design smell.

Is there a good way to come to a compromise between proper software design and not overarchitecting the solution?  I'm questioning if I need to have all of the "single implemenation interfaces" or if I could sacrifice a bit of good design and just have, for example, the base interface and then the single concrete, and not worry about programming to the interface if the implementation is that will ever be used.

答:
Why the marker interfaces? It strikes me that it's doing nothing more than "tagging". With a different "tag" for every factory-type, what's the point?

The purpose of an interface is to give a class "acts like" behavior, to give them "repository-ability" so to speak. So if all your concrete repository-types behave like the same IRepository (they all implement IRepository) then they all can be handled in the same way by other code - by the exact same code. At this point your design is extensible. Adding more concrete repository-types, all handled as generic IRepository(ies) - the same code handles all concrete types as "generic" repositories.

Interfaces are for handling things based on commonalities. But custom marker interfaces a) add no behavior. and b) force you to handle their uniqueness.

To the extent you design useful interfaces you get the OO goodness of not having to write specialized code to handle specialized classes, types, or custom marker interfaces that have a 1:1 correlation to concrete classes. That's pointless redundancy.

Off hand I can see a marker interface if, for example, you needed a strongly typed collection of lots of different classes. In the collection they are all "ImarkerInterface"s but as you pull them out you're having to cast them to their proper types.


问:
Teaching C++ to first time high school students: Where to draw the line?
I will be mentoring a team of high school students for the FIRST Robotics Competition, most teams here develop[ their robot software using C++. For many of the students on the team this will be their first introduction to programming. I wouldn't have chosen C++ for teaching programming to high schoolers (e.g. Python or Javascript would have been easier I think) but the choice is set.

I want to teach them proper C++ (i.e. avoid a mixed C/C++ dialect, i.e. C+) but I don't want to scare them either with needless complexity. For that matter:

Should I start using STL from day one, esp. vector or just stick with standard arrays? Arrays are easier to introduce but the pointer errors may be harder to catch.

For I/O, should I stick to cout, etc. or do you think printf would be easier to learn?

Are there any online resources for C++ that are suitable to use for such young learners?

Thanks!

EDIT: Thanks for so many excellent answers. In addition to Accelerated C++, which is suggested by many people, I have found that C++ For Everyone is an excellent text.

答:
Use How to Program C++ by Deitel and Deitel. EXCELLENT textbook in my opinion.

Sounds like you're trying to teach novices how to program and then have them program at some advanced level at the same time. If you hope to give them some monkey see monkey do coding snippets w/o an understanding you're doomed to failure.

Stay away from STL for a beginner class.

If you already have a coding solution for your robot - or a VERY GOOD IDEA of what it will look like then perhaps you can "map" the lessons in the textbook to the coding tasks for the robot. But let the textbook drive the learning.

If you force-feed coding, giving the students very narrow lessons and exposure to the language then I think as the ocean of code you write gets bigger and bigger, it will be like having just learned to dog paddle and you will drown because REAL swimming is required.

It's not a question of "should they learn cout or printf?" It's a question of learning enough to have insight on how to write code for given robot programming tasks to solve.

If this were a reading assignment, what would the results be if all they knew were simple subject-verb sentences and only half the vocabulary you KNOW will be required.

OwnerDisplayName: recipriversexclusion


答:
Release cycles shorter than one week have certainly been achieved in the software industry.  They employ the technique called continuous delivery (also called continuous deployment).

There is a company that releases 50 times a day.  This blog post describes how they do it.

Title: One-week release cycle: how do I make this feasible?

Body:
At my company (3-yr-old web industry startup), we have frequent problems with the product team saying "aaaah this is a crisis patch it now!" (doesn't everybody?)

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

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

My questions are:

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

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

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

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


问:
If attribution is done via a pseudonym, who owns the rights to the code?
I'm aware of a few cases where coders used a pseudonym for attribution instead of their real names.

Examples include:

Satoshi Nakamoto (Bitcoin)

Why (Ruby)

One thing I've wondered is if attribution is done via a pseudonym, who owns the rights to the code?

答:
The obvious advantage of a pseudonym: you stay anonymous if you want to (even if it may become difficult if you contribute to a well known project). This means several things:

You are not bothered with emails from people who know your name and the fact that you participate to the project,

If you work in some companies with strict policies, you avoid the problem where all you write belongs to this company¹,

You can quit the open source project at any moment, and nobody will bother you, never,

During an interview for a job, you will never have to answer questions like this:

Ten years ago, you contributed to project <Name here>. We've downloaded the code of this period from SVN, and there is a lot of unreadable code, difficult to maintain, with plenty of bugs, no comments at all, etc. Can you explain that, and what changed for the past ten years in your coding style?

At the opposite, it means that if you make a professional-level contribution, writing a high quality code, etc., you're not rewarded personally. You can still say that it's your code during interviews, but it's much more indirect.

¹ I'm not a lawyer, so it may be inexact in your country.


问:
The cost of running a Windows App Server
I want to know what is the cost of running a Windows Application Server.

I know the cost of running a Linux server with Java based Application Server is probably zero.

What is the cost of running a windows based server on which all Apps are written in C#? I assume is is just the license cost of a copy of Windows Server.

Is this true? Are there any other hidden cost for hosting with WIndows?

I think with Cloud based hosting, these license costs can be avoided then.

答:
There is the cost of the room that it is in, as well as cooling that room. Look at the specs for the server and find the max power usage and multiply that by the electricity price per Kw/H then multiply that by a period of time, say a year to get that running cost.

You need to allow for hardware failures and replacements as well, this will probably be hard drive failures.

These costs are the same irrespective of OS - the only difference between OS choices is licensing cost and the cost of getting skilled staff.

The cloud benefits from economies of scale, so if you have a small set-up you may save some money going to the cloud. But there will come a point where your size is such that you can get the same economies of scale and hence save on the cloud vendors profit margin.


问:
Is there an efficient way to align degenerate strings?
I have a degenerate string S1=xadcdax, where x can be replaced by any of the four characters a, b, c, or d. This S1 string is match with another non-degerate string S2=dcbaa.

I can first use brute force to find all possible strings of S1, which requires 4^n (n is the number of degenerates in a string), so the complexity is 4^2. After that, for each string of S1 matched with S2 by using dynamic programming which requires (i x j) running time (where i is the length of S1 and j is the length of S2).

But the total running time will be 4^n x ij = 4ij^n, which is quite slow.

Is there a more efficient algorithm for this?

答:
EDIT:

This feels like a modified Boyer-Moore string search:

http://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string_search_algorithm

You're basically trying to prove that matching S2 to different positions of S1 won't work with any set of substitutions (or won't work with the known characters), which allows you to skip them and move on.

In your specific example, you know that you need to match 5 chars.  Your string S1 has 2 places where it could be anything, with 5 places in the middle.  So, if you can match the left 4 characters in S2 to something that doesn't include an x in S1, or the right 4, you can then test the last character only.  (Neither works here.)

```<code>xadcdax
?cbaa
  dcba?
</code>```

If you had a string of 5 x's "xxxxx" and all of the characters in S2 where also found in the list of acceptable characters, then you have an automatic match.

```<code>xxxxx
?????
</code>```

To make this generic, you could search for all occurrences of x in S1, then attempt to match on the left or right side to S2, then fill in the blanks as needed.  If you had 2 occurrences of x in a row, you'd only need to search the left or right 3 chars of S2 (in your specific case.)  To search in the middle, you end up sliding S2 across the x found and attempting to match to the left and right.

```<code>??????x??????
  dcba?
   dcb?a
    dc?aa
     d?baa
      ?cbaa

????x??x???
dcba?
 dcb?a
  dc?aa
   d?ba?
    ?cb?a
     dc?aa
      d?baa
       ?cbaa
</code>```

Only when the characters in S1 that are specific match do you then need to do substitutions.

If all characters in your substitution list are in S2, you don't need to do substitutions at all, the string matches the position.

You can skip lining up positions where S2 has a character not in the substitution list that lands on a degenerate character.

I don't have any pseudo code, so I'm not sure of running time.

Body:
EDIT:

This feels like a modified Boyer-Moore string search:

http://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string_search_algorithm

You're basically trying to prove that matching S2 to different positions of S1 won't work with any set of substitutions (or won't work with the known characters), which allows you to skip them and move on.

In your specific example, you know that you need to match 5 chars.  Your string S1 has 2 places where it could be anything, with 5 places in the middle.  So, if you can match the left 4 characters in S2 to something that doesn't include an x in S1, or the right 4, you can then test the last character only.  (Neither works here.)

xadcdax
?cbaa
  dcba?

If you had a string of 5 x's "xxxxx" and all of the characters in S2 where also found in the list of acceptable characters, then you have an automatic match.

xxxxx
?????

To make this generic, you could search for all occurrences of x in S1, then attempt to match on the left or right side to S2, then fill in the blanks as needed.  If you had 2 occurrences of x in a row, you'd only need to search the left or right 3 chars of S2 (in your specific case.)  To search in the middle, you end up sliding S2 across the x found and attempting to match to the left and right.

??????x??????
  dcba?
   dcb?a
    dc?aa
     d?baa
      ?cbaa

????x??x???
dcba?
 dcb?a
  dc?aa
   d?ba?
    ?cb?a
     dc?aa
      d?baa
       ?cbaa

Only when the characters in S1 that are specific match do you then need to do substitutions.

If all characters in your substitution list are in S2, you don't need to do substitutions at all, the string matches the position.

You can skip lining up positions where S2 has a character not in the substitution list that lands on a degenerate character.

I don't have any pseudo code, so I'm not sure of running time.


答:
what common assumptions do you include with your estimates

Every single "fact" provided by the customer is listed as an assumption.

Those are the common assumptions.

Everything else is just fluff.  You can write down lots of fluffy things like you assume that plague doesn't break out, and zombies don't arise and eat our brains, but none of that makes any sense to a customer.

Taking their "facts" about the development effort, and relabeling each "fact" as an assumption makes it clear that everything is fanciful.

Then.

Study up on Agile methods and be sure to identify that -- really -- it's a matter of priorities and budget.  You'll build things from most important to least important and they can stop you at any time.

There are several -- irreconcilably different -- "intents" for an estimate.

It could be a firm, fixed price that will establish an upper limit on the budget and a lower limit on delivered functionality.

It could be a ballpark price used to reverse engineer an hourly rate used to qualify you as a resource.

It could be a cost number that goes into a cost/benefit decision.

Until you know what the "intent" is, the nature of the assumptions will vary.  There's no single right answer until you actually define the customer's intent.


问:
When is it appropriate to use Microsoft's Enterprise Library (EntLib)?
I'm not exactly sure when to use Enterprise Library, and when not to... and that is making me not learn it at all.  I feel that I have enough of a reason to start learning then perhaps one day I'll use it.

Are there times when I should use EntLib?

When shouldn't I use it?

答:
I've used EntLib for many years (since they were indiviual App Blocks).  I've found that at times it can be pretty heavy as far as the size of the components, especially if you only need one block and it needs to be downloaded.  Often I'll use the Data and Logging components together and that feels like enough functionality to justify the size.  If your app is strictly on the server side then this really isn't too much of an issue.  One of the things that is nice about it is that if you need more than one block you don't have to go to multiple implementations from multiple vendors that are configured in different ways.  They also provide a tool to help with the configuration (that's a plus and a minus, a plus that they make it easy, a minus that they NEED a tool to help configure it).

I've had the pleasure of being invinted to a couple of Patterns and Practices workshops where I was working side by side with the team members who wrote EntLib.  The intent in creating EntLib was to implement Microsoft's Best Practices in common components that everyone needs that are not part of the base Framework.  They are very stable, provide very good performance and very good flexibility.

I would start by using some of the easier blocks, like Data and Logging.  They're not too hard to configure and get started with.  Then once you understand those it will be a bit easier to move on to some of the other blocks.  I have not found a situation where you shouldn't use them, other than when you don't need them.


问:
Is the agile approach too much of a convenient excuse for cowboys
I believe that an agile approach is best for projects where the requirements are fuzzy and a lot of interaction is required to help shape the end user's ideas.

However... In my professional work, I keep ending up at companies where an "agile" approach is used as an excuse as to why no effort was put into an up front design; when the requirements are well understood.

I can't help but thinking that if the agile approach wasn't around, I'd be sitting here with a nice high-level specification and not having to revisit the same screen and functionality every second day when something else crops up or so and so hadn't thought of that.

Are the benefits of agile methodologies really enough to outweigh the excuse for being lame it gives to cowboy technical leads?

Update: Ironically I'm now a certified Scrum Master. One of the papers presented on the Scrum course observed that the best development process was one where there was a single expert or guru making the design decisions, however that has obvious weaknesses. Scrum shifts the responsibility for producing quality software to the "Team" which means a sub-standard team can get away with churning out spaghetti which I guess is no different to other Agile and non-Agile development processes.

答:
Agile when done properly should have the effect of reining in "cowboy" technical leads and "hero" programmers.  If you don't observe this effect, that may be a sign that something important is missing from your agile implementation.

I want to add that "Agile" is really an interface (I'm using an object-oriented metaphor here) and you cannot instantiate it.  If your concrete implementation of it is XP, then you have to follow a bunch of technical practices with a lot of discipline, which leaves little room for cowboy programming.  Another possibility is that the teamwork of a well-self-organized Scrum team will keep it in check.


答: It should go without saying that they should sign a Limitation of Liability... you don't want to be in a situation where you risk potentially millions of dollars of damages due to "lost profits" or "consequential damages" in exchange for a $5000 project.</p>


问:
is c or c++ necessary for game programming?
Do you need to learn c or c++ for game programming? I am very good with java. Is it true that most game engines are in c or c++.should i learn c or c++ or start making games in java.Can you suggest some books to start with</p>

答:
Many game engines are, indeed, in C or C++, particularly the first-person-shooter types. This is because that style of game typically needs to squeeze the maximum possible performance out of the graphics hardware.

Outside of that requirement, you can pretty much use whatever language you feel like. Puzzle Pirates is 100% pure Java, and Frozen Bubble is written in Perl.

So, to answer your question, no you do not need to learn C or C++. It will be helpful if you want to take full advantage of graphics hardware but not all games need that.

OwnerDisplayName: chintans

OwnerDisplayName: Cameron Skinner


问:
Static functions question
Something came to my mind today. I have been doing a lot of the following

```<code>new Object().doSomething();
</code>```

I create an object and call on of its functions, then forget about the object. I don't need it past this one instance. Does this signal a bad coding style. Is it best to convert these methods to a static function so a new object does not need to be created every time?

答:
Conceptually, you're already calling a static function, so the easy answer is to just go ahead and code them that way. A harder answer is that you probably have an underlying design flaw, such that this object is either a "misc" that you just threw a bunch of left over code into, or you are passing it a lot of state on each of those calls.

While they are all in that object, they're coupled, and you have less flexibility in refactoring the design. If you break it apart into just functions, then look at which go together, what state they are using, etc., you can move that functionality to where it belongs, either in one or more objects with discrete state, in the objects that are calling them (because it has to "borrow" their state), or as a singleton object that aggregates state.

Sometimes functions are just naturally static, they have no state aside from the parameterization, so they don't need to be part of an object.  It's still better to leave them as functions rather than bound together in an object, because as your code evolves, it will be easier to migrate them.

Title: Static functions question


答: United States copyright law acknowledges, and accommodates, anonymous as well as pseudonymous copyright holders (see U.S. Title 17 Ch 3 Sec 302, for instance).  The author (or their employer, as the case may be) hasn't automatically surrendered all rights to the work.  </p>

Title: If attribution is done via a pseudonym, who owns the rights to the code?

Body:
I'm aware of a few cases where coders used a pseudonym for attribution instead of their real names.

Examples include:

Satoshi Nakamoto (Bitcoin)

Why (Ruby)

One thing I've wondered is if attribution is done via a pseudonym, who owns the rights to the code?


问:
Is it bad practice to define/use "Preset" functions
Lets say I have an extremely robust and versatile function:

void DoAnything(action, target, context)

In my program, 90% of the time I call this function, it's with the same parameters:

DoAnything(eat, food, lunchtime);

Is it bad form for me to define a function such as:

void EatLunch(){  DoAnything(eat, food, lunchtime);  }

And call that instead?

答: It's a good thing to do when you find the code is more readable and more maintainable when wrapped using the invariant arguments. I do it often.


答:
There's the cost of the production server, Integration, Test & Development servers can be licensed under the terms of MSDN if EVERYONE that touches the server has an MSDN licence.  Build servers count as production so need to be licensed separately.

So, to have a MS development environment you need:-

At least 3 Windows Server licences (one for production, one for SQL Server & one for build) probably more if you want redundancy.

One Visual Studio + MSDN licence for every developer (I believe it's OK for contractors to have their own MSDN & attach to your servers)

One MSDN (probably involving the Test suite) for every tester

One MSDN for any sysadmins that administer the DB &/or servers

CALs for internal users that attach to SQL Server

Sharepoint's extra Team Foundation Server's extra...

Linux isn't free if you want enterprise support, neither is MySQL.  You can get away with a completely free stack and only buy things that you feel add value e.g. IDE, support etc.

For a very small company the initial cost of the MS licencing is probably an issue, however, as a percentage of the employment costs of a team of developers it's pretty modest.

Which way you go probably comes down to availability of programmers where you are.

Title: The cost of running a Windows App Server

Body:
I want to know what is the cost of running a Windows Application Server.

I know the cost of running a Linux server with Java based Application Server is probably zero.

What is the cost of running a windows based server on which all Apps are written in C#? I assume is is just the license cost of a copy of Windows Server.

Is this true? Are there any other hidden cost for hosting with WIndows?

I think with Cloud based hosting, these license costs can be avoided then.


问:
Why the scorn for COBOL?
When people mention COBOL, it's usually either met with a snort or groan. I don't know much about COBOL, but I've seen some programs written in it. I can see that it's wordy, and to uninitiated eyes such as mine, unintelligible. But, really, aren't all programming languages complete gibberish to a lay person?

I understand that it works, works well, and is still in widespread use in the industries it was designed for. Aren't those the hallmarks of a good language? What's so bad about COBOL?

答:
What's so bad about COBOL?

Nothing.

I think people have a preconceived notion that old is bad, "newest is bestest".  It's still very much in use, and I'm sure there will be enough maintenance work on code to be had for another half century.

In 1997, the Gartner Group reported that 80% of the world's business ran on COBOL with over 200 billion lines of code in existence and with an estimated 5 billion lines of new code annually.     (via wikipedia)

In coding, one must always select the best tool for the job, and with certain industries that are married to certain hardware, the language is optimal.  I've never worked in banking, where I had heard it was popular, but Sean's answer indicates this isn't the case.

If there's a problem with legacy code looking old, as long as you can slap a UI or a web interface in front of it, most users won't even know the difference.

Title: Why the scorn for COBOL?


答:
This is probably down to Djikstra. Djikstra stated that  "The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offense." Cobol was viewed as naive, unstructured and verbose. With the ability to self-alter code (a practice discouraged even among cobol programmers) it was viewed as quite difficult to debug or follow too.

Then there is the matter of great incompatibility between versions too.

I would suggest reading the criticism and defence section in Wikipedia for the language - http://en.wikipedia.org/wiki/COBOL#Criticism_and_defense

Title: Why the scorn for COBOL?

Body:
When people mention COBOL, it's usually either met with a snort or groan. I don't know much about COBOL, but I've seen some programs written in it. I can see that it's wordy, and to uninitiated eyes such as mine, unintelligible. But, really, aren't all programming languages complete gibberish to a lay person?

I understand that it works, works well, and is still in widespread use in the industries it was designed for. Aren't those the hallmarks of a good language? What's so bad about COBOL?


答:
It's age and verboseness are typically the things that make people groan about it.

I seem to recall that the main aim for IBM when designing COBOL was that it "should allow a bank manager to write a program". This goal obviously had a profound affect on the way the language was designed, and it now it evolved.

Apparently there's more COBOL out in the wild than any other language. However, after working in IT for almost 20 years (15 in banking) I've never encountered a single system that was implemented in it.

Title: Why the scorn for COBOL?


答:
When you're writing a library, adding convenience wrappers is often a service to your users.

For example, suppose I've written a stream compression library in C.  My highly versatile entry point might be:

```<code>Stream *compress_stream(Stream *input, StreamOptions *opts);
</code>```

However, many users will simply want a function like this:

```<code>void *compress(const void *data, size_t length, size_t *out_length);
</code>```

compress_stream is more versatile: it can both consume input and produce output lazily, and the user can supply additional parameters (e.g. algorithm, quality, etc.)

However if a user simply has a blob of data they want to make smaller, my compress_stream function will be extremely cumbersome by itself.  The user will have to learn about my Stream object:

```<code>typedef struct Stream Stream;

struct Stream
{
    size_t (*read)(Stream *s, void *buffer, size_t len);
    void free(Stream *s);
};
</code>```

Then they'll have to implement compress in their own terms:

```<code>typedef struct
{
    Stream stream;
    const char *data;
    size_t remaining;
} SimpleStream;

size_t SimpleStream_read(Stream *s, void *buffer, size_t len)
{
    SimpleStream *ss = container_of(s, Stream, stream);

    if (len > ss->remaining)
        len = ss->remaining;

    memcpy(buffer, ss->data, len);
    ss->data += len;
    ss->remaining -= len;
    return len;
}

void SimpleStream_free(Stream *s)
{
    free(container_of(s, Stream, stream));
}

Stream *SimpleStream_new(const void *data, size_t length)
{
    SimpleStream *ss = stream_new(sizeof(SimpleStream),
                                  SimpleStream_read,
                                  SimpleStream_free);
    if (ss == NULL)
        return NULL;

    ss->data = data;
    ss->remaining = length;
    return &ss->stream;
}

void *consume(Stream *s, size_t *out_length)
{
    char *buffer;
    size_t buffer_length = 0;
    size_t buffer_alloc = 16;

    buffer = malloc(buffer_alloc + 1);
    if (buffer == NULL)
        return NULL;

    for (;;) {
        size_t readlen;

        readlen = s->read(s, buffer + buffer_length, buffer_alloc - buffer_length);
        if (readlen == 0)
            break;

        buffer_length += readlen;
        assert(buffer_length <= buffer_alloc);
        if (buffer_alloc - buffer_length < 16) {
            char *tmp;

            buffer_alloc *= 2;
            tmp = realloc(buffer, buffer_alloc + 1);
            if (tmp == NULL) {
                free(buffer);
                return NULL;
            }
            buffer = tmp;
        }
    }

    buffer[buffer_length] = 0;
    *out_length = buffer_length;
    return buffer;
}

void *compress(const void *data, size_t length, size_t *out_length)
{
    Stream *input;
    Stream *output;
    void *ret;

    input = SimpleStream_new(data, length);
    output = compress_stream(input, NULL);
    input->free(input);
    ret = consume(output, out_length);
    output->free(output);
    return ret;
}
</code>```

This may be a contrived example, but I've seen libraries neglect to include simple wrappers on multiple occasions.  For users to implement those wrappers in their code, they will have to learn more about your library than they really wanted to.

Title: Is it bad practice to define/use "Preset" functions

Body:
Lets say I have an extremely robust and versatile function:

void DoAnything(action, target, context)

In my program, 90% of the time I call this function, it's with the same parameters:

DoAnything(eat, food, lunchtime);

Is it bad form for me to define a function such as:

void EatLunch(){  DoAnything(eat, food, lunchtime);  }

And call that instead?

Body:
When you're writing a library, adding convenience wrappers is often a service to your users.

For example, suppose I've written a stream compression library in C.  My highly versatile entry point might be:

Stream *compress_stream(Stream *input, StreamOptions *opts);

However, many users will simply want a function like this:

void *compress(const void *data, size_t length, size_t *out_length);

compress_stream is more versatile: it can both consume input and produce output lazily, and the user can supply additional parameters (e.g. algorithm, quality, etc.)

However if a user simply has a blob of data they want to make smaller, my compress_stream function will be extremely cumbersome by itself.  The user will have to learn about my Stream object:

typedef struct Stream Stream;

struct Stream
{
    size_t (*read)(Stream *s, void *buffer, size_t len);
    void free(Stream *s);
};

Then they'll have to implement compress in their own terms:

typedef struct
{
    Stream stream;
    const char *data;
    size_t remaining;
} SimpleStream;

size_t SimpleStream_read(Stream *s, void *buffer, size_t len)
{
    SimpleStream *ss = container_of(s, Stream, stream);

    if (len > ss->remaining)
        len = ss->remaining;

    memcpy(buffer, ss->data, len);
    ss->data += len;
    ss->remaining -= len;
    return len;
}

void SimpleStream_free(Stream *s)
{
    free(container_of(s, Stream, stream));
}

Stream *SimpleStream_new(const void *data, size_t length)
{
    SimpleStream *ss = stream_new(sizeof(SimpleStream),
                                  SimpleStream_read,
                                  SimpleStream_free);
    if (ss == NULL)
        return NULL;

    ss->data = data;
    ss->remaining = length;
    return &ss->stream;
}

void *consume(Stream *s, size_t *out_length)
{
    char *buffer;
    size_t buffer_length = 0;
    size_t buffer_alloc = 16;

    buffer = malloc(buffer_alloc + 1);
    if (buffer == NULL)
        return NULL;

    for (;;) {
        size_t readlen;

        readlen = s->read(s, buffer + buffer_length, buffer_alloc - buffer_length);
        if (readlen == 0)
            break;

        buffer_length += readlen;
        assert(buffer_length <= buffer_alloc);
        if (buffer_alloc - buffer_length < 16) {
            char *tmp;

            buffer_alloc *= 2;
            tmp = realloc(buffer, buffer_alloc + 1);
            if (tmp == NULL) {
                free(buffer);
                return NULL;
            }
            buffer = tmp;
        }
    }

    buffer[buffer_length] = 0;
    *out_length = buffer_length;
    return buffer;
}

void *compress(const void *data, size_t length, size_t *out_length)
{
    Stream *input;
    Stream *output;
    void *ret;

    input = SimpleStream_new(data, length);
    output = compress_stream(input, NULL);
    input->free(input);
    ret = consume(output, out_length);
    output->free(output);
    return ret;
}

This may be a contrived example, but I've seen libraries neglect to include simple wrappers on multiple occasions.  For users to implement those wrappers in their code, they will have to learn more about your library than they really wanted to.


答: Nope, it's good form to do this. By defining what it means to EatLunch() in one place you reduce code repetition. Also, if ever you need to change what it means to EatLunch() then you only have to do so in one place.


问:
What assumptions / disclaimers should be included with a software estimate?
I'm writing a lot of estimates lately and I'm finding that quite often, a client might argue scope, deliverables or (most often) cost.

In an effort to ensure that the breadth of coverage (of client requirements and mutually understood scope) for the estimate is clear (and given most clients will view an estimate as a fixed quote from Moses himself), what common assumptions do you include with your estimates such that expectations are clearly set with clients and disagreements around what is being delivered or charged are minimised?

答:
There have been several questions on this site about delivering code and not getting paid. Make it very clear that they can assume if they don't pay you, code will not be delivered in a usable format. Any attempt to use the code without payment is a breach of contract. You should be upfront about any technology you plan on implementing to achieve this.

The other details can come from some standard agreement or whatever the client will let you get away with.


答:
COBOL was one of the first languages I learned - if you ignore countless versions of Basic, three or four assembler languages and a variant of Forth, then it was in my first five, and learned concurrently with Pascal. IOW, I'm answering from personal experience using the language.

EDIT I should say ancient experience. I never used the language after the end of the 80s, though I did buy a new book (to replace the old one I threw away in disgust) so that I had something to refer to so my horror stories wouldn't get too distorted. But I have no idea how the language has evolved in at least the last 20 years.

Obviously, for many people, it is just that "old is bad" view that jonsca has already described - and also much more a third-hand pass-me-down attitudes thing. But there are real issues underlying that.

Being too wordy is a real problem - there's too much clutter in the way of understanding the code. This is by far the biggest issue. People who look at the MOVE, ADD and MULTIPLY etc statements in horror have a slightly exaggerated view of this, true - the COMPUTE statement is closer to the assignments in other languages. But there's still a lot of clutter in all those divisions and sections. One of the first things I learned in COBOL was to always start by copying a standard page-of-A4-long SKELETON.COB.

COBOL does have some interesting features, but those features (e.g. the PIC thing) tend to be things that are now more part of the DBMS rather than the programming language, and that seems to me to usually be a better way to separate those responsibilities. Also, some libraries in other languages use something comparable to PIC (e.g. printf and scanf in the C standard library). Arguably, the best has been kept, but the worst dropped.

Also, for every nice feature, there was at least one intolerable one. For example, no matter how trivial a loop is, you have to move the body into a separate procedure. The PERFORM ... UNTIL ... and similar statements are single statements - not block structures. In a sense, COBOL was a taste of structured programming from before structured programming was invented - there was a GO TO, but it's use was discouraged (at least when I used COBOL), but looping in particular just wasn't handled that well.

In fact, the language that I used after COBOL that most reminded me of it was... dBase. As in Ashton-Tate dBase III+. These days, people are more likely to remember all the now-dead-or-dying clones (Clipper, FoxPro etc) that led to the generic name xBase - and there is still a living descendant in xHarbour. The point is that these were database languages, but nothing like SQL.

Even then, where every COBOL program operating on a particular database needs to include a copy of the specification of that database (and the copies could end up inconsistent), that isn't really the case in xBase where the database knows it's own structure.

Taking that into account, then, COBOL is not so terrible if you accept it for what it is. But what it isn't is a language for writing data structures. Which may be why COBOL suffered a lot back in the times of the C vs. Pascal holy wars - both sides could agree that COBOL was no good for reinventing the binary tree yet again.

Oh - and one thing I'll never forget is how my first COBOL textbook didn't describe the SORT command, saying that it was outside the scope of the book - apparently, either the author couldn't cope with the idea of sorting, or considered it to be more than the tiny little minds of COBOL students could cope with [see edit at end]. That kind of thing made it very difficult to take COBOL seriously.

An odd aspect of this was Jackson Structured Programming, which I also was forced to learn at around the same time, and specifically for use with COBOL. Part of this was drawing a structure diagram for the input, then a structure diagram for the output, then drawing the in-between structure diagram for the code. Sorting was clearly expected to be an already-solved problem - you couldn't derive a sorting algorithm in this way. So it was odd to be told by the recommended text-book that the whole concept of sorting was beyond my tiny little mind, while at the same time being taught something like a dozen different sorting algorithms and how to implement them in Pascal.

The problems that JSP can handle are probably a good guide for the things that COBOL can do relatively well. But even then, that doesn't necessarily mean that either JSP or COBOL are good ways to handle those problems.

EDIT on 30th July 2014

I just got a reputation boost from this, reminding me it's here. As it happens, due to some nostalgia-fueled ancient book collecting, I can now correct a point WRT the SORT command.

The book I originally used as the recommended text when learning COBOL was "Methodical Programming in COBOL" by Ray Welland. This doesn't cover COBOL 85 (though there was a later edition "Methodical Programming in COBOL-85" which I've still never seen).

kindall comments below that "You were supposed to sort the input files before reading them, or sort the output file after generating it, using the sort utility that came with the OS". From my reply to that, I missed the "came with the OS" point. Kindall was suggesting something akin to the Unix philosophy AFAICT, with COBOL used for the bits it's good for, OS utilities such as a sort utility used for some other things, and presumably using a batch/scripting/shell language to glue the bits together. This makes much more sense in an ancient world where interactive software was rare to non-existent, so you'd be submitting batches of work (hence "batch language") anyway.

The following is quoted from page 165-166 of "Methodical Programming in COBOL"...

The use of ordered serial files implies that it is necessary to have
  a means of sorting records within a file into some specified order by
  key. Most larger computer systems have a sort utility which will sort
  a file given the position, type and size of each of the data-items
  forming the key.

There is also a facility for sorting records from within a COBOL
  program but this is beyond the scope of this book for two reasons:

(a) the interface to the operating system is often quite complex and
  varies from system to system,

(b) the sort module is an optional part of ANS '74 COBOL and may not be
  implemented in COBOL systems for smaller computers.

Therefore it will be assumed that facilities exist for sorting files
  into a specified order and the problem of updating such files will be
  considered.

In short, kindall is correct - the assumption was that usually sorting
would be done outside of COBOL. There may even have been a real justification
to excluding sorting from a programming language around 1974 for small computers.

What I said above was basically what you get after around 20 years of not
being able to check facts due to throwing away the book.

I should still point out, though, that I formally studied COBOL from this
recommended book that covered the 1974 standard (not the 1985
standard) in 1988 and 1989. The third edition of "COBOL for Students" (Parkin, Yorke, Barnes) - the first edition covering COBOL 85 - wasn't published until 1990. I'm not certain, but I think the COBOL 85 edition of "Methodical Programming" wasn't published until 1994.

But that doesn't necessarily represent the COBOL world dragging its feet - well, not that much anyway. New standards adoption takes time for any language, even now.

Title: Why the scorn for COBOL?


问:
Would you fork an open source project because it's "poorly managed"
If you know of an open source project whose organizer

has gotten really busy that he doesn't maintain it that much

and he's the type of guy that doesn't accept contributions until a few months later (busy I guess) if at all

and the project is starting to flounder

would you fork this project, give it a new name, and continue working hard on it and build a new community around it that's more encouraging to code contributions? Basically a better managed project since the concern now is bad management.

答: I would contact the original project organizer to see if he'd be willing to step aside and let you manage it. Of course, you need to build a good case as to why you would be better than him. If he's a decent guy who is willing to accept criticism, than you will work something out.</p>


问:
Do real-world algorithms that greatly outperform in the class below exist?
Last night I was discussing with another programmer that even though something may be O(1), an operation which is O(n) may outperform it if there are is a large constant in the O(1) algorithm. He disagreed, so I've brought it here.

Are there examples of algorithms which greatly outperform those in the class below it? For example, O(n) being faster than O(1) or O(n2) being faster than O(n).

Mathematically this can be demonstrated for a function with an asymptotic upper bounds, when you disregard constant factors, but do such algorithms exist in the wild? And where would I find examples of them? What types of situations are they used for?

答:
Sorting:

Insertion sort is O(n^2) but outperforms others O(n*log(n)) sorting algorithms for small number of elements.

This is the reason why most sort implementations use a combination of two algorithms. E.g. use merge sort to break down large arrays until they reach a array certain size, then use insertion sort to sort the smaller units and merge them again with merge sort.

See Timsort the current default implementation of Python and Java 7 sorting that use this technique.


答: Decryption is often 0(1). For example the key space for DES is 2^56, so decryption of any message is a constant time operation. Its just that you have a factor of 2^56 in there so its a really big constant.   </p>


答: Matrix multiplication. The naïve O(n^3) algorithm is often used in practice as faster than Strassen's O(n^2.8) for small-ish matrices; and Strassen's is used instead of the O(n^2.3) Coppersmith–Winograd algorithm for larger matrices.</p>


答:
If you really, really sure that doSomething will never ever need different implementations depending on the context (e.g. for testing), make it static, which gives you a utility class like java.lang.Math.

Using a singleton is considered more and more a bad idea: If it is possible that you need different implementations later, you should better use the factory pattern: The factory returns an implementation for an interface that defines doSomething.

The best solution in my opinion is using a dependency injection framework, which goes one step further than a factory by doing all the initialization in the background. E.g. using Google Guice you could write something like

```<code>public interface DoIt {
   void doSomething(Blubb blubb);
}

class User {

  @Inject DoIt doit;  //injected by the DI framework

  public void process() {
     Blubb blubb = new Blubb();
     doit.doSomething(blubb);
  }
}
</code>```

Of course you need to have some DoIt implementation, and you need to configure your "bindings" in the background, but the important point is that User doesn't know which DoIt was used or if it is a singleton or not. It is completely decoupled from such setup details, which can be changed without touching anything in User.

Title: Static functions question

Body:
If you really, really sure that doSomething will never ever need different implementations depending on the context (e.g. for testing), make it static, which gives you a utility class like java.lang.Math.

Using a singleton is considered more and more a bad idea: If it is possible that you need different implementations later, you should better use the factory pattern: The factory returns an implementation for an interface that defines doSomething.

The best solution in my opinion is using a dependency injection framework, which goes one step further than a factory by doing all the initialization in the background. E.g. using Google Guice you could write something like

public interface DoIt {
   void doSomething(Blubb blubb);
}

class User {

  @Inject DoIt doit;  //injected by the DI framework

  public void process() {
     Blubb blubb = new Blubb();
     doit.doSomething(blubb);
  }
}

Of course you need to have some DoIt implementation, and you need to configure your "bindings" in the background, but the important point is that User doesn't know which DoIt was used or if it is a singleton or not. It is completely decoupled from such setup details, which can be changed without touching anything in User.


答:
I have programmed in COBOL for several good years. Its syntax is simple compared to today's languages and you don't need to much theory to learn to get going. COBOL worked very well with IBM's CICS (an on-line transaction management system) and the programmer needs to do noting in the code to scale the application number of users from 1 to several thousands. CICS provided a character based GUI that worked with a screen as a unit of display (no windows). You could display charts using (IBM's GDDM) on the mainframe. COBOL can talk to indexed files (VSAM and ISAM) as well as DB2 (SQL based relational) and also IMS.
COBOL/CICS is a very robust environment and you can learn it in few weeks. That means you focus on the business not on the technology, so you work 7 out of the 8 hours on coding not at learning MVM, JavaScript and the like.

The issue with COBOL is bad marketing that lead to lack of interest from 3rd parties to develop tools and programming environments for it. Also, its lack of support to Windows like interface caused its popularity to decline after 1993. The mainframe cost lead customers to look for alternatives and compilers for COBOL was available in UNIX and DOS. The C language drew much of the light as it was able to be more portable and had direct access to OS functions which is something COBOL had very little of.

Languages like VB, DBase,FoxPro and Clipper had better ways to access 'databases' on the PC than the comparable COBOL on DOS so COBOL lost. CICS was not made cheap on DOS or UNIX for a long time, so its value was not present on these environments.

Today, COBOL is supported with .NET but I guess that it has lost the battle on all platforms except the mainframe (and possibly AS/400) where it is still there because of the huge number of mission-critical applications that are fully dependent on it.

Title: Why the scorn for COBOL?


答:
Bubblesort in memory can outperform quicksort when the program is being swapped to disk or need to read every item from disk when comparing.

This should be an example he can relate to.


问:
Which algorithms and data structures should a developer absolutely know?
I want to be a successful enterprise Java developer. With what algorithms and data structures should I be well versed? What books would you recommend to me?

To be a successful Java developer, do I need to know all the advanced algorithms such as those given in CLRS?

Can you suggest a list of the topics that I should learn in the descending order of their priority?

Must I know:

Searching?

Sorting?

Graphs/Trees?

etc?

答: In addition to the other answers, I would just like to add that the study of algorithms is not just for knowing about well-known techniques (which is still important), but also to be able to understand about the thought process that goes into devising a solution to a problem you run into in real life, not necessarily well known.</p>