答:
There are lots of strategies you can use, but you'll usually need approval or buy-in from management.

Pay developers overtime at an increased rate. Working extra hours isn't so bad when you're making a lot of extra money doing it. And if it starts to affect the company's bottom line management will apply pressure to sales to do a better job estimating.

Pay salespeople based on profit instead of gross sales. Every hour of work that they don't include in their estimate adversely affects their commission.

Limit the number of hours developers can work to 40 (or whatever the standard work week is in your part of the world).

Make the sales folks work every hour that the developers work. If they want you working extra hours to get their project done, they've got to be there too. Find something useful for them to do, like writing documentation or producing calligraphed, hand-illuminated copies of Design Patterns and The C++ Standard Template Library.

Have developers estimate each job instead of letting salespeople do it. At least this way you get some ability to make the schedule more reasonable. This isn't a great solution, though... developers are often terrible at estimating work required. Even if the estimate is reasonable, unforeseen events can prevent you from hitting your target. Also, we all tend not to work at the beginning of a long project with the same urgency that we do as the deadline approaches. These are the factors that motivate the short development cycles that the Agile proponents espouse.

Take the "agile" approach and refuse to commit. Going agile will require a lot more customer involvement, but it can also give the customer more flexibility because they don't necessarily have to commit up front to the final form of the project either. Sales might not be happy about that at first, but they might change their tune when they realize that it can provide a lot of opportunities to sell more work.

I think the least attractive solution is anything that makes the sales team look bad in the eyes of potential customers. The sales team is the face of the company. Making them look bad hurts the entire company, and it might not solve the problem -- they might feel like they need to make an even better deal for the customer in order to regain their confidence.


问:
Is there a way to combat Sales perpetually overcommitting?
I seem to be repeatedly stuck in a situation where release dates are set not based on anything technical, but because someone in Sales has committed to a customer by then.  Based on discussions with friends in development at other companies, the same thing seems to happen.

"Here is the committed feature set and here is the committed release date", and it's difficult to argue because at this point there is money riding on it, and that trumps everything.

In general, is there a way to push back on this?  If not for this release, what about in future?  The problem I have is that the only way I see one way of doing so, and that's by doing the best I can, but release the software 'as is', so to speak.

I don't want to release bug-ridden software since it's my name attached, but doing 80 hour weeks for months at a time just vindicates the arbitrarily set release date.

edit: for the record, I'm not doing 80 hour weeks now, just that comes to mind as what would be required to cover the expected feature set by the release date.

答:
I've worked both sides of the house.  Remember without sales people there would be no downstream jobs or projects.

How to battle sales over-commitment:  Estimate, then take at least a 130% multiple (always plan a minimum 30% contingency).  Provide and document said estimate.  Realize that your effort estimates will be reduced in the sales process.  That's OK, just have management carve out of the license/sales/commission agreement any reduction of those hours.  If you're a public company this gets tricky with VSOE, but until you hit the sales folks with contract accountability up-front during their sales process, it will become your accountability later.

ContentLicense: CC BY-SA 3.0


问:
Is "Computer Science != Software Engineering" an excuse to teach programming poorly?
We've all heard it; whenever there's a discussion about CS grads having poor development skills someone eventually says,

Computer science isn't software engineering.

The problem that I see is that programming and software development are taught in CS courses. They're just commonly taught poorly. If it's being taught, then why not teach it right the first time? *

So I would like to see what the opinions are on 2 questions:

Is the CS != SE argument a copout or excuse for not properly teaching programming skills.

Regardless of your answer to question 1; if you were in the almighty position of making such a decision: would you force an emphasis on proper teaching of programming in CS courses?

*. I have a suspicion, based on anecdotal evidence I obtained throughout my education, that most academics in the field haven't had to write code to be maintained and haven't maintained code, and as a result don't have the knowledge/skills to teach it effectively.

答:
I think the answer is yes (in a way).

The thing is it is not possible to teach to kids in a short period of time programming. They  should be tought the programers logic thinking, how to solve (in a smaller scale) the programmer´s problems.

I´m certain the school´s programms should be revised, I my very small "third world" country, fortunately, an effort is being made for this to happen. We are the first country to implement OLPC program; http://laptop.org/en/

ContentLicense: CC BY-SA 2.5


答:
There is absolutely no way to combat this entirely.  The very nature of sales is over-committing.  As a sales rep you are there to make the prospective customer's problems magically disappear.  Good sales reps will only slightly exaggerate, bad ones will cause themselves big embarrassment.

Anything you do will only cause aggravation or tension between the product people and the sales people (at least).  You can try very hard to prevent really bad gaffs on the part of your sales reps, but at the end of the day the devs and sales reps get paid out of the same bank account.  Your company will succeed or fail as a unit so starting a civil war with sales isn't going to help.

If you have one or more sales reps that are habitually embarrassing themselves, then the sales management will take care of the problem.  As a dev, you aren't going to have the clout to do anything about it so you should focus on delivering the best product you can with the time and resources that they give you.

Title: Is there a way to combat Sales perpetually overcommitting?

Body:
I seem to be repeatedly stuck in a situation where release dates are set not based on anything technical, but because someone in Sales has committed to a customer by then.  Based on discussions with friends in development at other companies, the same thing seems to happen.

"Here is the committed feature set and here is the committed release date", and it's difficult to argue because at this point there is money riding on it, and that trumps everything.

In general, is there a way to push back on this?  If not for this release, what about in future?  The problem I have is that the only way I see one way of doing so, and that's by doing the best I can, but release the software 'as is', so to speak.

I don't want to release bug-ridden software since it's my name attached, but doing 80 hour weeks for months at a time just vindicates the arbitrarily set release date.

edit: for the record, I'm not doing 80 hour weeks now, just that comes to mind as what would be required to cover the expected feature set by the release date.


问:
Example of where Functional Programming is Superior to Imperative or Object-Oriented Programming?

Possible Duplicate:

  Which problems domains are more suited  to functional programming solutions

I've been reading about functional programming.  I've been using mostly C#.net recently, and I would like to know of a good real-world example of where a functional language such as Lisp or F# would be a clearly superior tool for getting a job done.

答:
Functional programming is commonly used in academics. Some would argue that it is superior in teaching. It also is good for massive concurrent systems.

Most of what you're asking can be answered by several previous questions:

Lisp usages: https://stackoverflow.com/questions/794450/what-is-lisp-used-for-today-and-where-do-you-think-its-going

F# usage: https://stackoverflow.com/questions/36756/f-what-are-you-using-it-for

Haskell usage: https://stackoverflow.com/questions/1604790/what-is-haskell-actually-useful-for

Erlang usage: https://stackoverflow.com/questions/1636455/where-is-erlang-used-and-why


答:
It all comes down to one critical point; If you don't think you can sustain the pace necessary to meet the schedule Sales promised, then do not commit to the work. If Sales overpromises, it's not your problem, until you agree to the work. THEN it's your problem. Remind your boss that all the sales guys have to do is say yes and they get the check; you're the one that actually delivers on the promises, so if you say it won't work, your boss should be listening. If you have the ill fortune of having a manager who listens to his sales force more than his development force regarding what is and isn't possible, then you have the Dilbert-esque PHB, and you should be updating your resume.

This is one reason I like Agile; the development team is involved in the process from the initial design discussions. You can calibrate a "point" from both ends; the dev team decides (either explicitly or empirically) roughly how much development man-hours are inherent in a point, which management can then use to calculate points per week, points per month, etc which leads to a dollar figure. At that point, your sales team now has figures relating to the cost and time required for the current staff levels to get the current amount of scope done. If they overpromise once they have those numbers, they are out on their ass.


问:
C++ skills higher than C skills?
I feel that the often seen C/C++ doesn't really describe my skills in my CV. So I'm planning to separate it into advanced C++ knowledge and mediocre C skills.

Do you think this is confusing for the reader? She could think: "C is a subset of C++, so what is this guy trying to tel me?" Well, what I'm trying to tell is: I have done several real world C++ projects while pure C projects where just a hobby thing. Do you agree that a skilled C++ programmer not necessarily is a qualified C guy or do you think that this switch is done easily?

答:
You have asked so many questions in one; let me try to answer while segregating them. I hire many people which falls in this profile type and quite often i have to take so many interviews and reject people because often they don't quite have clear answer to the questions you asked.

Is having good mastery in C or C++ is good enough to qualify you for the other program?

If you are at a senior level actually NO. i.e. if you have been something like 6 years doing C++ programming on some core enterprise applications, and now i am trying to put you in embedded systems which is all in C - likely that your programming syntax and how to debug stuff is not an issue. But If you need think through of a problem - you are certainly very messy. This is true from either side to the other language. The more years you have been spending only one type of language - less easy to transform in other form! It is not about whether you can learn the syntax of language but you actually think differently when you are in C, C++, Java, perl and Python. To stretch the question - most often - C++ and Java guys can be used interchangeably and so is Perl,PHP, Phython. C is quite a different breed!

If you are a relatively young guy - chances are that you can catch up fast.

Does it mean that i have higher skill when i know C++ rather than C

Actually No. No because, as a general rule, if you are capable of creating a full product out of C is much more difficult task compared to doing it in C++. Number of people who can master troubleshooting shared memory systems are much less than number of people who can write a decent GUI program using VC++ or similar framework.

Does this mean knowing C (or the lowest level programming) is the highest level of achievement?

No again! This is not contradiction. This time it depends on the domain you compare. If you are looking at systems programming inside the Linux kernel, or something very close to hardware, programming ability in C is more relevant, However, if you are writing banking software or some business rule engines - C++ is a usually natural choice. The point is your true strength is not much about the syntax of the language but the way you solve a class of problems and you can only hope to master a few catagories/domain in your life. If you are putting something in your resume - that is what really counts.

Does it mean that if have only been in C - i don't know Object oriented programming?

Not at all. In fact, my litmus test in the interview to know whether guy is from C background or C++ is to ask a very simple question - "So can you do Object Oriented Programing in C?" - the guy jumps and says - "Definitely NO!" he/she is C++ fellow. The point is, when you really write very complex code like multimedia code, a multi-threaded system, a protocol layer stack, you still 'think like object code' - C compiler doesn't punish you if you are bad at encapsulating two routines or objects - but when the system scales that keeps firing you - i believe at times - there are many who are born in the era of object orientation, quite often are fairly weak on exactly how encapsulation really gets violated in a code which is pretty much filled with classes and objects. Sorry i digressed. But the point is - it is more of your skills of problem analysis and design that matters more than your programming skills alone.

Does it mean i should put domain specific exposure and design skills saperately?

Definitely yes!

Title: C++ skills higher than C skills?


问:
How best to prevent having to revisit a change after check in
Normally what happens is that I work on something for a while and then when I am done I check it in(After the test/review process of course).  Sometimes I have to go back and fix something that I got wrong the first time due to me not understanding the problem enough, lack of testing, etc..

What is an acceptable rate for this?  Ideally you would hope that you never have to go back but sometimes you do.  What rate does the average programmer have and what is the expert programmers rate?  Do people track this?  Lastly what kind of checks are best at preventing this?

PS: I am not counting the cases where the requirements have changed and you have to go back in.

I know that there is no real answer to this so let me change the actual question to: "What general checks could be implemented, before code is sent for review or checked in, that would help prevent the need to revisit the change later?"

答:
It's impossible to quantify. What is important is the total impact those bugs have, not the total number of bugs. </p>

<p>I would recommend you to look into Test Driven Development/Unit Testing if you want to reduce the number of bugs in your code. </p>

Body:
It's impossible to quantify. What is important is the total impact those bugs have, not the total number of bugs.

I would recommend you to look into Test Driven Development/Unit Testing if you want to reduce the number of bugs in your code.


答: I agree that 4 years is only enough time to give them a good foundation on which to grow. However, I think one thing that really helps is when people from the industry get involved in developing the curriculum and even teaching in the classroom. Last year I was an Industry Fellow in a Software Development class at a local university. It was a very eye-opening experience for me. The professor and I worked together on the course content and we put a lot more information about the development process, industry best practices, and "real-world" situations then they had been doing before. What we discovered was that, because most of the instructors do not develop widely used and maintained code, bringing in someone from industry helped to identify and teach the skills needed to do that. The professor did all the grading and provided the teaching expertise that I lacked. </p>

Title: Is "Computer Science != Software Engineering" an excuse to teach programming poorly?

Body:
We've all heard it; whenever there's a discussion about CS grads having poor development skills someone eventually says,

Computer science isn't software engineering.

The problem that I see is that programming and software development are taught in CS courses. They're just commonly taught poorly. If it's being taught, then why not teach it right the first time? *

So I would like to see what the opinions are on 2 questions:

Is the CS != SE argument a copout or excuse for not properly teaching programming skills.

Regardless of your answer to question 1; if you were in the almighty position of making such a decision: would you force an emphasis on proper teaching of programming in CS courses?

*. I have a suspicion, based on anecdotal evidence I obtained throughout my education, that most academics in the field haven't had to write code to be maintained and haven't maintained code, and as a result don't have the knowledge/skills to teach it effectively.


问:
HTTP requests/responses analyser for Android
When using Firefox on my PC, for example, HTTP analysis is quite easy using for example the Net tab of Firebug. GETs, POSTs, etc., all there.

What would be the best technique to see the HTTP requests an Android app sends? Another app? Some kind of hack via Wi-Fi and a router or USB modem?

答:
If you want to see outbound traffic from Android app to outside world, you can tap it if it passes through a local LAN. i.e. example if the HTTP request is going through 3G - that might not be possible,but through wifi, you can tap it at the LAN level. Basically, you can put any sniffer machine somewhere which runs something like wire-shark running on it.

If you are bothered about requests going to a particular application, server you can set the target URL as one of your local LAN server and tap it on the server side (using logs or sniffer).


答:
Many of the functional languages were designed for use in high-uptime systems. Erlang, for example, is the language behind the logic of most of our cell phone carrier systems (those built on Ericsson nodes, at least). Those systems are expected to provide very high levels of availability (we're talking Nine Nines, 99.9999999% uptime; that's something like 30 milliseconds per year of allowable downtime) while at the same time remaining modular and highly scalable. You do that with some of the features built into many functional languages, like hot-swappable code (no need to recompile DLLs and restart the system; just put the new package in there and the next call into that package will be with the new code).

Apart from that, many ideas in computing are most easily expressed functionally. Functional programming is inherently recursive and highly parallelizable, so tasks that are best designed in such ways lend themselves well to functional languages. Parallelization in particular is becoming more and more important as the power of a CPU is being increased by adding execution units to the chip instead of increasing clocks. File processing and other ETL tasks are definable functionally and benefit greatly from throwing more threads at the problem.

Title: Example of where Functional Programming is Superior to Imperative or Object-Oriented Programming?

Body:
Possible Duplicate:

  Which problems domains are more suited  to functional programming solutions

I've been reading about functional programming.  I've been using mostly C#.net recently, and I would like to know of a good real-world example of where a functional language such as Lisp or F# would be a clearly superior tool for getting a job done.


问:
Naming conventions: camelCase versus underscore_case ? what are your thoughts about it?
I've been using underscore_case for about 2 years and I recently switched to camelCase because of the new job (been using the later one for about 2 months and I still think underscore_case is better suited for large projects where there are alot of programmers involved, mainly because the code is easier to read).

Now everybody at work uses camelCase because (so they say) the code looks more elegant .

What are you're thoughts about camelCase or underscore_case

p.s. please excuse my bad english

Edit

Some update first:

platform used is PHP (but I'm not expecting strict PHP platform related answers , anybody can share their thoughts on which would be the best to use , that's why I came here in the first place)

I use camelCase just as everibody else in the team (just as most of you recomend)

we use Zend Framework which also recommends camelCase

Some examples (related to PHP) :

Codeigniter framework recommends underscore_case , and honestly the code is easier to read .

ZF recomends camelCase and I'm not the only one who thinks ZF code is a tad harder to follow through.

So my question would be rephrased:

Let's take a case where you have the platform Foo which doesn't recommend any naming conventions and it's the team leader's choice to pick one. You are that team leader, why would you pick camelCase or why underscore_case?

p.s. thanks everybody for the prompt answers so far

答:
I tend to prefer camelCase for the silly reason that I do most of my development in Eclipse (For Java, PHP and JavaScript), and when I Ctrl+← or Ctrl+→ through words, it actually stops at the camelCase boundaries.

I.e.: myIntVariable would be treated by Eclipse as 3 words when Ctrl+← →'ing through it.

I know it's a weird quirk, but I find myself preferring being able to edit the middle words in a camelCase name.


答:
Functional programming is superior across the board. I have not found a case where a functional programming language, or a more functional style in an imperative language, is a bad solution to a problem.

It’s simply a lot easier to get things done when the language is more expressive. It’s not about terseness—though that is a side effect—but rather about being able to understand and reason about more of your program at once. In a functional language, you don’t always have to write a description of how to compute what you want—you can write a description of what you actually want.

Using a functional programming language encourages you to think about your program in terms of data flow and computation, rather than state and mutation. It’s so much easier to solve problems functionally. And isn’t solving problems exactly what programmers are supposed to do?


问:
What's your favourite quote about programming?
What's your favourite quote about programming?

One quote per answer, and please check for duplicates before posting!

答:
If debugging is the process of
  removing software bugs, then
  programming must be the process of
  putting them in.

    — Edsger Dijkstra

LastEditorDisplayName: Roger Pate


问:
How to improve your ability to debug existing code
A common task in the working world is dealing with existing, but buggy code. What are some tips to improve your skills as a debugger?</p>

答:
Don't Assume Anything

It's often tempting to just say "oh, I know what this bit of code is doing, it's fine". Don't do that. Test every assumption and step through everything carefully.


答:
As to your original question, what's "acceptable" is impossible for us to answer. You yourself must decide how much reworking you can do while still moving ahead at the required pace of new development. Such has been the goal of project managers for decades.

No matter what system of development you're using (waterfall, UML, Rational Rose, Agile), two things are absolutely required:

The client must have communicated to you exactly what the code should do in the general case when performing some task. This isn't as impossible as it sounds; usually the "general case" breaks down to a "nominal case", an "exceptional case", and an "error case". The situations for these should be described and the expected behavior of the system in these situations defined.

Given requirements at a level of specificity that covers all expected scenarios, the code must adhere to the requirements. For the nominal, exceptional and error cases, the system should perform as defined before it is released to the customer.

Given these two things have happened for each task the system is capable of performing in all known situations, you have done all that is humanly possible to ensure a quality product. However, there will still be "defects"; the code cannot be guaranteed to perform as expected outside of the known scenarios, which may have inadvertently excluded some possible scenarios. That's not your fault as a developer; either you as an analyst did not think to ask what should happen in some particular case (probably because it seemed to fall into some defined situation), or the client did not properly define the requirements such that all possible cases were covered. Happens all the time. What happens as a result from a business perspective depends on the design methodology and business pattern, but you as a developer will probably eventually extend the code to cover the missed situations, and then you will verify that the system still works in all other situations.

This is where TDD really shines; if you accept that regression of functionality due to the introduction of defects in future work is possible, then it naturally follows that having a test that is always available to prove that the code will meet the requirements (and thus that you wrote what you thought you wrote) is an invaluable means to avoid said regression.

Title: How best to prevent having to revisit a change after check in

Body:
Normally what happens is that I work on something for a while and then when I am done I check it in(After the test/review process of course).  Sometimes I have to go back and fix something that I got wrong the first time due to me not understanding the problem enough, lack of testing, etc..

What is an acceptable rate for this?  Ideally you would hope that you never have to go back but sometimes you do.  What rate does the average programmer have and what is the expert programmers rate?  Do people track this?  Lastly what kind of checks are best at preventing this?

PS: I am not counting the cases where the requirements have changed and you have to go back in.

I know that there is no real answer to this so let me change the actual question to: "What general checks could be implemented, before code is sent for review or checked in, that would help prevent the need to revisit the change later?"


问:
Are Session implicit objects examples of Models in MVC?
I have read that the Model is responsible for maintaining state among HTTP requests, for example in this article:

The Model is responsible for maintaining state between HTTP requests.

Basically any data whether on a database, in a file, stored in the Session, or cached inside APC must be preserved between requests and thus forms part of the state of the application at the time the last request was completed. So always remember that the Model is not just the database. Even the data you get from web services can be expressed as a Model! Yes, even Atom feeds! Frameworks which rattle off introductions to the Model, almost never explain this upfront which only exacerbates misunderstandings.

When we use some implicit Session objects (say in PHP, JSP etc.,) does it mean that this Session is a Model object?

答:
From Wikipedia:

The model manages the behaviour and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller). In event-driven systems, the model notifies observers (usually views) when the information changes so that they can react.

That's the simplest definition of what a model is. If your session object has the facilities to respond to requests for information about its state and to instructions to change state, then you can definitely call it a Model.

It doesn't matter what the data storage is, remember that patterns are high level abstractions that are not supposed to be tied to specific implementations. You can build your models around every data storage facility, whether it's a database, some text files, LDAP, etc.

If it has the above discussed functionality, it's a model. Now, if it's a good / useful / efficient model it's a whole other discussion that greatly depends on how you use it.


问:
Basic premise on counting sort. How is k related to to Big Oh?
I am reading (Cormen) on counting sort.

I understand the structure of the algorithm but the statement:

In practice, we usually use counting sort when we have k = O(n), in
  which case the running time is Theta(n).

Is not clear to my mind.

k is just the range of integers expected in the input.

Why is the asymptotic notation used in this statement for k? I don't get it.

答: The complexity of a counting sort is O(max(k, n)), so if k = O(n) the sort runs in O(n) time.</p>


答:
At least as I interpret it, it's just saying that the range of the inputs and the number of inputs are kinda similar [Edit: least that be misunderstood, it's giving that as the condition under which the complexity is Theta(n), not saying that it's necessarily always true.]

Just for example, the usual estime is reasonable for a thousand or a million or a billion inputs of something like 32 or 64 bits each.

Ignoring, for the moment, the fact that you'd never actually finish, consider what would happen if you have a 500-digit (or 10,000 digit) number of 3-bit inputs. In such a case, the time taken to do each individual addition could start to become significant [Edit: I.e., would no longer be constant], so Theta(n) would no longer be accurate. In the usual case, we can ignore the time for the additions because it's a constant factor.

Title: Basic premise on counting sort. How is k related to to Big Oh?

Body:
I am reading (Cormen) on counting sort.

I understand the structure of the algorithm but the statement:

In practice, we usually use counting sort when we have k = O(n), in
  which case the running time is Theta(n).

Is not clear to my mind.

k is just the range of integers expected in the input.

Why is the asymptotic notation used in this statement for k? I don't get it.


答: Test your code. Make sure you have at least some unit tests around your code to check the tricky bits, and preferably completely covering any components that your changes touch. Run through the user stories you implemented to make sure they work as expected. Find out what tests the QA team will be performing to test the change, so you can try those tests out yourself.</p>


答: Understand functionally what the code is trying to do. If you don't know the complete picture (all test cases this code must pass) it's hard to debug properly without introducing new bugs</p>

Title: How to improve your ability to debug existing code

Body: A common task in the working world is dealing with existing, but buggy code. What are some tips to improve your skills as a debugger?</p>


答:
I agree that C and C++ are different languages and should be kept separate in the CV. Even though C is (almost) a subset of C++, I normally have a very different programming style when using C: I design differently, I code differently, and so on. I would even remove certain C features like #includes from C++ giving up backward compatibility altogether: they are simply different languages.

So my advice is to keep the two languages separate in your CV.

Title: C++ skills higher than C skills?

Body:
I feel that the often seen C/C++ doesn't really describe my skills in my CV. So I'm planning to separate it into advanced C++ knowledge and mediocre C skills.

Do you think this is confusing for the reader? She could think: "C is a subset of C++, so what is this guy trying to tel me?" Well, what I'm trying to tell is: I have done several real world C++ projects while pure C projects where just a hobby thing. Do you agree that a skilled C++ programmer not necessarily is a qualified C guy or do you think that this switch is done easily?


答:
Your quote is saying that if the range of integers k is linearly proportional to the total number of elements in the collection n, then a counting sort will have a best-case and a worst-case time complexity of O(n), making it a very efficient sort in such a case.

Big Oh (and others in the Bachman-Landau family of notations) are just simplifications of the precise complexity of the function in any given case, used to illustrate the increasing value of the function as N grows large. In programming, Big Oh is usually used in the context of time complexity; for n values, a function f(n) will execute in a time on the order of g(n), and thus we say it has a Big Oh complexity of O(g(n)). However the mathematical construct of Big Oh isn't so limited. In this particular case, it is being used to refer to the general relationship between k and N as numbers.

Simply put, when k (the range of the values of an n-element collection) increases as n does on the order of O(n), then the counting sort will be efficient. This will be true if, say, the list contained all multiples of 4 between 1 and x (in which case k~=x, and n=x/4, meaning that k ~= 4n = O(n)). The condition k=O(n) would be false for, say, the set of all perfect squares from 1 to x2 (in which case k=x2 but n=x, so k = n2 = O(n2)). In that case, k increases on the square (O(n2)) when N increases linearly (O(n)), so the counting sort would execute in the more complex time (which would be O(n2)), which would perform worse than some other sort implementation that ran in Theta(nlogn).


问:
Does having pagination lessens server load? (theory)
I was wondering what is the reason behind pagination? Is it used because it lessens the burden on the servers since we would technically limit the amount of rows returned per page?

I wanted to do something without pagination but given that I am new to this (I am an amateur) started wondering if its OK technically or not.

答:
The most value you gain from pagination is enhancing the speed of your application by:

1 - Limiting data transmitted between the client and the server. There is no point to read 1000000 customers if the user is looking for 10 of them.

2- Speeding the query performance significantly by retrieving only rows that can fit in a user's view. There is no point to read 1000000 customers if the user will look at the first 10 customers.

3 - Pagination helps by providing more fresh data. If your application shows many data rows and your application domain requires lots of update to data rows in the displayed table, chances are that by the time you go to page 20 of the list of pages, the data on some of the rows would have been changed. Think of an application that reads stock prices or available rooms in a  hotel. Retrieving old data and placing it on the client is of no use.

Pagination is one strategy that in combination with filtering and your understanding of how the end user needs from the particular scenario (which is expected to lead to a good design to serve this need) will greatly enhance the application specially when several users are hitting the database concurrently.

Pagination is not always trivial to program. In some cases it is simple but it is sometimes very complex to write so that the SQL query executes without performing a full table scan. This of course depends on your indexes, filter condition and your Where statement.


问:
How do you encourage your organization to move from Java to Scala?
Has anybody's organization started the migration from Java to Scala? If yes, how do you do that? What can I do to encourage my colleagues to do the same?</p>

答:
This question dove-tails in another question. That is for what kinds or projects does migrating to Scala provide added value? I do Java day my day job, but dream about the day I can use Scala "in anger".

A couple answers to my own question:

Problems for which Actor based concurrency would provide great benefit (Akka)

Web applications than have data pushed to them via COMET (Lift)

Any other insights or better yet experiences?


问:
How do you structure unit tests for multiple objects that exhibit the same behavior?
In a lot of cases I might have an existing class with some behavior:

```<code>class Lion
{
    public void Eat(Herbivore herbivore) { ... }
}
</code>```

...and I have a unit test...

```<code>[TestMethod]
public void Lion_can_eat_herbivore()
{
    var herbivore = buildHerbivoreForEating();
    var test = BuildLionForTest();
    test.Eat(herbivore);
    Assert.IsEaten(herbivore);
}
</code>```

Now, what happens is I need to create a Tiger class with idential behavior to that of the Lion:

```<code>class Tiger
{
    public void Eat(Herbivore herbivore) { ... }
}
</code>```

...and since I want the same behavior, I need to run the same test, I do something like this:

```<code>interface IHerbivoreEater
{
    void Eat(Herbivore herbivore);
}
</code>```

...and I refactor my test:

```<code>[TestMethod]
public void Lion_can_eat_herbivore()
{
    IHerbivoreEater_can_eat_herbivore(BuildLionForTest);
}

public void IHerbivoreEater_can_eat_herbivore(Func<IHerbivoreEater> builder)
{
    var herbivore = buildHerbivoreForEating();
    var test = builder();
    test.Eat(herbivore);
    Assert.IsEaten(herbivore);
}
</code>```

...and then I add another test for my new Tiger class:

```<code>[TestMethod]
public void Tiger_can_eat_herbivore()
{
    IHerbivoreEater_can_eat_herbivore(BuildTigerForTest);
}
</code>```

...and then I refactor my Lion and Tiger classes (usually by inheritance, but sometimes by composition):

```<code>class Lion : HerbivoreEater { }
class Tiger : HerbivoreEater { }

abstract class HerbivoreEater : IHerbivoreEater
{
    public void Eat(Herbivore herbivore) { ... }
}
</code>```

...and all is well.  However, since the functionality is now in the HerbivoreEater class, it now feels like there's something wrong with having tests for each of these behaviors on each subclass.  Yet it's the subclasses that are actually being consumed, and it's only an implementation detail that they happen to share overlapping behaviors (Lions and Tigers may have totally different end-uses, for instance).

It seems redundant to test the same code multiple times, but there are cases where the subclass can and does override the functionality of the base class (yes, it might violate the LSP, but lets face it, IHerbivoreEater is just a convenient testing interface - it may not matter to the end-user).  So these tests do have some value, I think.

What do other people do in this situation?  Do you just move your test to the base class, or do you test all subclasses for the expected behavior?

EDIT:

Based on the answer from @pdr I think we should consider this: the IHerbivoreEater is just a method signature contract; it does not specify behavior.  For instance:

```<code>[TestMethod]
public void Tiger_eats_herbivore_haunches_first()
{
    IHerbivoreEater_eats_herbivore_haunches_first(BuildTigerForTest);
}

[TestMethod]
public void Cheetah_eats_herbivore_haunches_first()
{
    IHerbivoreEater_eats_herbivore_haunches_first(BuildCheetahForTest);
}

[TestMethod]
public void Lion_eats_herbivore_head_first()
{
    IHerbivoreEater_eats_herbivore_head_first(BuildLionForTest);
}
</code>```

答:
This is great because it shows how tests truly drive the way you think about design. You are sensing problems in the design and asking the right questions.

There are two ways of looking at this.

IHerbivoreEater is a contract. All IHerbivoreEaters must have an Eat method which accepts a Herbivore. Now, your tests do not care how it is eaten; your Lion might start with the haunches and Tiger might start at the throat. All your test cares about is that after it calls Eat, the Herbivore is eaten.

On the other hand, part of what you're saying is that all IHerbivoreEaters eat the Herbivore in exactly the same way (hence the base class). That being the case, there is no point in having an IHerbivoreEater contract at all. It offers nothing. You may as well just inherit from HerbivoreEater.

Or maybe do away with Lion and Tiger completely.

But, if Lion and Tiger are different in every sense apart from their eating habits, then you need to start wondering if you are going to run into problems with a complex inheritance tree. What if you also want to derive both classes from Feline, or only Lion class from KingOfItsDomain (along with Shark, perhaps). This is where LSP truly comes in.

I would suggest that common code is better encapsulated.

```<code>public class Lion : IHerbivoreEater
{
    private IHerbivoreEatingStrategy _herbivoreEatingStrategy;
    private Lion (IHerbivoreEatingStrategy herbivoreEatingStrategy)
    {
        _herbivoreEatingStrategy = herbivoreEatingStrategy;
    }

    public Lion() : this(new StandardHerbivoreEatingStrategy())
    {
    }

    public void Eat(Herbivore herbivore)
    {
        _herbivoreEatingStrategy.Eat(herbivore);
    }
}
</code>```

Same goes for Tiger.

Now, here's a beautiful thing developing (beautiful because I didn't intend it). If you just make that private constructor available to the test, you can pass in a fake IHerbivoreEatingStrategy and simply test that the message is passed on to the encapsulated object properly.

And your complex test, the one you were worrying about in the first place, only has to test the StandardHerbivoreEatingStrategy. One class, one set of tests, no duplicated code to worry about.

And if, later, you want to tell Tigers that they should eat their herbivores a different way, none of these tests have to change. You're simply creating a new HerbivoreEatingStrategy and testing that. The wiring is tested at integration-test level.

Body:
This is great because it shows how tests truly drive the way you think about design. You are sensing problems in the design and asking the right questions.

There are two ways of looking at this.

IHerbivoreEater is a contract. All IHerbivoreEaters must have an Eat method which accepts a Herbivore. Now, your tests do not care how it is eaten; your Lion might start with the haunches and Tiger might start at the throat. All your test cares about is that after it calls Eat, the Herbivore is eaten.

On the other hand, part of what you're saying is that all IHerbivoreEaters eat the Herbivore in exactly the same way (hence the base class). That being the case, there is no point in having an IHerbivoreEater contract at all. It offers nothing. You may as well just inherit from HerbivoreEater.

Or maybe do away with Lion and Tiger completely.

But, if Lion and Tiger are different in every sense apart from their eating habits, then you need to start wondering if you are going to run into problems with a complex inheritance tree. What if you also want to derive both classes from Feline, or only Lion class from KingOfItsDomain (along with Shark, perhaps). This is where LSP truly comes in.

I would suggest that common code is better encapsulated.

public class Lion : IHerbivoreEater
{
    private IHerbivoreEatingStrategy _herbivoreEatingStrategy;
    private Lion (IHerbivoreEatingStrategy herbivoreEatingStrategy)
    {
        _herbivoreEatingStrategy = herbivoreEatingStrategy;
    }

    public Lion() : this(new StandardHerbivoreEatingStrategy())
    {
    }

    public void Eat(Herbivore herbivore)
    {
        _herbivoreEatingStrategy.Eat(herbivore);
    }
}

Same goes for Tiger.

Now, here's a beautiful thing developing (beautiful because I didn't intend it). If you just make that private constructor available to the test, you can pass in a fake IHerbivoreEatingStrategy and simply test that the message is passed on to the encapsulated object properly.

And your complex test, the one you were worrying about in the first place, only has to test the StandardHerbivoreEatingStrategy. One class, one set of tests, no duplicated code to worry about.

And if, later, you want to tell Tigers that they should eat their herbivores a different way, none of these tests have to change. You're simply creating a new HerbivoreEatingStrategy and testing that. The wiring is tested at integration-test level.


答:
It seems redundant to test the same code multiple times, but there are cases where the subclass can and does override the functionality of the base class

In a round-about way you're asking whether its appropriate to use white-box knowledge to omit some tests. From a black-box perspective, Lion and Tiger are different classes. So someone without familiarity with the code would test them, but you with deep implementation knowledge know that you can get away with simply testing one animal.

Part of the reason for developing unit tests is to allow yourself to refactor later but maintain the same black-box interface. The unit tests are helping you ensure your classes continue to meet their contract with clients, or at the very least forces you to realize and think carefully how the contract might change. You yourself realize that Lion or Tiger might override Eat at some later point. If this is remotely possible, a simple unit test testing that each animal you support can eat, in the manner of:

```<code>[TestMethod]
public void Tiger_can_eat_herbivore()
{
    IHerbivoreEater_can_eat_herbivore(BuildTigerForTest);
}
</code>```

should be very simple to do and suffice and will ensure that you can detect when objects fail to meet their contract.

Title: How do you structure unit tests for multiple objects that exhibit the same behavior?

Body:
In a lot of cases I might have an existing class with some behavior:

```<code>class Lion
{
    public void Eat(Herbivore herbivore) { ... }
}
</code>```

...and I have a unit test...

```<code>[TestMethod]
public void Lion_can_eat_herbivore()
{
    var herbivore = buildHerbivoreForEating();
    var test = BuildLionForTest();
    test.Eat(herbivore);
    Assert.IsEaten(herbivore);
}
</code>```

Now, what happens is I need to create a Tiger class with idential behavior to that of the Lion:

```<code>class Tiger
{
    public void Eat(Herbivore herbivore) { ... }
}
</code>```

...and since I want the same behavior, I need to run the same test, I do something like this:

```<code>interface IHerbivoreEater
{
    void Eat(Herbivore herbivore);
}
</code>```

...and I refactor my test:

```<code>[TestMethod]
public void Lion_can_eat_herbivore()
{
    IHerbivoreEater_can_eat_herbivore(BuildLionForTest);
}

public void IHerbivoreEater_can_eat_herbivore(Func<IHerbivoreEater> builder)
{
    var herbivore = buildHerbivoreForEating();
    var test = builder();
    test.Eat(herbivore);
    Assert.IsEaten(herbivore);
}
</code>```

...and then I add another test for my new Tiger class:

```<code>[TestMethod]
public void Tiger_can_eat_herbivore()
{
    IHerbivoreEater_can_eat_herbivore(BuildTigerForTest);
}
</code>```

...and then I refactor my Lion and Tiger classes (usually by inheritance, but sometimes by composition):

```<code>class Lion : HerbivoreEater { }
class Tiger : HerbivoreEater { }

abstract class HerbivoreEater : IHerbivoreEater
{
    public void Eat(Herbivore herbivore) { ... }
}
</code>```

...and all is well.  However, since the functionality is now in the HerbivoreEater class, it now feels like there's something wrong with having tests for each of these behaviors on each subclass.  Yet it's the subclasses that are actually being consumed, and it's only an implementation detail that they happen to share overlapping behaviors (Lions and Tigers may have totally different end-uses, for instance).

It seems redundant to test the same code multiple times, but there are cases where the subclass can and does override the functionality of the base class (yes, it might violate the LSP, but lets face it, IHerbivoreEater is just a convenient testing interface - it may not matter to the end-user).  So these tests do have some value, I think.

What do other people do in this situation?  Do you just move your test to the base class, or do you test all subclasses for the expected behavior?

EDIT:

Based on the answer from @pdr I think we should consider this: the IHerbivoreEater is just a method signature contract; it does not specify behavior.  For instance:

```<code>[TestMethod]
public void Tiger_eats_herbivore_haunches_first()
{
    IHerbivoreEater_eats_herbivore_haunches_first(BuildTigerForTest);
}

[TestMethod]
public void Cheetah_eats_herbivore_haunches_first()
{
    IHerbivoreEater_eats_herbivore_haunches_first(BuildCheetahForTest);
}

[TestMethod]
public void Lion_eats_herbivore_head_first()
{
    IHerbivoreEater_eats_herbivore_head_first(BuildLionForTest);
}
</code>```

Body:
It seems redundant to test the same code multiple times, but there are cases where the subclass can and does override the functionality of the base class

In a round-about way you're asking whether its appropriate to use white-box knowledge to omit some tests. From a black-box perspective, Lion and Tiger are different classes. So someone without familiarity with the code would test them, but you with deep implementation knowledge know that you can get away with simply testing one animal.

Part of the reason for developing unit tests is to allow yourself to refactor later but maintain the same black-box interface. The unit tests are helping you ensure your classes continue to meet their contract with clients, or at the very least forces you to realize and think carefully how the contract might change. You yourself realize that Lion or Tiger might override Eat at some later point. If this is remotely possible, a simple unit test testing that each animal you support can eat, in the manner of:

[TestMethod]
public void Tiger_can_eat_herbivore()
{
    IHerbivoreEater_can_eat_herbivore(BuildTigerForTest);
}

should be very simple to do and suffice and will ensure that you can detect when objects fail to meet their contract.


问:
How to maintain a demo version of an application?
I need to be able to demo our production application to prospective clients.  The way I have it setup today is simple.  The demo application is an exact duplicate of the production system, except that the data in the database is obfuscated to protect our current clients' data. This works great because it doesn't require any application changes.

Boss dropped a potential BOMBSHELL today and said that the demo system needs to contain a special link and that ONLY shows up on demo.  He went on to explain that in the future there may be much bigger differences between the demo and production apps (e.g. an entire area of functionality).  What do I do now?

Some things I have thought about doing:

Maintain a different branch in subversion specific to the demo system

Create an installation package that has the changes for demo, then revert and build a production installation package

Modularize the application (no idea how)

Say: "Screw you! I will not do it!" (LOL)

Use some sort of conditional logic in the app to determine if it is a demo or a production app.  E.g. (if the URL contains 'demo' then show else hide).

If you haven't guessed by now, this is a web application

Anyways, I have no experience in this scenario as to which one is better or if none of these are any good.  Anyone have an answer, strategy, something!?

答:
The best approach would be to modularize so you can turn items on or off in any app.

Your demo is a prod install, with a config that turns on different things than the actual prod app and points to a different database.


答:
You're doing it right. Think of a unit test as the test of the behavior of a single usage of your new code. This is the same call you would make from production code.

In that situation, you're completely correct; a user of a Lion or Tiger will not (won't have to, at least) care that they're both HerbivoreEaters and that the code that actually runs for the method is common to both up in the base class. Similarly, a user of a HerbivoreEater abstract (provided by the concrete Lion or Tiger) won't care which it has. What they care about is that their Lion, Tiger, or unknown concrete implementation of HerbivoreEater will Eat() a Herbivore correctly.

So, what you're basically testing is that a Lion will Eat as intended, and that a Tiger will Eat as intended. It's important to test both, because it may not always be true that they both eat exactly the same way; by testing both, you ensure that the one you didn't want to change, didn't. Because those are both of the HerbivoreEaters defined, at least until you add Cheetah you have also tested that all HerbivoreEaters will Eat as intended. Your testing both completely covers and adequately exercises the code (provided that you also make all expected assertions of what should result from a HerbivoreEater eating a Herbivore).


答:
Maintain a different branch in subversion specific to the demo system

Yes! This helps truly. But be careful in how you do it. Best is when main system evolves, you should know how to bring down your changes to as close as possible.

Create an installation package that has the changes for demo, then revert and build a production installation package

This might work - but if you are doing many demos - you will loose your good part of life on this.

Modularize the application (no idea how)

This is the best answer. See below.

Say: "Screw you! I will not do it!" (LOL)

Definitely no! Not because you should be afraid. But good engineer doesn't quit challenges.

Use some sort of conditional logic in the app to determine if it is a demo or a production app. E.g. (if url contains 'demo' then show else hide).

Definitely no! This would make your product very weak over time.

When you think of a Demo product (unless you are talking about trail versions) - don't think like a 'separate product' but think of it as a 'separate environment'. If you and me both install word-press engine in our respective sites, we will have same product but different data. You must architect your product such that installation (and usage) specific stuff - can be created like how one create different content sources. Similarly, for example - you are making a native .Net or JAVA application, the functionality remains the same - but where it get's visuals (including splash screens and buttons) from can be different folders to show them in different form. Later on - the demand will come to even alter the layouts - that's when you know you need more template stuff!

Don't jump for the modularization in one-shot. As and when requirement comes, first begin a separate branch (line of development) and give the demo! (Because all demos are typically next day morning 10:30 AM). The deviation you now created tells you what modularized should have been there to be picked up from external resources. Apply that and merge it back- next time same demo would be your standard version (with different URL).

Almost always if you end up making "separate product" as a demo - you are inviting trouble or pain or both!

Dipan.

Title: How to maintain a demo version of an application?

Body:
I need to be able to demo our production application to prospective clients.  The way I have it setup today is simple.  The demo application is an exact duplicate of the production system, except that the data in the database is obfuscated to protect our current clients' data. This works great because it doesn't require any application changes.

Boss dropped a potential BOMBSHELL today and said that the demo system needs to contain a special link and that ONLY shows up on demo.  He went on to explain that in the future there may be much bigger differences between the demo and production apps (e.g. an entire area of functionality).  What do I do now?

Some things I have thought about doing:

Maintain a different branch in subversion specific to the demo system

Create an installation package that has the changes for demo, then revert and build a production installation package

Modularize the application (no idea how)

Say: "Screw you! I will not do it!" (LOL)

Use some sort of conditional logic in the app to determine if it is a demo or a production app.  E.g. (if the URL contains 'demo' then show else hide).

If you haven't guessed by now, this is a web application

Anyways, I have no experience in this scenario as to which one is better or if none of these are any good.  Anyone have an answer, strategy, something!?


问:
What scripting language to use for large file transfers on windows xp client machines
I'm a java developer that is tasked with creating some scripts that will handle large xml document file transfers by hitting some web service api's from windows xp client machines.  There may be other document formats involved like .pdf, .doc, .xls or .txt, but I'm not sure on that at this point.

I've looked into powershell, groovy, perl, but I'm not sure which one would be the best to use as I've not done work with any of those and there may be a better alternative than these three I've listed.

So for security, ease of deployment, and maintenance for the script (not overly complicated to write or large), what would fit the best for these requirements?

答:
You might find Jython interesting.

I find it really powerful being able to run Jython scripts from inside my Java programs, and instantiate Java classes inside my Python scripts. It's also nice to be able to re-factor a Jython class into a Java class for speed and then retest it using the unit tests you developed your Jython class with.


问:
How to become a JavaScript ninja?
I want to choose JavaScript as my main development field, alongside HTML and CSS to become a developer commonly known as front-end developer. But I don't know how to become a JavaScript professional. I've read many books and learned the pieces including data types, syntax, tools usage (like IDEs, Debuggers, etc.), jQuery, etc. But when I look at some sophisticated JavaScript codes including famous libraries, I'm like "I never could write that code". What's wrong here? What step should I had taken that I didn't? I feel I'm missing something here to become a professional JavaScript developer.
I also watched training movies, including Douglas Crockford's movies at Yahoo Theater.

答:
I wouldn't call me a master in javascript, but pretty good anyway.
Read, understand and code from like these books:

http://www.amazon.com/Pro-JavaScript-Techniques-John-Resig/dp/1590597273/ref=sr_1_2?s=books&ie=UTF8&qid=1320176633&sr=1-2

http://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742/ref=pd_sim_b_1

That would cover the basics. Then explore the whole field. Try to learn as much as possible.
Learn to debug code in Firebug.
Learn a couple of javascript frameworks (somewhat decently) - Jquery being the easiest.
Maybe Dojo toolkit, Mootools and Prototype.
Try to read and understand the source code of javascript frameworks.
Build a plugin in jQuery.
Learn the Module pattern.
There's a lot to learn..

But the most important rule of them all is:

Code and try to better yourself every day!

And don't just become a framework junkie who needs the latest plugin or framework to do anything good. Try to master the core language and do plugins or widgets from the ground up yourself. If you can't do that, then you ain't not great yet.

Title: How to become a JavaScript ninja?


答:
CS is in fact not SE. And people seem to conflate the two all the time, even while admitting it. Computer science should really be renamed something like Computology, or the science of computing. In fact, computer science has very little to do with computers. It's graph theory, algorithm analysis, data structures, etc.

People want to assume a fresh CS grad is actually an ITT grad; they want someone who has been trained in a vocation. Computer science is science, programming is an art. These are not the same.

This is like asking why a fresh Physics grad isn't a good car engineer. It's silly.


答:
Definitely practice - but, IMHO, it's better not just to do busy work for practice; find a real problem to solve.  Think of something cool to accomplish, and go write it.  Find someone who want some javascript work done either for free (like for a charity or non profit) or for way cheap, and write code for them.  In other words, your best pratice will occur doing something meaningful.

Also - I think javascript is a really interesting and actually very powerful language - but I learned more about programming in general in the college C class I took years ago than from any one source before or since.  Learning C came with learning about how computers think, about memory in bits an bytes, and I had a pretty decent teacher who emphasized some really solid foundational programming practices.  The guy that said learn another language weren't completely wrong - learning another langauge changes your view of programming a bit and makes you appreciate the similarities and differences.

Title: How to become a JavaScript ninja?

Body:
I want to choose JavaScript as my main development field, alongside HTML and CSS to become a developer commonly known as front-end developer. But I don't know how to become a JavaScript professional. I've read many books and learned the pieces including data types, syntax, tools usage (like IDEs, Debuggers, etc.), jQuery, etc. But when I look at some sophisticated JavaScript codes including famous libraries, I'm like "I never could write that code". What's wrong here? What step should I had taken that I didn't? I feel I'm missing something here to become a professional JavaScript developer.
I also watched training movies, including Douglas Crockford's movies at Yahoo Theater.


答: Simply, if the person evaluating you had the propensity to think "C is a subset of C++," they're already confused, and I'm sure your explanation of what's written in your resume will be enough to wow them.</p>

Title: C++ skills higher than C skills?


答: Practice in the field and JQuery. This is the best advice I can give.</p>

Title: How to become a JavaScript ninja?


答:
Funny you should phrase your question this way. Most books on basic javascript do not help you understand why and how certain aspects of JavaScript should be used in order to achieve great code. What really REALLY helped me understand the more advanced side of JavaScript as well as best coding practices were the writings of John Resig, the lead engineer of JQuery.

http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=John+Resig

Particularly:

Pro JavaScript Techniques

Secrets of the JavaScript Ninja

These help you understand how advanced JavaScript features should be used and why. You may also want to read up on Patterns and Agile Principles, and in particular the writings of Martin Fowler for more generalized thoughts on best coding practices.

Title: How to become a JavaScript ninja?


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

What is your experience regarding code reviews?

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

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

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

答: Code Review is, IMO, needed. You're 99.999...% of the time not always going to be right, so you need to make sure it is correct. Do I have a set time? No. But I do take the time to check over my code. Usually I have a colleague do the same.</p>

OwnerDisplayName: Simeon

ContentLicense: CC BY-SA 4.0


问:
Can someone find a job as a programmer without an education?
Interested in knowing from the more experienced ones if someone can find a job as a programmer without even a highschool degree. Consider the said person to be an average programmer. Would someone even consider giving him/her a chance on an interview ? The languages of interest would be python/php/java/c#

Please answer for your region/city/country only. No "go back to school" answers please.

答:
Not without an education, no. But without a formal education, yes.

There is programming knowledge that is categorized horizontally (problem-solving, logic, software architecture, OOP, security, etc.) and vertically (iPhone, *NIX, CICS, bash, PERL, XML, etc).

There's also industry-specific knowledge you need to familiarize yourself with. Health care. Automotive. Systems Programming. Scientific computing. ERP. Manufacturing. etc.

But the key here is to realize your primary education is to acquire the skill to sell yourself.

One of the first facts a salesman learns is you don't win over the person with the checkbook, you win over the person who controls the person with the checkbook. HR manages the legal and administrative details of its relationship with employees. You don't want to go through HR unless you want to write programs for HR.

You've got to hit the department with the need for the type of programs you want to write. Instill in them the emotional bond that their future success requires them to get you on-board (which, once you've taken the time to learn what they do, how they do it, and their culture, won't be hard).

Take the time to develop a lot of practical software that applies to the department and industry you want the job in, for the programming environment typical in that industry. Plus a few more in related departments/industries/environments. And one or two in unrelated ones.

Odds are managers already know what graduates are like. You've got to be the iPhone of programmer candidates. The new, shiny that already fits into their culture and industry.

For end-user application development, become acquainted with their products and learn their features and their bugs. Learn it better than their salesmen. (It's a big bonus if you're familiar with their competitor's products too.) Hang out with their customers, and see what their needs are and how they use the software. Then go to conferences, user groups, networking events where salespeople interact with potential customers.

Salespeople have been known to varnish the truth. Don't call them out on it (publicly) and don't torpedo the sale. Listen to what objections prospects have about the product and how sales handles them. If you make a suggestion for a feature that the customer really wants you can ingratiate yourself to the sales department, and they can exercise their pull to get you hired. Because $$$ (or your local currency) makes the decisions. So don't torpedo the sale.

Maybe you find a hole in their product that you can fill by writing and selling your own product. Then they buy your company. That's another way to end up hired by a company without having a formal education.


问:
Micro vs Monolithic Server architecture
We are currently working on our new product/project, it is a client-server application directed towards certain specific industrial/service enterprises. We are building a server (C Language and Linux Only) running a custom protocol on top of TCP with a Java front-end. We are about 20% into the coding work and are faced with a situation having to choose between Micro or Monolithic Kernel Architecture.

I am aware that Micro vs. Monolithic is usually in relation to kernel architecture, but we are specifically talking about servers.

Why a custom server and not something existing?

Our UI needs are significant and very dynamic, thus Web/Web-browser based solutions were not appropriate.

The statistical processing is significant at the client end and therefore, again, browsers were of little help. (Of course, we could do the processing at the server end and pass on the processed data to the client but that would imply lot of load on the server and wastage of client resources).

Moreover, with atleast three technologies (JS/HTML/CSS) to manage even a single event makes the whole experience like sweeping the house in the midst of a desert storm - you sweep it n-times, the dust accumulates n+1 times.

What about Micro and Monolithic Server? What are you talking?

Consider the following (hypothetical) client request:

```<code>request-id: 123
request-service: HistoricDataSets
request-message: Fetch all records upto the year 2010
</code>```

On receving such request, a server, typically, does (we are ignoring concurrency techniques like thread and forks for simplicity):

Parse the request string

Identify the action (Fetch HistoricDataSets LIMIT  Year (2010) in our case)

Interact with the persistance layer (Oracle, lets say, in our example) and fetch the data.

Format the data as per the protocol. Ex:

response-id: 123

success: true

response-text: DataSets

Respond to the client with the thus formatted data.

This is what we are calling a Monolithic Server (akin to a monolithic kernel where all OS workings are done in the kernel space).

Consider the same request again, on receipt, this time the server (we have assumed only shared memory as IPC, again for simplicity):

Puts the request into the shared memory for the Parser process

The Parser parses the string, identifies the task and directs the Executioner process to execute the tasks.

The Executioner then passes the data to Fomatter process which, after formatting the data into a protocol string, returns to the server.

The server dispatches it to the client (response).

Of course, instead of Parser, Executioner and Formatter it could have been a single but separate process.  This is what we are calling a Micro Server (akin to a micro kernel doing barely minimum that is required). The server effectively is only listening and responding whereas all steps are taken care of by different process(es).

Which one to pick? We are confused! While monolithic servers are tried and tested (most HTTP-Web Servers?) and easier to program and can handle concurrency quite well. Micro servers, prima facie, seem swift and in line with UNIX principle of one program to do one task, but are also complicated to develop, esp. keeping concurrency in mind.

Question(s)

- What are (possibly could be) the pros and cons of each approach?

- When to use which? (It could also be interpreted as a general question: When to use IPC?)

- If Micro kernel is chosen, then what functions need to be a part of core-server and what not?

Similar/Related questions

Dangers of huge monolithic application

External Vs Embedded browser (Tangential)

Advice for converting Monolithic app into multithreaded (Tangential)

Some information that may be helpful:

Our prospective customers can be divided into two categories:

Large: About 1,700 - 2,000 requests per minute

Small: About 650 - 700 requests per minute

Data volume per request cycle (request and the subsequent response) can be assumed to be normally distributed with mean ~ 1.20 MB and worse case about 250-300 MB.

The product concept is relatively new but has the capability of impacting the core operations, therefore we expect the customer budgets to be flexible only post a certain lag (9-12 months) post deployment, this limits the amount of hardware the client will be willing to commit esp. the small ones.

Each customer will have his own client-server stack. The server will be running on the customer's hardware managed by the customer's team, while clients will be deployed on the machines of the functional employees

Remote updates for both client and server application is a must

Real time PUSH services by the server may be 'highly' desired if the product clicks!

答:
Economics sometimes govern much more critical answer than the core theory behind choices. The most important thing is that if you are looking at something 'vast' in your case, where you application needs genuinely tough deployment - the lesser the number of wheels you invent yourself, the better it is. If it works, i won't care if it is monolithic or micro; if it doesn't i won't care it either!

It may be true that very conventional Webpage based apps might not be for you - but you need to take a little broader look and see you can use things ready to go and later evolve your way out to see if you can replace that element by something better. That way, not only you will save time for the first thing - but you will also improve your understanding on what really matters in real life. Here are some pointers you might consider.

If you really need very high scalability, consider how your servers will divide the task rather than churn numbers as fast as they can. Eventually, you will have a load that one server cannot really take up even if intel makes fastest processor on earth and customer is ready to pay! So request routing and load balancing is more important than the efficiency of the protocol itself.

HTTP is still best -if you need to scale up. (You can also get easy to buy load balancers if you use it). Custom protocol requires custom arrangements.

HTTP doesn't mean you need to throw around HTML, java script at all. Doesn't even mean you need to have regular apache server and web browser. You can use HTTP between two custom clients and elements like AOL server or lighthttpd that can be used as a library if communication is not a huge data transfers. You can also use SOAP on both sides with tool kits like gSOAP.

Even if HTTP definitely doesn't fit the bill, consider something like BEEP, that helps you make things more efficient. Alternatively there are many proven RPC, RMI mechanisms that exists.

Try to see that you can do maximal work more by doing parallel processing in the back-end and servers are only queried when work is done. If this works -there are frameworks like MPI, or there are many other distributed computing tool kits that can be of help.

Finally, while i may not be in a position to know exact needs, but you may either need to distribute a lot of data or do a lot of computation, if you need both - there is still some core architectural inefficiencies.

To me, creating a new Protocol, and than creating a new server framework is a double experiment that you shouldn't do together. If your stakes are so high, first you should actually try to experiment with existing tools to see the limits of what is been done so far - only then you will know the real challenges.

Lot more has been accomplished in the research of distributed systems than just web apps. So you should research that.

Dipan.

Title: Micro vs Monolithic Server architecture


问:
Example of where Functional Programming is Superior to Imperative or Object-Oriented Programming?

Possible Duplicate:

  Which problems domains are more suited  to functional programming solutions

I've been reading about functional programming.  I've been using mostly C#.net recently, and I would like to know of a good real-world example of where a functional language such as Lisp or F# would be a clearly superior tool for getting a job done.

答:
I find functional languages better because they tend to demand very little ceremony for the functionality they provide. For example....let's take every number in a list of integers add one to the number, and then sum them.

In Clojure:

```<code>(reduce + (map inc mylist))
</code>```

In C# (functional style):

```<code>result = mylist.Select(i => i + 1).Sum();
</code>```

In C# (imperative style):

```<code>int sum = 0;
foreach (int i in mylist)
{
   sum += (i + 1);
}
</code>```

Let's look at the imperative style...we have to create a accumulator (sum), a locally scoped variable (i), and we also have to be explicit in how we enumerate our loop. What takes a single line of code, and is extremely readable in a functional language has ballooned into 5 lines of C# and it's not nearly as readable.

So after studying both imperative   and functional languages for several years, I've simply come to the conclusion that I would rather use less work to accomplish more. Since switching to Clojure for all my hobby projects I've found that I can suddenly accomplish much more with less code.

So back to your question, I never find myself asking "why would I use a functional language?", but instead, "why wouldn't I use a functional language?". Sometimes it requires thinking about the problem in a different way, but I find that my functional code is more concise, elegant, and readable than the code I'm forced to write in C#.

For context, I code in C# 8+ hours a day at work, and code around 1-2 hours in Clojure every night.

Body:
I find functional languages better because they tend to demand very little ceremony for the functionality they provide. For example....let's take every number in a list of integers add one to the number, and then sum them.

In Clojure:

(reduce + (map inc mylist))

In C# (functional style):

result = mylist.Select(i => i + 1).Sum();

In C# (imperative style):

int sum = 0;
foreach (int i in mylist)
{
   sum += (i + 1);
}

Let's look at the imperative style...we have to create a accumulator (sum), a locally scoped variable (i), and we also have to be explicit in how we enumerate our loop. What takes a single line of code, and is extremely readable in a functional language has ballooned into 5 lines of C# and it's not nearly as readable.

So after studying both imperative   and functional languages for several years, I've simply come to the conclusion that I would rather use less work to accomplish more. Since switching to Clojure for all my hobby projects I've found that I can suddenly accomplish much more with less code.

So back to your question, I never find myself asking "why would I use a functional language?", but instead, "why wouldn't I use a functional language?". Sometimes it requires thinking about the problem in a different way, but I find that my functional code is more concise, elegant, and readable than the code I'm forced to write in C#.

For context, I code in C# 8+ hours a day at work, and code around 1-2 hours in Clojure every night.


答:
This seems very academic to me. And frankly, I find the second approach to be just as monolithic. This is as far as you should go:

Parse the request

Handle the request

The request handler chosen based on the request parameters should encapsulate all aspects of handling the request. Whether or not the handler actually performs queries on your data store and whether or not it uses standard formatting to return the data is irrelevant from the layer above. As a matter of fact, it probably will do just that, but there's no value in making assumptions about it.

Title: Micro vs Monolithic Server architecture

Body:
We are currently working on our new product/project, it is a client-server application directed towards certain specific industrial/service enterprises. We are building a server (C Language and Linux Only) running a custom protocol on top of TCP with a Java front-end. We are about 20% into the coding work and are faced with a situation having to choose between Micro or Monolithic Kernel Architecture.

I am aware that Micro vs. Monolithic is usually in relation to kernel architecture, but we are specifically talking about servers.

Why a custom server and not something existing?

Our UI needs are significant and very dynamic, thus Web/Web-browser based solutions were not appropriate.

The statistical processing is significant at the client end and therefore, again, browsers were of little help. (Of course, we could do the processing at the server end and pass on the processed data to the client but that would imply lot of load on the server and wastage of client resources).

Moreover, with atleast three technologies (JS/HTML/CSS) to manage even a single event makes the whole experience like sweeping the house in the midst of a desert storm - you sweep it n-times, the dust accumulates n+1 times.

What about Micro and Monolithic Server? What are you talking?

Consider the following (hypothetical) client request:

```<code>request-id: 123
request-service: HistoricDataSets
request-message: Fetch all records upto the year 2010
</code>```

On receving such request, a server, typically, does (we are ignoring concurrency techniques like thread and forks for simplicity):

Parse the request string

Identify the action (Fetch HistoricDataSets LIMIT  Year (2010) in our case)

Interact with the persistance layer (Oracle, lets say, in our example) and fetch the data.

Format the data as per the protocol. Ex:

response-id: 123

success: true

response-text: DataSets

Respond to the client with the thus formatted data.

This is what we are calling a Monolithic Server (akin to a monolithic kernel where all OS workings are done in the kernel space).

Consider the same request again, on receipt, this time the server (we have assumed only shared memory as IPC, again for simplicity):

Puts the request into the shared memory for the Parser process

The Parser parses the string, identifies the task and directs the Executioner process to execute the tasks.

The Executioner then passes the data to Fomatter process which, after formatting the data into a protocol string, returns to the server.

The server dispatches it to the client (response).

Of course, instead of Parser, Executioner and Formatter it could have been a single but separate process.  This is what we are calling a Micro Server (akin to a micro kernel doing barely minimum that is required). The server effectively is only listening and responding whereas all steps are taken care of by different process(es).

Which one to pick? We are confused! While monolithic servers are tried and tested (most HTTP-Web Servers?) and easier to program and can handle concurrency quite well. Micro servers, prima facie, seem swift and in line with UNIX principle of one program to do one task, but are also complicated to develop, esp. keeping concurrency in mind.

Question(s)

- What are (possibly could be) the pros and cons of each approach?

- When to use which? (It could also be interpreted as a general question: When to use IPC?)

- If Micro kernel is chosen, then what functions need to be a part of core-server and what not?

Similar/Related questions

Dangers of huge monolithic application

External Vs Embedded browser (Tangential)

Advice for converting Monolithic app into multithreaded (Tangential)

Some information that may be helpful:

Our prospective customers can be divided into two categories:

Large: About 1,700 - 2,000 requests per minute

Small: About 650 - 700 requests per minute

Data volume per request cycle (request and the subsequent response) can be assumed to be normally distributed with mean ~ 1.20 MB and worse case about 250-300 MB.

The product concept is relatively new but has the capability of impacting the core operations, therefore we expect the customer budgets to be flexible only post a certain lag (9-12 months) post deployment, this limits the amount of hardware the client will be willing to commit esp. the small ones.

Each customer will have his own client-server stack. The server will be running on the customer's hardware managed by the customer's team, while clients will be deployed on the machines of the functional employees

Remote updates for both client and server application is a must

Real time PUSH services by the server may be 'highly' desired if the product clicks!


问:
Lean/Kanban *Inside* Software (i.e. WIP-Limits, Reducing Queues and Pull as Programming Techniques)
Thinking about Kanban, I realized that the queuing-theory behind the SW-development-methodology obviously also applies to concurrent software. Now I'm looking for whether this kind of thinking is explicitly applied in some area.

A simple example: We usually want to limit the number of threads to avoid cache-thrashing (WIP-Limits).

In the paper about the disruptor pattern[1], one statement that I found interesting was that producer/consumers are rarely balanced so when using queues, either consumers wait (queues are empty), or producers produce more than is consumed, resulting in either a full capacity-constrained queue or an unconstrained one blowing up and eating away memory. Both, in lean-speak, is waste, and increases lead-time.

Does anybody have examples of WIP-Limits, reducing/eliminating queues, pull or single piece flow being applied in programming?

http://disruptor.googlecode.com/files/Disruptor-1.0.pdf

答: I just recently came across the KanbanFlow pattern which seems almost identical to the Disruptor PDF you posted. You can see a simulation of the idea here.</p>


问:
Should interface names begin with an "I" prefix?
I have been reading "Clean Code" by Robert Martin to hopefully, become a better programmer.  While none of it so far has been really ground breaking it has made me think differently about the way I design applications and write code.

There is one part of the book that I not only don't agree with, but doesn't make sense to me, specifically in regards to interface naming conventions.  Here's the text, taken directly from the book.  I have bolded the aspect of this I find confusing and would like clarification on.

I prefer to leave interfaces unadorned. The preceding I, so common in today’s legacy wads, is a distraction at best and too much information at worst. I don’t want my users knowing that I’m handing them an interface.

Perhaps it is because I'm only a student, or maybe because I have never done any professional or team based programming but I would want the user to know it is an interface.  There's a big difference between implementing an interface and extending a class.

So, my question boils down to, "Why should we hide the fact that some part of the code is expecting an interface?"

Edit

In response to an answer:

If your type is an interface or a class is your business, not the business of someone using your code. So you shouldn't leak details of your code in this thrid party code.

Why should I not "leak" the details of whether a given type is an interface or a class to third-party code?  Isn't it important to the third-party developer using my code to know whether they will be implementing an interface or extending a class?  Are the differences simply not as important as I'm making them out to be in my mind?

答:
Well this is not about implementing the interface or extending a class. In thoses cases, you know anyway what you are doing.

However, when third party code (another module of the application for exemple) manipulates you data, this code should not care if you are presenting an interface or a class.

This is the whole point of abstraction. You are presenting to this third party code an object of a given type. This given type has some member function you can call. That's enough.

If your type is an interface or a class is your business, not the business of someone using your code. So you shouldn't leak details of your code to this third party code.

By the way, interfaces and classes are reference types at the end. And this is what matters. So this is what your naming convention must emphasize.


问:
Is "Computer Science != Software Engineering" an excuse to teach programming poorly?
We've all heard it; whenever there's a discussion about CS grads having poor development skills someone eventually says,

Computer science isn't software engineering.

The problem that I see is that programming and software development are taught in CS courses. They're just commonly taught poorly. If it's being taught, then why not teach it right the first time? *

So I would like to see what the opinions are on 2 questions:

Is the CS != SE argument a copout or excuse for not properly teaching programming skills.

Regardless of your answer to question 1; if you were in the almighty position of making such a decision: would you force an emphasis on proper teaching of programming in CS courses?

*. I have a suspicion, based on anecdotal evidence I obtained throughout my education, that most academics in the field haven't had to write code to be maintained and haven't maintained code, and as a result don't have the knowledge/skills to teach it effectively.

答:
I don't think it's a copout, but rather an assertion that computer science isn't software engineering, it isn't programming -- it's, well, the science of formalized computation. In essence, it's math (in fact, many CS programs started off as applied mathematics programs).

I think the problem lies more with industry than academia. Industry sees a CS degree listed on a résumé and thinks, "Great, this guy's good with computers," and hires him to do anything related to a computer: IT, programming, software development, whatever. Those things don't necessarily lie in the realm of expertise of a CS graduate. In turn, a lot of people who like building computers or playing videogames enter a CS program expecting to do that kind of stuff, and get a rude surprise; i.e., a lot of students going into CS don't really belong there, and would be better off in a more targeted degree program.

Secondly, there's a very limited time to teach CS -- a very broad subject -- in a typical undergraduate curriculum. My undergrad curriculum had 8 CS courses (for a BA) or 12 CS courses (for a BS), plus all the required math courses. That's not a lot of time to teach CS and math and programming and software engineering, so at some point you have to decide what's important, and what a student can pick up on their own.

That last point is crucial: I think a good student -- in any subject area -- will explore ideas on their own. I have a CS degree, but I think I came out of college as a decent developer, because I studied and wrote software on my own. College isn't all about classes; it's also about giving students time to develop their skills semi-autonomously, while still giving valuable guidance.

I maintain that teaching theory -- CS, math, etc. -- is just as important, if not more important, than teaching specific job-related skills. If you teach a student the why behind methods and techniques, and not just the what, you'll end up with someone who is much more adaptable when applying his knowledge. For example, I went to a much-maligned "Java school" and thus was taught in Java, but I also had courses in programming language theory, which explained the why behind many languages; as a result, I've learned to write much better software than if I didn't have that background. Sure, I don't write software in Haskell in my day job, but knowing a lot of programming language theory has allowed me to gain insight that has been applicable to my job as a programmer.

I also think industry is expecting too much from college students. Industry wants to cut its own costs, so instead of training new recruits for their jobs, they expect colleges to become trade/technical schools; in effect, they want colleges to do their training for them. College graduates can't be expected to know everything fresh out of college. Being a good developer is as much about experience as it is about knowledge (especially in a relatively young field like software development).


问:
Who owns the code I wrote, what rights do I have with respect to my employer
This is a legal question with mixing code I've written in my own time with code I've been paid to write for an employer.

I'm employed at a company with an employment contract, and am paid hourly. This is in Ontario, Canada in case that that affects matters.

I've been working on a project for my employer, and in this project I've incorporated some code that I had previously written in my own time at my house for another project (as in I own the code outright).

My code is now tightly coupled with the project at work (as in it won't work without it). I have at times needed to make changes to my original code to get it working with my work project, and since I am paid hourly for my time, I've technically been paid to work on my own code.

But since I was paid for it, does my employer now technically own this code?

Suppose I leave this company tomorrow, do I need to leave my source code behind? I'm not saying I would, but do I still retain exclusive and unrestricted rights to my original code?

答: Not sure on the wording of your particular contract but yes most likely the employer owns the code.  You were paid for the work and it is property now.  As for the code you created at home on your own time, I am no contract lawyer but that should be yours but only that code.</p>


答:
The answer will be in your contract.

My contract at work stats that all code written during my employment with the company is owned by the company.

Check your contract.

Title: Who owns the code I wrote, what rights do I have with respect to my employer

Body:
This is a legal question with mixing code I've written in my own time with code I've been paid to write for an employer.

I'm employed at a company with an employment contract, and am paid hourly. This is in Ontario, Canada in case that that affects matters.

I've been working on a project for my employer, and in this project I've incorporated some code that I had previously written in my own time at my house for another project (as in I own the code outright).

My code is now tightly coupled with the project at work (as in it won't work without it). I have at times needed to make changes to my original code to get it working with my work project, and since I am paid hourly for my time, I've technically been paid to work on my own code.

But since I was paid for it, does my employer now technically own this code?

Suppose I leave this company tomorrow, do I need to leave my source code behind? I'm not saying I would, but do I still retain exclusive and unrestricted rights to my original code?


问:
How can I track quality attributes on my team's Kanban?
My team uses a Kanban system for tracking day-to-day progress and it's worked out really well for understanding progress on features (captured as user stories).  We have largely allowed our system design to emerge as we develop features which worked out well until recently.  In the last two week we've had several discussions about architectural trade-offs specifically related to performance and modifiability quality attributes.

I think what's happening is as we implement features and design the system, we're implicitly making decisions about the architecture but not considering those decisions in terms of our known quality attribute requirements.  It would be really great if I could track/capture/visually depict how these important design decisions are being made so team members have a better chance to not create additional tension with in the system's architecture as it is being implemented.  And of course, to complicate things more, features on our board aren't exclusively functional and sometimes hide architectural complexity!

How can I track progress on quality attributes (or other architecturally relevant decisions) visually on my team's kanban?

答:
There are really two parts to this question. One part is: How do we know when the architecture gets changed. The second part is: How do we know that the architecture is still good.

For this first part: How do you know when the architecture gets changed?

The goal here is to take something that is being done implicitly and make it explicit

Alexei's suggestion is a one option. Create a column on the board for architecture review. Then move a card there if it will require architectural decisions

Another option is to create an explicit policy on how to handle this: "If we need to change architecture then we must pair with someone else" is an example of one such policy. In one project, we had a policy that code changes to certain specialised modules had to be done by pairing with specific people. When someone wanted to change code there, they would call for a pair and team up. The rest of the work was done solo. You can do something similar with the architecture.

You would probably go with the former, if many cards require review, or if the architect is not a part of the team and a handoff is required, or the review is going to be detailed enough to take some time which you want to track on the board. The latter is an option if only few cards touch the architecture, and its easy to find a pair on demand.

Now coming to the second question: How do we know that the architecture is still good?

I'm a big fan of visualisation. You could have a chart on the whiteboard with post-it notes describing the components and architecture.

There are also static analysers that will analyse the code base and generate an image with dependency graph of various components. You could run it, take a print out and stick it up on a wall once a week or so. Maybe the latest two printouts could be on the wall, so you can see if anything has changed in the last week.

What these allow you to do is to make your architecture and design visible. Team members will glance at it once in a while and comment on it if something could be changed or refactored or done in a better way.